changeset 24877:cc497780eaf9 stable

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]
author Matt Harbison <matt_harbison@yahoo.com>
date Tue, 03 Feb 2015 15:01:43 -0500
parents b5513ee85dd8
children e530cde6d115
files mercurial/subrepo.py tests/test-subrepo-missing.t
diffstat 2 files changed, 15 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/subrepo.py	Mon Apr 27 21:34:23 2015 -0400
+++ b/mercurial/subrepo.py	Tue Feb 03 15:01:43 2015 -0500
@@ -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)
--- a/tests/test-subrepo-missing.t	Mon Apr 27 21:34:23 2015 -0400
+++ b/tests/test-subrepo-missing.t	Tue Feb 03 15:01:43 2015 -0500
@@ -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 ..