Mercurial > hg
comparison mercurial/cmdutil.py @ 12617:2063d36b406e
revsets: make revpair revsets-aware
revpair returns the first and last members of the computed revset(s)
author | Matt Mackall <mpm@selenic.com> |
---|---|
date | Thu, 07 Oct 2010 18:05:04 -0500 |
parents | cb59654c2c7a |
children | 0ae35296fbf4 |
comparison
equal
deleted
inserted
replaced
12616:e797fdf91df4 | 12617:2063d36b406e |
---|---|
110 else: | 110 else: |
111 limit = None | 111 limit = None |
112 return limit | 112 return limit |
113 | 113 |
114 def revpair(repo, revs): | 114 def revpair(repo, revs): |
115 '''return pair of nodes, given list of revisions. second item can | |
116 be None, meaning use working dir.''' | |
117 | |
118 def revfix(repo, val, defval): | |
119 if not val and val != 0 and defval is not None: | |
120 val = defval | |
121 return repo.lookup(val) | |
122 | |
123 if not revs: | 115 if not revs: |
124 return repo.dirstate.parents()[0], None | 116 return repo.dirstate.parents()[0], None |
125 end = None | 117 |
126 if len(revs) == 1: | 118 l = revrange(repo, revs) |
127 if revrangesep in revs[0]: | 119 |
128 start, end = revs[0].split(revrangesep, 1) | 120 if len(l) == 0: |
129 start = revfix(repo, start, 0) | 121 return repo.dirstate.parents()[0], None |
130 end = revfix(repo, end, len(repo) - 1) | 122 |
131 else: | 123 if len(l) == 1: |
132 start = revfix(repo, revs[0], None) | 124 return repo.lookup(l[0]), None |
133 elif len(revs) == 2: | 125 |
134 if revrangesep in revs[0] or revrangesep in revs[1]: | 126 return repo.lookup(l[0]), repo.lookup(l[-1]) |
135 raise util.Abort(_('too many revisions specified')) | |
136 start = revfix(repo, revs[0], None) | |
137 end = revfix(repo, revs[1], None) | |
138 else: | |
139 raise util.Abort(_('too many revisions specified')) | |
140 return start, end | |
141 | 127 |
142 def revrange(repo, revs): | 128 def revrange(repo, revs): |
143 """Yield revision as strings from a list of revision specifications.""" | 129 """Yield revision as strings from a list of revision specifications.""" |
144 | 130 |
145 def revfix(repo, val, defval): | 131 def revfix(repo, val, defval): |