Patchwork [3,of,3,V3] copies: extract an explicit `computechangesetfilesremoved` method from context

login
register
mail settings
Submitter Pierre-Yves David
Date Aug. 7, 2019, 1:46 p.m.
Message ID <49740823dab3e2673ece.1565185610@nodosa.octopoid.net>
Download mbox | patch
Permalink /patch/41193/
State Accepted
Headers show

Comments

Pierre-Yves David - Aug. 7, 2019, 1:46 p.m.
# HG changeset patch
# User Pierre-Yves David <pierre-yves.david@octobus.net>
# Date 1560343372 -3600
#      Wed Jun 12 13:42:52 2019 +0100
# Node ID 49740823dab3e2673ece70974080a274f2b8cf94
# Parent  791b66f0c3e2f67dd7cb093cf58d662f63e4273f
# EXP-Topic extrameta
# Available At https://bitbucket.org/octobus/mercurial-devel/
#              hg pull https://bitbucket.org/octobus/mercurial-devel/ -r 49740823dab3
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 scmutil
module) for clarity. This clarity will help to explicitly compute and caches
these data in the future.
Yuya Nishihara - Aug. 7, 2019, 11:37 p.m.
On Wed, 07 Aug 2019 15:46:50 +0200, Pierre-Yves David wrote:
> # HG changeset patch
> # User Pierre-Yves David <pierre-yves.david@octobus.net>
> # Date 1560343372 -3600
> #      Wed Jun 12 13:42:52 2019 +0100
> # Node ID 49740823dab3e2673ece70974080a274f2b8cf94
> # Parent  791b66f0c3e2f67dd7cb093cf58d662f63e4273f
> # EXP-Topic extrameta
> # Available At https://bitbucket.org/octobus/mercurial-devel/
> #              hg pull https://bitbucket.org/octobus/mercurial-devel/ -r 49740823dab3
> copies: extract an explicit `computechangesetfilesremoved` method from context

Queued with s/copies:/changectx:/, thanks.

Patch

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 scmutil.computechangesetfilesremoved(self)
 
     @propertycache
     def _copies(self):
diff --git a/mercurial/scmutil.py b/mercurial/scmutil.py
--- a/mercurial/scmutil.py
+++ b/mercurial/scmutil.py
@@ -1993,3 +1993,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