# HG changeset patch # User Matt Harbison # Date 2018-05-28 05:36:34 # Node ID dfb888aae17a943c8eba7a53c1833aefd9caccd3 # Parent fc72beec2a1aff984f8c88598f38cea73e178b11 outgoing: pay attention to `default:pushurl` for bookmarks and subrepos The problem here was that `default:pushurl` and `default` get translated to a single entry in `ui.paths` named 'default', with an attribute for 'pushloc', 'loc', and 'rawloc'. ui.expandpath() then always takes the `rawloc` attribute. Maybe the ui.expandpath() API is busted and should be removed? Or maybe getpath() should return a copy that adds an attribute reflecting the URL of the path chosen? I thought that I could remove the code in hg._outgoing() and pass the location resolved in commands.py as `dest`, but unfortunately that code is needed there to resolve #branch type URLs. Maybe that should be pulled up to commands.py, because I can't see any reasonable behavior for a subrepo path that's constructed out of that type of URL. The push command already resolves this early, so that works properly. But it looks like bundle, histedit, largefiles, patchbomb, and summary use a similar pattern, so they are likely similarly affected. diff --git a/mercurial/commands.py b/mercurial/commands.py --- a/mercurial/commands.py +++ b/mercurial/commands.py @@ -3711,6 +3711,13 @@ def outgoing(ui, repo, dest=None, **opts Returns 0 if there are outgoing changes, 1 otherwise. """ + # hg._outgoing() needs to re-resolve the path in order to handle #branch + # style URLs, so don't overwrite dest. + 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'")) + opts = pycompat.byteskwargs(opts) if opts.get('graph'): logcmdutil.checkunsupportedgraphflags([], opts) @@ -3728,7 +3735,7 @@ def outgoing(ui, repo, dest=None, **opts return 0 if opts.get('bookmarks'): - dest = ui.expandpath(dest or 'default-push', dest or 'default') + dest = path.pushloc or path.loc dest, branches = hg.parseurl(dest, opts.get('branch')) other = hg.peer(repo, opts, dest) if 'bookmarks' not in other.listkeys('namespaces'): @@ -3738,7 +3745,7 @@ def outgoing(ui, repo, dest=None, **opts ui.pager('outgoing') return bookmarks.outgoing(ui, repo, other) - repo._subtoppath = ui.expandpath(dest or 'default-push', dest or 'default') + repo._subtoppath = path.pushloc or path.loc try: return hg.outgoing(ui, repo, dest, opts) finally: diff --git a/tests/test-ssh.t b/tests/test-ssh.t --- a/tests/test-ssh.t +++ b/tests/test-ssh.t @@ -230,7 +230,7 @@ test pushkeys and bookmarks namespaces phases $ hg book foo -r 0 - $ hg out -B + $ hg out -B --config paths.default=bogus://invalid --config paths.default:pushurl=`hg paths default` comparing with ssh://user@dummy/remote searching for changed bookmarks foo 1160648e36ce diff --git a/tests/test-subrepo-relative-path.t b/tests/test-subrepo-relative-path.t --- a/tests/test-subrepo-relative-path.t +++ b/tests/test-subrepo-relative-path.t @@ -56,6 +56,30 @@ Clone main from hgweb new changesets 863c1745b441 3 files updated, 0 files merged, 0 files removed, 0 files unresolved +Ensure that subrepos pay attention to default:pushurl + + $ cat > cloned/.hg/hgrc << EOF + > [paths] + > default:pushurl = http://localhost:$HGPORT/main + > EOF + + $ hg -R cloned out -S --config paths.default=bogus://invalid + comparing with http://localhost:$HGPORT/main + searching for changes + no changes found + comparing with http://localhost:$HGPORT/sub + searching for changes + no changes found + [1] + + $ hg -R cloned push --config paths.default=bogus://invalid + pushing to http://localhost:$HGPORT/main + no changes made to subrepo sub since last push to http://localhost:$HGPORT/sub + searching for changes + no changes found + abort: HTTP Error 403: ssl required + [255] + Checking cloned repo ids $ hg id -R cloned