Mercurial > hg
view hgext/interhg.py @ 6858:8f256bf98219
Add support for multiple possible bisect results (issue1228, issue1182)
The real reason for both issue is that bisect can not handle cases where there
are multiple possibilities for the result.
Example (from issue1228):
rev 0 -> good
rev 1 -> skipped
rev 2 -> skipped
rev 3 -> skipped
rev 4 -> bad
Note that this patch does not only fix the reported Assertion Error but also
the problem of a non converging bisect:
hg init
for i in `seq 3`; do echo $i > $i; hg add $i; hg ci -m$i; done
hg bisect -b 2
hg bisect -g 0
hg bisect -s
From this state on, you can:
a) mark as bad forever (non converging!)
b) mark as good to get an inconsistent state
c) skip for the Assertion Error
Minor description and code edits by pmezard.
author | Bernhard Leiner <bleiner@gmail.com> |
---|---|
date | Sat, 02 Aug 2008 22:10:10 +0200 |
parents | 9f1e6ab76069 |
children | 2af657eafeba |
line wrap: on
line source
# interhg.py - interhg # # Copyright 2007 OHASHI Hideya <ohachige@gmail.com> # # Contributor(s): # Edward Lee <edward.lee@engineering.uiuc.edu> # # This software may be used and distributed according to the terms # of the GNU General Public License, incorporated herein by reference. # # The `interhg' Mercurial extension allows you to change changelog and # summary text just like InterWiki way. # # To enable this extension: # # [extensions] # interhg = # # These are some example patterns (link to bug tracking, etc.) # # [interhg] # issues = s!issue(\d+)!<a href="http://bts/issue\1">issue\1<\/a>! # bugzilla = s!((?:bug|b=|(?=#?\d{4,}))(?:\s*#?)(\d+))!<a..=\2">\1</a>!i # boldify = s/(^|\s)#(\d+)\b/ <b>#\2<\/b>/ # # Add any number of names and patterns to match import re from mercurial.hgweb import hgweb_mod from mercurial import templatefilters orig_escape = templatefilters.filters["escape"] interhg_table = [] def interhg_escape(x): escstr = orig_escape(x) for regexp, format in interhg_table: escstr = regexp.sub(format, escstr) return escstr templatefilters.filters["escape"] = interhg_escape orig_refresh = hgweb_mod.hgweb.refresh def interhg_refresh(self): interhg_table[:] = [] for key, pattern in self.repo.ui.configitems('interhg'): # grab the delimiter from the character after the "s" unesc = pattern[1] delim = re.escape(unesc) # identify portions of the pattern, taking care to avoid escaped # delimiters. the replace format and flags are optional, but delimiters # are required. match = re.match(r'^s%s(.+)(?:(?<=\\\\)|(?<!\\))%s(.*)%s([ilmsux])*$' % (delim, delim, delim), pattern) if not match: self.repo.ui.warn("interhg: invalid pattern for %s: %s\n" % (key, pattern)) continue # we need to unescape the delimiter for regexp and format delim_re = re.compile(r'(?<!\\)\\%s' % delim) regexp = delim_re.sub(unesc, match.group(1)) format = delim_re.sub(unesc, match.group(2)) # the pattern allows for 6 regexp flags, so set them if necessary flagin = match.group(3) flags = 0 if flagin: for flag in flagin.upper(): flags |= re.__dict__[flag] try: regexp = re.compile(regexp, flags) interhg_table.append((regexp, format)) except re.error: self.repo.ui.warn("interhg: invalid regexp for %s: %s\n" % (key, regexp)) return orig_refresh(self) hgweb_mod.hgweb.refresh = interhg_refresh