# HG changeset patch # User Pierre-Yves David # Date 2019-06-12 12:42:52 # Node ID 53c07f08fea157e5f2cbd1fb8e7dda52c3a2dc42 # Parent 87c4cd89b539880fc157e319a5fc690011e31c49 changectx: extract 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. 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