stack: demonstrate that not reusing cached property gives different results stable
authorAnton Shestakov <av6@dwimlabs.net>
Fri, 06 Sep 2019 12:16:34 +0700
branchstable
changeset 4828 aaf8742e09a0
parent 4826 efc76b1563f0
child 4829 6b82b4f72347
stack: demonstrate that not reusing cached property gives different results Instead of using self._dependencies, which is a cached property, let's get fresh deps and rdeps in stack.revs method using a newly introduced stack.builddependencies method (will be removed in the next patch). This makes it easier to explain why the next patch is correct.
hgext3rd/topic/stack.py
tests/test-topic-stack.t
--- a/hgext3rd/topic/stack.py	Tue Sep 03 13:02:20 2019 +0700
+++ b/hgext3rd/topic/stack.py	Fri Sep 06 12:16:34 2019 +0700
@@ -88,6 +88,9 @@
 
     @util.propertycache
     def _dependencies(self):
+        return self.builddependencies()
+
+    def builddependencies(self):
         deps, rdeps = builddependencies(self._repo, self._revs)
 
         repo = self._repo
@@ -143,7 +146,7 @@
         # processed dependency graph.
 
         # Step 1: compute relation of revision with each other
-        dependencies, rdependencies = self._dependencies
+        dependencies, rdependencies = self.builddependencies()
         dependencies = dependencies.copy()
         rdependencies = rdependencies.copy()
         # Step 2: Build the ordering
--- a/tests/test-topic-stack.t	Tue Sep 03 13:02:20 2019 +0700
+++ b/tests/test-topic-stack.t	Fri Sep 06 12:16:34 2019 +0700
@@ -794,7 +794,7 @@
 
   $ hg stack red
   ### topic: red
-  ### target: default (branch), ambiguous rebase destination - topic 'red' has 3 heads
+  ### target: default (branch), 7 behind
   s5$ c_H (orphan)
     ^ c_G
     ^ c_D
@@ -868,7 +868,7 @@
 
   $ hg stack red
   ### topic: red
-  ### target: default (branch), ambiguous rebase destination - topic 'red' has 3 heads
+  ### target: default (branch), 7 behind
   s5$ c_H (orphan)
     ^ c_G
     ^ c_D