Mercurial > public > mercurial-scm > hg
comparison mercurial/cmdutil.py @ 12618:0ae35296fbf4
revsets: introduce revsingle helper
revsingle returns a context for the last revision of the supplied revspec
author | Matt Mackall <mpm@selenic.com> |
---|---|
date | Thu, 07 Oct 2010 18:24:29 -0500 |
parents | 2063d36b406e |
children | 7178f6fedb9d |
comparison
equal
deleted
inserted
replaced
12617:2063d36b406e | 12618:0ae35296fbf4 |
---|---|
108 if limit <= 0: | 108 if limit <= 0: |
109 raise util.Abort(_('limit must be positive')) | 109 raise util.Abort(_('limit must be positive')) |
110 else: | 110 else: |
111 limit = None | 111 limit = None |
112 return limit | 112 return limit |
113 | |
114 def revsingle(repo, revspec, default=None): | |
115 if not revspec: | |
116 return repo[default] | |
117 | |
118 l = revrange(repo, [revspec]) | |
119 if len(l) < 1: | |
120 raise util.Abort("empty revision set") | |
121 return repo[l[-1]] | |
113 | 122 |
114 def revpair(repo, revs): | 123 def revpair(repo, revs): |
115 if not revs: | 124 if not revs: |
116 return repo.dirstate.parents()[0], None | 125 return repo.dirstate.parents()[0], None |
117 | 126 |