[patch] move more weave debugging commands to bzr
Martin Pool
mbp at sourcefrog.net
Fri Mar 24 12:40:10 GMT 2006
This adds more weave commands under bzr: 'weave-plan-merge' and
'weave-merge-texts'. These are intended only for debugging use and
moved here just as a way to make them more easily accessible.
It would be nice to put a proper interface on plan-merge, e.g.
bzr explain-merge foo.c
where foo.c has an uncommitted merge, and possibly a conflict. I'm not
doing that right now.
--
Martin
-------------- next part --------------
=== modified file 'a/bzrlib/builtins.py'
--- a/bzrlib/builtins.py
+++ b/bzrlib/builtins.py
@@ -2401,4 +2401,5 @@
# details were needed.
from bzrlib.conflicts import cmd_resolve, cmd_conflicts, restore
from bzrlib.sign_my_commits import cmd_sign_my_commits
-from bzrlib.weave_commands import cmd_weave_list, cmd_weave_join
+from bzrlib.weave_commands import cmd_weave_list, cmd_weave_join, \
+ cmd_weave_plan_merge, cmd_weave_merge_text
=== modified file 'a/bzrlib/weave.py'
--- a/bzrlib/weave.py
+++ b/bzrlib/weave.py
@@ -1358,12 +1358,13 @@
print ' '.join(map(str, w._parents[int(argv[3])]))
elif cmd == 'plan-merge':
+ # replaced by 'bzr weave-plan-merge'
w = readit()
for state, line in w.plan_merge(int(argv[3]), int(argv[4])):
if line:
print '%14s | %s' % (state, line),
-
elif cmd == 'merge':
+ # replaced by 'bzr weave-merge-text'
w = readit()
p = w.plan_merge(int(argv[3]), int(argv[4]))
sys.stdout.writelines(w.weave_merge(p))
=== modified file 'a/bzrlib/weave_commands.py'
--- a/bzrlib/weave_commands.py
+++ b/bzrlib/weave_commands.py
@@ -23,6 +23,7 @@
import sys
from bzrlib.commands import Command
+from bzrlib.trace import mutter, warning
class cmd_weave_list(Command):
"""List the revision ids present in a weave, in alphabetical order"""
@@ -55,3 +56,35 @@
w2 = read_weave(file(weave2, 'rb'))
w1.join(w2)
write_weave(w1, sys.stdout)
+
+
+class cmd_weave_plan_merge(Command):
+ """Show the plan for merging two versions within a weave"""
+ hidden = True
+ takes_args = ['weave_file', 'revision_a', 'revision_b']
+
+ def run(self, weave_file, revision_a, revision_b):
+ from bzrlib.weavefile import read_weave, write_weave
+ w = read_weave(file(weave_file, 'rb'))
+ for state, line in w.plan_merge(revision_a, revision_b):
+ # make sure to print every line with a newline, even if it doesn't
+ # really have one
+ if not line:
+ continue
+ if line[-1] != '\n':
+ state += '!eol'
+ line += '\n'
+ if '\n' in line[:-1]:
+ warning("line in weave contains embedded newline: %r" % line)
+ print '%15s | %s' % (state, line),
+
+class cmd_weave_merge_text(Command):
+ """Debugging command to merge two texts of a weave"""
+ hidden = True
+ takes_args = ['weave_file', 'revision_a', 'revision_b']
+
+ def run(self, weave_file, revision_a, revision_b):
+ from bzrlib.weavefile import read_weave, write_weave
+ w = read_weave(file(weave_file, 'rb'))
+ p = w.plan_merge(revision_a, revision_b)
+ sys.stdout.writelines(w.weave_merge(p))
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 191 bytes
Desc: Digital signature
Url : https://lists.ubuntu.com/archives/bazaar/attachments/20060324/569d6734/attachment.pgp
More information about the bazaar
mailing list