##// END OF EJS Templates
Create local ui object per repository, so .hg/hgrc don't get mixed....
Thomas Arendsen Hein -
r1839:876e4e6a default
parent child Browse files
Show More
@@ -0,0 +1,13 b''
1 #!/bin/sh
2 hg init 1
3 echo '[ui]' >> 1/.hg/hgrc
4 echo 'timeout = 10' >> 1/.hg/hgrc
5 echo foo > 1/foo
6 hg --cwd 1 ci -A -m foo
7 hg clone 1 2
8 hg clone 2 3
9 echo '[hooks]' >> 2/.hg/hgrc
10 echo 'changegroup.push = hg push -qf ../1' >> 2/.hg/hgrc
11 echo bar >> 3/foo
12 hg --cwd 3 ci -m bar
13 hg --cwd 3 push ../2
@@ -0,0 +1,7 b''
1 adding foo
2 pushing to ../2
3 searching for changes
4 adding changesets
5 adding manifests
6 adding file changes
7 added 1 changesets with 1 changes to 1 files
@@ -852,7 +852,7 b' class queue:'
852
852
853 def qrepo(self, create=False):
853 def qrepo(self, create=False):
854 if create or os.path.isdir(os.path.join(self.path, ".hg")):
854 if create or os.path.isdir(os.path.join(self.path, ".hg")):
855 return hg.repository(ui=self.ui, path=self.path, create=create)
855 return hg.repository(self.ui, path=self.path, create=create)
856
856
857 def restore(self, repo, rev, delete=None, qupdate=None):
857 def restore(self, repo, rev, delete=None, qupdate=None):
858 c = repo.changelog.read(rev)
858 c = repo.changelog.read(rev)
@@ -780,7 +780,7 b' def clone(ui, source, dest=None, **opts)'
780 f.close()
780 f.close()
781
781
782 if not opts['noupdate']:
782 if not opts['noupdate']:
783 update(ui, repo)
783 update(repo.ui, repo)
784
784
785 d.close()
785 d.close()
786
786
@@ -1067,6 +1067,7 b' def debugconfig(ui):'
1067 """show combined config settings from all hgrc files"""
1067 """show combined config settings from all hgrc files"""
1068 try:
1068 try:
1069 repo = hg.repository(ui)
1069 repo = hg.repository(ui)
1070 ui = repo.ui
1070 except hg.RepoError:
1071 except hg.RepoError:
1071 pass
1072 pass
1072 for section, name, value in ui.walkconfig():
1073 for section, name, value in ui.walkconfig():
@@ -1777,7 +1778,8 b' def paths(ui, search=None):'
1777 and $HOME/.hgrc. If run inside a repository, .hg/hgrc is used, too.
1778 and $HOME/.hgrc. If run inside a repository, .hg/hgrc is used, too.
1778 """
1779 """
1779 try:
1780 try:
1780 repo = hg.repository(ui=ui)
1781 repo = hg.repository(ui)
1782 ui = repo.ui
1781 except hg.RepoError:
1783 except hg.RepoError:
1782 pass
1784 pass
1783
1785
@@ -2852,7 +2854,8 b' def dispatch(args):'
2852
2854
2853 if cmd not in norepo.split():
2855 if cmd not in norepo.split():
2854 path = options["repository"] or ""
2856 path = options["repository"] or ""
2855 repo = hg.repository(ui=u, path=path)
2857 repo = hg.repository(u, path=path)
2858 u = repo.ui
2856 for x in external:
2859 for x in external:
2857 if hasattr(x, 'reposetup'):
2860 if hasattr(x, 'reposetup'):
2858 x.reposetup(u, repo)
2861 x.reposetup(u, repo)
@@ -10,12 +10,12 b' import filelog, manifest, changelog, dir'
10 from node import *
10 from node import *
11 from i18n import gettext as _
11 from i18n import gettext as _
12 from demandload import *
12 from demandload import *
13 demandload(globals(), "re lock transaction tempfile stat mdiff errno")
13 demandload(globals(), "re lock transaction tempfile stat mdiff errno ui")
14
14
15 class localrepository(object):
15 class localrepository(object):
16 def __del__(self):
16 def __del__(self):
17 self.transhandle = None
17 self.transhandle = None
18 def __init__(self, ui, path=None, create=0):
18 def __init__(self, parentui, path=None, create=0):
19 if not path:
19 if not path:
20 p = os.getcwd()
20 p = os.getcwd()
21 while not os.path.isdir(os.path.join(p, ".hg")):
21 while not os.path.isdir(os.path.join(p, ".hg")):
@@ -30,7 +30,7 b' class localrepository(object):'
30 raise repo.RepoError(_("repository %s not found") % path)
30 raise repo.RepoError(_("repository %s not found") % path)
31
31
32 self.root = os.path.abspath(path)
32 self.root = os.path.abspath(path)
33 self.ui = ui
33 self.ui = ui.ui(parentui=parentui)
34 self.opener = util.opener(self.path)
34 self.opener = util.opener(self.path)
35 self.wopener = util.opener(self.root)
35 self.wopener = util.opener(self.root)
36 self.manifest = manifest.manifest(self.opener)
36 self.manifest = manifest.manifest(self.opener)
@@ -45,7 +45,7 b' class localrepository(object):'
45 os.mkdir(self.path)
45 os.mkdir(self.path)
46 os.mkdir(self.join("data"))
46 os.mkdir(self.join("data"))
47
47
48 self.dirstate = dirstate.dirstate(self.opener, ui, self.root)
48 self.dirstate = dirstate.dirstate(self.opener, self.ui, self.root)
49 try:
49 try:
50 self.ui.readconfig(self.join("hgrc"))
50 self.ui.readconfig(self.join("hgrc"))
51 except IOError:
51 except IOError:
@@ -12,18 +12,23 b' demandload(globals(), "re socket sys uti'
12
12
13 class ui(object):
13 class ui(object):
14 def __init__(self, verbose=False, debug=False, quiet=False,
14 def __init__(self, verbose=False, debug=False, quiet=False,
15 interactive=True):
15 interactive=True, parentui=None):
16 self.overlay = {}
16 self.overlay = {}
17 self.cdata = ConfigParser.SafeConfigParser()
17 self.cdata = ConfigParser.SafeConfigParser()
18 self.readconfig(util.rcpath)
18 self.parentui = parentui and parentui.parentui or parentui
19 if parentui is None:
20 self.readconfig(util.rcpath)
19
21
20 self.quiet = self.configbool("ui", "quiet")
22 self.quiet = self.configbool("ui", "quiet")
21 self.verbose = self.configbool("ui", "verbose")
23 self.verbose = self.configbool("ui", "verbose")
22 self.debugflag = self.configbool("ui", "debug")
24 self.debugflag = self.configbool("ui", "debug")
23 self.interactive = self.configbool("ui", "interactive", True)
25 self.interactive = self.configbool("ui", "interactive", True)
24
26
25 self.updateopts(verbose, debug, quiet, interactive)
27 self.updateopts(verbose, debug, quiet, interactive)
26 self.diffcache = None
28 self.diffcache = None
29
30 def __getattr__(self, key):
31 return getattr(self.parentui, key)
27
32
28 def updateopts(self, verbose=False, debug=False, quiet=False,
33 def updateopts(self, verbose=False, debug=False, quiet=False,
29 interactive=True):
34 interactive=True):
@@ -49,22 +54,34 b' class ui(object):'
49 return self.overlay[(section, name)]
54 return self.overlay[(section, name)]
50 if self.cdata.has_option(section, name):
55 if self.cdata.has_option(section, name):
51 return self.cdata.get(section, name)
56 return self.cdata.get(section, name)
52 return default
57 if self.parentui is None:
58 return default
59 else:
60 return self.parentui.config(section, name, default)
53
61
54 def configbool(self, section, name, default=False):
62 def configbool(self, section, name, default=False):
55 if self.overlay.has_key((section, name)):
63 if self.overlay.has_key((section, name)):
56 return self.overlay[(section, name)]
64 return self.overlay[(section, name)]
57 if self.cdata.has_option(section, name):
65 if self.cdata.has_option(section, name):
58 return self.cdata.getboolean(section, name)
66 return self.cdata.getboolean(section, name)
59 return default
67 if self.parentui is None:
68 return default
69 else:
70 return self.parentui.configbool(section, name, default)
60
71
61 def configitems(self, section):
72 def configitems(self, section):
73 items = {}
74 if self.parentui is not None:
75 items = dict(self.parentui.configitems(section))
62 if self.cdata.has_section(section):
76 if self.cdata.has_section(section):
63 return self.cdata.items(section)
77 items.update(dict(self.cdata.items(section)))
64 return []
78 x = items.items()
79 x.sort()
80 return x
65
81
66 def walkconfig(self):
82 def walkconfig(self, seen=None):
67 seen = {}
83 if seen is None:
84 seen = {}
68 for (section, name), value in self.overlay.iteritems():
85 for (section, name), value in self.overlay.iteritems():
69 yield section, name, value
86 yield section, name, value
70 seen[section, name] = 1
87 seen[section, name] = 1
@@ -73,6 +90,9 b' class ui(object):'
73 if (section, name) in seen: continue
90 if (section, name) in seen: continue
74 yield section, name, value.replace('\n', '\\n')
91 yield section, name, value.replace('\n', '\\n')
75 seen[section, name] = 1
92 seen[section, name] = 1
93 if self.parentui is not None:
94 for parent in self.parentui.walkconfig(seen):
95 yield parent
76
96
77 def extensions(self):
97 def extensions(self):
78 return self.configitems("extensions")
98 return self.configitems("extensions")
@@ -171,3 +191,4 b' class ui(object):'
171 os.unlink(name)
191 os.unlink(name)
172
192
173 return t
193 return t
194
General Comments 0
You need to be logged in to leave comments. Login now