##// END OF EJS Templates
mq: don't use len(list) unless necessary
Benoit Boissinot -
r10686:0c68c2c3 default
parent child Browse files
Show More
@@ -539,7 +539,7 b' class queue(object):'
539 (p1, p2) = repo.dirstate.parents()
539 (p1, p2) = repo.dirstate.parents()
540 if p2 == nullid:
540 if p2 == nullid:
541 return p1
541 return p1
542 if len(self.applied) == 0:
542 if not self.applied:
543 return None
543 return None
544 return self.applied[-1].node
544 return self.applied[-1].node
545 p1, p2 = repo.changelog.parents(rev)
545 p1, p2 = repo.changelog.parents(rev)
@@ -548,7 +548,7 b' class queue(object):'
548 return p1
548 return p1
549
549
550 def mergepatch(self, repo, mergeq, series, diffopts):
550 def mergepatch(self, repo, mergeq, series, diffopts):
551 if len(self.applied) == 0:
551 if not self.applied:
552 # each of the patches merged in will have two parents. This
552 # each of the patches merged in will have two parents. This
553 # can confuse the qrefresh, qdiff, and strip code because it
553 # can confuse the qrefresh, qdiff, and strip code because it
554 # needs to know which parent is actually in the patch queue.
554 # needs to know which parent is actually in the patch queue.
@@ -779,7 +779,7 b' class queue(object):'
779 self._cleanup(realpatches, numrevs, opts.get('keep'))
779 self._cleanup(realpatches, numrevs, opts.get('keep'))
780
780
781 def check_toppatch(self, repo):
781 def check_toppatch(self, repo):
782 if len(self.applied) > 0:
782 if self.applied:
783 top = self.applied[-1].node
783 top = self.applied[-1].node
784 patch = self.applied[-1].name
784 patch = self.applied[-1].name
785 pp = repo.dirstate.parents()
785 pp = repo.dirstate.parents()
@@ -940,7 +940,7 b' class queue(object):'
940 return None
940 return None
941 if matches:
941 if matches:
942 return matches[0]
942 return matches[0]
943 if len(self.series) > 0 and len(self.applied) > 0:
943 if self.series and self.applied:
944 if s == 'qtip':
944 if s == 'qtip':
945 return self.series[self.series_end(True)-1]
945 return self.series[self.series_end(True)-1]
946 if s == 'qbase':
946 if s == 'qbase':
@@ -1101,7 +1101,7 b' class queue(object):'
1101 if not info:
1101 if not info:
1102 raise util.Abort(_("patch %s is not applied") % patch)
1102 raise util.Abort(_("patch %s is not applied") % patch)
1103
1103
1104 if len(self.applied) == 0:
1104 if not self.applied:
1105 # Allow qpop -a to work repeatedly,
1105 # Allow qpop -a to work repeatedly,
1106 # but not qpop without an argument
1106 # but not qpop without an argument
1107 self.ui.warn(_("no patches applied\n"))
1107 self.ui.warn(_("no patches applied\n"))
@@ -1179,7 +1179,7 b' class queue(object):'
1179 self.ui.status(_("popping %s\n") % patch.name)
1179 self.ui.status(_("popping %s\n") % patch.name)
1180 del self.applied[start:end]
1180 del self.applied[start:end]
1181 self.strip(repo, rev, update=False, backup='strip')
1181 self.strip(repo, rev, update=False, backup='strip')
1182 if len(self.applied):
1182 if self.applied:
1183 self.ui.write(_("now at: %s\n") % self.applied[-1].name)
1183 self.ui.write(_("now at: %s\n") % self.applied[-1].name)
1184 else:
1184 else:
1185 self.ui.write(_("patch queue now empty\n"))
1185 self.ui.write(_("patch queue now empty\n"))
@@ -1200,7 +1200,7 b' class queue(object):'
1200 self.printdiff(repo, diffopts, node1, node2, files=pats, opts=opts)
1200 self.printdiff(repo, diffopts, node1, node2, files=pats, opts=opts)
1201
1201
1202 def refresh(self, repo, pats=None, **opts):
1202 def refresh(self, repo, pats=None, **opts):
1203 if len(self.applied) == 0:
1203 if not self.applied:
1204 self.ui.write(_("no patches applied\n"))
1204 self.ui.write(_("no patches applied\n"))
1205 return 1
1205 return 1
1206 msg = opts.get('msg', '').rstrip()
1206 msg = opts.get('msg', '').rstrip()
@@ -1522,7 +1522,7 b' class queue(object):'
1522 hg.clean(r, qpp[0])
1522 hg.clean(r, qpp[0])
1523
1523
1524 def save(self, repo, msg=None):
1524 def save(self, repo, msg=None):
1525 if len(self.applied) == 0:
1525 if not self.applied:
1526 self.ui.warn(_("save: no patches applied, exiting\n"))
1526 self.ui.warn(_("save: no patches applied, exiting\n"))
1527 return 1
1527 return 1
1528 if self.issaveline(self.applied[-1]):
1528 if self.issaveline(self.applied[-1]):
@@ -1549,7 +1549,7 b' class queue(object):'
1549 self.removeundo(repo)
1549 self.removeundo(repo)
1550
1550
1551 def full_series_end(self):
1551 def full_series_end(self):
1552 if len(self.applied) > 0:
1552 if self.applied:
1553 p = self.applied[-1].name
1553 p = self.applied[-1].name
1554 end = self.find_series(p)
1554 end = self.find_series(p)
1555 if end is None:
1555 if end is None:
@@ -1574,7 +1574,7 b' class queue(object):'
1574 self.explain_pushable(i)
1574 self.explain_pushable(i)
1575 i += 1
1575 i += 1
1576 return i
1576 return i
1577 if len(self.applied) > 0:
1577 if self.applied:
1578 p = self.applied[-1].name
1578 p = self.applied[-1].name
1579 try:
1579 try:
1580 end = self.series.index(p)
1580 end = self.series.index(p)
General Comments 0
You need to be logged in to leave comments. Login now