[PATCH 1 of 2] subrepo: add the parent context to hgsubrepo

Matt Harbison mharbison72 at gmail.com
Thu Mar 19 20:40:35 CDT 2015


# HG changeset patch
# User Matt Harbison <matt_harbison at yahoo.com>
# Date 1426733801 14400
#      Wed Mar 18 22:56:41 2015 -0400
# Node ID 449fccab8331e05fb69d967b6916ebac9be614b7
# Parent  dc7588ce06b30a6ef347f7554e9646ac00e4456a
subrepo: add the parent context to hgsubrepo

This brings parity with gitsubrepo and svnsubrepo (which already reference their
parent), and will be used in an upcoming patch.

I'm a bit concerned that the parent context could get stale (consider what
happens when the parent repo is reverted for example).  I tried adding the
parent context to the substate tuple so that the parent is available everywhere
a state change is possible, but that made submerge() unhappy.  Even with
removing the parent context inside submerge(), I wasn't able to get all of the
test diffs fixed.

But since the other subrepos reference their parent too, if there is a problem,
it is a preexisting one (that nobody seems to be running into).  It can be fixed
if/when it pops up.

diff --git a/mercurial/subrepo.py b/mercurial/subrepo.py
--- a/mercurial/subrepo.py
+++ b/mercurial/subrepo.py
@@ -519,6 +519,7 @@
         super(hgsubrepo, self).__init__(ctx.repo().ui)
         self._path = path
         self._state = state
+        self._ctx = ctx
         r = ctx.repo()
         root = r.wjoin(path)
         create = not r.wvfs.exists('%s/.hg' % path)


More information about the Mercurial-devel mailing list