changeset 26057:10917b062adf

commands.push: use paths API 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.
author Gregory Szorc <gregory.szorc@gmail.com>
date Fri, 07 Aug 2015 22:39:47 -0700
parents 5f2a4fc3c4fa
children e7fe0a12376c
files mercurial/commands.py tests/test-default-push.t
diffstat 2 files changed, 6 insertions(+), 11 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/commands.py	Sat Aug 08 00:16:02 2015 -0700
+++ b/mercurial/commands.py	Fri Aug 07 22:39:47 2015 -0700
@@ -5274,18 +5274,14 @@
                 # 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)]
--- a/tests/test-default-push.t	Sat Aug 08 00:16:02 2015 -0700
+++ b/tests/test-default-push.t	Fri Aug 07 22:39:47 2015 -0700
@@ -18,7 +18,6 @@
 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]