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

mail settings
Submitter Matt Harbison
Date March 20, 2015, 1:40 a.m.
Message ID <449fccab8331e05fb69d.1426815635@Envy>
Download mbox | patch
Permalink /patch/8194/
State Accepted
Commit 30b8db6d0c0430309aedf2b8aa5669a487adeebb
Headers show


Matt Harbison - March 20, 2015, 1:40 a.m.
# HG changeset patch
# User Matt Harbison <>
# 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/ b/mercurial/
--- a/mercurial/
+++ b/mercurial/
@@ -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)