[PATCH] patiencediff.py/unified_diff: do not insert trailing whitespace if filedate is empty
John Arbash Meinel
john at arbash-meinel.com
Mon Jan 5 20:26:10 GMT 2009
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Adeodato Simó wrote:
> Hi there.
>
> When using unified_diff from bzrlib.patiencediff and writing the result
> through a colordiff.DiffWriter object, the +++/--- lines were signaled
> as having trailing whitespace.
>
> The attached patch fixes this nuisance, it would be great if you could
> apply it in bzr.dev. Feel free to drop the str()'s if you feel that's
> too much pedantry.
>
> Thanks,
>
> (Please CC me on replies.)
>
>
BB:comment
I'm not sure, but there may be programs that expect a trailing blank space.
I know we ran into problems elsewhere, like needing to use a real tab
(\t) character rather than just a space character in other parts of the
diff header.
I'll also comment that the header we are emitting is *exactly* the one
that is being emitted by the python standard lib's 'unified_diff' code:
for group in SequenceMatcher(None,a,b).get_grouped_opcodes(n):
if not started:
yield '--- %s %s%s' % (fromfile, fromfiledate, lineterm)
yield '+++ %s %s%s' % (tofile, tofiledate, lineterm)
So I'm tempted to reject this change, in favor of updating
colordiff.DiffWriter to allow trailing whitespace on lines starting with
"+++ "
I can certainly be convinced otherwise, but since difflib.unified_diff()
produces the same output as our current output, I hesitate to change it.
John
=:->
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (Cygwin)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
iEYEARECAAYFAklibOIACgkQJdeBCYSNAAM/OQCgyv020iVsLScFRZy9WC1rGUtl
PuEAoM0YUeQ0Wcf2Kb3waDsziyH7a05G
=nN1O
-----END PGP SIGNATURE-----
More information about the bazaar
mailing list