changeset 25257:07326d76f19d

record: extract code to compute newly added and modified files We want to reuse this logic in revert.
author Laurent Charignon <lcharignon@fb.com>
date Thu, 21 May 2015 14:32:14 -0700
parents 5a8398b085ed
children f37a69ec3f47
files mercurial/cmdutil.py
diffstat 1 files changed, 9 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/cmdutil.py	Thu May 21 14:28:02 2015 -0700
+++ b/mercurial/cmdutil.py	Thu May 21 14:32:14 2015 -0700
@@ -21,6 +21,14 @@
     hunkclasses = (crecordmod.uihunk, patch.recordhunk)
     return isinstance(x, hunkclasses)
 
+def newandmodified(chunks, originalchunks):
+    newlyaddedandmodifiedfiles = set()
+    for chunk in chunks:
+        if ishunk(chunk) and chunk.header.isnewfile() and chunk not in \
+            originalchunks:
+            newlyaddedandmodifiedfiles.add(chunk.header.filename())
+    return newlyaddedandmodifiedfiles
+
 def parsealiases(cmd):
     return cmd.lstrip("^").split("|")
 
@@ -109,11 +117,7 @@
         # We need to keep a backup of files that have been newly added and
         # modified during the recording process because there is a previous
         # version without the edit in the workdir
-        newlyaddedandmodifiedfiles = set()
-        for chunk in chunks:
-            if ishunk(chunk) and chunk.header.isnewfile() and chunk not in \
-                originalchunks:
-                newlyaddedandmodifiedfiles.add(chunk.header.filename())
+        newlyaddedandmodifiedfiles = newandmodified(chunks, originalchunks)
         contenders = set()
         for h in chunks:
             try: