merge with crew
authorBenoit Boissinot <benoit.boissinot@ens-lyon.org>
Sat, 18 Oct 2008 23:20:23 +0200
changeset 7146 266324983681
parent 7145 6f4a253f2a64 (current diff)
parent 7143 2bbdae4f39d1 (diff)
child 7147 94cf0d1f48a3
child 7154 7fdf7a0a41b7
merge with crew
--- a/hgext/mq.py	Sat Oct 18 23:06:29 2008 +0200
+++ b/hgext/mq.py	Sat Oct 18 23:20:23 2008 +0200
@@ -2331,6 +2331,23 @@
         repo.__class__ = mqrepo
         repo.mq = queue(ui, repo.join(""))
 
+def uisetup(ui):
+    # override import to disallow importing over patch
+    importalias, importcmd = cmdutil.findcmd(ui, 'import', commands.table)
+    for alias, cmd in commands.table.iteritems():
+        if cmd is importcmd:
+            importkey = alias
+            break
+    orig_import = importcmd[0]
+    def mqimport(ui, repo, patch1, *patches, **opts):
+        if hasattr(repo, 'abort_if_wdir_patched'):
+            repo.abort_if_wdir_patched(_('cannot import over an applied patch'),
+                                       opts.get('force'))
+            orig_import(ui, repo, patch1, *patches, **opts)
+    importcmd = list(importcmd)
+    importcmd[0] = mqimport
+    commands.table[importkey] = tuple(importcmd)
+
 seriesopts = [('s', 'summary', None, _('print first line of patch header'))]
 
 cmdtable = {
--- a/tests/test-mq	Sat Oct 18 23:06:29 2008 +0200
+++ b/tests/test-mq	Sat Oct 18 23:20:23 2008 +0200
@@ -199,6 +199,14 @@
 echo % push should fail
 hg push ../../k
 
+echo % import should fail
+hg st .
+echo foo >> ../a
+hg diff > ../../import.diff
+hg revert --no-backup ../a
+hg import ../../import.diff
+hg st
+
 echo % qunapplied
 hg qunapplied
 
--- a/tests/test-mq.out	Sat Oct 18 23:06:29 2008 +0200
+++ b/tests/test-mq.out	Sat Oct 18 23:20:23 2008 +0200
@@ -169,6 +169,8 @@
 % push should fail
 pushing to ../../k
 abort: source has mq patches applied
+% import should fail
+abort: cannot import over an applied patch
 % qunapplied
 test2.patch
 % qpush/qpop with index