spectral created this revision. Herald added a reviewer: hg-reviewers. Herald added a subscriber: mercurial-patches.
REVISION SUMMARY I have no idea if this is *actually* supported by the patch file format, but at least when reading from a patch file created by running `hg shelve`, it is written out such that there's a trailing space after the second (`b`) filename. When we read the patch file, we remove the space before parsing the filenames, so it doesn't end up matching the other sources of what files are in the shelve. We observed this internally due to a wrapper around unshelve that called into patch.changedfiles, but `hg patch` is able to reproduce the issue as well, so I've included both tests. REPOSITORY rHG Mercurial BRANCH default REVISION DETAIL https://phab.mercurial-scm.org/D9729 AFFECTED FILES mercurial/patch.py tests/test-shelve.t CHANGE DETAILS diff --git a/tests/test-shelve.t b/tests/test-shelve.t --- a/tests/test-shelve.t +++ b/tests/test-shelve.t @@ -1512,3 +1512,26 @@ $ hg unshelve -i --keep abort: --keep on --interactive is not yet supported [255] + + $ hg update -q --clean . + +Test that we can successfully shelve and unshelve a file with a trailing space +in the filename. Such filenames are supposedly unsupported on Windows, so we +wrap it in the no-windows check. Also test `hg patch` of the .patch file +produced by `hg shelve`. +#if no-windows + $ echo hi > 'my filename ' + $ hg add 'my filename ' + warning: filename ends with ' ', which is not allowed on Windows: 'my filename ' + $ hg shelve + shelved as default-01 + 0 files updated, 0 files merged, 1 files removed, 0 files unresolved + $ cp .hg/shelved/default-01.patch test_patch.patch + $ hg unshelve + unshelving change 'default-01' + $ cat 'my filename ' + hi + $ hg update -q --clean . + $ hg patch -p1 test_patch.patch + applying test_patch.patch +#endif diff --git a/mercurial/patch.py b/mercurial/patch.py --- a/mercurial/patch.py +++ b/mercurial/patch.py @@ -393,7 +393,7 @@ gp = None gitpatches = [] for line in lr: - line = line.rstrip(b' \r\n') + line = line.rstrip(b'\r\n') if line.startswith(b'diff --git a/'): m = gitre.match(line) if m: @@ -2073,7 +2073,7 @@ yield b'file', (afile, bfile, h, gp and gp.copy() or None) yield b'hunk', h elif x.startswith(b'diff --git a/'): - m = gitre.match(x.rstrip(b' \r\n')) + m = gitre.match(x.rstrip(b'\r\n')) if not m: continue if gitpatches is None: To: spectral, #hg-reviewers Cc: mercurial-patches, mercurial-devel _______________________________________________ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel