Mercurial > hg > mercurial-crew-with-dirclash
comparison mercurial/hg.py @ 199:2424676edd8c
annotate: deal with merges
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
annotate: deal with merges
This rewrite of the annotate code deals with merges:
- - find all ancestors
- - sort ancestors topologically
- - for each ancestor, pairwise annotate with parents
- - keep a cache of annotations for efficiency
manifest hash: b960d9b9c6a7f6ba351c97675b00a1dd3004dcf1
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.0 (GNU/Linux)
iD8DBQFCnJclywK+sNU5EO8RAphZAKCkUuHh4jEJz7YwD9uzCT76GaSR/wCfUVUQ
VbGna/9jrOAFlrB3mZ3e4qg=
=yDFy
-----END PGP SIGNATURE-----
author | mpm@selenic.com |
---|---|
date | Tue, 31 May 2005 08:56:05 -0800 |
parents | 5d8553352d2e |
children | 8450c18f2a45 |
comparison
equal
deleted
inserted
replaced
198:c88ef31fb5c0 | 199:2424676edd8c |
---|---|
22 return self.revision(node) | 22 return self.revision(node) |
23 def add(self, text, transaction, link, p1=None, p2=None): | 23 def add(self, text, transaction, link, p1=None, p2=None): |
24 return self.addrevision(text, transaction, link, p1, p2) | 24 return self.addrevision(text, transaction, link, p1, p2) |
25 | 25 |
26 def annotate(self, node): | 26 def annotate(self, node): |
27 revs = [] | 27 |
28 while node != nullid: | 28 def decorate(text, rev): |
29 revs.append(node) | 29 return [(rev, l) for l in text.splitlines(1)] |
30 node = self.parents(node)[0] | 30 |
31 revs.reverse() | 31 def strip(annotation): |
32 prev = [] | 32 return [e[1] for e in annotation] |
33 annotate = [] | 33 |
34 | 34 def pair(parent, child): |
35 for node in revs: | |
36 curr = self.read(node).splitlines(1) | |
37 linkrev = self.linkrev(node) | |
38 sm = SequenceMatcher(None, prev, curr) | |
39 new = [] | 35 new = [] |
36 sm = SequenceMatcher(None, strip(parent), strip(child)) | |
40 for o, m, n, s, t in sm.get_opcodes(): | 37 for o, m, n, s, t in sm.get_opcodes(): |
41 if o == 'equal': | 38 if o == 'equal': |
42 new += annotate[m:n] | 39 new += parent[m:n] |
43 else: | 40 else: |
44 new += [(linkrev, l) for l in curr[s:t]] | 41 new += child[s:t] |
45 annotate, prev = new, curr | 42 return new |
46 return annotate | 43 |
44 needed = {} | |
45 visit = [node] | |
46 while visit: | |
47 n = visit.pop(0) | |
48 for p in self.parents(n): | |
49 if p not in needed: | |
50 needed[p] = 1 | |
51 visit.append(p) | |
52 | |
53 visit = needed.keys() | |
54 visit = [ (self.rev(n), n) for n in visit ] | |
55 visit.sort() | |
56 visit = [ p[1] for p in visit ] | |
57 hist = {} | |
58 | |
59 for n in visit: | |
60 curr = decorate(self.read(n), self.linkrev(n)) | |
61 for p in self.parents(n): | |
62 if p != nullid: | |
63 curr = pair(hist[p], curr) | |
64 hist[n] = curr | |
65 | |
66 return hist[n] | |
47 | 67 |
48 class manifest(revlog): | 68 class manifest(revlog): |
49 def __init__(self, opener): | 69 def __init__(self, opener): |
50 self.mapcache = None | 70 self.mapcache = None |
51 self.listcache = None | 71 self.listcache = None |