comparison hgext/mq.py @ 6762:f67d1468ac50

util: add sort helper
author Matt Mackall <mpm@selenic.com>
date Fri, 27 Jun 2008 18:28:45 -0500
parents 4faaa0535ea7
children 04503b757935
comparison
equal deleted inserted replaced
6761:cb981fc955fb 6762:f67d1468ac50
141 def set_active(self, guards): 141 def set_active(self, guards):
142 for guard in guards: 142 for guard in guards:
143 bad = self.check_guard(guard) 143 bad = self.check_guard(guard)
144 if bad: 144 if bad:
145 raise util.Abort(bad) 145 raise util.Abort(bad)
146 guards = dict.fromkeys(guards).keys() 146 guards = util.sort(util.unique(guards))
147 guards.sort()
148 self.ui.debug('active guards: %s\n' % ' '.join(guards)) 147 self.ui.debug('active guards: %s\n' % ' '.join(guards))
149 self.active_guards = guards 148 self.active_guards = guards
150 self.guards_dirty = True 149 self.guards_dirty = True
151 150
152 def active(self): 151 def active(self):
534 err = 1 533 err = 1
535 break 534 break
536 return (err, n) 535 return (err, n)
537 536
538 def _clean_series(self, patches): 537 def _clean_series(self, patches):
539 indices = [self.find_series(p) for p in patches] 538 indices = util.sort([self.find_series(p) for p in patches])
540 indices.sort()
541 for i in indices[-1::-1]: 539 for i in indices[-1::-1]:
542 del self.full_series[i] 540 del self.full_series[i]
543 self.parse_series() 541 self.parse_series()
544 self.series_dirty = 1 542 self.series_dirty = 1
545 543
546 def finish(self, repo, revs): 544 def finish(self, repo, revs):
547 revs.sort() 545 revs.sort()
548 firstrev = repo.changelog.rev(revlog.bin(self.applied[0].rev)) 546 firstrev = repo[self.applied[0].rev].rev()
549 appliedbase = 0 547 appliedbase = 0
550 patches = [] 548 patches = []
551 for rev in revs: 549 for rev in util.sort(revs):
552 if rev < firstrev: 550 if rev < firstrev:
553 raise util.Abort(_('revision %d is not managed') % rev) 551 raise util.Abort(_('revision %d is not managed') % rev)
554 base = revlog.bin(self.applied[appliedbase].rev) 552 base = revlog.bin(self.applied[appliedbase].rev)
555 node = repo.changelog.node(rev) 553 node = repo.changelog.node(rev)
556 if node != base: 554 if node != base:
1259 if (fl not in self.series and 1257 if (fl not in self.series and
1260 fl not in (self.status_path, self.series_path, 1258 fl not in (self.status_path, self.series_path,
1261 self.guards_path) 1259 self.guards_path)
1262 and not fl.startswith('.')): 1260 and not fl.startswith('.')):
1263 msng_list.append(fl) 1261 msng_list.append(fl)
1264 msng_list.sort() 1262 for x in util.sort(msng_list):
1265 for x in msng_list:
1266 pfx = self.ui.verbose and ('D ') or '' 1263 pfx = self.ui.verbose and ('D ') or ''
1267 self.ui.write("%s%s\n" % (pfx, displayname(x))) 1264 self.ui.write("%s%s\n" % (pfx, displayname(x)))
1268 1265
1269 def issaveline(self, l): 1266 def issaveline(self, l):
1270 if l.name == '.hg.patches.save.line': 1267 if l.name == '.hg.patches.save.line':