filectx.ancestor: use fctx._repopath to cache filelogs (issue1035)
authorAlexis S. L. Carvalho <alexis@cecm.usp.br>
Sun, 16 Mar 2008 06:10:47 -0300
changeset 6286 90a4329a6b4a
parent 6285 4b81eecc8aa2
child 6287 c86207d41512
filectx.ancestor: use fctx._repopath to cache filelogs (issue1035) _repopath may be different from _path for workingfilectx when there are renames involved.
mercurial/context.py
tests/test-mv-cp-st-diff
tests/test-mv-cp-st-diff.out
--- a/mercurial/context.py	Sat Mar 15 12:42:41 2008 -0700
+++ b/mercurial/context.py	Sun Mar 16 06:10:47 2008 -0300
@@ -190,6 +190,9 @@
         elif name == '_filerev':
             self._filerev = self._filelog.rev(self._filenode)
             return self._filerev
+        elif name == '_repopath':
+            self._repopath = self._path
+            return self._repopath
         else:
             raise AttributeError, name
 
@@ -404,7 +407,7 @@
                 pl = [(n.path(), n.filenode()) for n in c.parents()]
                 acache[(c._path, None)] = pl
 
-        flcache = {self._path:self._filelog, fc2._path:fc2._filelog}
+        flcache = {self._repopath:self._filelog, fc2._repopath:fc2._filelog}
         def parents(vertex):
             if vertex in acache:
                 return acache[vertex]
--- a/tests/test-mv-cp-st-diff	Sat Mar 15 12:42:41 2008 -0700
+++ b/tests/test-mv-cp-st-diff	Sun Mar 16 06:10:47 2008 -0300
@@ -65,3 +65,4 @@
 tb "hg cp a b" "add b b1" "add a w" "single copy"
 tb "hg mv a b" "hg mv b c" "hg mv c d" "rename chain"
 tb "hg cp a b" "hg cp b c" "hg cp c d" "copy chain"
+tb "add a a1" "hg mv a b" "hg mv b a" "circular rename"
--- a/tests/test-mv-cp-st-diff.out	Sat Mar 15 12:42:41 2008 -0700
+++ b/tests/test-mv-cp-st-diff.out	Sun Mar 16 06:10:47 2008 -0300
@@ -793,3 +793,103 @@
 -5
 
 
+** circular rename **
+** add a a1 / hg mv a b / hg mv b a
+- working to parent: 
+A a
+  b
+R b
+
+diff --git a/b b/a
+rename from b
+rename to a
+
+- working to root: --rev 0
+M a
+
+diff --git a/a b/a
+--- a/a
++++ b/a
+@@ -1,1 +1,3 @@
+ a
++6
++a1
+
+- working to branch: --rev 2
+M a
+
+diff --git a/a b/a
+--- a/a
++++ b/a
+@@ -1,3 +1,3 @@
+ a
+-m1
+-m2
++6
++a1
+
+- root to parent: --rev 0 --rev .
+A b
+  a
+R a
+
+diff --git a/a b/b
+rename from a
+rename to b
+--- a/a
++++ b/b
+@@ -1,1 +1,3 @@
+ a
++6
++a1
+
+- parent to root: --rev . --rev 0
+A a
+  b
+R b
+
+diff --git a/b b/a
+rename from b
+rename to a
+--- a/b
++++ b/a
+@@ -1,3 +1,1 @@
+ a
+-6
+-a1
+
+- branch to parent: --rev 2 --rev .
+A b
+  a
+R a
+
+diff --git a/a b/b
+rename from a
+rename to b
+--- a/a
++++ b/b
+@@ -1,3 +1,3 @@
+ a
+-m1
+-m2
++6
++a1
+
+- parent to branch: --rev . --rev 2
+A a
+  b
+R b
+
+diff --git a/b b/a
+rename from b
+rename to a
+--- a/b
++++ b/a
+@@ -1,3 +1,3 @@
+ a
+-6
+-a1
++m1
++m2
+
+