[MERGE] Allow changing --[no-]trees with reconfigure (bug 145033)

Matthew D. Fuller fullermd at over-yonder.net
Thu Jan 8 08:30:48 GMT 2009


I feel like I've said "Yeah, just poke around manually in
.bzr/repository/ to change that" quite enough freakin' times.

I should note that I know neither bzrlib nor python.  However, this
seems to work right.  And I don't think it dirties interfaces up too
much.

I expect the major bikeshed will be the naming of the options,
"--with-trees" and "--with-no-trees".  init-repo uses --trees and
--no-trees.  However, reconfigure already has a --tree option, and I
fear that --trees would get lost against that too easily.  There's
also the matter of how --trees and --no-trees would get sorted in the
help output (far apart).  So, I'm reasonably happy with that choice.


-- 
Matthew Fuller     (MF4839)   |  fullermd at over-yonder.net
Systems/Network Administrator |  http://www.over-yonder.net/~fullermd/
           On the Internet, nobody can hear you scream.
-------------- next part --------------
# Bazaar merge directive format 2 (Bazaar 0.90)
# revision_id: fullermd at over-yonder.net-20090108082123-\
#   rpb8qwvrzpdyof9l
# target_branch: file:///home/fullermd/src/bzr/bzr.dev/
# testament_sha1: c8d3c34a4c8149b80345dc77c256f39387f9ca84
# timestamp: 2009-01-08 02:22:00 -0600
# base_revision_id: pqm at pqm.ubuntu.com-20081229142916-z08eu2alga2acrh6
# 
# Begin patch
=== modified file 'bzrlib/builtins.py'
--- bzrlib/builtins.py	2008-12-23 22:34:38 +0000
+++ bzrlib/builtins.py	2009-01-08 08:07:25 +0000
@@ -4666,7 +4666,11 @@
                      ' checkout (with no local history).',
                      standalone='Reconfigure to be a standalone branch '
                         '(i.e. stop using shared repository).',
-                     use_shared='Reconfigure to use a shared repository.'),
+                     use_shared='Reconfigure to use a shared repository.',
+                     with_trees='Reconfigure repository to create '
+                        'working trees on branches by default',
+                     with_no_trees='Reconfigure repository to not create '
+                        'working trees on branches by default'),
                      Option('bind-to', help='Branch to bind checkout to.',
                             type=str),
                      Option('force',
@@ -4692,6 +4696,12 @@
             reconfiguration = reconfigure.Reconfigure.to_use_shared(directory)
         elif target_type == 'standalone':
             reconfiguration = reconfigure.Reconfigure.to_standalone(directory)
+        elif target_type == 'with-trees':
+            reconfiguration = reconfigure.Reconfigure.set_repository_trees(
+                directory, True)
+        elif target_type == 'with-no-trees':
+            reconfiguration = reconfigure.Reconfigure.set_repository_trees(
+                directory, False)
         reconfiguration.apply(force)
 
 

=== modified file 'bzrlib/errors.py'
--- bzrlib/errors.py	2008-12-19 16:48:04 +0000
+++ bzrlib/errors.py	2009-01-08 08:06:33 +0000
@@ -2744,6 +2744,18 @@
     _fmt = "'%(display_url)s' is already standalone."
 
 
+class AlreadyWithTrees(BzrDirError):
+
+    _fmt = "Shared repository '%(display_url)s' already creates " \
+           "working trees."
+
+
+class AlreadyWithNoTrees(BzrDirError):
+
+    _fmt = "Shared repository '%(display_url)s' already doesn't create " \
+           "working trees."
+
+
 class ReconfigurationNotSupported(BzrDirError):
 
     _fmt = "Requested reconfiguration of '%(display_url)s' is not supported."

=== modified file 'bzrlib/reconfigure.py'
--- bzrlib/reconfigure.py	2008-04-24 04:58:42 +0000
+++ bzrlib/reconfigure.py	2009-01-08 08:07:00 +0000
@@ -24,9 +24,10 @@
 
 class Reconfigure(object):
 
-    def __init__(self, bzrdir, new_bound_location=None):
+    def __init__(self, bzrdir, new_bound_location=None, with_trees=None):
         self.bzrdir = bzrdir
         self.new_bound_location = new_bound_location
+        self.with_trees = with_trees
         try:
             self.repository = self.bzrdir.find_repository()
         except errors.NoRepositoryPresent:
@@ -62,6 +63,8 @@
         self._create_tree = False
         self._create_repository = False
         self._destroy_repository = False
+        self._set_with_trees = False
+        self._set_with_no_trees = False
 
     @staticmethod
     def to_branch(bzrdir):
@@ -140,14 +143,31 @@
             raise errors.AlreadyStandalone(bzrdir)
         return reconfiguration
 
+    @classmethod
+    def set_repository_trees(klass, bzrdir, with_trees):
+        """Convert a repository branch into a standalone branch"""
+        reconfiguration = klass(bzrdir, with_trees=with_trees)
+        reconfiguration._plan_changes(want_tree=False, want_branch=False,
+                                      want_bound=False, want_reference=False,
+                                      want_shared_repository=True)
+        if not reconfiguration.changes_planned():
+            if with_trees:
+                raise errors.AlreadyWithTrees(bzrdir)
+            else:
+                raise errors.AlreadyWithNoTrees(bzrdir)
+        return reconfiguration
+
     def _plan_changes(self, want_tree, want_branch, want_bound,
-                      want_reference):
+                      want_reference, want_shared_repository=False):
         """Determine which changes are needed to assume the configuration"""
