##// END OF EJS Templates
hgit rev-list support...
mpm@selenic.com -
r356:7dec9a46 default
parent child Browse files
Show More
@@ -128,7 +128,7 b' def catfile(args, ui, repo):'
128 128 # telling you which commits are reachable from the supplied ones via
129 129 # a bitmask based on arg position.
130 130 # you can specify a commit to stop at by starting the sha1 with ^
131 def revtree(args, repo):
131 def revtree(args, repo, full="tree", maxnr=0):
132 132 # calculate and return the reachability bitmask for sha
133 133 def is_reachable(ar, reachable, sha):
134 134 if len(ar) == 0:
@@ -143,6 +143,7 b' def revtree(args, repo):'
143 143 reachable = []
144 144 stop_sha1 = []
145 145 want_sha1 = []
146 count = 0
146 147
147 148 # figure out which commits they are asking for and which ones they
148 149 # want us to stop on
@@ -153,6 +154,7 b' def revtree(args, repo):'
153 154 want_sha1.append(s)
154 155 elif args[i] != 'HEAD':
155 156 want_sha1.append(args[i])
157
156 158 # calculate the graph for the supplied commits
157 159 for i in range(len(want_sha1)):
158 160 reachable.append({});
@@ -169,40 +171,53 b' def revtree(args, repo):'
169 171 visit.append(p)
170 172 if p in stop_sha1:
171 173 break
174
172 175 # walk the repository looking for commits that are in our
173 176 # reachability graph
174 for i in range(repo.changelog.count()):
177 for i in range(repo.changelog.count()-1, -1, -1):
175 178 n = repo.changelog.node(i)
176 179 mask = is_reachable(want_sha1, reachable, n)
177 180 if mask:
178 changes = repo.changelog.read(n)
179 (p1, p2) = repo.changelog.parents(n)
180 (h, h1, h2) = map(hg.hex, (n, p1, p2))
181 (i1, i2) = map(repo.changelog.rev, (p1, p2))
181 if not full:
182 print hg.hex(n)
183 elif full is "commit":
184 print hg.hex(n)
185 catcommit(repo, n, ' ')
186 else:
187 changes = repo.changelog.read(n)
188 (p1, p2) = repo.changelog.parents(n)
189 (h, h1, h2) = map(hg.hex, (n, p1, p2))
190 (i1, i2) = map(repo.changelog.rev, (p1, p2))
182 191
183 date = changes[2].split(' ')[0]
184 print "%s %s:%s" % (date, h, mask),
185 mask = is_reachable(want_sha1, reachable, p1)
186 if i1 != -1 and mask > 0:
187 print "%s:%s " % (h1, mask),
188 mask = is_reachable(want_sha1, reachable, p2)
189 if i2 != -1 and mask > 0:
190 print "%s:%s " % (h2, mask),
191 print ""
192 date = changes[2].split(' ')[0]
193 print "%s %s:%s" % (date, h, mask),
194 mask = is_reachable(want_sha1, reachable, p1)
195 if i1 != -1 and mask > 0:
196 print "%s:%s " % (h1, mask),
197 mask = is_reachable(want_sha1, reachable, p2)
198 if i2 != -1 and mask > 0:
199 print "%s:%s " % (h2, mask),
200 print ""
201 if maxnr and count >= maxnr:
202 break
203 count += 1
192 204
193 205 # git rev-list tries to order things by date, and has the ability to stop
194 206 # at a given commit without walking the whole repo. TODO add the stop
195 207 # parameter
196 208 def revlist(args, repo):
197 209 doptions = {}
198 opts = [('c', 'commit', None, 'commit')]
210 opts = [('c', 'commit', None, 'commit'),
211 ('n', 'max-nr', 0, 'max-nr')]
199 212 args = fancyopts.fancyopts(args, opts, doptions,
200 213 'hg rev-list')
201 for i in range(repo.changelog.count()):
202 n = repo.changelog.node(i)
203 print hg.hex(n)
204 if doptions['commit']:
205 catcommit(repo, n, ' ')
214 if doptions['commit']:
215 full = "commit"
216 else:
217 full = None
218 for i in range(1, len(args)):
219 args[i] = '^' + args[i]
220 revtree(args, repo, full, doptions['max-nr'])
206 221
207 222 def catchterm(*args):
208 223 raise SignalInterrupt
General Comments 0
You need to be logged in to leave comments. Login now