# HG changeset patch # User Augie Fackler # Date 2014-09-09 21:16:24 # Node ID 82b2ba904e3ec0668760c0cefd5ced87b533b45d # Parent 38a393d59e777e2c7b05705f58a7c2b97471a3e5 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. diff --git a/mercurial/hg.py b/mercurial/hg.py --- a/mercurial/hg.py +++ b/mercurial/hg.py @@ -432,12 +432,23 @@ def clone(ui, peeropts, source, dest=Non 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 \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') diff --git a/tests/test-hgrc.t b/tests/test-hgrc.t --- a/tests/test-hgrc.t +++ b/tests/test-hgrc.t @@ -28,6 +28,14 @@ Issue1199: Can't use '%' in hgrc (eg url 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 [paths] default = $TESTTMP/foo%bar (glob) $ hg paths diff --git a/tests/test-pull-http.t b/tests/test-pull-http.t --- a/tests/test-pull-http.t +++ b/tests/test-pull-http.t @@ -26,6 +26,14 @@ Cloning with a password in the URL shoul 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 [paths] default = http://foo@localhost:$HGPORT/ $ "$TESTDIR/killdaemons.py" $DAEMON_PIDS diff --git a/tests/test-revset-outgoing.t b/tests/test-revset-outgoing.t --- a/tests/test-revset-outgoing.t +++ b/tests/test-revset-outgoing.t @@ -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 [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 [paths] default = $TESTTMP/a#stable (glob) green = ../a#default diff --git a/tests/test-url-rev.t b/tests/test-url-rev.t --- a/tests/test-url-rev.t +++ b/tests/test-url-rev.t @@ -41,6 +41,14 @@ Test basic functionality of url#rev synt 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 [paths] default = $TESTTMP/repo#foo (glob)