Patchwork [2,of,2,V3] config: use the same hgrc for a cloned repo as for an uninitted repo

login
register
mail settings
Submitter Jordi Gutiérrez Hermoso
Date Oct. 8, 2014, 9:42 p.m.
Message ID <ac56ac72a4f34fc8ceef.1412804522@Iris>
Download mbox | patch
Permalink /patch/6162/
State Accepted
Headers show

Comments

Jordi Gutiérrez Hermoso - Oct. 8, 2014, 9:42 p.m.
# HG changeset patch
# User Jordi Gutiérrez Hermoso <jordigh@octave.org>
# Date 1412627702 14400
#      Mon Oct 06 16:35:02 2014 -0400
# Node ID ac56ac72a4f34fc8ceef9d2b300e96028bf5feff
# Parent  8b24e30d30e8f9b95ef1284da81746a1f3e0ee64
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.
Augie Fackler - Oct. 9, 2014, 2:03 p.m.
On Wed, Oct 08, 2014 at 05:42:02PM -0400, Jordi Gutiérrez Hermoso wrote:
> # HG changeset patch
> # User Jordi Gutiérrez Hermoso <jordigh@octave.org>
> # Date 1412627702 14400
> #      Mon Oct 06 16:35:02 2014 -0400
> # Node ID ac56ac72a4f34fc8ceef9d2b300e96028bf5feff
> # Parent  8b24e30d30e8f9b95ef1284da81746a1f3e0ee64
> config: use the same hgrc for a cloned repo as for an uninitted repo

Looks good, at least as a start. Queued.

>
> 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/hg.py b/mercurial/hg.py
> --- a/mercurial/hg.py
> +++ b/mercurial/hg.py
> @@ -9,9 +9,10 @@
>  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 cmdutil, discovery, repoview, exchange, ui
>  import merge as mergemod
>  import verify as verifymod
>  import errno, os, shutil
> @@ -422,18 +423,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 <jdoe@example.com>\n'
> -                '[paths]\n'
> -                'default = %s\n'
> -                )
> +            template = ui.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@example.com>
> +""",
> +
>      'local':
>  """# example repository config (see "hg help config" for more info)
>  [paths]
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel@selenic.com
> http://selenic.com/mailman/listinfo/mercurial-devel
Augie Fackler - Oct. 9, 2014, 6:26 p.m.
On Thu, Oct 9, 2014 at 10:03 AM, Augie Fackler <raf@durin42.com> wrote:
> On Wed, Oct 08, 2014 at 05:42:02PM -0400, Jordi Gutiérrez Hermoso wrote:
>> # HG changeset patch
>> # User Jordi Gutiérrez Hermoso <jordigh@octave.org>
>> # Date 1412627702 14400
>> #      Mon Oct 06 16:35:02 2014 -0400
>> # Node ID ac56ac72a4f34fc8ceef9d2b300e96028bf5feff
>> # Parent  8b24e30d30e8f9b95ef1284da81746a1f3e0ee64
>> config: use the same hgrc for a cloned repo as for an uninitted repo
>
> Looks good, at least as a start. Queued.


Pushed with some test fixes, FYI.

Patch

diff --git a/mercurial/hg.py b/mercurial/hg.py
--- a/mercurial/hg.py
+++ b/mercurial/hg.py
@@ -9,9 +9,10 @@ 
 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 cmdutil, discovery, repoview, exchange, ui
 import merge as mergemod
 import verify as verifymod
 import errno, os, shutil
@@ -422,18 +423,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 <jdoe@example.com>\n'
-                '[paths]\n'
-                'default = %s\n'
-                )
+            template = ui.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@example.com>
+""",
+
     'local':
 """# example repository config (see "hg help config" for more info)
 [paths]