# HG changeset patch # User Jason Orendorff # Date 1231234222 -3600 # Node ID 12df451ce20562b1378aa8e26ccbea2534cae2a1 # Parent 0946294d1f320d1e658ae9d28bba71cb7b749ada mq: don't warn about ambiguous patch name when using patch index (issue1439) diff -r 0946294d1f32 -r 12df451ce205 hgext/mq.py --- a/hgext/mq.py Mon Jan 05 14:34:20 2009 +0100 +++ b/hgext/mq.py Tue Jan 06 10:30:22 2009 +0100 @@ -838,14 +838,11 @@ if s == 'qbase': return self.series[0] return None + if patch == None: return None - - # we don't want to return a partial match until we make - # sure the file name passed in does not exist (checked below) - res = partial_name(patch) - if res and res == patch: - return res + if patch in self.series: + return patch if not os.path.isfile(self.join(patch)): try: @@ -853,10 +850,11 @@ except(ValueError, OverflowError): pass else: - if sno < len(self.series): + if -len(self.series) <= sno < len(self.series): return self.series[sno] + if not strict: - # return any partial match made above + res = partial_name(patch) if res: return res minus = patch.rfind('-') diff -r 0946294d1f32 -r 12df451ce205 tests/test-mq-qgoto --- a/tests/test-mq-qgoto Mon Jan 05 14:34:20 2009 +0100 +++ b/tests/test-mq-qgoto Tue Jan 06 10:30:22 2009 +0100 @@ -25,3 +25,25 @@ hg qgoto a.patch hg qgoto c.patch hg qgoto b.patch + +echo +echo % Using index +hg qgoto 0 +hg qgoto 2 + +echo +echo % No warnings when using index +hg qnew bug314159 +echo d >> c +hg qrefresh +hg qnew bug141421 +echo e >> c +hg qrefresh +hg qgoto 1 +hg qgoto 3 + +echo +echo % Detect ambiguous non-index +hg qgoto 14 + +exit 0 diff -r 0946294d1f32 -r 12df451ce205 tests/test-mq-qgoto.out --- a/tests/test-mq-qgoto.out Mon Jan 05 14:34:20 2009 +0100 +++ b/tests/test-mq-qgoto.out Tue Jan 06 10:30:22 2009 +0100 @@ -4,3 +4,21 @@ applying c.patch Now at: c.patch Now at: b.patch + +% Using index +Now at: a.patch +applying b.patch +applying c.patch +Now at: c.patch + +% No warnings when using index +Now at: b.patch +applying c.patch +applying bug314159 +Now at: bug314159 + +% Detect ambiguous non-index +patch name "14" is ambiguous: + bug314159 + bug141421 +abort: patch 14 not in series