[PATCH] patch: improve handling of filenames containing spaces on import (issue3723)

Alastair Houghton alastair at alastairs-place.net
Thu Dec 6 15:00:19 CST 2012


On 6 Dec 2012, at 18:55, Matt Mackall <mpm at selenic.com> wrote:

> Between your bug report and this description, there's lots of confusion
> about whether you're talking about git diffs, standard diffs, or diffs
> in general. I've been assuming the latter up to now.

Well, it is a general problem, but I certainly hadn't intended to try to fix it for the general case because there isn't a good general solution.  It seems to me that you can only reliably solve it for the git format; you *might* get away with a fix for non-git-format unified/contextual diffs that parsed the --- and +++ lines to grab the filename(s) from there, though I imagine there might be problems separating the name and the date/time and/or extra information that some tools put there.

Anyway, I didn't specifically set out to fix any of this; I was just looking at the Mercurial code in this area to see how Mercurial went about parsing patches and generating diffs, mainly because I want to parse some diffs myself and wanted to know what formats I was likely to encounter.  Sadly there doesn't seem to be any written specification that I could find that actually defines the diff formats in any detail---the most detailed thing I can find is the Single Unix Specification, which appears in some respects to be inaccurate.

I should also add that, contrary to the impression that the few people who have commented on the bug report appear to have, I was not and have never been wedded to the idea of changing Mercurial's output.  It just seemed logical that git format should generally behave the same way git does, and since that fixes the problem it seemed a sensible idea.  Perhaps I hadn't appreciated it would be such a contentious topic.

Oh, one other thing I realised about my patch after sending it---it currently doesn't fix the diffstat functions.

Kind regards,

Alastair.

--
http://alastairs-place.net






More information about the Mercurial-devel mailing list