[PATCH v4] outgoing: respect ":pushurl" paths (issue5365)
Augie Fackler
raf at durin42.com
Fri Dec 15 18:10:19 EST 2017
> On Dec 15, 2017, at 11:22, Hollis Blanchard <hollis_blanchard at mentor.com> wrote:
>
> # HG changeset patch
> # User Hollis Blanchard <hollis_blanchard at mentor.com>
> # Date 1513292635 28800
> # Thu Dec 14 15:03:55 2017 -0800
> # Node ID ad9e8305ba268522808a3a0ee415b47e5b9d7874
> # Parent 4937db58b663faa6893c51a41cec28114a165dd0
> outgoing: respect ":pushurl" paths (issue5365)
Queued, thanks.
>
> 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'.
> ---
> v4:
> * simplify the code by allowing the "not found!" error message to change
> * fix handling of invalid/unknown paths
> * update 'outgoing()' revset predicate too
>
> diff --git a/mercurial/hg.py b/mercurial/hg.py
> --- a/mercurial/hg.py
> +++ b/mercurial/hg.py
> @@ -912,8 +912,13 @@ def incoming(ui, repo, source, opts):
> 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 --git a/mercurial/revset.py b/mercurial/revset.py
> --- a/mercurial/revset.py
> +++ b/mercurial/revset.py
> @@ -1416,8 +1416,16 @@ def outgoing(repo, subset, x):
> 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 --git a/tests/test-incoming-outgoing.t b/tests/test-incoming-outgoing.t
> --- a/tests/test-incoming-outgoing.t
> +++ b/tests/test-incoming-outgoing.t
> @@ -491,3 +491,63 @@ incoming from empty remote repository
> 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 --git a/tests/test-revset-outgoing.t b/tests/test-revset-outgoing.t
> --- a/tests/test-revset-outgoing.t
> +++ b/tests/test-revset-outgoing.t
> @@ -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 ..
More information about the Mercurial-devel
mailing list