[PATCH] graphlog: fix output when both a limit and a path are provided

Martin Geisler mg at lazybytes.net
Tue Dec 15 17:03:42 CST 2009


Patrick Mézard <pmezard at gmail.com> writes:

> Le 14/12/09 01:08, Nicolas Dumazet a écrit :
>
>> -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:
>> +    if limit < sys.maxint:
>> +        lower = max(0, filerev - limit + 1)
>> +    else:
>> +        lower = 0
>
> Any reason to use sys.maxint instead of None?

The cmdutils.loglimit function uses sys.maxint and the limit argument is
parsed by that function in the caller.

I agree with you that using None would be better (there's no sys.maxint
in Python 3 and it generally feels weird to use sys.maxint). I talked
with Nicolas about it on IRC and he promissed to send a cleanup patch
after this one which will switch away from sys.maxint in general.

>> +    count = 0
>> +    rev = stop + 1
>> +    while filerev >= lower 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
>>          filerev -= 1
>>  
>>  def nodes(repo, nodes):
>
> Looks good to me.

It's definitely an improvment and we're closer to the behavior of log.
But there are still some small flaws if you both narrow the revision
range and add a limit:

 hg glog i18n/hggettext -r 8000:8600 -l 1
 hg log i18n/hggettext -r 8000:8600 -l 1

I would be okay with putting in the current patch and fix those in a
later patch.

-- 
Martin Geisler

VIFF (Virtual Ideal Functionality Framework) brings easy and efficient
SMPC (Secure Multiparty Computation) to Python. See: http://viff.dk/.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 197 bytes
Desc: not available
URL: <http://selenic.com/pipermail/mercurial-devel/attachments/20091216/da5c8542/attachment.pgp>


More information about the Mercurial-devel mailing list