comparison mercurial/subrepo.py @ 16429:71dcce391a44

revert: add support for reverting subrepos Reverting a subrepo is done by updating it to the revision that is selected on the parent repo .hgsubstate file. * ISSUES/TODO: - reverting added and removed subrepos is not supported yet. - reverting subrepos is only supported if the --no-backup flag is used (this limitation will be removed on another patch). - The behavior of the --all flag has been changed. It now reverts subrepos as well. Note that this may lead to data loss if the user has a dirty subrepo.
author Angel Ezquerra <angel.ezquerra@gmail.com>
date Wed, 28 Mar 2012 11:42:17 +0200
parents 0196c437ca9f
children 6883c2363f44
comparison
equal deleted inserted replaced
16428:9b26d541e972 16429:71dcce391a44
366 pass 366 pass
367 367
368 def forget(self, ui, match, prefix): 368 def forget(self, ui, match, prefix):
369 return [] 369 return []
370 370
371 def revert(self, ui, substate, *pats, **opts):
372 return []
373
371 class hgsubrepo(abstractsubrepo): 374 class hgsubrepo(abstractsubrepo):
372 def __init__(self, ctx, path, state): 375 def __init__(self, ctx, path, state):
373 self._path = path 376 self._path = path
374 self._state = state 377 self._state = state
375 r = ctx._repo 378 r = ctx._repo
570 return ctx.walk(match) 573 return ctx.walk(match)
571 574
572 def forget(self, ui, match, prefix): 575 def forget(self, ui, match, prefix):
573 return cmdutil.forget(ui, self._repo, match, 576 return cmdutil.forget(ui, self._repo, match,
574 os.path.join(prefix, self._path), True) 577 os.path.join(prefix, self._path), True)
578
579 def revert(self, ui, substate, *pats, **opts):
580 # reverting a subrepo is done by updating it to the revision
581 # specified in the corresponding substate dictionary
582 ui.status(_('reverting subrepo %s\n') % substate[0])
583
584 # Update the repo to the revision specified in the given substate
585 self.get(substate, overwrite=True)
575 586
576 class svnsubrepo(abstractsubrepo): 587 class svnsubrepo(abstractsubrepo):
577 def __init__(self, ctx, path, state): 588 def __init__(self, ctx, path, state):
578 self._path = path 589 self._path = path
579 self._state = state 590 self._state = state