# HG changeset patch # User Hollis Blanchard # Date 1513292635 28800 # Node ID 0ebd94ac56d13862df511c8e56c76238c5d282d4 # Parent cf532a62e337645e949da9529c41ff1a5ab4d981 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'. diff -r cf532a62e337 -r 0ebd94ac56d1 mercurial/hg.py --- 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: diff -r cf532a62e337 -r 0ebd94ac56d1 mercurial/revset.py --- 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] diff -r cf532a62e337 -r 0ebd94ac56d1 tests/test-incoming-outgoing.t --- 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] + diff -r cf532a62e337 -r 0ebd94ac56d1 tests/test-revset-outgoing.t --- 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 ..