# HG changeset patch # User Dirkjan Ochtman # Date 2008-04-16 14:04:07 # Node ID 3182602fa1fbb6b8064f291a283d415afec8d9ca # Parent 0bb76d168437134afe93760f98713249bb793a58 mq: don't commit local changes on pushing empty patch (issue1087) diff --git a/hgext/mq.py b/hgext/mq.py --- a/hgext/mq.py +++ b/hgext/mq.py @@ -509,7 +509,8 @@ class queue: 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")) diff --git a/tests/test-mq b/tests/test-mq --- a/tests/test-mq +++ b/tests/test-mq @@ -497,3 +497,35 @@ hg qnew -f -e changea 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 diff --git a/tests/test-mq.out b/tests/test-mq.out --- a/tests/test-mq.out +++ b/tests/test-mq.out @@ -484,3 +484,63 @@ adding a 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