changeset 4829:6b82b4f72347 stable

stack: make a deep copy of `dependencies` before modifying its items The algorithm later on in this method uses .remove() to remove individual elements from items in dependencies, which before this patch modified the cached property contents. So for further use that dictionary was in the form of {1: set([])}, i.e. all sets were empty. This deep copy block could be way simpler, but the problem is that sometimes we get lists of _succs() from evolvebits.builddependencies(). Note: this happens only in topic's stack version of builddependencies() and it looks like a suboptimal way to handle multiple successors (see evolve's counterpart function). stack.builddependencies method is removed, it has served its purpose (see the previous patch).
author Anton Shestakov <av6@dwimlabs.net>
date Fri, 06 Sep 2019 12:53:46 +0700
parents aaf8742e09a0
children 4c5377ab147a
files CHANGELOG hgext3rd/topic/stack.py
diffstat 2 files changed, 13 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/CHANGELOG	Fri Sep 06 12:16:34 2019 +0700
+++ b/CHANGELOG	Fri Sep 06 12:53:46 2019 +0700
@@ -6,6 +6,7 @@
 
   * evolve: test that target is not orig in _solveunstable() (issue6097)
   * obslog: correct spacing of patch output with word-diff=yes (issue6175)
+  * stack: make sure to preserve dependencies, fixes certain complex cases
 
 
 9.1.0 -- 2019-07-29
--- a/hgext3rd/topic/stack.py	Fri Sep 06 12:16:34 2019 +0700
+++ b/hgext3rd/topic/stack.py	Fri Sep 06 12:53:46 2019 +0700
@@ -88,9 +88,6 @@
 
     @util.propertycache
     def _dependencies(self):
-        return self.builddependencies()
-
-    def builddependencies(self):
         deps, rdeps = builddependencies(self._repo, self._revs)
 
         repo = self._repo
@@ -146,8 +143,18 @@
         # processed dependency graph.
 
         # Step 1: compute relation of revision with each other
-        dependencies, rdependencies = self.builddependencies()
-        dependencies = dependencies.copy()
+        origdeps, rdependencies = self._dependencies
+        dependencies = {}
+        # Making a deep copy of origdeps because we modify contents of values
+        # later on. Checking for list here only because right now
+        # builddependencies in evolvebits.py can return a list of _succs()
+        # objects. When that will be dealt with, this deep copy code can be
+        # simplified a lot.
+        for k, v in origdeps.items():
+            if isinstance(v, list):
+                dependencies[k] = [i.copy() for i in v]
+            else:
+                dependencies[k] = v.copy()
         rdependencies = rdependencies.copy()
         # Step 2: Build the ordering
         # Remove the revisions with no dependency(A) and add them to the ordering.