Rev 4540: Change cmd_mv not to take out branch locks. (Robert Collins, bug 216541) in http://bazaar.launchpad.net/~lifeless/bzr/bug-216541

Robert Collins robertc at robertcollins.net
Thu Jul 16 02:37:03 BST 2009


At http://bazaar.launchpad.net/~lifeless/bzr/bug-216541

------------------------------------------------------------
revno: 4540
revision-id: robertc at robertcollins.net-20090716013657-6f1046zvotn9shm3
parent: pqm at pqm.ubuntu.com-20090715231357-3abvg8h62kjh3zak
committer: Robert Collins <robertc at robertcollins.net>
branch nick: bug-216541
timestamp: Thu 2009-07-16 11:36:57 +1000
message:
  Change cmd_mv not to take out branch locks. (Robert Collins, bug 216541)
=== modified file 'NEWS'
--- a/NEWS	2009-07-15 23:13:57 +0000
+++ b/NEWS	2009-07-16 01:36:57 +0000
@@ -30,6 +30,9 @@
   commit that found a missing file will leave the tree unedited.
   (Robert Collins, #282402)
 
+* ``bzr mv`` no longer takes out branch locks, which allows it to work
+  when the branch is readonly. (Robert Collins, #216541)
+
 * ``WorkingTree4.unversion`` will no longer fail to unversion ids which
   were present in a parent tree but renamed in the working tree.
   (Robert Collins, #187207)

=== modified file 'bzrlib/builtins.py'
--- a/bzrlib/builtins.py	2009-07-15 07:32:26 +0000
+++ b/bzrlib/builtins.py	2009-07-16 01:36:57 +0000
@@ -799,7 +799,7 @@
         if len(names_list) < 2:
             raise errors.BzrCommandError("missing file argument")
         tree, rel_names = tree_files(names_list, canonicalize=False)
-        tree.lock_write()
+        tree.lock_tree_write()
         try:
             self._run(tree, names_list, rel_names, after)
         finally:
@@ -813,7 +813,7 @@
             raise errors.BzrCommandError('--after cannot be specified with'
                                          ' --auto.')
         work_tree, file_list = tree_files(names_list, default_branch='.')
-        work_tree.lock_write()
+        work_tree.lock_tree_write()
         try:
             rename_map.RenameMap.guess_renames(work_tree, dry_run)
         finally:

=== modified file 'bzrlib/tests/blackbox/test_mv.py'
--- a/bzrlib/tests/blackbox/test_mv.py	2009-04-01 20:30:51 +0000
+++ b/bzrlib/tests/blackbox/test_mv.py	2009-07-16 01:36:57 +0000
@@ -18,6 +18,7 @@
 
 import os
 
+import bzrlib.branch
 from bzrlib import (
     osutils,
     workingtree,
@@ -485,3 +486,13 @@
                                 retcode=3)
         self.assertEqual('bzr: ERROR: --after cannot be specified with'
                          ' --auto.\n', err)
+
+    def test_mv_readonly_lightweight_checkout(self):
+        branch = self.make_branch('foo')
+        branch = bzrlib.branch.Branch.open('readonly+' + branch.base)
+        tree = branch.create_checkout('tree', lightweight=True)
+        self.build_tree(['tree/path'])
+        tree.add('path')
+        # If this fails, the tree is trying to acquire a branch lock, which it
+        # shouldn't.
+        self.run_bzr(['mv', 'tree/path', 'tree/path2'])




More information about the bazaar-commits mailing list