[PATCH 2 of 2 V2] config: use the same hgrc for a cloned repo as for an uninitted repo

Jordi Gutiérrez Hermoso jordigh at octave.org
Mon Oct 6 15:41:30 CDT 2014


# HG changeset patch
# User Jordi Gutiérrez Hermoso <jordigh at octave.org>
# Date 1412627702 14400
#      Mon Oct 06 16:35:02 2014 -0400
# Node ID d14bc6947adc7229ae464bdb67ff79f2e10f04c2
# Parent  eaf28cae9dedb26c7a78a371b7435589a1482cf3
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.

diff --git a/mercurial/hg.py b/mercurial/hg.py
--- a/mercurial/hg.py
+++ b/mercurial/hg.py
@@ -422,18 +422,8 @@ 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 <jdoe at example.com>\n'
-                '[paths]\n'
-                'default = %s\n'
-                )
+            from ui import samplehgrcs
+            template = 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 <jdoe at example.com>
+""",
+
     'local':
 """# example repository config (see "hg help config" for more info)
 [paths]


More information about the Mercurial-devel mailing list