# HG changeset patch # User Matt Harbison # Date 2015-06-15 01:51:57 # Node ID 3d8c044ed513e36cdeec009167b9fd3501b00b4d # Parent 1abfe639a70c529f0507ff467e41ac553724108f 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. diff --git a/mercurial/subrepo.py b/mercurial/subrepo.py --- a/mercurial/subrepo.py +++ b/mercurial/subrepo.py @@ -662,6 +662,15 @@ class hgsubrepo(abstractsubrepo): 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