Commit 8e6c43d6 authored by Yuya Nishihara's avatar Yuya Nishihara

revert: stabilize status message of chunks selected interactively

Unfortunately, patch.filterpatch() doesn't preserve the order of the input
files. We have to sort them manually.
parent babad5ebaf0a
......@@ -3152,15 +3152,12 @@ def _performrevert(repo, parents, ctx, names, actions, interactive=False,
tobackup = set()
# Apply changes
fp = stringio()
# `fnames` keeps track of filenames for which we have initiated changes,
# to make sure that we print status msg only once per file.
fnames = set()
# chunks are serialized per file, but files aren't sorted
for f in sorted(set(c.header.filename() for c in chunks if ishunk(c))):
prntstatusmsg('revert', f)
for c in chunks:
if ishunk(c):
abs = c.header.filename()
if abs not in fnames:
fnames.add(abs)
prntstatusmsg('revert', abs)
# Create a backup file only if this hunk should be backed up
if c.header.filename() in tobackup:
target = repo.wjoin(abs)
......
......@@ -112,8 +112,8 @@ Revert interactive tests
2 hunks, 2 lines changed
examine changes to 'folder2/h'? [Ynesfdaq?] n
reverting folder1/g
reverting f
reverting folder1/g
$ cat f
1
2
......@@ -243,8 +243,8 @@ Test --no-backup
2 hunks, 2 lines changed
examine changes to 'folder2/h'? [Ynesfdaq?] n
reverting folder1/g
reverting f
reverting folder1/g
$ cat f
1
2
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment