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

Matthew D. Fuller fullermd at over-yonder.net
Fri Jan 9 02:47:19 GMT 2009


On Fri, Jan 09, 2009 at 10:58:23AM +1000 I heard the voice of
Ian Clatworthy, and lo! it spake thus:
> 
> I think you need a test covering "reconfiguration not supported"
> when used in a non-shared repo.
> 
> Please add an item to NEWS as well, mentioning the bug and taking
> the credit for fixing it.

Added to blackbox tests and done.

One thing that came to mind in doing that was that this WILL do its
thing if run on a branch in a shared repo (e.g., will change the
repo's setting); it doesn't only work when in/pointed at the repo base
itself.  I don't know if that could be construed as a problem, but I
don't think it is.


-- 
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-20090109024355-\
#   v3z4gp203of33r7s
# target_branch: file:///home/fullermd/src/bzr/bzr.dev/
# testament_sha1: 2df79ef1df984767be1c9610376d6e4833f7f2d7
# timestamp: 2009-01-08 20:44:16 -0600
# base_revision_id: pqm at pqm.ubuntu.com-20081229142916-z08eu2alga2acrh6
# 
# Begin patch
=== modified file 'NEWS'
--- NEWS	2008-12-29 13:51:19 +0000
+++ NEWS	2009-01-09 02:43:55 +0000
@@ -34,6 +34,10 @@
     * ``bzr revision-info`` now supports a -d option to specify an
       alternative branch. (Michael Hudson)
 
+    * ``bzr reconfigure`` now supports --with-trees and --with-no-trees
+      options to change the default tree-creation policy of shared
+      repositories. (Matthew Fuller, #145033)
+
   BUG FIXES:
   
     * Fix a problem with CIFS client/server lag on windows colliding with

=== 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-09 02:41:44 +0000
@@ -86,3 +86,33 @@
         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')
+
+    def test_make_with_trees_nonshared_repo(self):
+        branch = self.make_branch('branch')
+        self.run_bzr_error(
+            ["Requested reconfiguration of '.*' is not supported"],
+            'reconfigure --with-trees branch')

=== 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
IyBCYXphYXIgcmV2aXNpb24gYnVuZGxlIHY0CiMKQlpoOTFBWSZTWRelNeUADkV/gFTUdEBb////
f2Mcjv////pgFUm+17nDXp7nr6+9vYPg2owiWzShVEdKIvoPR6O73nj0GnXVCgaxBQaHoa5dGEok
aBT1GjeqGgPUb0KA0AAMgAGgAASiAAEITQo8pH6n6pqPUNNAZGIGNQGnqZABKAiNKTxTGBE0xANA
aB6gAAAAAEmlEUPUmmp4ptIPJNNqZqaeoAepo0AABoBoBFREaYphPRqZoozSMnpqPSbRNqNBoAAD
QACpJAQAEE0yMRMyahGKeR6hpogA0AHlJwiVEEBUwXeKsrKrd9pUoPpqUpgkbOo+SNtbI65fWgUw
V+hzGsPa9x8CuIKO19pb2WL+z2FDc/yP+s1JU3cdxYVMkFsqBFnBvZZrLqxB6AqJh7KKqoi/QZen
GOl1FKFBhSjT+2S9TcqW6haRYDJugagEyChOQoU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