Mercurial > hg
changeset 7621:6d891df43a5f
mq: allow qpop if popped revisions are not working dir parents
author | Dirkjan Ochtman <dirkjan@ochtman.nl> |
---|---|
date | Mon, 12 Jan 2009 09:07:02 +0100 |
parents | fbfd92d51540 |
children | 4dd7b28003d2 |
files | hgext/mq.py tests/test-mq tests/test-mq-safety.out tests/test-mq.out |
diffstat | 4 files changed, 27 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/hgext/mq.py Mon Jan 12 09:53:55 2009 +0100 +++ b/hgext/mq.py Mon Jan 12 09:07:02 2009 +0100 @@ -1011,6 +1011,14 @@ if p in rr: self.ui.warn(_("qpop: forcing dirstate update\n")) update = True + else: + parents = [p.hex() for p in repo[None].parents()] + needupdate = False + for entry in self.applied[start:]: + if entry.rev in parents: + needupdate = True + break + update = needupdate if not force and update: self.check_localchanges(repo) @@ -1021,7 +1029,13 @@ if update: top = self.check_toppatch(repo) - if repo.changelog.heads(rev) != [revlog.bin(self.applied[-1].rev)]: + try: + heads = repo.changelog.heads(rev) + except revlog.LookupError: + node = short(rev) + raise util.Abort(_('trying to pop unknown node %s') % node) + + if heads != [revlog.bin(self.applied[-1].rev)]: raise util.Abort(_("popping would remove a revision not " "managed by this patch queue"))
--- a/tests/test-mq Mon Jan 12 09:53:55 2009 +0100 +++ b/tests/test-mq Mon Jan 12 09:07:02 2009 +0100 @@ -289,7 +289,7 @@ hg strip -qn tip hg tip 2>&1 | sed -e 's/unknown node .*/unknown node/' hg branches 2>&1 | sed -e 's/unknown node .*/unknown node/' -hg qpop +hg qpop 2>&1 | sed -e 's/unknown node .*/unknown node/' cat >>$HGRCPATH <<EOF [diff] @@ -510,3 +510,8 @@ hg st hg diff --config diff.nodates=True hg qdiff --config diff.nodates=True + +echo % test popping revisions not in working dir ancestry +hg qseries -v +hg up qparent +hg qpop
--- a/tests/test-mq-safety.out Mon Jan 12 09:53:55 2009 +0100 +++ b/tests/test-mq-safety.out Mon Jan 12 09:07:02 2009 +0100 @@ -1,7 +1,7 @@ % try to commit on top of a patch abort: cannot commit over an applied mq patch % qpop/qrefresh on the wrong revision -abort: working directory revision is not qtip +abort: popping would remove a revision not managed by this patch queue using patch queue: abort: popping would remove a revision not managed by this patch queue abort: working directory revision is not qtip
--- a/tests/test-mq.out Mon Jan 12 09:53:55 2009 +0100 +++ b/tests/test-mq.out Mon Jan 12 09:07:02 2009 +0100 @@ -294,7 +294,7 @@ mq status file refers to unknown node default 0:cb9a9f314b8b -abort: working directory revision is not qtip +abort: trying to pop unknown node new file diff --git a/new b/new @@ -538,3 +538,7 @@ hello +world +universe +% test popping revisions not in working dir ancestry +0 A empty +1 files updated, 0 files merged, 0 files removed, 0 files unresolved +Patch queue now empty