changeset 25572:3d8c044ed513

subrepo: introduce hgsubrepo._getctx() This code is already used in a couple of places, and will need to be used in others where wdir() support is needed. Trying to get the wdir() revision stored in self._substate[1] when creating the object in subrepo.subrepo() resulted in breaking various status and diff tests. This is a far less invasive change.
author Matt Harbison <matt_harbison@yahoo.com>
date Sun, 14 Jun 2015 21:51:57 -0400
parents 1abfe639a70c
children 3e89e67f17e8
files mercurial/subrepo.py
diffstat 1 files changed, 9 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/subrepo.py	Sun Jun 14 13:08:11 2015 -0400
+++ b/mercurial/subrepo.py	Sun Jun 14 21:51:57 2015 -0400
@@ -662,6 +662,15 @@
         finally:
             lock.release()
 
+    def _getctx(self):
+        '''fetch the context for this subrepo revision, possibly a workingctx
+        '''
+        if self._ctx.rev() is None:
+            return self._repo[None]  # workingctx if parent is workingctx
+        else:
+            rev = self._state[1]
+            return self._repo[rev]
+
     @annotatesubrepoerror
     def _initrepo(self, parentrepo, source, create):
         self._repo._subparent = parentrepo