changeset 42710:87c4cd89b539

changectx: extract explicit computechangesetfilesadded method from context Right now, the logic around changeset centric added files data are buried into the "changectx" code. We extract this code in a dedicated method (in the scmutil module) for clarity. This clarity will help to explicitly compute and caches these data in the future.
author Pierre-Yves David <pierre-yves.david@octobus.net>
date Wed, 12 Jun 2019 13:42:22 +0100
parents 3cffc7bbec26
children 53c07f08fea1
files mercurial/context.py mercurial/scmutil.py
diffstat 2 files changed, 10 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/context.py	Tue Aug 06 03:17:40 2019 +0200
+++ b/mercurial/context.py	Wed Jun 12 13:42:22 2019 +0100
@@ -459,12 +459,7 @@
             (source == 'compatibility' and
              self._changeset.filesadded is not None)):
             return self._changeset.filesadded or []
-
-        added = []
-        for f in self.files():
-            if not any(f in p for p in self.parents()):
-                added.append(f)
-        return added
+        return scmutil.computechangesetfilesadded(self)
     def filesremoved(self):
         source = self._repo.ui.config('experimental', 'copies.read-from')
         if (source == 'changeset-only' or
--- a/mercurial/scmutil.py	Tue Aug 06 03:17:40 2019 +0200
+++ b/mercurial/scmutil.py	Wed Jun 12 13:42:22 2019 +0100
@@ -1984,3 +1984,12 @@
                      "ancestors(head() and not bookmark(%s)) - "
                      "ancestors(bookmark() and not bookmark(%s))",
                      mark, mark, mark)
+
+def computechangesetfilesadded(ctx):
+    """return the list of files added in a changeset
+    """
+    added = []
+    for f in ctx.files():
+        if not any(f in p for p in ctx.parents()):
+            added.append(f)
+    return added