Mercurial > hg
comparison hgext/mq.py @ 14586:af91cb281975
mq: rename series_end to seriesend
author | Adrian Buehlmann <adrian@cadifra.com> |
---|---|
date | Mon, 13 Jun 2011 12:11:49 +0200 |
parents | 74bf9c84cfd0 |
children | 5d3bb4460256 |
comparison
equal
deleted
inserted
replaced
14585:74bf9c84cfd0 | 14586:af91cb281975 |
---|---|
1027 return None | 1027 return None |
1028 if matches: | 1028 if matches: |
1029 return matches[0] | 1029 return matches[0] |
1030 if self.series and self.applied: | 1030 if self.series and self.applied: |
1031 if s == 'qtip': | 1031 if s == 'qtip': |
1032 return self.series[self.series_end(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: | 1037 if patch is None: |
1107 _('qpush: %s is already at the top\n') % patch) | 1107 _('qpush: %s is already at the top\n') % patch) |
1108 return 0 | 1108 return 0 |
1109 | 1109 |
1110 pushable, reason = self.pushable(patch) | 1110 pushable, reason = self.pushable(patch) |
1111 if pushable: | 1111 if pushable: |
1112 if self.series.index(patch) < self.series_end(): | 1112 if self.series.index(patch) < self.seriesend(): |
1113 raise util.Abort( | 1113 raise util.Abort( |
1114 _("cannot push to a previous patch: %s") % patch) | 1114 _("cannot push to a previous patch: %s") % patch) |
1115 else: | 1115 else: |
1116 if reason: | 1116 if reason: |
1117 reason = _('guarded by %s') % reason | 1117 reason = _('guarded by %s') % reason |
1128 # Following the above example, starting at 'top' of B: | 1128 # Following the above example, starting at 'top' of B: |
1129 # qpush should be performed (pushes C), but a subsequent | 1129 # qpush should be performed (pushes C), but a subsequent |
1130 # qpush without an argument is an error (nothing to | 1130 # qpush without an argument is an error (nothing to |
1131 # apply). This allows a loop of "...while hg qpush..." to | 1131 # apply). This allows a loop of "...while hg qpush..." to |
1132 # work as it detects an error when done | 1132 # work as it detects an error when done |
1133 start = self.series_end() | 1133 start = self.seriesend() |
1134 if start == len(self.series): | 1134 if start == len(self.series): |
1135 self.ui.warn(_('patch series already fully applied\n')) | 1135 self.ui.warn(_('patch series already fully applied\n')) |
1136 return 1 | 1136 return 1 |
1137 | 1137 |
1138 if exact: | 1138 if exact: |
1532 | 1532 |
1533 def unapplied(self, repo, patch=None): | 1533 def unapplied(self, repo, patch=None): |
1534 if patch and patch not in self.series: | 1534 if patch and patch not in self.series: |
1535 raise util.Abort(_("patch %s is not in series file") % patch) | 1535 raise util.Abort(_("patch %s is not in series file") % patch) |
1536 if not patch: | 1536 if not patch: |
1537 start = self.series_end() | 1537 start = self.seriesend() |
1538 else: | 1538 else: |
1539 start = self.series.index(patch) + 1 | 1539 start = self.series.index(patch) + 1 |
1540 unapplied = [] | 1540 unapplied = [] |
1541 for i in xrange(start, len(self.series)): | 1541 for i in xrange(start, len(self.series)): |
1542 pushable, reason = self.pushable(i) | 1542 pushable, reason = self.pushable(i) |
1700 if end is None: | 1700 if end is None: |
1701 return len(self.fullseries) | 1701 return len(self.fullseries) |
1702 return end + 1 | 1702 return end + 1 |
1703 return 0 | 1703 return 0 |
1704 | 1704 |
1705 def series_end(self, all_patches=False): | 1705 def seriesend(self, all_patches=False): |
1706 """If all_patches is False, return the index of the next pushable patch | 1706 """If all_patches is False, return the index of the next pushable patch |
1707 in the series, or the series length. If all_patches is True, return the | 1707 in the series, or the series length. If all_patches is True, return the |
1708 index of the first patch past the last applied one. | 1708 index of the first patch past the last applied one. |
1709 """ | 1709 """ |
1710 end = 0 | 1710 end = 0 |
1886 if patch: | 1886 if patch: |
1887 if patch not in q.series: | 1887 if patch not in q.series: |
1888 raise util.Abort(_("patch %s is not in series file") % patch) | 1888 raise util.Abort(_("patch %s is not in series file") % patch) |
1889 end = q.series.index(patch) + 1 | 1889 end = q.series.index(patch) + 1 |
1890 else: | 1890 else: |
1891 end = q.series_end(True) | 1891 end = q.seriesend(True) |
1892 | 1892 |
1893 if opts.get('last') and not end: | 1893 if opts.get('last') and not end: |
1894 ui.write(_("no patches applied\n")) | 1894 ui.write(_("no patches applied\n")) |
1895 return 1 | 1895 return 1 |
1896 elif opts.get('last') and end == 1: | 1896 elif opts.get('last') and end == 1: |
1918 if patch: | 1918 if patch: |
1919 if patch not in q.series: | 1919 if patch not in q.series: |
1920 raise util.Abort(_("patch %s is not in series file") % patch) | 1920 raise util.Abort(_("patch %s is not in series file") % patch) |
1921 start = q.series.index(patch) + 1 | 1921 start = q.series.index(patch) + 1 |
1922 else: | 1922 else: |
1923 start = q.series_end(True) | 1923 start = q.seriesend(True) |
1924 | 1924 |
1925 if start == len(q.series) and opts.get('first'): | 1925 if start == len(q.series) and opts.get('first'): |
1926 ui.write(_("all patches applied\n")) | 1926 ui.write(_("all patches applied\n")) |
1927 return 1 | 1927 return 1 |
1928 | 1928 |
2130 def top(ui, repo, **opts): | 2130 def top(ui, repo, **opts): |
2131 """print the name of the current patch | 2131 """print the name of the current patch |
2132 | 2132 |
2133 Returns 0 on success.""" | 2133 Returns 0 on success.""" |
2134 q = repo.mq | 2134 q = repo.mq |
2135 t = q.applied and q.series_end(True) or 0 | 2135 t = q.applied and q.seriesend(True) or 0 |
2136 if t: | 2136 if t: |
2137 q.qseries(repo, start=t - 1, length=1, status='A', | 2137 q.qseries(repo, start=t - 1, length=1, status='A', |
2138 summary=opts.get('summary')) | 2138 summary=opts.get('summary')) |
2139 else: | 2139 else: |
2140 ui.write(_("no patches applied\n")) | 2140 ui.write(_("no patches applied\n")) |
2144 def next(ui, repo, **opts): | 2144 def next(ui, repo, **opts): |
2145 """print the name of the next patch | 2145 """print the name of the next patch |
2146 | 2146 |
2147 Returns 0 on success.""" | 2147 Returns 0 on success.""" |
2148 q = repo.mq | 2148 q = repo.mq |
2149 end = q.series_end() | 2149 end = q.seriesend() |
2150 if end == len(q.series): | 2150 if end == len(q.series): |
2151 ui.write(_("all patches applied\n")) | 2151 ui.write(_("all patches applied\n")) |
2152 return 1 | 2152 return 1 |
2153 q.qseries(repo, start=end, length=1, summary=opts.get('summary')) | 2153 q.qseries(repo, start=end, length=1, summary=opts.get('summary')) |
2154 | 2154 |