changeset 20558:c4f45ce85351

push: provide a hint when no paths in configured (issue3692) When user type "hg push" command then this patch helps user by providing hint if no default path is configured. Second patch is the test coverage, to test the change behaviour of first patch.
author anuraggoel <anurag.dsps@gmail.com>
date Tue, 25 Feb 2014 04:11:11 +0530
parents 514d32de6646
children 165b117ffc1e
files mercurial/commands.py tests/test-default-push.t
diffstat 2 files changed, 19 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/commands.py	Mon Feb 24 22:42:14 2014 +0100
+++ b/mercurial/commands.py	Tue Feb 25 04:11:11 2014 +0530
@@ -4620,7 +4620,15 @@
     dest, branches = hg.parseurl(dest, opts.get('branch'))
     ui.status(_('pushing to %s\n') % util.hidepassword(dest))
     revs, checkout = hg.addbranchrevs(repo, repo, branches, opts.get('rev'))
-    other = hg.peer(repo, opts, dest)
+    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
+
     if revs:
         revs = [repo.lookup(r) for r in scmutil.revrange(repo, revs)]
 
--- a/tests/test-default-push.t	Mon Feb 24 22:42:14 2014 +0100
+++ b/tests/test-default-push.t	Tue Feb 25 04:11:11 2014 +0530
@@ -15,6 +15,16 @@
   $ echo b >> b/a
   $ hg --cwd b ci -mb
 
+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]
+
+  $ cd ..
+
 Push should push to 'default' when 'default-push' not set:
 
   $ hg --cwd b push