Patchwork hg should provide hint when no paths configured

login
register
mail settings
Submitter Anurag Goel
Date Feb. 9, 2014, 9:04 p.m.
Message ID <621cf9216b4a4378314e.1391979878@ubuntu.ubuntu-domain>
Download mbox | patch
Permalink /patch/3523/
State Deferred
Headers show

Comments

Anurag Goel - Feb. 9, 2014, 9:04 p.m.
# HG changeset patch
# User anuraggoel <anurag.dsps@gmail.com>
# Date 1391979569 -19800
#      Mon Feb 10 02:29:29 2014 +0530
# Node ID 621cf9216b4a4378314e7ddf5d0ab36c95d46cfd
# Parent  fff0a71f8177be4ca634784d8b603c8e4d6c3601
hg should provide hint when no paths configured

push : hg should provide hint when no paths configured (issue3692)

Previously when user type the command "hg push" ,it directly push the file into default set path which if congiured in .hgrc file.But now it notifies user with mesaage showing location of default path and also prompt user whether he wants to continue or not.
Matt Mackall - Feb. 9, 2014, 10:08 p.m.
On Mon, 2014-02-10 at 02:34 +0530, Anurag Goel wrote:
> # HG changeset patch
> # User anuraggoel <anurag.dsps@gmail.com>
> # Date 1391979569 -19800
> #      Mon Feb 10 02:29:29 2014 +0530
> # Node ID 621cf9216b4a4378314e7ddf5d0ab36c95d46cfd
> # Parent  fff0a71f8177be4ca634784d8b603c8e4d6c3601
> hg should provide hint when no paths configured

What is this line?

> push : hg should provide hint when no paths configured (issue3692)

This should be the first line. But there is an extra space before the
colon.

> Previously when user type the command "hg push" ,it directly push the
> file into default set path which if congiured in .hgrc file.

Which is 100% exactly the way it should work.

> But now it notifies user with mesaage showing location of default path
> and also prompt user whether he wants to continue or not.

Uh.. what??

Why would anyone want a confirmation prompt for the path they've already
configured? This is not what the bug report is asking for at all.

We ONLY want it to do something different if there is NO default path
and NO default-push path configured. In which case there is nothing to
prompt for, because there's nothing to do except abort. Instead, you
provide the user a HINT (see the 'hint' in your subject?) on how to
configure their default path. For instance:

$ hg push
abort: no default path configured
(see the 'path' section in 'hg help config') <- this is a hint
$

> +            choice=raw_input()

This line doesn't pass check-code.

Patch

diff -r fff0a71f8177 -r 621cf9216b4a mercurial/commands.py
--- a/mercurial/commands.py	Thu Feb 06 02:17:48 2014 +0100
+++ b/mercurial/commands.py	Mon Feb 10 02:29:29 2014 +0530
@@ -4707,7 +4707,15 @@ 
                 # this lets simultaneous -r, -b options continue working
                 opts.setdefault('rev', []).append("null")
 
-    dest = ui.expandpath(dest or 'default-push', dest or 'default')
+    if not dest:           
+        dest=ui.expandpath('default-push','default')
+        if dest != 'default-push':
+            ui.status(_('Your default push location is %s\n') % util.hidepassword(dest))
+            ui.status('choose option to continue pushing [y/n] ')
+            choice=raw_input()
+            if choice == 'n':
+                return 
+
     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'))