Shortened commands.revrange() a little bit, added docstring.
--- a/mercurial/commands.py Fri Aug 26 15:19:18 2005 +0200
+++ b/mercurial/commands.py Fri Aug 26 15:26:44 2005 +0200
@@ -125,6 +125,7 @@
revrangesep = ':'
def revrange(ui, repo, revs, revlog=None):
+ """Yield revision as strings from a list of revision specifications."""
if revlog is None:
revlog = repo.changelog
revcount = revlog.count()
@@ -153,13 +154,8 @@
start, end = spec.split(revrangesep, 1)
start = fix(start, 0)
end = fix(end, revcount - 1)
- if end > start:
- end += 1
- step = 1
- else:
- end -= 1
- step = -1
- for rev in xrange(start, end, step):
+ step = start > end and -1 or 1
+ for rev in xrange(start, end+step, step):
yield str(rev)
else:
yield str(fix(spec, None))