changeset 39414:1cbe19eb496d

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.
author Yuya Nishihara <yuya@tcha.org>
date Mon, 03 Sep 2018 23:03:19 +0900
parents babad5ebaf0a
children b69fbdd77c40
files mercurial/cmdutil.py tests/test-revert-interactive.t
diffstat 2 files changed, 5 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/cmdutil.py	Wed Aug 29 14:29:01 2018 -0700
+++ b/mercurial/cmdutil.py	Mon Sep 03 23:03:19 2018 +0900
@@ -3152,15 +3152,12 @@
             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)
--- a/tests/test-revert-interactive.t	Wed Aug 29 14:29:01 2018 -0700
+++ b/tests/test-revert-interactive.t	Mon Sep 03 23:03:19 2018 +0900
@@ -112,8 +112,8 @@
   2 hunks, 2 lines changed
   examine changes to 'folder2/h'? [Ynesfdaq?] n
   
+  reverting f
   reverting folder1/g
-  reverting f
   $ cat f
   1
   2
@@ -243,8 +243,8 @@
   2 hunks, 2 lines changed
   examine changes to 'folder2/h'? [Ynesfdaq?] n
   
+  reverting f
   reverting folder1/g
-  reverting f
   $ cat f
   1
   2