Mercurial > public > mercurial-scm > hg
comparison mercurial/revset.py @ 20459:51890507c6b3
revset: added lazyset implementation to matching revset
Performance Benchmarking:
$ time hg log -qr "first(matching(0))"
0:9117c6561b0b
real 0m2.213s
user 0m2.149s
sys 0m0.055s
$ time ./hg log -qr "first(matching(0))"
0:9117c6561b0b
real 0m0.177s
user 0m0.137s
sys 0m0.038s
author | Lucas Moscovicz <lmoscovicz@fb.com> |
---|---|
date | Tue, 04 Feb 2014 09:14:45 -0800 |
parents | 8dabcc889e33 |
children | 3a88d0d0c6b6 |
comparison
equal
deleted
inserted
replaced
20458:8dabcc889e33 | 20459:51890507c6b3 |
---|---|
1363 # convert the getfield array of functions into a "getinfo" function | 1363 # convert the getfield array of functions into a "getinfo" function |
1364 # which returns an array of field values (or a single value if there | 1364 # which returns an array of field values (or a single value if there |
1365 # is only one field to match) | 1365 # is only one field to match) |
1366 getinfo = lambda r: [f(r) for f in getfieldfuncs] | 1366 getinfo = lambda r: [f(r) for f in getfieldfuncs] |
1367 | 1367 |
1368 matches = set() | 1368 def matches(x): |
1369 for rev in revs: | 1369 for rev in revs: |
1370 target = getinfo(rev) | 1370 target = getinfo(rev) |
1371 for r in subset: | |
1372 match = True | 1371 match = True |
1373 for n, f in enumerate(getfieldfuncs): | 1372 for n, f in enumerate(getfieldfuncs): |
1374 if target[n] != f(r): | 1373 if target[n] != f(x): |
1375 match = False | 1374 match = False |
1376 break | |
1377 if match: | 1375 if match: |
1378 matches.add(r) | 1376 return True |
1379 return baseset([r for r in subset if r in matches]) | 1377 return False |
1378 | |
1379 return lazyset(subset, matches) | |
1380 | 1380 |
1381 def reverse(repo, subset, x): | 1381 def reverse(repo, subset, x): |
1382 """``reverse(set)`` | 1382 """``reverse(set)`` |
1383 Reverse order of set. | 1383 Reverse order of set. |
1384 """ | 1384 """ |