comparison hgext/mq.py @ 15256:8caf7a757afa

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.
author Mads Kiilerich <mads@kiilerich.com>
date Sun, 31 Oct 2010 18:29:56 +0100
parents 510184e5a09e
children a8555f9908d1
comparison
equal deleted inserted replaced
15255:7ab05d752405 15256:8caf7a757afa
1010 return None 1010 return None
1011 1011
1012 # if the exact patch name does not exist, we try a few 1012 # if the exact patch name does not exist, we try a few
1013 # variations. If strict is passed, we try only #1 1013 # variations. If strict is passed, we try only #1
1014 # 1014 #
1015 # 1) a number to indicate an offset in the series file 1015 # 1) a number (as string) to indicate an offset in the series file
1016 # 2) a unique substring of the patch name was given 1016 # 2) a unique substring of the patch name was given
1017 # 3) patchname[-+]num to indicate an offset in the series file 1017 # 3) patchname[-+]num to indicate an offset in the series file
1018 def lookup(self, patch, strict=False): 1018 def lookup(self, patch, strict=False):
1019 patch = patch and str(patch)
1020
1021 def partialname(s): 1019 def partialname(s):
1022 if s in self.series: 1020 if s in self.series:
1023 return s 1021 return s
1024 matches = [x for x in self.series if s in x] 1022 matches = [x for x in self.series if s in x]
1025 if len(matches) > 1: 1023 if len(matches) > 1:
2872 ui.status(_('popping guarded patches\n')) 2870 ui.status(_('popping guarded patches\n'))
2873 popped = True 2871 popped = True
2874 if i == 0: 2872 if i == 0:
2875 q.pop(repo, all=True) 2873 q.pop(repo, all=True)
2876 else: 2874 else:
2877 q.pop(repo, i - 1) 2875 q.pop(repo, str(i - 1))
2878 break 2876 break
2879 if popped: 2877 if popped:
2880 try: 2878 try:
2881 if reapply: 2879 if reapply:
2882 ui.status(_('reapplying unguarded patches\n')) 2880 ui.status(_('reapplying unguarded patches\n'))