Mercurial > hg
comparison mercurial/commands.py @ 1066:ea878688221e
Shortened commands.revrange() a little bit, added docstring.
author | Thomas Arendsen Hein <thomas@intevation.de> |
---|---|
date | Fri, 26 Aug 2005 15:26:44 +0200 |
parents | 6e94c0365d98 |
children | fae1204603dc |
comparison
equal
deleted
inserted
replaced
1065:6e94c0365d98 | 1066:ea878688221e |
---|---|
123 yield 'iter', rev, None | 123 yield 'iter', rev, None |
124 | 124 |
125 revrangesep = ':' | 125 revrangesep = ':' |
126 | 126 |
127 def revrange(ui, repo, revs, revlog=None): | 127 def revrange(ui, repo, revs, revlog=None): |
128 """Yield revision as strings from a list of revision specifications.""" | |
128 if revlog is None: | 129 if revlog is None: |
129 revlog = repo.changelog | 130 revlog = repo.changelog |
130 revcount = revlog.count() | 131 revcount = revlog.count() |
131 def fix(val, defval): | 132 def fix(val, defval): |
132 if not val: | 133 if not val: |
151 for spec in revs: | 152 for spec in revs: |
152 if spec.find(revrangesep) >= 0: | 153 if spec.find(revrangesep) >= 0: |
153 start, end = spec.split(revrangesep, 1) | 154 start, end = spec.split(revrangesep, 1) |
154 start = fix(start, 0) | 155 start = fix(start, 0) |
155 end = fix(end, revcount - 1) | 156 end = fix(end, revcount - 1) |
156 if end > start: | 157 step = start > end and -1 or 1 |
157 end += 1 | 158 for rev in xrange(start, end+step, step): |
158 step = 1 | |
159 else: | |
160 end -= 1 | |
161 step = -1 | |
162 for rev in xrange(start, end, step): | |
163 yield str(rev) | 159 yield str(rev) |
164 else: | 160 else: |
165 yield str(fix(spec, None)) | 161 yield str(fix(spec, None)) |
166 | 162 |
167 def make_filename(repo, r, pat, node=None, | 163 def make_filename(repo, r, pat, node=None, |