Mercurial > hg-stable
comparison hgext/mq.py @ 15257:a8555f9908d1
mq: cleanup of lookup - handling of None is not relevant
Patch specifications in mq is passed around as a string or None. None is
generally used when no patch has been specified and there thus is nothing to
lookup and the calling code should do something else. One code path did however
pass None all the way to lookup. That case was handled in lookup, but there was
really need for that, it was undocumented, and it used to cause trouble back
when patches was specified as integers.
author | Mads Kiilerich <mads@kiilerich.com> |
---|---|
date | Fri, 14 Oct 2011 02:50:06 +0200 |
parents | 8caf7a757afa |
children | fe9677449331 |
comparison
equal
deleted
inserted
replaced
15256:8caf7a757afa | 15257:a8555f9908d1 |
---|---|
1032 return self.series[self.seriesend(True)-1] | 1032 return self.series[self.seriesend(True)-1] |
1033 if s == 'qbase': | 1033 if s == 'qbase': |
1034 return self.series[0] | 1034 return self.series[0] |
1035 return None | 1035 return None |
1036 | 1036 |
1037 if patch is None: | |
1038 return None | |
1039 if patch in self.series: | 1037 if patch in self.series: |
1040 return patch | 1038 return patch |
1041 | 1039 |
1042 if not os.path.isfile(self.join(patch)): | 1040 if not os.path.isfile(self.join(patch)): |
1043 try: | 1041 try: |
1093 | 1091 |
1094 if not self.series: | 1092 if not self.series: |
1095 self.ui.warn(_('no patches in series\n')) | 1093 self.ui.warn(_('no patches in series\n')) |
1096 return 0 | 1094 return 0 |
1097 | 1095 |
1098 patch = self.lookup(patch) | |
1099 # Suppose our series file is: A B C and the current 'top' | 1096 # Suppose our series file is: A B C and the current 'top' |
1100 # patch is B. qpush C should be performed (moving forward) | 1097 # patch is B. qpush C should be performed (moving forward) |
1101 # qpush B is a NOP (no change) qpush A is an error (can't | 1098 # qpush B is a NOP (no change) qpush A is an error (can't |
1102 # go backwards with qpush) | 1099 # go backwards with qpush) |
1103 if patch: | 1100 if patch: |
1101 patch = self.lookup(patch) | |
1104 info = self.isapplied(patch) | 1102 info = self.isapplied(patch) |
1105 if info and info[0] >= len(self.applied) - 1: | 1103 if info and info[0] >= len(self.applied) - 1: |
1106 self.ui.warn( | 1104 self.ui.warn( |
1107 _('qpush: %s is already at the top\n') % patch) | 1105 _('qpush: %s is already at the top\n') % patch) |
1108 return 0 | 1106 return 0 |