Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/subrepo.py @ 16430:6883c2363f44
revert: add support for reverting subrepos without --no-backup and/or --all
When a subrepo is reverted but --no-backup is not set, call revert on the
subrepo that is being reverted prior to updating it to the revision specified
in the parent repo's .hgsubstate file.
The --all flag is passed down to the subrepo when it is being reverted. If the
--all flag is not set, all files that are modified on the subrepo will be
reverted.
author | Angel Ezquerra <angel.ezquerra@gmail.com> |
---|---|
date | Wed, 28 Mar 2012 11:42:17 +0200 |
parents | 71dcce391a44 |
children | 9c431cfdca12 |
comparison
equal
deleted
inserted
replaced
16429:71dcce391a44 | 16430:6883c2363f44 |
---|---|
575 def forget(self, ui, match, prefix): | 575 def forget(self, ui, match, prefix): |
576 return cmdutil.forget(ui, self._repo, match, | 576 return cmdutil.forget(ui, self._repo, match, |
577 os.path.join(prefix, self._path), True) | 577 os.path.join(prefix, self._path), True) |
578 | 578 |
579 def revert(self, ui, substate, *pats, **opts): | 579 def revert(self, ui, substate, *pats, **opts): |
580 # reverting a subrepo is done by updating it to the revision | 580 # reverting a subrepo is a 2 step process: |
581 # specified in the corresponding substate dictionary | 581 # 1. if the no_backup is not set, revert all modified |
582 # files inside the subrepo | |
583 # 2. update the subrepo to the revision specified in | |
584 # the corresponding substate dictionary | |
582 ui.status(_('reverting subrepo %s\n') % substate[0]) | 585 ui.status(_('reverting subrepo %s\n') % substate[0]) |
586 if not opts.get('no_backup'): | |
587 # Revert all files on the subrepo, creating backups | |
588 # Note that this will not recursively revert subrepos | |
589 # We could do it if there was a set:subrepos() predicate | |
590 opts = opts.copy() | |
591 opts['date'] = None | |
592 opts['rev'] = substate[1] | |
593 | |
594 pats = [] | |
595 if not opts['all']: | |
596 pats = ['set:modified()'] | |
597 self.filerevert(ui, *pats, **opts) | |
583 | 598 |
584 # Update the repo to the revision specified in the given substate | 599 # Update the repo to the revision specified in the given substate |
585 self.get(substate, overwrite=True) | 600 self.get(substate, overwrite=True) |
601 | |
602 def filerevert(self, ui, *pats, **opts): | |
603 ctx = self._repo[opts['rev']] | |
604 parents = self._repo.dirstate.parents() | |
605 if opts['all']: | |
606 pats = ['set:modified()'] | |
607 else: | |
608 pats = [] | |
609 cmdutil.revert(ui, self._repo, ctx, parents, *pats, **opts) | |
586 | 610 |
587 class svnsubrepo(abstractsubrepo): | 611 class svnsubrepo(abstractsubrepo): |
588 def __init__(self, ctx, path, state): | 612 def __init__(self, ctx, path, state): |
589 self._path = path | 613 self._path = path |
590 self._state = state | 614 self._state = state |