Mercurial > public > mercurial-scm > hg
comparison mercurial/subrepo.py @ 25600:70ac1868b707
subrepo: allow a representation of the working directory subrepo
Some code cannot handle a subrepo based on the working directory (e.g.
sub.dirty()), so the caller must opt in. This will be useful for archive, and
perhaps some other commands. The git and svn methods where this is used may
need to be fixed up on a case by case basis.
author | Matt Harbison <matt_harbison@yahoo.com> |
---|---|
date | Tue, 16 Jun 2015 23:03:36 -0400 |
parents | f1d46075b13a |
children | 3ec8351fa6ed |
comparison
equal
deleted
inserted
replaced
25599:695b93a79d17 | 25600:70ac1868b707 |
---|---|
322 if f.lower() == 'hgrc': | 322 if f.lower() == 'hgrc': |
323 ui.warn(_("warning: removing potentially hostile 'hgrc' " | 323 ui.warn(_("warning: removing potentially hostile 'hgrc' " |
324 "in '%s'\n") % vfs.join(dirname)) | 324 "in '%s'\n") % vfs.join(dirname)) |
325 vfs.unlink(vfs.reljoin(dirname, f)) | 325 vfs.unlink(vfs.reljoin(dirname, f)) |
326 | 326 |
327 def subrepo(ctx, path): | 327 def subrepo(ctx, path, allowwdir=False): |
328 """return instance of the right subrepo class for subrepo in path""" | 328 """return instance of the right subrepo class for subrepo in path""" |
329 # subrepo inherently violates our import layering rules | 329 # subrepo inherently violates our import layering rules |
330 # because it wants to make repo objects from deep inside the stack | 330 # because it wants to make repo objects from deep inside the stack |
331 # so we manually delay the circular imports to not break | 331 # so we manually delay the circular imports to not break |
332 # scripts that don't use our demand-loading | 332 # scripts that don't use our demand-loading |
336 | 336 |
337 pathutil.pathauditor(ctx.repo().root)(path) | 337 pathutil.pathauditor(ctx.repo().root)(path) |
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 if allowwdir: | |
342 state = (state[0], ctx.subrev(path), state[2]) | |
341 return types[state[2]](ctx, path, state[:2]) | 343 return types[state[2]](ctx, path, state[:2]) |
342 | 344 |
343 def nullsubrepo(ctx, path, pctx): | 345 def nullsubrepo(ctx, path, pctx): |
344 """return an empty subrepo in pctx for the extant subrepo in ctx""" | 346 """return an empty subrepo in pctx for the extant subrepo in ctx""" |
345 # subrepo inherently violates our import layering rules | 347 # subrepo inherently violates our import layering rules |