Mercurial > public > mercurial-scm > hg
comparison mercurial/revset.py @ 28427:969a4615c4c4
revset: add inspection data to max() and min() functions
We are likely to be interested in how these functions build a result set.
author | Yuya Nishihara <yuya@tcha.org> |
---|---|
date | Tue, 16 Feb 2016 21:44:13 +0900 |
parents | 3d39ac06af9a |
children | d749b1832d2f |
comparison
equal
deleted
inserted
replaced
28426:3d39ac06af9a | 28427:969a4615c4c4 |
---|---|
1323 """ | 1323 """ |
1324 os = getset(repo, fullreposet(repo), x) | 1324 os = getset(repo, fullreposet(repo), x) |
1325 try: | 1325 try: |
1326 m = os.max() | 1326 m = os.max() |
1327 if m in subset: | 1327 if m in subset: |
1328 return baseset([m]) | 1328 return baseset([m], datarepr=('<max %r, %r>', subset, os)) |
1329 except ValueError: | 1329 except ValueError: |
1330 # os.max() throws a ValueError when the collection is empty. | 1330 # os.max() throws a ValueError when the collection is empty. |
1331 # Same as python's max(). | 1331 # Same as python's max(). |
1332 pass | 1332 pass |
1333 return baseset() | 1333 return baseset(datarepr=('<max %r, %r>', subset, os)) |
1334 | 1334 |
1335 @predicate('merge()', safe=True) | 1335 @predicate('merge()', safe=True) |
1336 def merge(repo, subset, x): | 1336 def merge(repo, subset, x): |
1337 """Changeset is a merge changeset. | 1337 """Changeset is a merge changeset. |
1338 """ | 1338 """ |
1368 """ | 1368 """ |
1369 os = getset(repo, fullreposet(repo), x) | 1369 os = getset(repo, fullreposet(repo), x) |
1370 try: | 1370 try: |
1371 m = os.min() | 1371 m = os.min() |
1372 if m in subset: | 1372 if m in subset: |
1373 return baseset([m]) | 1373 return baseset([m], datarepr=('<min %r, %r>', subset, os)) |
1374 except ValueError: | 1374 except ValueError: |
1375 # os.min() throws a ValueError when the collection is empty. | 1375 # os.min() throws a ValueError when the collection is empty. |
1376 # Same as python's min(). | 1376 # Same as python's min(). |
1377 pass | 1377 pass |
1378 return baseset() | 1378 return baseset(datarepr=('<min %r, %r>', subset, os)) |
1379 | 1379 |
1380 @predicate('modifies(pattern)', safe=True) | 1380 @predicate('modifies(pattern)', safe=True) |
1381 def modifies(repo, subset, x): | 1381 def modifies(repo, subset, x): |
1382 """Changesets modifying files matched by pattern. | 1382 """Changesets modifying files matched by pattern. |
1383 | 1383 |