D10163: paths: add a `*` special path to define default sub option

marmoute (Pierre-Yves David) phabricator at mercurial-scm.org
Thu Mar 11 17:09:13 UTC 2021


marmoute created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REPOSITORY
  rHG Mercurial

BRANCH
  default

REVISION DETAIL
  https://phab.mercurial-scm.org/D10163

AFFECTED FILES
  mercurial/ui.py
  tests/test-default-push.t

CHANGE DETAILS

diff --git a/tests/test-default-push.t b/tests/test-default-push.t
--- a/tests/test-default-push.t
+++ b/tests/test-default-push.t
@@ -146,4 +146,40 @@
     ^ here)
   [10]
 
+default :pushrev is taking in account
+
+  $ echo babar > foo
+  $ hg ci -m 'extra commit'
+  $ hg up '.^'
+  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
+  $ echo celeste > foo
+  $ hg ci -m 'extra other commit'
+  created new head
+  $ cat >> .hg/hgrc << EOF
+  > [paths]
+  > other = file://$WD/../pushurldest
+  > *:pushrev = .
+  > EOF
+  $ hg push other
+  pushing to file:/*/$TESTTMP/pushurlsource/../pushurldest (glob)
+  searching for changes
+  adding changesets
+  adding manifests
+  adding file changes
+  added 1 changesets with 1 changes to 1 files
+  $ hg push file://$WD/../pushurldest
+  pushing to file:/*/$TESTTMP/pushurlsource/../pushurldest (glob)
+  searching for changes
+  no changes found
+  [1]
+
+for comparison, pushing everything would give different result
+
+  $ hg push file://$WD/../pushurldest --rev 'all()'
+  pushing to file:/*/$TESTTMP/pushurlsource/../pushurldest (glob)
+  searching for changes
+  abort: push creates new remote head 1616ce7cecc8
+  (merge or see 'hg help push' for details about pushing new heads)
+  [20]
+
   $ cd ..
diff --git a/mercurial/ui.py b/mercurial/ui.py
--- a/mercurial/ui.py
+++ b/mercurial/ui.py
@@ -2190,12 +2190,16 @@
     def __init__(self, ui):
         dict.__init__(self)
 
+        _path, base_sub_options = ui.configsuboptions(b'paths', b'*')
         for name, loc in ui.configitems(b'paths', ignoresub=True):
             # No location is the same as not existing.
             if not loc:
                 continue
             loc, sub = ui.configsuboptions(b'paths', name)
-            self[name] = path(ui, name, rawloc=loc, suboptions=sub)
+            sub_opts = base_sub_options.copy()
+            sub_opts.update(sub)
+            self[name] = path(ui, name, rawloc=loc, suboptions=sub_opts)
+        self._default_sub_opts = base_sub_options
 
     def getpath(self, ui, name, default=None):
         """Return a ``path`` from a string, falling back to default.
@@ -2230,7 +2234,9 @@
             # Try to resolve as a local path or URI.
             try:
                 # we pass the ui instance are warning might need to be issued
-                return path(ui, None, rawloc=name)
+                return path(
+                    ui, None, rawloc=name, suboptions=self._default_sub_opts
+                )
             except ValueError:
                 raise error.RepoError(_(b'repository %s does not exist') % name)
 



To: marmoute, #hg-reviewers
Cc: mercurial-patches, mercurial-devel


More information about the Mercurial-devel mailing list