| From | Sent On | Attachments |
|---|---|---|
| Peter Arrenbrecht | Mar 4, 2008 11:21 pm | |
| Bryan O'Sullivan | Mar 5, 2008 12:00 pm | |
| John Coomes | Mar 5, 2008 3:51 pm | |
| Peter Arrenbrecht | Mar 5, 2008 10:43 pm | |
| John Coomes | Mar 6, 2008 11:51 am | |
| Peter Arrenbrecht | Mar 6, 2008 11:53 pm |
| Subject: | [PATCH] RFC: localrepo: look at .hg/hgrc.d/*.rc after .hg/hgrc | |
|---|---|---|
| From: | Peter Arrenbrecht (pete...@gmail.com) | |
| Date: | Mar 4, 2008 11:21:03 pm | |
| List: | com.selenic.mercurial-devel | |
# HG changeset patch # User Peter Arrenbrecht <peter.arrenbrecht at gmail.com> # Date 1204618799 -3600 # Node ID d0ff9b65278517095c7707911e5ef5e005e30097 # Parent 834b4431d05e35428326d3643655e112901c62b8 RFC: localrepo: look at .hg/hgrc.d/*.rc after .hg/hgrc
This is an attempt to solve the problem of configuring sets of related server repos such that common config is kept central. Instead of adding an include directive to .hg/hgrc, I simply mimick /etc/mercurial/hgrc.d/*.rc for .hg/hgrc.d/*.rc. This allows me to use symlinks to factor out common config:
/var/hg/repos/ hgrc-clonable main/ .hg/ hgrc #contains description, contact hgrc.d/ clonable.rc -> ../../../hgrc-clonable
If this is acceptable, I shall supply tests, too.
diff --git a/mercurial/dispatch.py b/mercurial/dispatch.py
--- a/mercurial/dispatch.py
+++ b/mercurial/dispatch.py
@@ -259,7 +259,7 @@ def _dispatch(ui, args):
if path:
try:
lui = _ui.ui(parentui=ui)
- lui.readconfig(os.path.join(path, ".hg", "hgrc"))
+ lui.readconfig(util.localrepo_rcpath(os.path.join(path, ".hg")),
path)
except IOError:
pass
diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py --- a/mercurial/localrepo.py +++ b/mercurial/localrepo.py @@ -86,7 +86,7 @@ class localrepository(repo.repository):
self.ui = ui.ui(parentui=parentui) try: - self.ui.readconfig(self.join("hgrc"), self.root) + self.ui.readconfig(util.localrepo_rcpath(self.path), self.root) extensions.loadall(self.ui) except IOError: pass diff --git a/mercurial/util.py b/mercurial/util.py --- a/mercurial/util.py +++ b/mercurial/util.py @@ -904,6 +904,20 @@ def lookup_reg(key, name=None, scope=Non def lookup_reg(key, name=None, scope=None): return None
+def rcfiles(path): + rcs = [os.path.join(path, 'hgrc')] + rcdir = os.path.join(path, 'hgrc.d') + try: + rcs.extend([os.path.join(rcdir, f) + for f, kind in osutil.listdir(rcdir) + if f.endswith(".rc")]) + except OSError: + pass + return rcs + +def localrepo_rcpath(reporoot): + return rcfiles(reporoot) + # Platform specific variants if os.name == 'nt': import msvcrt @@ -1096,17 +1110,6 @@ if os.name == 'nt':
else: nulldev = '/dev/null' - - def rcfiles(path): - rcs = [os.path.join(path, 'hgrc')] - rcdir = os.path.join(path, 'hgrc.d') - try: - rcs.extend([os.path.join(rcdir, f) - for f, kind in osutil.listdir(rcdir) - if f.endswith(".rc")]) - except OSError: - pass - return rcs
def system_rcpath(): path = []





