# HG changeset patch # User Mads Kiilerich # Date 1288546196 -3600 # Node ID 8caf7a757afa6a204e6fa15c6d603a53ffaf522e # Parent 7ab05d7524058368bf34fc89d2044461a4723fcd mq: fix corner cases for handling of patch 0 in qselect Most of the code paths in mq would always pass patch specifications as a string. Patches can be specified by their index, but one code path passed that (through pop) to lookup as an integer - all other code paths used a string. Unfortunately pop and lookup (like many other parts of mq) used the boolean value of the patch specification to see if it was None, and they would thus incorrectly handle patch 0 as None. This patch makes the code comply with the actual internal duck typing of patch specifications: patch indices must be encoded as strings. The (now) unused code for partial and thus incorrect handling of indices as integers is removed. diff -r 7ab05d752405 -r 8caf7a757afa hgext/mq.py --- a/hgext/mq.py Thu Oct 13 21:42:54 2011 -0400 +++ b/hgext/mq.py Sun Oct 31 18:29:56 2010 +0100 @@ -1012,12 +1012,10 @@ # if the exact patch name does not exist, we try a few # variations. If strict is passed, we try only #1 # - # 1) a number to indicate an offset in the series file + # 1) a number (as string) to indicate an offset in the series file # 2) a unique substring of the patch name was given # 3) patchname[-+]num to indicate an offset in the series file def lookup(self, patch, strict=False): - patch = patch and str(patch) - def partialname(s): if s in self.series: return s @@ -2874,7 +2872,7 @@ if i == 0: q.pop(repo, all=True) else: - q.pop(repo, i - 1) + q.pop(repo, str(i - 1)) break if popped: try: diff -r 7ab05d752405 -r 8caf7a757afa tests/test-mq-guards.t --- a/tests/test-mq-guards.t Thu Oct 13 21:42:54 2011 -0400 +++ b/tests/test-mq-guards.t Sun Oct 31 18:29:56 2010 +0100 @@ -478,19 +478,19 @@ $ hg qselect --reapply not-c popping guarded patches popping d.patch - now at: c.patch + popping c.patch + now at: new.patch reapplying unguarded patches applying d.patch patch d.patch is empty now at: d.patch $ hg qser -v 0 A new.patch - 1 A c.patch + 1 G c.patch 2 A d.patch $ hg qselect --reapply not-new popping guarded patches popping d.patch - popping c.patch popping new.patch patch queue now empty reapplying unguarded patches