changeset 22380:82b2ba904e3e

clone: provide sample username = config entry in .hg/hgrc (issue4359) Some users clone from a server before ever running 'hg config --edit', so they don't see our helpful template for things like enabling the username. Attempt to give them some helpful guidance.
author Augie Fackler <raf@durin42.com>
date Tue, 09 Sep 2014 17:16:24 -0400
parents 38a393d59e77
children 392ae5cb8d62
files mercurial/hg.py tests/test-hgrc.t tests/test-pull-http.t tests/test-revset-outgoing.t tests/test-url-rev.t
diffstat 5 files changed, 53 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/hg.py	Tue Sep 09 16:51:21 2014 -0400
+++ b/mercurial/hg.py	Tue Sep 09 17:16:24 2014 -0400
@@ -432,12 +432,23 @@
                 destpeer.pushkey('bookmarks', k, '', hex(n))
 
         if destrepo:
+            template = (
+                '# You may want to set your username here if it is not set\n'
+                "# globally, or this repository requires a different\n"
+                '# username from your usual configuration. If you want to\n'
+                '# set something for all of your repositories on this\n'
+                '# computer, try running the command\n'
+                "# 'hg config --edit --global'\n"
+                '# [ui]\n'
+                '# username = Jane Doe <jdoe@example.com>\n'
+                '[paths]\n'
+                'default = %s\n'
+                )
             fp = destrepo.opener("hgrc", "w", text=True)
-            fp.write("[paths]\n")
             u = util.url(abspath)
             u.passwd = None
             defaulturl = str(u)
-            fp.write("default = %s\n" % defaulturl)
+            fp.write(template % defaulturl)
             fp.close()
 
             destrepo.ui.setconfig('paths', 'default', defaulturl, 'clone')
--- a/tests/test-hgrc.t	Tue Sep 09 16:51:21 2014 -0400
+++ b/tests/test-hgrc.t	Tue Sep 09 17:16:24 2014 -0400
@@ -28,6 +28,14 @@
   0 files updated, 0 files merged, 0 files removed, 0 files unresolved
   $ cd foobar
   $ cat .hg/hgrc
+  # You may want to set your username here if it is not set
+  # globally, or this repository requires a different
+  # username from your usual configuration. If you want to
+  # set something for all of your repositories on this
+  # computer, try running the command
+  # 'hg config --edit --global'
+  # [ui]
+  # username = Jane Doe <jdoe@example.com>
   [paths]
   default = $TESTTMP/foo%bar (glob)
   $ hg paths
--- a/tests/test-pull-http.t	Tue Sep 09 16:51:21 2014 -0400
+++ b/tests/test-pull-http.t	Tue Sep 09 17:16:24 2014 -0400
@@ -26,6 +26,14 @@
   updating to branch default
   1 files updated, 0 files merged, 0 files removed, 0 files unresolved
   $ cat test3/.hg/hgrc
+  # You may want to set your username here if it is not set
+  # globally, or this repository requires a different
+  # username from your usual configuration. If you want to
+  # set something for all of your repositories on this
+  # computer, try running the command
+  # 'hg config --edit --global'
+  # [ui]
+  # username = Jane Doe <jdoe@example.com>
   [paths]
   default = http://foo@localhost:$HGPORT/
   $ "$TESTDIR/killdaemons.py" $DAEMON_PIDS
--- a/tests/test-revset-outgoing.t	Tue Sep 09 16:51:21 2014 -0400
+++ b/tests/test-revset-outgoing.t	Tue Sep 09 17:16:24 2014 -0400
@@ -36,6 +36,14 @@
 
   $ cd b
   $ cat .hg/hgrc
+  # You may want to set your username here if it is not set
+  # globally, or this repository requires a different
+  # username from your usual configuration. If you want to
+  # set something for all of your repositories on this
+  # computer, try running the command
+  # 'hg config --edit --global'
+  # [ui]
+  # username = Jane Doe <jdoe@example.com>
   [paths]
   default = $TESTTMP/a#stable (glob)
 
@@ -76,6 +84,14 @@
   $ echo "green = ../a#default" >> .hg/hgrc
 
   $ cat .hg/hgrc
+  # You may want to set your username here if it is not set
+  # globally, or this repository requires a different
+  # username from your usual configuration. If you want to
+  # set something for all of your repositories on this
+  # computer, try running the command
+  # 'hg config --edit --global'
+  # [ui]
+  # username = Jane Doe <jdoe@example.com>
   [paths]
   default = $TESTTMP/a#stable (glob)
   green = ../a#default
--- a/tests/test-url-rev.t	Tue Sep 09 16:51:21 2014 -0400
+++ b/tests/test-url-rev.t	Tue Sep 09 17:16:24 2014 -0400
@@ -41,6 +41,14 @@
   summary:     change a
   
   $ cat clone/.hg/hgrc
+  # You may want to set your username here if it is not set
+  # globally, or this repository requires a different
+  # username from your usual configuration. If you want to
+  # set something for all of your repositories on this
+  # computer, try running the command
+  # 'hg config --edit --global'
+  # [ui]
+  # username = Jane Doe <jdoe@example.com>
   [paths]
   default = $TESTTMP/repo#foo (glob)