Patchwork [4,of,4,STABLE] subrepo: propagate the --hidden option to hg subrepositories

login
register
mail settings
Submitter Matt Harbison
Date April 28, 2015, 3:18 a.m.
Message ID <faba8a5fe5170721c8b6.1430191116@Envy>
Download mbox | patch
Permalink /patch/8811/
State Accepted
Headers show

Comments

Matt Harbison - April 28, 2015, 3:18 a.m.
# HG changeset patch
# User Matt Harbison <matt_harbison@yahoo.com>
# Date 1422993703 18000
#      Tue Feb 03 15:01:43 2015 -0500
# Branch stable
# Node ID faba8a5fe5170721c8b662f822789909b329adfb
# Parent  563baf18e9d05b9717db864533bab51368d38d7e
subrepo: propagate the --hidden option to hg subrepositories

With many commands accepting a '-S' or an explicit path to trigger recursing
into subrepos, it seems that --hidden needs to be propagated too.
Unfortunately, many of the subrepo layer methods discard the options map, so
passing the option along explicitly isn't currently an option.  It also isn't
clear if other filtered views need to be propagated, so changing all of those
commands may be insufficient anyway.

The specific jam I got into was amending an ancestor of qbase in a subrepo, and
then evolving.  The patch ended up being hidden, and outgoing said it would only
push one unrelated commit.  But push aborted with an 'unknown revision' that I
traced back to the patch.  (Odd it didn't say 'filtered revision'.)  A push with
--hidden worked from the subrepo, but that wasn't possible from the parent repo
before this.

Since the underlying problem doesn't actually require a subrepo, there's
probably more to investigate here in the discovery area.  Yes, evolve + mq is
not exactly sane, but I don't know what is seeing the hidden revision.

In lieu of creating a test for the above situation (evolving mq should probably
be blocked), the test here is a marginally useful case where --hidden is needed
in a subrepo: cat'ing a file in a hidden revision.  Without this change, cat
aborts with:

  $ hg --hidden cat subrepo/a
  skipping missing subrepository: subrepo
  [1]
Matt Mackall - April 28, 2015, 11:29 p.m.
On Mon, 2015-04-27 at 23:18 -0400, Matt Harbison wrote:
> # HG changeset patch
> # User Matt Harbison <matt_harbison@yahoo.com>
> # Date 1422993703 18000
> #      Tue Feb 03 15:01:43 2015 -0500
> # Branch stable
> # Node ID faba8a5fe5170721c8b662f822789909b329adfb
> # Parent  563baf18e9d05b9717db864533bab51368d38d7e
> subrepo: propagate the --hidden option to hg subrepositories

Queued for stable, thanks.

Patch

diff --git a/mercurial/subrepo.py b/mercurial/subrepo.py
--- a/mercurial/subrepo.py
+++ b/mercurial/subrepo.py
@@ -569,6 +569,11 @@ 
         root = r.wjoin(path)
         create = not r.wvfs.exists('%s/.hg' % path)
         self._repo = hg.repository(r.baseui, root, create=create)
+
+        # Propagate the parent's --hidden option
+        if r is r.unfiltered():
+            self._repo = self._repo.unfiltered()
+
         self.ui = self._repo.ui
         for s, k in [('ui', 'commitsubrepos')]:
             v = r.ui.config(s, k)
diff --git a/tests/test-subrepo-missing.t b/tests/test-subrepo-missing.t
--- a/tests/test-subrepo-missing.t
+++ b/tests/test-subrepo-missing.t
@@ -96,4 +96,14 @@ 
   revision 102a90ea7b4a in subrepo subrepo is hidden
   1 files updated, 0 files merged, 0 files removed, 0 files unresolved
 
+check that --hidden is propagated to the subrepo
+
+  $ hg -R subrepo up tip
+  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
+  $ hg ci -m 'commit with amended subrepo'
+  $ echo bar > subrepo/a
+  $ hg -R subrepo ci --amend -m "amend a (again)"
+  $ hg --hidden cat subrepo/a
+  foo
+
   $ cd ..