[PATCH 2 of 2] commands.push: use paths API
Augie Fackler
raf at durin42.com
Fri Aug 21 20:30:59 UTC 2015
On Tue, Aug 18, 2015 at 10:07:55PM -0700, Gregory Szorc wrote:
> # HG changeset patch
> # User Gregory Szorc <gregory.szorc at gmail.com>
> # Date 1439012387 25200
> # Fri Aug 07 22:39:47 2015 -0700
> # Node ID d75d57eea9af5d62a24356f129aa2d774ec32c03
> # Parent 1699cd0bac167bd24f710c849d78d6a6c0089ac9
> commands.push: use paths API
patches lgtm, queued, thanks
>
> ui.path instances now collect most of the data used by commands.push().
> Move away from ui.expandpath() and call ui.paths.getpath() to get a
> path instance.
>
> Some "pushing to" output was dropped as one test demonstrates. I believe
> the dropped message was redundant with the error message and the change
> to be acceptable.
>
> diff --git a/mercurial/commands.py b/mercurial/commands.py
> --- a/mercurial/commands.py
> +++ b/mercurial/commands.py
> @@ -5273,20 +5273,16 @@ def push(ui, repo, dest=None, **opts):
> # if we try to push a deleted bookmark, translate it to null
> # this lets simultaneous -r, -b options continue working
> opts.setdefault('rev', []).append("null")
>
> - dest = ui.expandpath(dest or 'default-push', dest or 'default')
> - dest, branches = hg.parseurl(dest, opts.get('branch'))
> + path = ui.paths.getpath(dest or 'default-push', default='default')
> + if not path:
> + raise util.Abort(_('default repository not configured!'),
> + hint=_('see the "path" section in "hg help config"'))
> + dest, branches = path.loc, (path.branch, opts.get('branch') or [])
> ui.status(_('pushing to %s\n') % util.hidepassword(dest))
> revs, checkout = hg.addbranchrevs(repo, repo, branches, opts.get('rev'))
> - try:
> - other = hg.peer(repo, opts, dest)
> - except error.RepoError:
> - if dest == "default-push":
> - raise util.Abort(_("default repository not configured!"),
> - hint=_('see the "path" section in "hg help config"'))
> - else:
> - raise
> + other = hg.peer(repo, opts, dest)
>
> if revs:
> revs = [repo.lookup(r) for r in scmutil.revrange(repo, revs)]
> if not revs:
> 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
> @@ -17,9 +17,8 @@
>
> Push should provide a hint when both 'default' and 'default-push' not set:
> $ cd c
> $ hg push --config paths.default=
> - pushing to default-push
> abort: default repository not configured!
> (see the "path" section in "hg help config")
> [255]
>
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel at selenic.com
> https://selenic.com/mailman/listinfo/mercurial-devel
More information about the Mercurial-devel
mailing list