comparison mercurial/revset.py @ 22999:88ac1be3f767

revset-only: use __nonzero__ to check if a revset is empty For some smartsets, computing length is more expensive than checking if the set is empty.
author Pierre-Yves David <pierre-yves.david@fb.com>
date Wed, 08 Oct 2014 02:45:21 -0700
parents 93e5d24692cc
children 62d19ce9d7b6
comparison
equal deleted inserted replaced
22998:93e5d24692cc 22999:88ac1be3f767
396 cl = repo.changelog 396 cl = repo.changelog
397 # i18n: "only" is a keyword 397 # i18n: "only" is a keyword
398 args = getargs(x, 1, 2, _('only takes one or two arguments')) 398 args = getargs(x, 1, 2, _('only takes one or two arguments'))
399 include = getset(repo, spanset(repo), args[0]) 399 include = getset(repo, spanset(repo), args[0])
400 if len(args) == 1: 400 if len(args) == 1:
401 if len(include) == 0: 401 if not include:
402 return baseset() 402 return baseset()
403 403
404 descendants = set(_revdescendants(repo, include, False)) 404 descendants = set(_revdescendants(repo, include, False))
405 exclude = [rev for rev in cl.headrevs() 405 exclude = [rev for rev in cl.headrevs()
406 if not rev in descendants and not rev in include] 406 if not rev in descendants and not rev in include]