mq: don't warn on qpush against a branch head
authorDirkjan Ochtman <djc.ochtman@kentyde.com>
Sun, 07 Feb 2010 14:06:05 +0100
changeset 10362 2e3ec7ef5349
parent 10361 49cd2e7fd91c
child 10363 c07974215b3d
mq: don't warn on qpush against a branch head
hgext/mq.py
tests/test-mq-safety
tests/test-mq-safety.out
--- a/hgext/mq.py	Sun Feb 07 13:49:52 2010 +0100
+++ b/hgext/mq.py	Sun Feb 07 14:06:05 2010 +0100
@@ -987,7 +987,12 @@
         diffopts = self.diffopts()
         wlock = repo.wlock()
         try:
-            if repo.dirstate.parents()[0] not in repo.heads():
+            heads = []
+            for b, ls in repo.branchmap().iteritems():
+                heads += ls
+            if not heads:
+                heads = [nullid]
+            if repo.dirstate.parents()[0] not in heads:
                 self.ui.status(_("(working directory not at a head)\n"))
 
             if not self.series:
--- a/tests/test-mq-safety	Sun Feb 07 13:49:52 2010 +0100
+++ b/tests/test-mq-safety	Sun Feb 07 14:06:05 2010 +0100
@@ -42,3 +42,23 @@
 
 echo '% tip:'
 hg tip --template '{rev} {desc}\n'
+
+echo '% qpush warning branchheads'
+cd ..
+hg init branchy
+cd branchy
+echo q > q
+hg add q
+hg qnew -f qp
+hg qpop
+echo a > a
+hg ci -Ama
+hg up null
+hg branch b
+echo c > c
+hg ci -Amc
+hg merge default
+hg ci -mmerge
+hg up default
+hg log
+hg qpush
--- a/tests/test-mq-safety.out	Sun Feb 07 13:49:52 2010 +0100
+++ b/tests/test-mq-safety.out	Sun Feb 07 14:06:05 2010 +0100
@@ -12,3 +12,37 @@
 abort: cannot refresh a revision with children
 % tip:
 3 append quux
+% qpush warning branchheads
+popping qp
+patch queue now empty
+adding a
+0 files updated, 0 files merged, 1 files removed, 0 files unresolved
+marked working directory as branch b
+adding c
+created new head
+1 files updated, 0 files merged, 0 files removed, 0 files unresolved
+(branch merge, don't forget to commit)
+0 files updated, 0 files merged, 1 files removed, 0 files unresolved
+changeset:   2:65309210bf4e
+branch:      b
+tag:         tip
+parent:      1:707adb4c8ae1
+parent:      0:cb9a9f314b8b
+user:        test
+date:        Thu Jan 01 00:00:00 1970 +0000
+summary:     merge
+
+changeset:   1:707adb4c8ae1
+branch:      b
+parent:      -1:000000000000
+user:        test
+date:        Thu Jan 01 00:00:00 1970 +0000
+summary:     c
+
+changeset:   0:cb9a9f314b8b
+user:        test
+date:        Thu Jan 01 00:00:00 1970 +0000
+summary:     a
+
+applying qp
+now at: qp