proposal for a nice enhancement to "bzr diff --using <tool>"
James Westby
jw+debian at jameswestby.net
Wed Sep 10 14:25:13 BST 2008
On Wed, 2008-09-10 at 15:06 +0200, David Ingamells wrote:
> Since my python and bzr internals knowledge is almost zero and
> absolutely zero respectively, I'll only be able to implement this myself
> (which I'm willing to do) if someone can point me at the right place in
> the code.
Looking in bzrlib/builtins.py where the commands are defined
for cmd_diff, and then where the "using" option goes, shows
that it just gets passed through to "show_diff_trees" in
bzrlib/diff.py.
This passes it on to DiffTree.from_trees_options, which has
if using is not None:
extra_factories = [DiffFromTool.make_from_diff_tree(using)]
which creates a DiffFromTool for the --using argument. It then passes
extra_factories to it's own __init__, which puts them in self.differs.
Looking to where else this is used brings us to show_diff, which
has
if changed_content:
self.diff(file_id, oldpath, newpath)
and looking at diff() shows
try:
old_kind = self.old_tree.kind(file_id)
except (errors.NoSuchId, errors.NoSuchFile):
old_kind = None
and similar for new_kind. This is then passed to
DiffPath._diff_many which loops over the differs
and calls diff() on each.
Looking at the implementation of diff() from DiffFromTool (what
--using created above) shows
if (old_kind, new_kind) != ('file', 'file'):
return DiffPath.CANNOT_DIFF
and as old_kind will be "None" for added files it will refuse to
work on them.
I expect the start of the fix would be changing these lines and
making it handle None for either old_kind or new_kind. Presumably
file->symlink etc. still shouldn't be handled by the graphical
diff tool.
I hope this is a start for you.
Thanks,
James
More information about the bazaar
mailing list