comparison mercurial/subrepo.py @ 12176:ecab10820983

subrepos: add function for iterating over ctx subrepos
author Martin Geisler <mg@lazybytes.net>
date Tue, 07 Sep 2010 16:34:07 +0200
parents d2c5b0927c28
children affec9fb56ef
comparison
equal deleted inserted replaced
12175:c0a8f9dea0f6 12176:ecab10820983
182 return posixpath.normpath(os.path.join(parent, repo._subsource)) 182 return posixpath.normpath(os.path.join(parent, repo._subsource))
183 if push and repo.ui.config('paths', 'default-push'): 183 if push and repo.ui.config('paths', 'default-push'):
184 return repo.ui.config('paths', 'default-push', repo.root) 184 return repo.ui.config('paths', 'default-push', repo.root)
185 return repo.ui.config('paths', 'default', repo.root) 185 return repo.ui.config('paths', 'default', repo.root)
186 186
187 def itersubrepos(ctx1, ctx2):
188 """find subrepos in ctx1 or ctx2"""
189 # Create a (subpath, ctx) mapping where we prefer subpaths from
190 # ctx1. The subpaths from ctx2 are important when the .hgsub file
191 # has been modified (in ctx2) but not yet committed (in ctx1).
192 subpaths = dict.fromkeys(ctx2.substate, ctx2)
193 subpaths.update(dict.fromkeys(ctx1.substate, ctx1))
194 for subpath, ctx in sorted(subpaths.iteritems()):
195 yield subpath, ctx.sub(subpath)
196
187 def subrepo(ctx, path): 197 def subrepo(ctx, path):
188 """return instance of the right subrepo class for subrepo in path""" 198 """return instance of the right subrepo class for subrepo in path"""
189 # subrepo inherently violates our import layering rules 199 # subrepo inherently violates our import layering rules
190 # because it wants to make repo objects from deep inside the stack 200 # because it wants to make repo objects from deep inside the stack
191 # so we manually delay the circular imports to not break 201 # so we manually delay the circular imports to not break