Merge lp:~maria-captains/bzr/diffoptions into lp:bzr
Status: | Work in progress |
---|---|
Proposed branch: | lp:~maria-captains/bzr/diffoptions |
Merge into: | lp:bzr |
Diff against target: |
24 lines (+12/-2) 1 file modified
bzrlib/diff.py (+12/-2) |
To merge this branch: | bzr merge lp:~maria-captains/bzr/diffoptions |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Andrew Bennetts | Needs Fixing | ||
Jelmer Vernooij (community) | Abstain | ||
Sergei Golubchik | Pending | ||
Review via email: mp+54139@code.launchpad.net |
Description of the change
[GZ: Starting fresh review which I think was Sergei's intention in the earlier merge proposal:
<https:/
]
Thanks, John, for the discussion.
Let me summarize:
1. It's not always easy to find the "current branch" to be able to get its config.
2. having "-F regex" specified only globally is not flexible enough, as different branches (e.g. one with the C code, another with the Python code) may need different regexps.
2.1 Actually, even one regexp per branch is not enough, as one branch may have both python and C files.
3. Allowing the user to specify arbitrary diff options that affect all generated diffs is too dangerous - "diff -w" will break merge bundles (and "diff -c" breaks bzr shelve and everything that parses diffs).
3.1 But "diff -p" seems to be safe everywhere.
So, I took another approach. It's more strict and more flexible at the same time. More flexible as in the 2.1 above (regexp can be specified per file or a group of files) and more strict as in the 3.1 above (only diff -p - really, diff -F - is allowed).
The patch uses rules to find the regexp for a given tree and for a given file. And runs external diff with -F regexp command-line option.
Please, see the patch. It lacks tests and the documentation is not updated - but it works, and shows the approach.
Unmerged revisions
- 5729. By Sergei Golubchik
-
support diff -F in all generated diffs
with per-file configuration rules
+ # if the user requested function names in the diff
+ # we use the external diff
My main issue with this kind of change is that actually using an external diff rather than the bzr internal one *can* be a big behaviour change. Some people don't have an external diff installed at all, and encoding handling is completely different.
If it's happening in non-obvious circumstances, we risk confusing users over when diff works the way they expect and when it breaks. Implementing '-F' in the bzr internal differ is way more work, but would also do what you want here I think.