[PATCH 2 of 3] copies: extract an explicit `computechangesetfilesadded` method from context
Pierre-Yves David
pierre-yves.david at ens-lyon.org
Tue Aug 6 05:50:39 EDT 2019
# HG changeset patch
# User Pierre-Yves David <pierre-yves.david at octobus.net>
# Date 1560343342 -3600
# Wed Jun 12 13:42:22 2019 +0100
# Node ID 8e63367b5e07024527f1afbd3585f9af651c2d64
# Parent fc8e461200c7262246ebd610100bcf9a75ded461
# EXP-Topic extrameta
# Available At https://bitbucket.org/octobus/mercurial-devel/
# hg pull https://bitbucket.org/octobus/mercurial-devel/ -r 8e63367b5e07
copies: extract an 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 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
@@ -459,12 +459,7 @@ class changectx(basectx):
(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 copies.computechangesetfilesadded(self)
def filesremoved(self):
source = self._repo.ui.config('experimental', 'copies.read-from')
if (source == 'changeset-only' or
diff --git a/mercurial/copies.py b/mercurial/copies.py
--- a/mercurial/copies.py
+++ b/mercurial/copies.py
@@ -834,3 +834,12 @@ def computechangesetcopies(ctx):
elif src in p2 and p2[src].filenode() == srcnode:
p2copies[dst] = src
return p1copies, p2copies
+
+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
More information about the Mercurial-devel
mailing list