-        if not want_branch and not want_reference:
+        if not want_branch and not want_reference and \
+            not want_shared_repository:
             raise errors.ReconfigurationNotSupported(self.bzrdir)
         if want_branch and want_reference:
             raise errors.ReconfigurationNotSupported(self.bzrdir)
         if self.repository is None:
+            if want_shared_repository:
+                raise errors.ReconfigurationNotSupported(self.bzrdir)
             if not want_reference:
                 self._create_repository = True
         else:
@@ -155,6 +175,16 @@
                                    == self.bzrdir.root_transport.base):
                 if not self.repository.is_shared():
                     self._destroy_repository = True
+            if want_shared_repository:
+                if not self.repository.is_shared():
+                    raise errors.ReconfigurationNotSupported(self.bzrdir)
+                else:
+                    if self.with_trees is True and \
+                        not self.repository.make_working_trees():
+                        self._set_with_trees = True
+                    elif self.with_trees is False and \
+                        self.repository.make_working_trees():
+                        self._set_with_no_trees = True
         if self.referenced_branch is None:
             if want_reference:
                 self._create_reference = True
@@ -195,7 +225,8 @@
         return (self._unbind or self._bind or self._destroy_tree
                 or self._create_tree or self._destroy_reference
                 or self._create_branch or self._create_repository
-                or self._create_reference or self._destroy_repository)
+                or self._create_reference or self._destroy_repository
+                or self._set_with_trees or self._set_with_no_trees)
 
     def _check(self):
         """Raise if reconfiguration would destroy local changes"""
@@ -302,3 +333,7 @@
             local_branch.bind(branch.Branch.open(bind_location))
         if self._destroy_repository:
             self.bzrdir.destroy_repository()
+        if self._set_with_trees:
+            self.repository.set_make_working_trees(True)
+        if self._set_with_no_trees:
+            self.repository.set_make_working_trees(False)

=== modified file 'bzrlib/tests/blackbox/test_reconfigure.py'
--- bzrlib/tests/blackbox/test_reconfigure.py	2008-04-12 05:48:07 +0000
+++ bzrlib/tests/blackbox/test_reconfigure.py	2009-01-08 08:21:23 +0000
@@ -86,3 +86,27 @@
         tree = workingtree.WorkingTree.open('repo/tree')
         self.assertEqual(tree.bzrdir.root_transport.base,
             tree.branch.repository.bzrdir.root_transport.base)
+
+    def test_make_with_trees(self):
+        repo = self.make_repository('repo', shared=True)
+        repo.set_make_working_trees(False)
+        self.run_bzr('reconfigure --with-trees', working_dir='repo')
+        self.assertIs(True, repo.make_working_trees())
+
+    def test_make_with_trees_already_trees(self):
+        repo = self.make_repository('repo', shared=True)
+        repo.set_make_working_trees(True)
+        self.run_bzr_error([" already creates working trees"],
+                            'reconfigure --with-trees repo')
+
+    def test_make_without_trees(self):
+        repo = self.make_repository('repo', shared=True)
+        repo.set_make_working_trees(True)
+        self.run_bzr('reconfigure --with-no-trees', working_dir='repo')
+        self.assertIs(False, repo.make_working_trees())
+
+    def test_make_without_trees_already_no_trees(self):
+        repo = self.make_repository('repo', shared=True)
+        repo.set_make_working_trees(False)
+        self.run_bzr_error([" already doesn't create working trees"],
+                            'reconfigure --with-no-trees repo')

