comparison mercurial/graphmod.py @ 10084:4c844f16bf39 stable

graphlog: fix output when both a limit and a path are provided Limit was interpreted as absolute, from the topmost revision, without counting the number of revisions matching a given file. Which caused "glog -lN file" to show sometimes less than N csets if the file was not modified in all of the N previous csets. glog will now match the behavior of log.
author Nicolas Dumazet <nicdumz.commits@gmail.com>
date Fri, 11 Dec 2009 15:25:33 +0900
parents d00cee04a746
children 27457d31ae3f 25e572394f5c
comparison
equal deleted inserted replaced
10079:7f5a71946aaa 10084:4c844f16bf39
15 The node and parent ids are arbitrary integers which identify a node in the 15 The node and parent ids are arbitrary integers which identify a node in the
16 context of the graph returned. Type is a constant specifying the node type. 16 context of the graph returned. Type is a constant specifying the node type.
17 Data depends on type. 17 Data depends on type.
18 """ 18 """
19 19
20 import sys
20 from mercurial.node import nullrev 21 from mercurial.node import nullrev
21 22
22 CHANGESET = 'C' 23 CHANGESET = 'C'
23 24
24 def revisions(repo, start, stop): 25 def revisions(repo, start, stop):
34 ctx = repo[cur] 35 ctx = repo[cur]
35 parents = [p.rev() for p in ctx.parents() if p.rev() != nullrev] 36 parents = [p.rev() for p in ctx.parents() if p.rev() != nullrev]
36 yield (cur, CHANGESET, ctx, sorted(parents)) 37 yield (cur, CHANGESET, ctx, sorted(parents))
37 cur -= 1 38 cur -= 1
38 39
39 def filerevs(repo, path, start, stop): 40 def filerevs(repo, path, start, stop, limit=sys.maxint):
40 """file cset DAG generator yielding (id, CHANGESET, ctx, [parentids]) tuples 41 """file cset DAG generator yielding (id, CHANGESET, ctx, [parentids]) tuples
41 42
42 This generator function walks through the revision history of a single 43 This generator function walks through the revision history of a single
43 file from revision start down to revision stop. 44 file from revision start down to revision stop.
44 """ 45 """
45 filerev = len(repo.file(path)) - 1 46 filerev = len(repo.file(path)) - 1
46 while filerev >= 0: 47 rev = stop + 1
48 count = 0
49 while filerev >= 0 and rev > stop:
47 fctx = repo.filectx(path, fileid=filerev) 50 fctx = repo.filectx(path, fileid=filerev)
48 parents = [f.linkrev() for f in fctx.parents() if f.path() == path] 51 parents = [f.linkrev() for f in fctx.parents() if f.path() == path]
49 rev = fctx.rev() 52 rev = fctx.rev()
50 if rev <= start: 53 if rev <= start:
51 yield (rev, CHANGESET, fctx.changectx(), sorted(parents)) 54 yield (rev, CHANGESET, fctx.changectx(), sorted(parents))
52 if rev <= stop: 55 count += 1
53 break 56 if count == limit:
57 break
54 filerev -= 1 58 filerev -= 1
55 59
56 def nodes(repo, nodes): 60 def nodes(repo, nodes):
57 """cset DAG generator yielding (id, CHANGESET, ctx, [parentids]) tuples 61 """cset DAG generator yielding (id, CHANGESET, ctx, [parentids]) tuples
58 62