changeset 43023:008e74b34fb7

context: clarify the various mode in the filesadded method The previous code was compact but a bit dense. The new proposed code deal with each mode separately, there are some duplicated lines, but the meaning of each mode stand out. One of the benefit it to make it simpler to add further mode in the future. Differential Revision: https://phab.mercurial-scm.org/D6931
author Pierre-Yves David <pierre-yves.david@octobus.net>
date Fri, 27 Sep 2019 00:06:02 +0200
parents f3bcae1e9e23
children 15badd621825
files mercurial/context.py
diffstat 1 files changed, 12 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/context.py	Thu Sep 26 23:43:32 2019 +0200
+++ b/mercurial/context.py	Fri Sep 27 00:06:02 2019 +0200
@@ -453,13 +453,20 @@
         modified.difference_update(self.filesadded())
         modified.difference_update(self.filesremoved())
         return sorted(modified)
+
     def filesadded(self):
         source = self._repo.ui.config('experimental', 'copies.read-from')
-        if (source == 'changeset-only' or
-            (source == 'compatibility' and
-             self._changeset.filesadded is not None)):
-            return self._changeset.filesadded or []
-        return scmutil.computechangesetfilesadded(self)
+        filesadded = self._changeset.filesadded
+        if source == 'changeset-only':
+            if filesadded is None:
+                filesadded = []
+        elif source == 'compatibility':
+            if filesadded is None:
+                filesadded = scmutil.computechangesetfilesadded(self)
+        else:
+            filesadded = scmutil.computechangesetfilesadded(self)
+        return filesadded
+
     def filesremoved(self):
         source = self._repo.ui.config('experimental', 'copies.read-from')
         if (source == 'changeset-only' or