Show More
@@ -10,7 +10,7 b' from node import *' | |||
|
10 | 10 | from i18n import gettext as _ |
|
11 | 11 | demandload(globals(), "os re sys signal shutil imp urllib pdb") |
|
12 | 12 | demandload(globals(), "fancyopts ui hg util lock revlog templater bundlerepo") |
|
13 | demandload(globals(), "fnmatch mdiff random signal tempfile time") | |
|
13 | demandload(globals(), "fnmatch mdiff difflib random signal tempfile time") | |
|
14 | 14 | demandload(globals(), "traceback errno socket version struct atexit sets bz2") |
|
15 | 15 | demandload(globals(), "archival cStringIO changegroup email.Parser") |
|
16 | 16 | demandload(globals(), "hgweb.server sshserver") |
@@ -1644,41 +1644,54 b' def grep(ui, repo, pattern, *pats, **opt' | |||
|
1644 | 1644 | self.linenum = linenum |
|
1645 | 1645 | self.colstart = colstart |
|
1646 | 1646 | self.colend = colend |
|
1647 | ||
|
1647 | 1648 | def __eq__(self, other): |
|
1648 | 1649 | return self.line == other.line |
|
1649 | def __hash__(self): | |
|
1650 | return hash(self.line) | |
|
1651 | 1650 | |
|
1652 | 1651 | matches = {} |
|
1653 | 1652 | def grepbody(fn, rev, body): |
|
1654 |
matches[rev].setdefault(fn, |
|
|
1653 | matches[rev].setdefault(fn, []) | |
|
1655 | 1654 | m = matches[rev][fn] |
|
1656 | 1655 | for lnum, cstart, cend, line in matchlines(body): |
|
1657 | 1656 | s = linestate(line, lnum, cstart, cend) |
|
1658 |
m |
|
|
1659 | ||
|
1660 | # FIXME: prev isn't used, why ? | |
|
1657 | m.append(s) | |
|
1658 | ||
|
1659 | def difflinestates(a, b): | |
|
1660 | sm = difflib.SequenceMatcher(None, a, b) | |
|
1661 | for tag, alo, ahi, blo, bhi in sm.get_opcodes(): | |
|
1662 | if tag == 'insert': | |
|
1663 | for i in range(blo, bhi): | |
|
1664 | yield ('+', b[i]) | |
|
1665 | elif tag == 'delete': | |
|
1666 | for i in range(alo, ahi): | |
|
1667 | yield ('-', a[i]) | |
|
1668 | elif tag == 'replace': | |
|
1669 | for i in range(alo, ahi): | |
|
1670 | yield ('-', a[i]) | |
|
1671 | for i in range(blo, bhi): | |
|
1672 | yield ('+', b[i]) | |
|
1673 | ||
|
1661 | 1674 | prev = {} |
|
1662 | 1675 | ucache = {} |
|
1663 | 1676 | def display(fn, rev, states, prevstates): |
|
1664 | diff = list(sets.Set(states).symmetric_difference(sets.Set(prevstates))) | |
|
1665 | diff.sort(lambda x, y: cmp(x.linenum, y.linenum)) | |
|
1666 | 1677 | counts = {'-': 0, '+': 0} |
|
1667 | 1678 | filerevmatches = {} |
|
1668 | for l in diff: | |
|
1669 | 1679 |
|
|
1670 | change = ((l in prevstates) and '-') or '+' | |
|
1680 | a, b = prevstates, states | |
|
1681 | else: | |
|
1682 | a, b = states, prevstates | |
|
1683 | for change, l in difflinestates(a, b): | |
|
1684 | if incrementing or not opts['all']: | |
|
1671 | 1685 | r = rev |
|
1672 | 1686 | else: |
|
1673 | change = ((l in states) and '-') or '+' | |
|
1674 | 1687 | r = prev[fn] |
|
1675 |
cols = [fn, str(r |
|
|
1688 | cols = [fn, str(r)] | |
|
1676 | 1689 | if opts['line_number']: |
|
1677 | 1690 | cols.append(str(l.linenum)) |
|
1678 | 1691 | if opts['all']: |
|
1679 | 1692 | cols.append(change) |
|
1680 | 1693 | if opts['user']: |
|
1681 |
cols.append(trimuser(ui, getchange(r |
|
|
1694 | cols.append(trimuser(ui, getchange(r)[1], rev, | |
|
1682 | 1695 |
|
|
1683 | 1696 | if opts['files_with_matches']: |
|
1684 | 1697 | c = (fn, rev) |
@@ -18,6 +18,5 b' head -n 3 port > port1' | |||
|
18 | 18 | mv port1 port |
|
19 | 19 | hg commit -m 4 -u spam -d '4 0' |
|
20 | 20 | hg grep port port |
|
21 | echo 'FIXME: history is wrong here' | |
|
22 | 21 | hg grep --all -nu port port |
|
23 | 22 | hg grep import port |
@@ -1,10 +1,13 b'' | |||
|
1 | 1 | port:4:export |
|
2 | 2 | port:4:vaportight |
|
3 | 3 | port:4:import/export |
|
4 | FIXME: history is wrong here | |
|
5 |
port: |
|
|
6 | port:1:2:+:eggs:vaportight | |
|
7 |
port: |
|
|
8 |
port: |
|
|
9 |
port: |
|
|
4 | port:4:4:-:spam:import/export | |
|
5 | port:3:4:+:eggs:import/export | |
|
6 | port:2:1:-:spam:import | |
|
7 | port:2:2:-:spam:export | |
|
8 | port:2:1:+:spam:export | |
|
9 | port:2:2:+:spam:vaportight | |
|
10 | port:2:3:+:spam:import/export | |
|
11 | port:1:2:+:eggs:export | |
|
12 | port:0:1:+:eggs:import | |
|
10 | 13 | port:4:import/export |
General Comments 0
You need to be logged in to leave comments.
Login now