[PATCH 3 of 3] copies: extract an explicit `computechangesetfilesremoved` method from context

Pierre-Yves David pierre-yves.david at ens-lyon.org
Tue Aug 6 05:50:40 EDT 2019


# HG changeset patch
# User Pierre-Yves David <pierre-yves.david at octobus.net>
# Date 1560343372 -3600
#      Wed Jun 12 13:42:52 2019 +0100
# Node ID 8e554943127cd8daf0fe6561fb3c2e1930d8c8e1
# Parent  8e63367b5e07024527f1afbd3585f9af651c2d64
# EXP-Topic extrameta
# Available At https://bitbucket.org/octobus/mercurial-devel/
#              hg pull https://bitbucket.org/octobus/mercurial-devel/ -r 8e554943127c
copies: extract an explicit `computechangesetfilesremoved` method from context

Right now, the logic around changeset centric removed files data are buried into
the "changectx" code. We extract this code in a dedicated method (in the copies
module) for clarity. This clarity will help to explicitly compute and caches
these data in the future.

diff --git a/mercurial/context.py b/mercurial/context.py
--- a/mercurial/context.py
+++ b/mercurial/context.py
@@ -466,12 +466,7 @@ class changectx(basectx):
             (source == 'compatibility' and
              self._changeset.filesremoved is not None)):
             return self._changeset.filesremoved or []
-
-        removed = []
-        for f in self.files():
-            if f not in self:
-                removed.append(f)
-        return removed
+        return copies.computechangesetfilesremoved(self)
 
     @propertycache
     def _copies(self):
diff --git a/mercurial/copies.py b/mercurial/copies.py
--- a/mercurial/copies.py
+++ b/mercurial/copies.py
@@ -843,3 +843,12 @@ def computechangesetfilesadded(ctx):
         if not any(f in p for p in ctx.parents()):
             added.append(f)
     return added
+
+def computechangesetfilesremoved(ctx):
+    """return the list of files removed in a changeset
+    """
+    removed = []
+    for f in ctx.files():
+        if f not in ctx:
+            removed.append(f)
+    return removed


More information about the Mercurial-devel mailing list