[patch] improve 'commit DIR'

Martin Pool mbp at canonical.com
Wed May 10 12:14:33 BST 2006


This fixes an edge case of the current commit command: you cannot say
'bzr commit DIR' if there is a pending merge in DIR.  It's not super
important but is useful in writing another test.

-- 
Martin
-------------- next part --------------
=== modified file 'bzrlib/builtins.py'
--- bzrlib/builtins.py	
+++ bzrlib/builtins.py	
@@ -1580,6 +1580,12 @@
         # TODO: if the commit *does* happen to fail, then save the commit 
         # message to a temporary file where it can be recovered
         tree, selected_list = tree_files(selected_list)
+        if selected_list == ['']:
+            # workaround - commit of root of tree should be exactly the same
+            # as just default commit in that tree, and succeed even though
+            # selected-file merge commit is not done yet
+            selected_list = []
+
         if local and not tree.branch.get_bound_location():
             raise errors.LocalRequiresBoundBranch()
         if message is None and not file:

=== modified file 'bzrlib/commit.py'
--- bzrlib/commit.py	
+++ bzrlib/commit.py	
@@ -296,7 +296,8 @@
 
             self._gather_parents()
             if len(self.parents) > 1 and self.specific_files:
-                raise NotImplementedError('selected-file commit of merges is not supported yet')
+                raise NotImplementedError('selected-file commit of merges is not supported yet: files %r',
+                        self.specific_files)
             self._check_parents_present()
             
             self._remove_deleted()

=== modified file 'bzrlib/tests/blackbox/test_commit.py'
--- bzrlib/tests/blackbox/test_commit.py	
+++ bzrlib/tests/blackbox/test_commit.py	
@@ -36,6 +36,27 @@
         self.runbzr("init")
         self.build_tree(['hello.txt'])
         self.runbzr("commit -m empty", retcode=3)
+
+    def test_commit_with_path(self):
+        """Commit tree with path of root specified"""
+        self.run_bzr('init', 'a')
+        self.build_tree(['a/a_file'])
+        self.run_bzr('add', 'a/a_file')
+        self.run_bzr('commit', '-m', 'first commit', 'a')
+
+        self.run_bzr('branch', 'a', 'b')
+        self.build_tree_contents([('b/a_file', 'changes in b')])
+        self.run_bzr('commit', '-m', 'first commit in b', 'b')
+
+        self.build_tree_contents([('a/a_file', 'new contents')])
+        self.run_bzr('commit', '-m', 'change in a', 'a')
+
+        os.chdir('b')
+        self.run_bzr('merge', '../a', retcode=1) # will conflict
+        os.chdir('..')
+        self.run_bzr('resolved', 'b/a_file')
+        self.run_bzr('commit', '-m', 'merge into b', 'b')
+
 
     def test_10_verbose_commit(self):
         """Add one file and examine verbose commit output"""



More information about the bazaar mailing list