comparison mercurial/subrepo.py @ 10670:97022cef0a20

merge with stable
author Benoit Boissinot <benoit.boissinot@ens-lyon.org>
date Sat, 13 Mar 2010 17:02:41 +0100
parents 05856e682521 4c50a90b90fc
children 001ffc2b3d22
comparison
equal deleted inserted replaced
10668:05856e682521 10670:97022cef0a20
129 def _abssource(repo, push=False): 129 def _abssource(repo, push=False):
130 if hasattr(repo, '_subparent'): 130 if hasattr(repo, '_subparent'):
131 source = repo._subsource 131 source = repo._subsource
132 if source.startswith('/') or '://' in source: 132 if source.startswith('/') or '://' in source:
133 return source 133 return source
134 parent = _abssource(repo._subparent) 134 parent = _abssource(repo._subparent, push)
135 if '://' in parent: 135 if '://' in parent:
136 if parent[-1] == '/': 136 if parent[-1] == '/':
137 parent = parent[:-1] 137 parent = parent[:-1]
138 return parent + '/' + source 138 return parent + '/' + source
139 return os.path.join(parent, repo._subsource) 139 return os.path.join(parent, repo._subsource)
175 def __init__(self, ctx, path, state): 175 def __init__(self, ctx, path, state):
176 self._path = path 176 self._path = path
177 self._state = state 177 self._state = state
178 r = ctx._repo 178 r = ctx._repo
179 root = r.wjoin(path) 179 root = r.wjoin(path)
180 if os.path.exists(os.path.join(root, '.hg')): 180 create = False
181 self._repo = hg.repository(r.ui, root) 181 if not os.path.exists(os.path.join(root, '.hg')):
182 else: 182 create = True
183 util.makedirs(root) 183 util.makedirs(root)
184 self._repo = hg.repository(r.ui, root, create=True) 184 self._repo = hg.repository(r.ui, root, create=create)
185 f = file(os.path.join(root, '.hg', 'hgrc'), 'w')
186 f.write('[paths]\ndefault = %s\n' % os.path.join(
187 _abssource(ctx._repo), path))
188 f.close()
189 self._repo._subparent = r 185 self._repo._subparent = r
190 self._repo._subsource = state[0] 186 self._repo._subsource = state[0]
187
188 if create:
189 fp = self._repo.opener("hgrc", "w", text=True)
190 fp.write('[paths]\n')
191
192 def addpathconfig(key, value):
193 fp.write('%s = %s\n' % (key, value))
194 self._repo.ui.setconfig('paths', key, value)
195
196 defpath = os.path.join(_abssource(ctx._repo), path)
197 addpathconfig('default', defpath)
198 fp.close()
191 199
192 def dirty(self): 200 def dirty(self):
193 r = self._state[1] 201 r = self._state[1]
194 if r == '': 202 if r == '':
195 return True 203 return True
196 w = self._repo[None] 204 w = self._repo[None]
197 if w.p1() != self._repo[r]: # version checked out changed 205 if w.p1() != self._repo[r]: # version checked out change
198 return True 206 return True
199 return w.dirty() # working directory changed 207 return w.dirty() # working directory changed
200 208
201 def commit(self, text, user, date): 209 def commit(self, text, user, date):
202 self._repo.ui.debug("committing subrepo %s\n" % self._path) 210 self._repo.ui.debug("committing subrepo %s\n" % self._path)