[PATCH 5 of 5] shelve: allow shelving of a change with an mq patch applied
David Soria Parra
dsp at experimentalworks.net
Tue Sep 17 15:55:21 UTC 2013
# HG changeset patch
# User David Soria Parra <dsp at experimentalworks.net>
# Date 1377793335 25200
# Thu Aug 29 09:22:15 2013 -0700
# Node ID 3af046c2331103662f5c08d8459b50bbc345e15c
# Parent bc1dc2bd16d7ba0e44c7756ca24153ed9c1127d3
shelve: allow shelving of a change with an mq patch applied
We allow shelving of of changes on top of a MQ repository. MQ will
not allow repository changes on top of applied patches. We introduce
checkapplied in MQ to bypass this check.
diff --git a/hgext/mq.py b/hgext/mq.py
--- a/hgext/mq.py
+++ b/hgext/mq.py
@@ -332,6 +332,7 @@
except error.ConfigError:
self.gitmode = ui.config('mq', 'git', 'auto').lower()
self.plainmode = ui.configbool('mq', 'plain', False)
+ self.checkapplied = True
@util.propertycache
def applied(self):
@@ -3438,7 +3439,7 @@
return queue(self.ui, self.baseui, self.path)
def abortifwdirpatched(self, errmsg, force=False):
- if self.mq.applied and not force:
+ if self.mq.applied and self.mq.checkapplied and not force:
parents = self.dirstate.parents()
patches = [s.node for s in self.mq.applied]
if parents[0] in patches or parents[1] in patches:
@@ -3454,7 +3455,7 @@
editor, extra)
def checkpush(self, force, revs):
- if self.mq.applied and not force:
+ if self.mq.applied and self.mq.checkapplied and not force:
outapplied = [e.node for e in self.mq.applied]
if revs:
# Assume applied patches have no non-patch descendants and
diff --git a/hgext/shelve.py b/hgext/shelve.py
--- a/hgext/shelve.py
+++ b/hgext/shelve.py
@@ -164,7 +164,11 @@
# check modified, added, removed, deleted only
for flist in repo.status(match=match)[:4]:
shelvedfiles.extend(flist)
- return repo.commit(message, user, opts.get('date'), match)
+ saved, repo.mq.checkapplied = repo.mq.checkapplied, False
+ try:
+ return repo.commit(message, user, opts.get('date'), match)
+ finally:
+ repo.mq.checkapplied = saved
desc = parent.description().split('\n', 1)[0]
diff --git a/tests/test-shelve.t b/tests/test-shelve.t
--- a/tests/test-shelve.t
+++ b/tests/test-shelve.t
@@ -1,7 +1,9 @@
$ echo "[extensions]" >> $HGRCPATH
+ $ echo "mq=" >> $HGRCPATH
$ echo "shelve=" >> $HGRCPATH
$ echo "[defaults]" >> $HGRCPATH
$ echo "diff = --nodates --git" >> $HGRCPATH
+ $ echo "qnew = --date '0 0'" >> $HGRCPATH
$ hg init repo
$ cd repo
@@ -25,11 +27,12 @@
nothing changed
[1]
-create another commit
+create an mq patch - shelving should work fine with a patch applied
$ echo n > n
$ hg add n
$ hg commit n -m second
+ $ hg qnew second.patch
shelve a change that we will delete later
@@ -71,11 +74,11 @@
ensure that our shelved changes exist
$ hg shelve -l
- default-01 (*) second (glob)
- default (*) second (glob)
+ default-01 (*) [mq]: second.patch (glob)
+ default (*) [mq]: second.patch (glob)
$ hg shelve -l -p default
- default (*) second (glob)
+ default (*) [mq]: second.patch (glob)
diff --git a/a/a b/a/a
--- a/a/a
@@ -87,6 +90,7 @@
delete our older shelved change
$ hg shelve -d default
+ $ hg qfinish -a -q
local edits should prevent a shelved change from applying
@@ -195,11 +199,11 @@
ensure that we have a merge with unresolved conflicts
$ hg heads -q
- 3:b1ebf939e049
- 2:ceefc37abe1e
+ 4:c6c476131de9
+ 3:2e69b451d1ea
$ hg parents -q
- 2:ceefc37abe1e
- 3:b1ebf939e049
+ 3:2e69b451d1ea
+ 4:c6c476131de9
$ hg status
M a/a
M b.rename/b
@@ -259,9 +263,9 @@
$ hg shelve --unshelve -a
unshelve of 'default' aborted
$ hg heads -q
- 2:ceefc37abe1e
+ 3:2e69b451d1ea
$ hg parents
- changeset: 2:ceefc37abe1e
+ changeset: 3:2e69b451d1ea
tag: tip
user: test
date: Thu Jan 01 00:00:00 1970 +0000
@@ -305,14 +309,14 @@
ensure the repo is as we hope
$ hg parents
- changeset: 2:ceefc37abe1e
+ changeset: 3:2e69b451d1ea
tag: tip
user: test
date: Thu Jan 01 00:00:00 1970 +0000
summary: second
$ hg heads -q
- 2:ceefc37abe1e
+ 3:2e69b451d1ea
$ hg status -C
M a/a
@@ -377,7 +381,7 @@
merging a/a
0 files updated, 1 files merged, 0 files removed, 0 files unresolved
$ hg parents -q
- 4:be7e79683c99
+ 5:01ba9745dc5a
$ hg shelve -l
$ hg status
M a/a
More information about the Mercurial-devel
mailing list