##// END OF EJS Templates
revert: add support for reverting subrepos without --no-backup and/or --all...
Angel Ezquerra -
r16430:6883c236 default
parent child Browse files
Show More
@@ -1369,11 +1369,8 b' def revert(ui, repo, ctx, parents, *pats'
1369 if abs not in names:
1369 if abs not in names:
1370 names[abs] = m.rel(abs), m.exact(abs)
1370 names[abs] = m.rel(abs), m.exact(abs)
1371
1371
1372 # get the list of subrepos that must be reverted
1372 targetsubs = [s for s in repo[node].substate if m(s)]
1373 targetsubs = [s for s in repo[node].substate if m(s)]
1373 if targetsubs and not opts.get('no_backup'):
1374 msg = _("cannot revert subrepos without --no-backup")
1375 raise util.Abort(msg)
1376
1377 m = scmutil.matchfiles(repo, names)
1374 m = scmutil.matchfiles(repo, names)
1378 changes = repo.status(match=m)[:4]
1375 changes = repo.status(match=m)[:4]
1379 modified, added, removed, deleted = map(set, changes)
1376 modified, added, removed, deleted = map(set, changes)
@@ -577,13 +577,37 b' class hgsubrepo(abstractsubrepo):'
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)
586
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)
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
@@ -38,20 +38,20 b' Issue2232: committing a subrepo without '
38 update: (current)
38 update: (current)
39 $ hg ci -m1
39 $ hg ci -m1
40
40
41 Revert can't (yet) revert subrepos:
41 Revert subrepo:
42
42
43 $ echo b > s/a
43 $ echo b > s/a
44 $ hg revert s
44 $ hg revert s
45 abort: cannot revert subrepos without --no-backup
45 reverting subrepo s
46 [255]
46 reverting s/a
47
47 $ rm s/a.orig
48 Revert currently ignores subrepos by default
49
48
50 $ hg revert -a
49 Revert subrepo with no backup. The "reverting s/a" line is gone since
51 abort: cannot revert subrepos without --no-backup
50 we're really running 'hg update' in the subrepo:
52 [255]
51
53 $ hg revert -R s -a -C
52 $ echo b > s/a
54 reverting s/a (glob)
53 $ hg revert --no-backup s
54 reverting subrepo s
55
55
56 Issue2022: update -C
56 Issue2022: update -C
57
57
General Comments 0
You need to be logged in to leave comments. Login now