[PATCH 2 of 5] record: extract code to compute newly added and modified files

Laurent Charignon lcharignon at fb.com
Thu May 21 18:17:14 CDT 2015


# HG changeset patch
# User Laurent Charignon <lcharignon at fb.com>
# Date 1432243934 25200
#      Thu May 21 14:32:14 2015 -0700
# Node ID 28cfe523bf0759b57761f6131450fca3c4a749eb
# Parent  6a07454641dd43d5b7ba727769df984f1647b4e9
record: extract code to compute newly added and modified files

We want to reuse this logic in revert.

diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py
--- a/mercurial/cmdutil.py
+++ b/mercurial/cmdutil.py
@@ -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:


More information about the Mercurial-devel mailing list