# HG changeset patch # User Jordi GutiƩrrez Hermoso # Date 2014-10-06 20:35:02 # Node ID 2be7d5ebd4d0552493ce18c509686286ee712010 # Parent 5a831e4e6d7a4a33651f51c73ff413cb3d77eb9e 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. diff --git a/mercurial/commands.py b/mercurial/commands.py --- a/mercurial/commands.py +++ b/mercurial/commands.py @@ -22,6 +22,7 @@ import dagparser, context, simplemerge, import random import setdiscovery, treediscovery, dagutil, pvec, localrepo import phases, obsolete, exchange +import ui as uimod table = {} @@ -1558,14 +1559,12 @@ def config(ui, repo, *values, **opts): 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") diff --git a/mercurial/hg.py b/mercurial/hg.py --- a/mercurial/hg.py +++ b/mercurial/hg.py @@ -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 @@ def clone(ui, peeropts, source, dest=Non 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 \n' - '[paths]\n' - 'default = %s\n' - ) + template = uimod.samplehgrcs['cloned'] fp = destrepo.opener("hgrc", "w", text=True) u = util.url(abspath) u.passwd = None diff --git a/mercurial/ui.py b/mercurial/ui.py --- a/mercurial/ui.py +++ b/mercurial/ui.py @@ -26,6 +26,23 @@ username = # 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 +""", + 'local': """# example repository config (see "hg help config" for more info) [paths] diff --git a/tests/test-default-push.t b/tests/test-default-push.t --- a/tests/test-default-push.t +++ b/tests/test-default-push.t @@ -37,6 +37,7 @@ Push should push to 'default' when 'defa 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 @@ Push should push to 'default-push' when adding manifests adding file changes added 1 changesets with 1 changes to 1 files - diff --git a/tests/test-hgrc.t b/tests/test-hgrc.t --- a/tests/test-hgrc.t +++ b/tests/test-hgrc.t @@ -28,16 +28,20 @@ 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] + # 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 - [paths] - default = $TESTTMP/foo%bar (glob) $ hg paths default = $TESTTMP/foo%bar (glob) $ hg showconfig 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,16 +26,20 @@ 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 + # 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 $ "$TESTDIR/killdaemons.py" $DAEMON_PIDS expect error, cloning not allowed 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,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 - [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 - [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 .. 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,16 +41,20 @@ 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] + # 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 - [paths] - default = $TESTTMP/repo#foo (glob) Changing original repo: