comparison mercurial/subrepo.py @ 25416:c4a92867c048

subrepo: introduce the nullsubrepo() method This will be used in an upcoming patch. It's a one-off use, but seems better to be contained in the subrepo module, than for the next patch to overwrite the _ctx and _state fields in another module. '' is used as the default revision in subrepo.state() if it can't be found, so it seems like a safe choice.
author Matt Harbison <matt_harbison@yahoo.com>
date Wed, 03 Jun 2015 13:45:42 -0400
parents 63a57a2727b6
children 3d8c044ed513
comparison
equal deleted inserted replaced
25415:21b536f01eda 25416:c4a92867c048
338 state = ctx.substate[path] 338 state = ctx.substate[path]
339 if state[2] not in types: 339 if state[2] not in types:
340 raise util.Abort(_('unknown subrepo type %s') % state[2]) 340 raise util.Abort(_('unknown subrepo type %s') % state[2])
341 return types[state[2]](ctx, path, state[:2]) 341 return types[state[2]](ctx, path, state[:2])
342 342
343 def nullsubrepo(ctx, path, pctx):
344 """return an empty subrepo in pctx for the extant subrepo in ctx"""
345 # subrepo inherently violates our import layering rules
346 # because it wants to make repo objects from deep inside the stack
347 # so we manually delay the circular imports to not break
348 # scripts that don't use our demand-loading
349 global hg
350 import hg as h
351 hg = h
352
353 pathutil.pathauditor(ctx.repo().root)(path)
354 state = ctx.substate[path]
355 if state[2] not in types:
356 raise util.Abort(_('unknown subrepo type %s') % state[2])
357 subrev = ''
358 if state[2] == 'hg':
359 subrev = "0" * 40
360 return types[state[2]](pctx, path, (state[0], subrev))
361
343 def newcommitphase(ui, ctx): 362 def newcommitphase(ui, ctx):
344 commitphase = phases.newcommitphase(ui) 363 commitphase = phases.newcommitphase(ui)
345 substate = getattr(ctx, "substate", None) 364 substate = getattr(ctx, "substate", None)
346 if not substate: 365 if not substate:
347 return commitphase 366 return commitphase