strip: add --keep flag to avoid modifying wc during strip

Fixes issue1564.
This commit is contained in:
Augie Fackler 2010-10-09 11:02:11 -05:00
parent 2187fcb2bb
commit 35723d1610
2 changed files with 52 additions and 4 deletions

View File

@ -2522,7 +2522,18 @@ def strip(ui, repo, *revs, **opts):
del q.applied[start:end]
q.save_dirty()
repo.mq.strip(repo, list(rootnodes), backup=backup, update=update,
revs = list(rootnodes)
if update and opts.get('keep'):
wlock = repo.wlock()
try:
urev = repo.mq.qparents(repo, revs[0])
repo.dirstate.rebuild(urev, repo[urev].manifest())
repo.dirstate.write()
update = False
finally:
wlock.release()
repo.mq.strip(repo, revs, backup=backup, update=update,
force=opts.get('force'))
return 0
@ -3145,9 +3156,10 @@ cmdtable = {
('b', 'backup', None, _('bundle only changesets with local revision'
' number greater than REV which are not'
' descendants of REV (DEPRECATED)')),
('n', 'no-backup', None, _('no backups')),
('', 'nobackup', None, _('no backups (DEPRECATED)'))],
_('hg strip [-f] [-n] REV...')),
('n', 'no-backup', None, _('no backups')),
('', 'nobackup', None, _('no backups (DEPRECATED)')),
('k', 'keep', None, _("do not modify working copy during strip"))],
_('hg strip [-k] [-f] [-n] REV...')),
"qtop": (top, [] + seriesopts, _('hg qtop [-s]')),
"qunapplied":
(unapplied,

View File

@ -380,3 +380,39 @@ stripping ancestor of queue
applied patches after stripping ancestor of queue
$ hg qapplied
Verify strip protects against stripping wc parent when there are uncommited mods
$ echo b > b
$ hg add b
$ hg ci -m 'b'
$ hg log --graph
@ changeset: 1:7519abd79d14
| tag: tip
| user: test
| date: Thu Jan 01 00:00:00 1970 +0000
| summary: b
|
o changeset: 0:9ab35a2d17cb
user: test
date: Thu Jan 01 00:00:00 1970 +0000
summary: a
$ echo c > b
$ echo c > bar
$ hg strip tip
abort: local changes found
[255]
$ hg strip tip --keep
saved backup bundle to * (glob)
$ hg log --graph
@ changeset: 0:9ab35a2d17cb
tag: tip
user: test
date: Thu Jan 01 00:00:00 1970 +0000
summary: a
$ hg status
M bar
? b