comparison mercurial/commands.py @ 1257:fe7fbfdb066d

Clamp negative rev numbers at zero. Prior to this change, trying to run "hg log -r -50:" in a repo with less than 50 changes caused an error. Now that we clamp at zero: no more error.
author Bryan O'Sullivan <bos@serpentine.com>
date Thu, 15 Sep 2005 00:04:29 -0700
parents e825dfea3823
children 325c07fd2ebd
comparison
equal deleted inserted replaced
1255:e825dfea3823 1257:fe7fbfdb066d
161 return defval 161 return defval
162 try: 162 try:
163 num = int(val) 163 num = int(val)
164 if str(num) != val: 164 if str(num) != val:
165 raise ValueError 165 raise ValueError
166 if num < 0: 166 if num < 0: num += revcount
167 num += revcount 167 if num < 0: num = 0
168 if not (0 <= num < revcount): 168 elif num >= revcount:
169 raise ValueError 169 raise ValueError
170 except ValueError: 170 except ValueError:
171 try: 171 try:
172 num = repo.changelog.rev(repo.lookup(val)) 172 num = repo.changelog.rev(repo.lookup(val))
173 except KeyError: 173 except KeyError: