# HG changeset patch # User Nicolas Dumazet # Date 1260512733 -32400 # Node ID 4c844f16bf393bbe078766f71d5f3149f0614760 # Parent 7f5a71946aaa35d091aab1d3b6d6a598b025ab35 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. diff -r 7f5a71946aaa -r 4c844f16bf39 hgext/graphlog.py --- a/hgext/graphlog.py Wed Dec 16 12:10:21 2009 +0100 +++ b/hgext/graphlog.py Fri Dec 11 15:25:33 2009 +0900 @@ -241,15 +241,15 @@ check_unsupported_flags(opts) limit = cmdutil.loglimit(opts) start, stop = get_revs(repo, opts["rev"]) - stop = max(stop, start - limit + 1) if start == nullrev: return if path: path = util.canonpath(repo.root, os.getcwd(), path) if path: # could be reset in canonpath - revdag = graphmod.filerevs(repo, path, start, stop) + revdag = graphmod.filerevs(repo, path, start, stop, limit) else: + stop = max(stop, start - limit + 1) revdag = graphmod.revisions(repo, start, stop) displayer = show_changeset(ui, repo, opts, buffered=True) diff -r 7f5a71946aaa -r 4c844f16bf39 mercurial/graphmod.py --- a/mercurial/graphmod.py Wed Dec 16 12:10:21 2009 +0100 +++ b/mercurial/graphmod.py Fri Dec 11 15:25:33 2009 +0900 @@ -17,6 +17,7 @@ Data depends on type. """ +import sys from mercurial.node import nullrev CHANGESET = 'C' @@ -36,21 +37,24 @@ yield (cur, CHANGESET, ctx, sorted(parents)) cur -= 1 -def filerevs(repo, path, start, stop): +def filerevs(repo, path, start, stop, limit=sys.maxint): """file cset DAG generator yielding (id, CHANGESET, ctx, [parentids]) tuples This generator function walks through the revision history of a single file from revision start down to revision stop. """ filerev = len(repo.file(path)) - 1 - while filerev >= 0: + rev = stop + 1 + count = 0 + while filerev >= 0 and rev > stop: fctx = repo.filectx(path, fileid=filerev) parents = [f.linkrev() for f in fctx.parents() if f.path() == path] rev = fctx.rev() if rev <= start: yield (rev, CHANGESET, fctx.changectx(), sorted(parents)) - if rev <= stop: - break + count += 1 + if count == limit: + break filerev -= 1 def nodes(repo, nodes): diff -r 7f5a71946aaa -r 4c844f16bf39 tests/test-glog --- a/tests/test-glog Wed Dec 16 12:10:21 2009 +0100 +++ b/tests/test-glog Fri Dec 11 15:25:33 2009 +0900 @@ -175,3 +175,19 @@ hg incoming --graph ../repo cd .. hg -R repo outgoing --graph repo2 + +cd repo +echo % file + limit with revs != cset revs +touch b +hg ci -Aqm0 +# this used to show only one cset +hg glog -l2 a + +echo "% file + limit + -ra:b, (b - a) < limit" +hg glog -l3000 -r32:tip a + +echo "% file + limit + -ra:b, b < tip" +hg glog -l1 -r32:34 a + +echo "% file + limit + -ra:b, b < tip, (b - a) < limit" +hg glog -l10 -r33:34 a diff -r 7f5a71946aaa -r 4c844f16bf39 tests/test-glog.out --- a/tests/test-glog.out Wed Dec 16 12:10:21 2009 +0100 +++ b/tests/test-glog.out Fri Dec 11 15:25:33 2009 +0900 @@ -643,3 +643,56 @@ date: Thu Jan 01 00:00:27 1970 +0000 summary: (27) collapse +% file + limit with revs != cset revs +o changeset: 34:fea3ac5810e0 +| parent: 32:d06dffa21a31 +| user: test +| date: Thu Jan 01 00:00:34 1970 +0000 +| summary: (34) head +| +| o changeset: 33:68608f5145f9 +| | parent: 18:1aa84d96232a +| | user: test +| | date: Thu Jan 01 00:00:33 1970 +0000 +| | summary: (33) head +| | +% file + limit + -ra:b, (b - a) < limit +o changeset: 34:fea3ac5810e0 +| parent: 32:d06dffa21a31 +| user: test +| date: Thu Jan 01 00:00:34 1970 +0000 +| summary: (34) head +| +| o changeset: 33:68608f5145f9 +| | parent: 18:1aa84d96232a +| | user: test +| | date: Thu Jan 01 00:00:33 1970 +0000 +| | summary: (33) head +| | +o | changeset: 32:d06dffa21a31 +|\ \ parent: 27:886ed638191b +| | | parent: 31:621d83e11f67 +| | | user: test +| | | date: Thu Jan 01 00:00:32 1970 +0000 +| | | summary: (32) expand +| | | +% file + limit + -ra:b, b < tip +o changeset: 34:fea3ac5810e0 +| parent: 32:d06dffa21a31 +| user: test +| date: Thu Jan 01 00:00:34 1970 +0000 +| summary: (34) head +| +% file + limit + -ra:b, b < tip, (b - a) < limit +o changeset: 34:fea3ac5810e0 +| parent: 32:d06dffa21a31 +| user: test +| date: Thu Jan 01 00:00:34 1970 +0000 +| summary: (34) head +| +| o changeset: 33:68608f5145f9 +| | parent: 18:1aa84d96232a +| | user: test +| | date: Thu Jan 01 00:00:33 1970 +0000 +| | summary: (33) head +| |