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

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

Comments

Anurag Goel - Feb. 22, 2014, 2:14 p.m.
# HG changeset patch
# User anuraggoel <anurag.dsps@gmail.com>
# Date 1393077250 -19800
#      Sat Feb 22 19:24:10 2014 +0530
# Node ID b542f30f7b0a71608fa4e43030b35c7226753b87
# Parent  0e2877f8605dcaf4fdf2ab7e0046f1f6f80161dd
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.
Mads Kiilerich - Feb. 22, 2014, 3:39 p.m.
On 02/22/2014 03:14 PM, Anurag Goel wrote:
> # HG changeset patch
> # User anuraggoel <anurag.dsps@gmail.com>
> # Date 1393077250 -19800
> #      Sat Feb 22 19:24:10 2014 +0530
> # Node ID b542f30f7b0a71608fa4e43030b35c7226753b87
> # Parent  0e2877f8605dcaf4fdf2ab7e0046f1f6f80161dd
> 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.

http://mercurial.selenic.com/wiki/ContributingChanges#Patch_descriptions
"all lines less than 80 characters"

> diff -r 0e2877f8605d -r b542f30f7b0a mercurial/commands.py
> --- a/mercurial/commands.py	Sat Feb 15 22:09:32 2014 -0600
> +++ b/mercurial/commands.py	Sat Feb 22 19:24: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)
> +    if dest == "default-push":
> +        try:
> +            other = hg.peer(repo, opts, dest)
> +        except error.RepoError:
> +            raise util.Abort(_("repository default-push not found!"),

How about http://bz.selenic.com/show_bug.cgi?id=3692#c3 ?

(Actually, I would prefer to say something like "default repository not 
configured" and leave the description of the actual names 'default' and 
'default-push' to the help.)

> +                    hint=_('see the "path" section in "hg help config"'))
> +    else:
> +        other = hg.peer(repo, opts, dest)

This way of doing it gives duplication of the 'other =' line.

How about always catching RepoError, then check if dest is default-push 
and either abort or re-raise.

/Mads
Anurag Goel - Feb. 22, 2014, 11:02 p.m.
Apologize for the mistake of "more than 80 characters" in one line.

About the duplication of the 'other =' line, i don't think always catching
RepoError would be a good idea.
There are different RepoError with different abort messages.So if we always
catch RepoError then we have to handle each error message explicitly.
For eg. abort message by "RepoError"  in file "mercurial/sshpeer.py" and
"mercurial/localrepo.py" is different.



On Sat, Feb 22, 2014 at 9:09 PM, Mads Kiilerich <mads@kiilerich.com> wrote:

> On 02/22/2014 03:14 PM, Anurag Goel wrote:
>
>> # HG changeset patch
>> # User anuraggoel <anurag.dsps@gmail.com>
>> # Date 1393077250 -19800
>> #      Sat Feb 22 19:24:10 2014 +0530
>> # Node ID b542f30f7b0a71608fa4e43030b35c7226753b87
>> # Parent  0e2877f8605dcaf4fdf2ab7e0046f1f6f80161dd
>> 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.
>>
>
> http://mercurial.selenic.com/wiki/ContributingChanges#Patch_descriptions
> "all lines less than 80 characters"
>
>
>  diff -r 0e2877f8605d -r b542f30f7b0a mercurial/commands.py
>> --- a/mercurial/commands.py     Sat Feb 15 22:09:32 2014 -0600
>> +++ b/mercurial/commands.py     Sat Feb 22 19:24: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)
>> +    if dest == "default-push":
>> +        try:
>> +            other = hg.peer(repo, opts, dest)
>> +        except error.RepoError:
>> +            raise util.Abort(_("repository default-push not found!"),
>>
>
> How about http://bz.selenic.com/show_bug.cgi?id=3692#c3 ?
>
> (Actually, I would prefer to say something like "default repository not
> configured" and leave the description of the actual names 'default' and
> 'default-push' to the help.)
>
>
>  +                    hint=_('see the "path" section in "hg help config"'))
>> +    else:
>> +        other = hg.peer(repo, opts, dest)
>>
>
> This way of doing it gives duplication of the 'other =' line.
>
> How about always catching RepoError, then check if dest is default-push
> and either abort or re-raise.
>
> /Mads
>
>
Mads Kiilerich - Feb. 23, 2014, 8:37 p.m.
On 02/23/2014 12:02 AM, Anurag Goel wrote:
> Apologize for the mistake of "more than 80 characters" in one line.

And for top posting? :-) http://mercurial.selenic.com/wiki/MailingLists

> About the duplication of the 'other =' line, i don't think always 
> catching RepoError would be a good idea.
> There are different RepoError with different abort messages.So if we 
> always catch RepoError then we have to handle each error message 
> explicitly.
> For eg. abort message by "RepoError"  in file "mercurial/sshpeer.py" 
> and "mercurial/localrepo.py" is different.

Yes, thus the suggestion to re-raise the exception if it not is from a 
default-push dest.

/Mads

Patch

diff -r 0e2877f8605d -r b542f30f7b0a mercurial/commands.py
--- a/mercurial/commands.py	Sat Feb 15 22:09:32 2014 -0600
+++ b/mercurial/commands.py	Sat Feb 22 19:24: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)
+    if dest == "default-push":
+        try:
+            other = hg.peer(repo, opts, dest)
+        except error.RepoError:
+            raise util.Abort(_("repository default-push not found!"),
+                    hint=_('see the "path" section in "hg help config"'))
+    else:
+        other = hg.peer(repo, opts, dest)
+
     if revs:
         revs = [repo.lookup(r) for r in scmutil.revrange(repo, revs)]