changeset 35438:0ebd94ac56d1

outgoing: respect ":pushurl" paths (issue5365) Make 'hg outgoing' respect "paths.default:pushurl" in addition to "paths.default-push". 'hg outgoing' has always meant "what will happen if I run 'hg push'?" and it's still documented that way: Show changesets not found in the specified destination repository or the default push location. These are the changesets that would be pushed if a push was requested. If the user uses the now-deprecated "paths.default-push" path, it continues to work that way. However, as described at https://bz.mercurial-scm.org/show_bug.cgi?id=5365, it doesn't behave the same with "paths.default:pushurl". Why does it matter? Similar to the bugzilla reporter, I have a read-only mirror of a non-Mercurial repository: upstream -> imported mirror -> user clone ^-----------------------/ Users push directly to upstream, and that content is then imported into the mirror. However, those repositories are not the same; it's possible that the mirroring has either broken completely, or an import process is running and not yet complete. In those cases, 'hg outgoing' will list changesets that have already been pushed. Mozilla's desired behavior described in bug 5365 can be accomplished through other means (e.g. 'hg outgoing default'), preserving the consistency and meaning of 'hg outgoing'.
author Hollis Blanchard <hollis_blanchard@mentor.com>
date Thu, 14 Dec 2017 15:03:55 -0800
parents cf532a62e337
children e7bb5fc4570c
files mercurial/hg.py mercurial/revset.py tests/test-incoming-outgoing.t tests/test-revset-outgoing.t
diffstat 4 files changed, 79 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/hg.py	Fri Dec 15 17:52:38 2017 -0500
+++ b/mercurial/hg.py	Thu Dec 14 15:03:55 2017 -0800
@@ -916,8 +916,13 @@
     return _incoming(display, subreporecurse, ui, repo, source, opts)
 
 def _outgoing(ui, repo, dest, opts):
-    dest = ui.expandpath(dest or 'default-push', dest or 'default')
-    dest, branches = parseurl(dest, opts.get('branch'))
+    path = ui.paths.getpath(dest, default=('default-push', 'default'))
+    if not path:
+        raise error.Abort(_('default repository not configured!'),
+                hint=_("see 'hg help config.paths'"))
+    dest = path.pushloc or path.loc
+    branches = path.branch, opts.get('branch') or []
+
     ui.status(_('comparing with %s\n') % util.hidepassword(dest))
     revs, checkout = addbranchrevs(repo, repo, branches, opts.get('rev'))
     if revs:
--- a/mercurial/revset.py	Fri Dec 15 17:52:38 2017 -0500
+++ b/mercurial/revset.py	Thu Dec 14 15:03:55 2017 -0800
@@ -1418,8 +1418,16 @@
     l = getargs(x, 0, 1, _("outgoing takes one or no arguments"))
     # i18n: "outgoing" is a keyword
     dest = l and getstring(l[0], _("outgoing requires a repository path")) or ''
-    dest = repo.ui.expandpath(dest or 'default-push', dest or 'default')
-    dest, branches = hg.parseurl(dest)
+    if not dest:
+        # ui.paths.getpath() explicitly tests for None, not just a boolean
+        dest = None
+    path = repo.ui.paths.getpath(dest, default=('default-push', 'default'))
+    if not path:
+        raise error.Abort(_('default repository not configured!'),
+                hint=_("see 'hg help config.paths'"))
+    dest = path.pushloc or path.loc
+    branches = path.branch, []
+
     revs, checkout = hg.addbranchrevs(repo, repo, branches, [])
     if revs:
         revs = [repo.lookup(rev) for rev in revs]
--- a/tests/test-incoming-outgoing.t	Fri Dec 15 17:52:38 2017 -0500
+++ b/tests/test-incoming-outgoing.t	Thu Dec 14 15:03:55 2017 -0800
@@ -491,3 +491,63 @@
   searching for changes
   no changes found
   [1]
+
+Create a "split" repo that pulls from r1 and pushes to r2, using default-push
+
+  $ hg clone r1 split
+  updating to branch default
+  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
+  $ cat > split/.hg/hgrc << EOF
+  > [paths]
+  > default = $TESTTMP/r3
+  > default-push = $TESTTMP/r2
+  > EOF
+  $ hg -R split outgoing
+  comparing with $TESTTMP/r2
+  searching for changes
+  changeset:   0:3e92d79f743a
+  tag:         tip
+  user:        test
+  date:        Thu Jan 01 00:00:00 1970 +0000
+  summary:     a
+  
+
+Use default:pushurl instead of default-push
+
+Windows needs a leading slash to make a URL that passes all of the checks
+  $ WD=`pwd`
+#if windows
+  $ WD="/$WD"
+#endif
+  $ cat > split/.hg/hgrc << EOF
+  > [paths]
+  > default = $WD/r3
+  > default:pushurl = file://$WD/r2
+  > EOF
+  $ hg -R split outgoing
+  comparing with file:/*/$TESTTMP/r2 (glob)
+  searching for changes
+  changeset:   0:3e92d79f743a
+  tag:         tip
+  user:        test
+  date:        Thu Jan 01 00:00:00 1970 +0000
+  summary:     a
+  
+
+Push and then double-check outgoing
+
+  $ echo a >> split/foo
+  $ hg -R split commit -Ama
+  $ hg -R split push
+  pushing to file:/*/$TESTTMP/r2 (glob)
+  searching for changes
+  adding changesets
+  adding manifests
+  adding file changes
+  added 2 changesets with 2 changes to 1 files
+  $ hg -R split outgoing
+  comparing with file:/*/$TESTTMP/r2 (glob)
+  searching for changes
+  no changes found
+  [1]
+
--- a/tests/test-revset-outgoing.t	Fri Dec 15 17:52:38 2017 -0500
+++ b/tests/test-revset-outgoing.t	Thu Dec 14 15:03:55 2017 -0800
@@ -105,12 +105,11 @@
   green = ../a#default
 
   $ hg tout green
-  comparing with green
-  abort: repository green not found!
+  abort: repository green does not exist!
   [255]
 
   $ hg tlog -r 'outgoing("green")'
-  abort: repository green not found!
+  abort: repository green does not exist!
   [255]
 
   $ cd ..