Major diff/merge changes in bzr and explorer

Andreas Sommer andreas.sommer87 at googlemail.com
Mon May 7 21:33:38 UTC 2012


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Andreas Sommer wrote:
> From: Aaron Bentley <aaron at aaronbentley.com> Sent: 03.05.2012
> 16:07 To: bazaar at lists.canonical.com Subject: Re: Major diff/merge
> changes in bzr and explorer
>> On 12-05-03 04:41 AM, Andreas Sommer wrote:
>>> From: Gordon Tyler <gordon at doxxx.net>
> 
>>>> Another diff-related feature request that I recall seeing
>>>> was for proper handling of multi-file diffs with tools that
>>>> can handle them.
> 
>>> Good point. There is an important distinction to make:
> 
>>> 1) Tools that show multiple 2-way diffs, e.g. in tabs. This is 
>>> done by multiple process invocations (e.g. WinMerge) or
>>> passing the file pairs as parameters (e.g. meld) as described
>>> in the bug comments.
> 
>>> 2) Tools that can handle 3+ way diffs like Diffuse. 'bzr diff' 
>>> can only compare two revisions at the moment, so
>>> multi-revision diff tools can not be used yet. But it might be
>>> worth considering it in the implementation of a common tool
>>> invocation module. For example, instead of parameters
>>> (old_filename,new_filename) one could use a list new_filenames
>>> (that would contain one filename in case of the traditional
>>> 2-way diff).
> 
>> I would distinguish between per-file diff tools and per-tree diff
>>  tools.  The diff code I wrote handles per-file diff tools as 
>> extra_factories for DiffTree.  I imagined that per-tree diff
>> tools would be implemented using the same API as DiffTree, and 
>> registered with bzrlib.diff.format_registry, but I didn't do any 
>> work on that.
> 
>> Aaron
> 
> Not sure what you mean by per-tree diff tools - no tool except for
> the bzr textual representation can display all different types of
> changes (modified text files or pictures, symlinks, changed
> directories, renames).
> 
> I propose the following: Bazaar's textual representation remains
> the default, and the differs in extra_factories are tried first.
> The "--format" parameter which does the selection in 
> bzrlib.diff.format_registry, will only be valid for the internal
> diff (e.g. one could implement different formats apart from the
> unified diff, that's how I understand the word "format"). Now for
> the external tools: I will add an option like 
> "bzr.difftool.MyDiffTool.is_default" (true/false). Also an option 
> ".is_console_based" that says whether it can be run without a 
> graphical environment. "bzr diff" without the "--tool" parameter
> will try all "default" differs first before using the textual 
> representation (if there's no graphical environment like in an SSH 
> session (how would I check this??), only the ones with 
> .is_console_based==true). In contrast, "bzr diff
> --tool=MyCoolTool" will select the tool with that name and use it
> for all changes that it supports, else falls back to other
> preferred tools, then to built-in diff. The ".is_default" option
> thus means that "bzr diff" uses them automatically without the
> "--tool" parameter, so that a user can replace the default diff
> algorithm completely by another tool.
> 
> Does that make sense somehow? Or how did you imagine this, also 
> regarding the existing DiffPath implementation?
> 
> Andreas

So now I implemented it as described above, with some small changes:
- - Added the following options for each diff tool (default value in
parentheses): is_default (false), is_gui (false), filename_regex
(None), file_types (text,binary)
  - filename_regex defines which filenames are supported, e.g.
\.docx?$ for a tool that can diff Word documents
  - file_types defines whether text, binary or both can be handled
  - is_default defines whether "bzr diff" may choose this tool
automatically
  - is_gui is for default (is_default=true) tools that should only be
chosen if the new "--ui" parameter is given

Conclusion: "bzr diff" stays as is because no default tools are
defined for the command line (yet?!). The user can define own
preferred tools. "bzr diff --ui" will start a GUI-based tool if available.

Since I'm using Windows/Tortoise{Git,SVN} quite often, I already added
TortoiseMerge (also works as diff tool despite its name) for text
files and the TortoiseSVN MS Word diff script for .doc and .docx files.

See branch at
https://code.launchpad.net/~andidog/bzr/diff-merge-tools, feedback
welcome!! Thanks,
 Andreas
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.17 (MingW32)

iQIcBAEBAgAGBQJPqD+xAAoJEPeCHX6zCCMvi6YQAM8WzLJt8Kjps82b3BApJqsL
015kYZPAm2HWQ4oz2+MrUYvVhAo5yyxsthtbbbX7x3rGgyqBsP3Jx6UcpbhB5B+D
vlmfjAaNqMeEenKC7zMaFzTk4wNDTQdJtP3BFpuKXFAZjRZ3PUIMXppn0kKjCgEr
UIIkOHrlkBgpRct3+tZvKJPE5/aLNUjtZOIl1bWtbtexNqodoLUQpMQcnJ/JIUPF
tMbKwhkhB7w/Z4B7SLfYgPklYmlhGPPbTvzPYuaAmknk/W8PGwTnhkeNJDrDeHBS
/KDmAKR7y0w33o2hzcVppGNqKpbioML3PKsmRJN5tlPrBwWSIL9fLnsRNAcK9IYE
6et8q3uY1wQ71CJVBYYafz/z6t8Tm7Avv3wVyEae/HgWh5tTdzdtWYr4uWN8gycQ
8cMCgL0Mw7lBNWTHyFUBl2fij8zNn4UVxjUr/XArAiP0tLTCyO/b9aANo56v4/qE
HeeXecLuRxyfzwgLMtDi8RV69/uaWGE//qVrUXKpVsFSB+rm1U6YRQIDHOUQmpbJ
9I/BYK0P9aHrToJcQQqK1R6GPY4zl+iNyTFJGOKtKR6Epc6wPAmlpr74SDeIT5j/
7wPJzoGNz3PLZP/bgqN5FM6N0QK80XtsosvrCnIbrVaeuABqLiIVkq3/vUNoSMK8
6CYr8d7GE7hXz0yNR3TT
=1wDn
-----END PGP SIGNATURE-----



More information about the bazaar mailing list