changeset 6554:3182602fa1fb

mq: don't commit local changes on pushing empty patch (issue1087)
author Dirkjan Ochtman <dirkjan@ochtman.nl>
date Wed, 16 Apr 2008 16:04:07 +0200
parents 0bb76d168437
children 550c53d66949 90ec0e8fa4d0
files hgext/mq.py tests/test-mq tests/test-mq.out
diffstat 3 files changed, 94 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/hgext/mq.py	Wed Apr 16 12:09:16 2008 +0200
+++ b/hgext/mq.py	Wed Apr 16 16:04:07 2008 +0200
@@ -509,7 +509,8 @@
                 p1, p2 = repo.dirstate.parents()
                 repo.dirstate.setparents(p1, merge)
             files = patch.updatedir(self.ui, repo, files)
-            n = repo.commit(files, message, user, date, force=1)
+            n = repo.commit(files, message, user, date, match=util.never,
+                            force=True)
 
             if n == None:
                 raise util.Abort(_("repo commit failed"))
--- a/tests/test-mq	Wed Apr 16 12:09:16 2008 +0200
+++ b/tests/test-mq	Wed Apr 16 16:04:07 2008 +0200
@@ -497,3 +497,35 @@
 hg qpop
 hg qpush
 cd ..
+
+echo % test qpush with --force, issue1087
+hg init forcepush
+cd forcepush
+echo hello > hello.txt
+echo bye > bye.txt
+hg ci -Ama
+hg qnew -d '0 0' empty
+hg qpop
+echo world >> hello.txt
+
+echo % qpush should fail, local changes
+hg qpush
+
+echo % apply force, should not discard changes with empty patch
+hg qpush -f
+hg diff --config diff.nodates=True
+hg qdiff --config diff.nodates=True
+hg log -l1 -p
+hg qref -d '0 0'
+hg qpop
+echo universe >> hello.txt
+echo universe >> bye.txt
+
+echo % qpush should fail, local changes
+hg qpush
+
+echo % apply force, should discard changes in hello, but not bye
+hg qpush -f
+hg st
+hg diff --config diff.nodates=True
+hg qdiff --config diff.nodates=True
--- a/tests/test-mq.out	Wed Apr 16 12:09:16 2008 +0200
+++ b/tests/test-mq.out	Wed Apr 16 16:04:07 2008 +0200
@@ -484,3 +484,63 @@
 Patch queue now empty
 applying changea
 Now at: changea
+% test qpush with --force, issue1087
+adding bye.txt
+adding hello.txt
+Patch queue now empty
+% qpush should fail, local changes
+abort: local changes found, refresh first
+% apply force, should not discard changes with empty patch
+applying empty
+/usr/bin/patch: **** Only garbage was found in the patch input.
+patch failed, unable to continue (try -v)
+patch empty is empty
+Now at: empty
+diff -r bf5fc3f07a0a hello.txt
+--- a/hello.txt
++++ b/hello.txt
+@@ -1,1 +1,2 @@
+ hello
++world
+diff -r 9ecee4f634e3 hello.txt
+--- a/hello.txt
++++ b/hello.txt
+@@ -1,1 +1,2 @@
+ hello
++world
+changeset:   1:bf5fc3f07a0a
+tag:         qtip
+tag:         tip
+tag:         empty
+tag:         qbase
+user:        test
+date:        Thu Jan 01 00:00:00 1970 +0000
+summary:     imported patch empty
+
+
+Patch queue now empty
+% qpush should fail, local changes
+abort: local changes found, refresh first
+% apply force, should discard changes in hello, but not bye
+applying empty
+Now at: empty
+M bye.txt
+diff -r ba252371dbc1 bye.txt
+--- a/bye.txt
++++ b/bye.txt
+@@ -1,1 +1,2 @@
+ bye
++universe
+diff -r 9ecee4f634e3 bye.txt
+--- a/bye.txt
++++ b/bye.txt
+@@ -1,1 +1,2 @@
+ bye
++universe
+diff -r 9ecee4f634e3 hello.txt
+--- a/hello.txt
++++ b/hello.txt
+@@ -1,1 +1,3 @@
+ hello
++world
++universe