=== modified file 'bzrlib/tests/test_reconfigure.py'
--- bzrlib/tests/test_reconfigure.py	2008-04-25 22:16:00 +0000
+++ bzrlib/tests/test_reconfigure.py	2009-01-08 08:13:29 +0000
@@ -377,3 +377,33 @@
     def test_unsynced_branch_to_lightweight_checkout_forced(self):
         reconfiguration = self.make_unsynced_branch_reconfiguration()
         reconfiguration.apply(force=True)
+
+    def make_repository_with_without_trees(self, with_trees):
+        repo = self.make_repository('repo', shared=True)
+        repo.set_make_working_trees(with_trees)
+        return repo
+
+    def test_make_with_trees(self):
+        repo = self.make_repository_with_without_trees(False)
+        reconfiguration = reconfigure.Reconfigure.set_repository_trees(
+            repo.bzrdir, True)
+        reconfiguration.apply()
+        self.assertIs(True, repo.make_working_trees())
+
+    def test_make_without_trees(self):
+        repo = self.make_repository_with_without_trees(True)
+        reconfiguration = reconfigure.Reconfigure.set_repository_trees(
+            repo.bzrdir, False)
+        reconfiguration.apply()
+        self.assertIs(False, repo.make_working_trees())
+
+    def test_make_with_trees_already_with_trees(self):
+        repo = self.make_repository_with_without_trees(True)
+        self.assertRaises(errors.AlreadyWithTrees,
+            reconfigure.Reconfigure.set_repository_trees, repo.bzrdir, True)
+
+    def test_make_without_trees_already_no_trees(self):
+        repo = self.make_repository_with_without_trees(False)
+        self.assertRaises(errors.AlreadyWithNoTrees,
+            reconfigure.Reconfigure.set_repository_trees, repo.bzrdir, False)
+

# Begin bundle
IyBCYXphYXIgcmV2aXNpb24gYnVuZGxlIHY0CiMKQlpoOTFBWSZTWQz8OxQACz3/gETUdEBT5///
f2Mcjr////pgEb7e+1vuCnu9a0uiFAFW2gVddbbs3HYKq6x3YbVtporTVam2YCjRHDTTBDIaaZGT
CAaaAMJo0yYAEDQSSAAjSBNI1GGlPUMmgAAPUA09TEARTxNE1TE0YGjQgYAAABMmEYRoYEmpEKYJ
pNNlI/TSnoh+qeUeoZkgaGQBoD1ACKSaJinom0U0zKeTEnplT9KPTTJPKaaNNAepoaA9QKkiBCYm
mQI0xMKbVPU09NRN6p6g9IaBoAP1RxNMAgQ3X/pLYa9PjUOnn1QVW0mic4q1aty13Fn3Tk93xeet
nkWlt9Zi5j4fAqe8+wj9Jw46lmyXa7ActXeJy21DCAyasKzKkfUVpvjdPCdRQmNYf3UzLtza/Zrx
VgdnuTtQzJSHQlJa3RXKv14b+Tg+gpeTJJcNP63JA4+hqtg7Ot0fDYagtnfLOdaQtK2KsY256R4R
EhrgSjg39H1YOCYOxWDV67b1TeE6ScxEkVYiKR1/pANmbvwJRFCTyR0BTgKjyTYK5AkwANajeRBc
YwlrJog4huseBCTQjQiQHvdRzozdB1mfc7BlHmgdwMdBvJe0XjPxdIlJdjwX0/VnGfbNmrBemp5P
3ImDesBWuM1EnUSPjVzH1ZFJK+KmYimn6vrcsKYsXlqYYjdM17VF8dSjHIQmYFUpROqKzDMMwzDM
DPqnM1UFhyzatkWcz6yET/21wW1ZcP1EFgszErkwAAjY1oiMACJEdhICxBTWmB+gQH/LzlGJ1PV0
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