Rev 3: Make it so that running without arguments runs against all conflicted files, and allow multiple files in http://bzr.arbash-meinel.com/plugins/per_file_remerge
John Arbash Meinel
john at arbash-meinel.com
Wed Jun 18 15:02:38 BST 2008
At http://bzr.arbash-meinel.com/plugins/per_file_remerge
------------------------------------------------------------
revno: 3
revision-id: john at arbash-meinel.com-20080618140230-3vj2w9t5zlhq3ria
parent: john at arbash-meinel.com-20080618135040-6d22o4pkjgxffoy0
committer: John Arbash Meinel <john at arbash-meinel.com>
branch nick: per_file_remerge
timestamp: Wed 2008-06-18 09:02:30 -0500
message:
Make it so that running without arguments runs against all conflicted files, and allow multiple files
-------------- next part --------------
=== modified file '__init__.py'
--- a/__init__.py 2008-06-18 13:50:40 +0000
+++ b/__init__.py 2008-06-18 14:02:30 +0000
@@ -24,21 +24,27 @@
class cmd_per_file_remerge(commands.Command):
- """Recompute the merge for a given file, using its per-file graph."""
+ """Recompute the merge for a given file, using its per-file graph.
+
+ Any number of files can be given. If no files are given, then the current
+ working tree is opened, and all files marked conflicted are processed.
+ """
- takes_args = ['filename']
+ takes_args = ['file*']
takes_options = ['merge-type']
- def run(self, filename, merge_type=None):
+ def run(self, file_list=[], merge_type=None):
from bzrlib import (
+ builtins,
merge,
+ trace,
ui,
workingtree,
)
import per_file_remerge
if merge_type is None:
merge_type = merge.Merge3Merger
- tree, relpath = workingtree.WorkingTree.open_containing(filename)
+ tree, relpaths = builtins.tree_files(file_list)
tree.lock_tree_write()
try:
parent_ids = tree.get_parent_ids()
@@ -46,8 +52,23 @@
raise errors.BzrCommandError(
"Sorry, per-file-remerge only works after normal"
" merges. Not cherrypicking or multi-merges.")
- num_conflicts = per_file_remerge._remerge_file(tree, relpath,
- merge_type)
+ if not relpaths:
+ # use the list of conflicted files
+ trace.mutter('Doing per-file remerge using the conflict list')
+ relpaths = []
+ for conflict in tree.conflicts():
+ if conflict.typestring == 'text conflict':
+ relpaths.append(conflict.path)
+ num_conflicts = 0
+ pb = ui.ui_factory.nested_progress_bar()
+ try:
+ num_conflicted = len(relpaths)
+ for idx, relpath in enumerate(relpaths):
+ pb.update('resolving', idx, num_conflicted)
+ num_conflicts += per_file_remerge._remerge_file(tree,
+ relpath, merge_type)
+ finally:
+ pb.finished()
finally:
tree.unlock()
=== modified file 'test_per_file_remerge.py'
--- a/test_per_file_remerge.py 2008-06-18 13:50:40 +0000
+++ b/test_per_file_remerge.py 2008-06-18 14:02:30 +0000
@@ -116,3 +116,19 @@
'=======\n'
'new a contents\n'
'>>>>>>> MERGE-SOURCE\n', 'tree1/a')
+
+ def test_remerge(self):
+ tree1, tree2 = self.create_criss_cross_merge()
+ # Add another file into tree2, to make sure it gets merged, but not
+ # touched by remerge
+ self.build_tree_contents([('tree2/c', 'c contents\n')])
+ tree2.add(['c'], ['c-id'])
+ tree2.commit('G', rev_id='rev-G')
+ num_conflicts = tree1.merge_from_branch(tree2.branch)
+ self.assertEqual(2, num_conflicts)
+
+ # Without arguments, 'per-file-remerge' should remerge all conflicted files
+ self.run_bzr(['per-file-remerge'], working_dir='tree1')
+ self.assertFileEqual('updated a contents\n', 'tree1/a')
+ self.assertFileEqual('updated b contents\n', 'tree1/b')
+ self.assertFileEqual('c contents\n', 'tree1/c')
More information about the bazaar-commits
mailing list