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

login
register
mail settings
Submitter Anurag Goel
Date Feb. 24, 2014, 10:44 p.m.
Message ID <4da8330542ac0b05a206.1393281859@ubuntu.ubuntu-domain>
Download mbox | patch
Permalink /patch/3752/
State Accepted
Commit c4f45ce85351ae17d637c8f276d6805d4ed580a4
Headers show

Comments

Anurag Goel - Feb. 24, 2014, 10:44 p.m.
# HG changeset patch
# User anuraggoel <anurag.dsps@gmail.com>
# Date 1393281671 -19800
#      Tue Feb 25 04:11:11 2014 +0530
# Node ID 4da8330542ac0b05a206f85aabd33e51f15705ca
# 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.

Second patch is the test coverage, to test the change behaviour of
first patch.
Matt Mackall - Feb. 24, 2014, 11:22 p.m.
On Tue, 2014-02-25 at 04:14 +0530, Anurag Goel wrote:
> # HG changeset patch
> # User anuraggoel <anurag.dsps@gmail.com>
> # Date 1393281671 -19800
> #      Tue Feb 25 04:11:11 2014 +0530
> # Node ID 4da8330542ac0b05a206f85aabd33e51f15705ca
> # Parent  aa021ece4506f5e962c8d87ab58ab594a0105ced
> push: provide a hint when no paths in configured (issue3692)

Queued. Congrats!

By the way, check-code said:

tests/test-default-push.t:20:
 >   $ hg push --config paths.default= 
 trailing whitespace on non-output
*** check-code complained ***

..which is something the test suite should be telling you when you run
it. I've fixed it on my end.
Anurag Goel - Feb. 24, 2014, 11:40 p.m.
Finally my first patch gets accepted.

Looking forward to work harder so that more patch gets accepted and
correspondingly make my contribution of efforts to this org.

Thanks for helping me out.
Anurag


On Tue, Feb 25, 2014 at 4:52 AM, Matt Mackall <mpm@selenic.com> wrote:

> On Tue, 2014-02-25 at 04:14 +0530, Anurag Goel wrote:
> > # HG changeset patch
> > # User anuraggoel <anurag.dsps@gmail.com>
> > # Date 1393281671 -19800
> > #      Tue Feb 25 04:11:11 2014 +0530
> > # Node ID 4da8330542ac0b05a206f85aabd33e51f15705ca
> > # Parent  aa021ece4506f5e962c8d87ab58ab594a0105ced
> > push: provide a hint when no paths in configured (issue3692)
>
> Queued. Congrats!
>
> By the way, check-code said:
>
> tests/test-default-push.t:20:
>  >   $ hg push --config paths.default=
>  trailing whitespace on non-output
> *** check-code complained ***
>
> ..which is something the test suite should be telling you when you run
> it. I've fixed it on my end.
>
> --
> Mathematics is the supreme nostalgia of our time.
>
>
>

Patch

diff -r aa021ece4506 -r 4da8330542ac mercurial/commands.py
--- a/mercurial/commands.py	Thu Feb 20 00:46:13 2014 -0600
+++ b/mercurial/commands.py	Tue Feb 25 04:11:11 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)]
 
diff -r aa021ece4506 -r 4da8330542ac tests/test-default-push.t
--- a/tests/test-default-push.t	Thu Feb 20 00:46:13 2014 -0600
+++ 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