config: use the same hgrc for a cloned repo as for an uninitted repo
This just copies the same local sample hgrc, except it sets the
default path to the repo it was cloned from.
This is cut-and-paste from the local sample hgrc, but I think it's
acceptable, since the two pieces of code are right next to each other
and they're small. There is danger of them going out of synch, but it
would complicate the code too much to get rid of this C&P.
I also add ui as an import to hg.py, but with demandimport, this
should not be a noticeable performance hit.
--- a/mercurial/commands.py Wed Oct 08 07:45:51 2014 -0400
+++ b/mercurial/commands.py Mon Oct 06 16:35:02 2014 -0400
@@ -22,6 +22,7 @@
import random
import setdiscovery, treediscovery, dagutil, pvec, localrepo
import phases, obsolete, exchange
+import ui as uimod
table = {}
@@ -1558,14 +1559,12 @@
if os.path.exists(f):
break
else:
- from ui import samplehgrcs
-
if opts.get('global'):
- samplehgrc = samplehgrcs['global']
+ samplehgrc = uimod.samplehgrcs['global']
elif opts.get('local'):
- samplehgrc = samplehgrcs['local']
+ samplehgrc = uimod.samplehgrcs['local']
else:
- samplehgrc = samplehgrcs['user']
+ samplehgrc = uimod.samplehgrcs['user']
f = paths[0]
fp = open(f, "w")
--- a/mercurial/hg.py Wed Oct 08 07:45:51 2014 -0400
+++ b/mercurial/hg.py Mon Oct 06 16:35:02 2014 -0400
@@ -9,9 +9,11 @@
from i18n import _
from lock import release
from node import nullid
+
import localrepo, bundlerepo, unionrepo, httppeer, sshpeer, statichttprepo
import bookmarks, lock, util, extensions, error, node, scmutil, phases, url
import cmdutil, discovery, repoview, exchange
+import ui as uimod
import merge as mergemod
import verify as verifymod
import errno, os, shutil
@@ -429,18 +431,7 @@
destrepo = destpeer.local()
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'
- )
+ template = uimod.samplehgrcs['cloned']
fp = destrepo.opener("hgrc", "w", text=True)
u = util.url(abspath)
u.passwd = None
--- a/mercurial/ui.py Wed Oct 08 07:45:51 2014 -0400
+++ b/mercurial/ui.py Mon Oct 06 16:35:02 2014 -0400
@@ -26,6 +26,23 @@
# progress =
# color =""",
+ 'cloned':
+"""# example repository config (see "hg help config" for more info)
+[paths]
+default = %s
+
+# path aliases to other clones of this repo in URLs or filesystem paths
+# (see "hg help config.paths" for more info)
+#
+# default-push = ssh://jdoe@example.net/hg/jdoes-fork
+# my-fork = ssh://jdoe@example.net/hg/jdoes-fork
+# my-clone = /home/jdoe/jdoes-clone
+
+[ui]
+# name and email (local to this repository, optional), e.g.
+# username = Jane Doe <jdoe@example.com>
+""",
+
'local':
"""# example repository config (see "hg help config" for more info)
[paths]
--- a/tests/test-default-push.t Wed Oct 08 07:45:51 2014 -0400
+++ b/tests/test-default-push.t Mon Oct 06 16:35:02 2014 -0400
@@ -37,6 +37,7 @@
Push should push to 'default-push' when set:
+ $ echo '[paths]' >> b/.hg/hgrc
$ echo 'default-push = ../c' >> b/.hg/hgrc
$ hg --cwd b push
pushing to $TESTTMP/c (glob)
@@ -45,4 +46,3 @@
adding manifests
adding file changes
added 1 changesets with 1 changes to 1 files
-
--- a/tests/test-hgrc.t Wed Oct 08 07:45:51 2014 -0400
+++ b/tests/test-hgrc.t Mon Oct 06 16:35:02 2014 -0400
@@ -28,16 +28,20 @@
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]
+ # example repository config (see "hg help config" for more info)
+ [paths]
+ default = $TESTTMP/foo%bar
+
+ # path aliases to other clones of this repo in URLs or filesystem paths
+ # (see "hg help config.paths" for more info)
+ #
+ # default-push = ssh://jdoe@example.net/hg/jdoes-fork
+ # my-fork = ssh://jdoe@example.net/hg/jdoes-fork
+ # my-clone = /home/jdoe/jdoes-clone
+
+ [ui]
+ # name and email (local to this repository, optional), e.g.
# username = Jane Doe <jdoe@example.com>
- [paths]
- default = $TESTTMP/foo%bar (glob)
$ hg paths
default = $TESTTMP/foo%bar (glob)
$ hg showconfig
--- a/tests/test-pull-http.t Wed Oct 08 07:45:51 2014 -0400
+++ b/tests/test-pull-http.t Mon Oct 06 16:35:02 2014 -0400
@@ -26,16 +26,20 @@
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>
+ # example repository config (see "hg help config" for more info)
[paths]
default = http://foo@localhost:$HGPORT/
+
+ # path aliases to other clones of this repo in URLs or filesystem paths
+ # (see "hg help config.paths" for more info)
+ #
+ # default-push = ssh://jdoe@example.net/hg/jdoes-fork
+ # my-fork = ssh://jdoe@example.net/hg/jdoes-fork
+ # my-clone = /home/jdoe/jdoes-clone
+
+ [ui]
+ # name and email (local to this repository, optional), e.g.
+ # username = Jane Doe <jdoe@example.com>
$ "$TESTDIR/killdaemons.py" $DAEMON_PIDS
expect error, cloning not allowed
--- a/tests/test-revset-outgoing.t Wed Oct 08 07:45:51 2014 -0400
+++ b/tests/test-revset-outgoing.t Mon Oct 06 16:35:02 2014 -0400
@@ -36,16 +36,20 @@
$ 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]
+ # example repository config (see "hg help config" for more info)
+ [paths]
+ default = $TESTTMP/a#stable
+
+ # path aliases to other clones of this repo in URLs or filesystem paths
+ # (see "hg help config.paths" for more info)
+ #
+ # default-push = ssh://jdoe@example.net/hg/jdoes-fork
+ # my-fork = ssh://jdoe@example.net/hg/jdoes-fork
+ # my-clone = /home/jdoe/jdoes-clone
+
+ [ui]
+ # name and email (local to this repository, optional), e.g.
# username = Jane Doe <jdoe@example.com>
- [paths]
- default = $TESTTMP/a#stable (glob)
$ echo red >> a
$ hg ci -qm3
@@ -84,24 +88,29 @@
$ 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]
+ # example repository config (see "hg help config" for more info)
+ [paths]
+ default = $TESTTMP/a#stable
+
+ # path aliases to other clones of this repo in URLs or filesystem paths
+ # (see "hg help config.paths" for more info)
+ #
+ # default-push = ssh://jdoe@example.net/hg/jdoes-fork
+ # my-fork = ssh://jdoe@example.net/hg/jdoes-fork
+ # my-clone = /home/jdoe/jdoes-clone
+
+ [ui]
+ # name and email (local to this repository, optional), e.g.
# username = Jane Doe <jdoe@example.com>
- [paths]
- default = $TESTTMP/a#stable (glob)
green = ../a#default
$ hg tout green
- comparing with $TESTTMP/a (glob)
- searching for changes
- 3:f0461977a3db: '4'
+ comparing with green
+ abort: repository green not found!
+ [255]
$ hg tlog -r 'outgoing("green")'
- 3:f0461977a3db: '4'
+ abort: repository green not found!
+ [255]
$ cd ..
--- a/tests/test-url-rev.t Wed Oct 08 07:45:51 2014 -0400
+++ b/tests/test-url-rev.t Mon Oct 06 16:35:02 2014 -0400
@@ -41,16 +41,20 @@
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]
+ # example repository config (see "hg help config" for more info)
+ [paths]
+ default = $TESTTMP/repo#foo
+
+ # path aliases to other clones of this repo in URLs or filesystem paths
+ # (see "hg help config.paths" for more info)
+ #
+ # default-push = ssh://jdoe@example.net/hg/jdoes-fork
+ # my-fork = ssh://jdoe@example.net/hg/jdoes-fork
+ # my-clone = /home/jdoe/jdoes-clone
+
+ [ui]
+ # name and email (local to this repository, optional), e.g.
# username = Jane Doe <jdoe@example.com>
- [paths]
- default = $TESTTMP/repo#foo (glob)
Changing original repo: