obsutil: don't assume leftctx and rightctx repo as same
authorPulkit Goyal <pulkit@yandex-team.ru>
Fri, 15 Feb 2019 17:36:57 +0300
changeset 41713 9de6c4f61608
parent 41712 88d4477ac4f6
child 41714 70827ebba453
obsutil: don't assume leftctx and rightctx repo as same Backed out changeset 520514af2d93. hgsubversion can pass leftctx and rightctx which are instances of two different repositories. This was making tests fail on hgsubversion with 4.9. The two different instances are: (Pdb) p rightctx.repo() <filteredrepo:served <hgsubversion.svnrepo.svnlocalrepo object at 0x7fe29d296d10>> (Pdb) p leftctx.repo() <filteredrepo:visible <hgsubversion.svnrepo.svnlocalrepo object at 0x7fe29d494590>> Differential Revision: https://phab.mercurial-scm.org/D5968
mercurial/obsutil.py
--- a/mercurial/obsutil.py	Fri Feb 15 13:46:30 2019 -0800
+++ b/mercurial/obsutil.py	Fri Feb 15 17:36:57 2019 +0300
@@ -397,14 +397,17 @@
 
     This is a first and basic implementation, with many shortcoming.
     """
-    # lefctx.repo() and rightctx.repo() are the same here
-    repo = leftctx.repo()
-    diffopts = diffutil.diffallopts(repo.ui, {'git': True})
+    diffopts = diffutil.diffallopts(leftctx.repo().ui, {'git': True})
+
     # Leftctx or right ctx might be filtered, so we need to use the contexts
     # with an unfiltered repository to safely compute the diff
-    leftunfi = repo.unfiltered()[leftctx.rev()]
+
+    # leftctx and rightctx can be from different repository views in case of
+    # hgsubversion, do don't try to access them from same repository
+    # rightctx.repo() and leftctx.repo() are not always the same
+    leftunfi = leftctx._repo.unfiltered()[leftctx.rev()]
     leftdiff = leftunfi.diff(opts=diffopts)
-    rightunfi = repo.unfiltered()[rightctx.rev()]
+    rightunfi = rightctx._repo.unfiltered()[rightctx.rev()]
     rightdiff = rightunfi.diff(opts=diffopts)
 
     left, right = (0, 0)