##// END OF EJS Templates
revert: add support for reverting subrepos...
Angel Ezquerra -
r16429:71dcce39 default
parent child Browse files
Show More
@@ -1356,8 +1356,6 b' def revert(ui, repo, ctx, parents, *pats'
1356 if path in names:
1356 if path in names:
1357 return
1357 return
1358 if path in repo[node].substate:
1358 if path in repo[node].substate:
1359 ui.warn("%s: %s\n" % (m.rel(path),
1360 'reverting subrepos is unsupported'))
1361 return
1359 return
1362 path_ = path + '/'
1360 path_ = path + '/'
1363 for f in names:
1361 for f in names:
@@ -1371,6 +1369,11 b' def revert(ui, repo, ctx, parents, *pats'
1371 if abs not in names:
1369 if abs not in names:
1372 names[abs] = m.rel(abs), m.exact(abs)
1370 names[abs] = m.rel(abs), m.exact(abs)
1373
1371
1372 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
1374 m = scmutil.matchfiles(repo, names)
1377 m = scmutil.matchfiles(repo, names)
1375 changes = repo.status(match=m)[:4]
1378 changes = repo.status(match=m)[:4]
1376 modified, added, removed, deleted = map(set, changes)
1379 modified, added, removed, deleted = map(set, changes)
@@ -1499,6 +1502,10 b' def revert(ui, repo, ctx, parents, *pats'
1499 checkout(f)
1502 checkout(f)
1500 normal(f)
1503 normal(f)
1501
1504
1505 if targetsubs:
1506 # Revert the subrepos on the revert list
1507 for sub in targetsubs:
1508 ctx.sub(sub).revert(ui, ctx.substate[sub], *pats, **opts)
1502 finally:
1509 finally:
1503 wlock.release()
1510 wlock.release()
1504
1511
@@ -368,6 +368,9 b' class abstractsubrepo(object):'
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
@@ -573,6 +576,14 b' class hgsubrepo(abstractsubrepo):'
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)
575
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)
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
@@ -42,11 +42,14 b" Revert can't (yet) revert subrepos:"
42
42
43 $ echo b > s/a
43 $ echo b > s/a
44 $ hg revert s
44 $ hg revert s
45 s: reverting subrepos is unsupported
45 abort: cannot revert subrepos without --no-backup
46 [255]
46
47
47 Revert currently ignores subrepos by default
48 Revert currently ignores subrepos by default
48
49
49 $ hg revert -a
50 $ hg revert -a
51 abort: cannot revert subrepos without --no-backup
52 [255]
50 $ hg revert -R s -a -C
53 $ hg revert -R s -a -C
51 reverting s/a (glob)
54 reverting s/a (glob)
52
55
General Comments 0
You need to be logged in to leave comments. Login now