Mercurial > public > mercurial-scm > evolve
diff hgext/evolve.py @ 1221:524dbc8ffeac
prune: add --keep to not touch the working copy
In order to more closely emulate strip, lets add --keep to leave the working
copy untouched when we do our prune.
author | Durham Goode <durham@fb.com> |
---|---|
date | Fri, 20 Mar 2015 12:51:57 -0700 |
parents | 71240f696f26 |
children | 901d2f4b21a9 |
line wrap: on
line diff
--- a/hgext/evolve.py Thu Mar 19 12:31:51 2015 -0700 +++ b/hgext/evolve.py Fri Mar 20 12:51:57 2015 -0700 @@ -1741,6 +1741,7 @@ [('n', 'new', [], _("successor changeset (DEPRECATED)")), ('s', 'succ', [], _("successor changeset")), ('r', 'rev', [], _("revisions to prune")), + ('k', 'keep', None, _("does not modify working copy during prune")), ('', 'biject', False, _("do a 1-1 map between rev and successor ranges")), ('B', 'bookmark', '', _("remove revs only reachable from given" " bookmark"))] + metadataopts, @@ -1833,8 +1834,28 @@ newnode = newnode.parents()[0] if newnode.node() != wdp.node(): - commands.update(ui, repo, newnode.rev()) - ui.status(_('working directory now at %s\n') % newnode) + if opts.get('keep', False): + # This is largely the same as the implementation in + # strip.stripcmd(). We might want to refactor this somewhere + # common at some point. + + # only reset the dirstate for files that would actually change + # between the working context and uctx + descendantrevs = repo.revs("%d::." % newnode.rev()) + changedfiles = [] + for rev in descendantrevs: + # blindly reset the files, regardless of what actually changed + changedfiles.extend(repo[rev].files()) + + # reset files that only changed in the dirstate too + dirstate = repo.dirstate + dirchanges = [f for f in dirstate if dirstate[f] != 'n'] + changedfiles.extend(dirchanges) + repo.dirstate.rebuild(newnode.node(), newnode.manifest(), changedfiles) + repo.dirstate.write() + else: + commands.update(ui, repo, newnode.rev()) + ui.status(_('working directory now at %s\n') % newnode) # update bookmarks if bookmark: _deletebookmark(ui, marks, bookmark)