Patchwork [V4] push: provide a hint when no paths in configured (issue3692)

login
register
mail settings
Submitter Anurag Goel
Date Feb. 24, 2014, 2:22 p.m.
Message ID <933e6df22e746615a7eb.1393251732@ubuntu.ubuntu-domain>
Download mbox | patch
Permalink /patch/3742/
State Superseded
Commit c4f45ce85351ae17d637c8f276d6805d4ed580a4
Headers show

Comments

Anurag Goel - Feb. 24, 2014, 2:22 p.m.
# HG changeset patch
# User anuraggoel <anurag.dsps@gmail.com>
# Date 1393251550 -19800
#      Mon Feb 24 19:49:10 2014 +0530
# Node ID 933e6df22e746615a7ebc7e6f3856e26580ec685
# Parent  aa021ece4506f5e962c8d87ab58ab594a0105ced
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.
Matt Mackall - Feb. 24, 2014, 6:56 p.m.
On Mon, 2014-02-24 at 19:52 +0530, Anurag Goel wrote:
> # HG changeset patch
> # User anuraggoel <anurag.dsps@gmail.com>
> # Date 1393251550 -19800
> #      Mon Feb 24 19:49:10 2014 +0530
> # Node ID 933e6df22e746615a7ebc7e6f3856e26580ec685
> # Parent  aa021ece4506f5e962c8d87ab58ab594a0105ced
> 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.

Please add test coverage. That means:

a) find a test that does a push
b) add a push with no default path
c) make sure the test passes with the right result

Patch

diff -r aa021ece4506 -r 933e6df22e74 mercurial/commands.py
--- a/mercurial/commands.py	Thu Feb 20 00:46:13 2014 -0600
+++ b/mercurial/commands.py	Mon Feb 24 19:49:10 2014 +0530
@@ -4614,7 +4614,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)]