|
a/Allura/allura/model/repo.py |
|
b/Allura/allura/model/repo.py |
|
... |
|
... |
201 |
override this method to provide more descriptive link text.
|
201 |
override this method to provide more descriptive link text.
|
202 |
'''
|
202 |
'''
|
203 |
return self.shorthand_id()
|
203 |
return self.shorthand_id()
|
204 |
|
204 |
|
205 |
def log_iter(self, skip, count):
|
205 |
def log_iter(self, skip, count):
|
206 |
for oids in utils.chunked_iter(commitlog(self._id), QSIZE):
|
206 |
for oids in utils.chunked_iter(commitlog([self._id]), QSIZE):
|
207 |
oids = list(oids)
|
207 |
oids = list(oids)
|
208 |
commits = dict(
|
208 |
commits = dict(
|
209 |
(ci._id, ci) for ci in self.query.find(dict(
|
209 |
(ci._id, ci) for ci in self.query.find(dict(
|
210 |
_id={'$in': oids})))
|
210 |
_id={'$in': oids})))
|
211 |
for oid in oids:
|
211 |
for oid in oids:
|
|
... |
|
... |
223 |
def log(self, skip, count):
|
223 |
def log(self, skip, count):
|
224 |
return list(self.log_iter(skip, count))
|
224 |
return list(self.log_iter(skip, count))
|
225 |
|
225 |
|
226 |
def count_revisions(self):
|
226 |
def count_revisions(self):
|
227 |
result = 0
|
227 |
result = 0
|
228 |
for oid in commitlog(self._id): result += 1
|
228 |
for oid in commitlog([self._id]): result += 1
|
229 |
return result
|
229 |
return result
|
230 |
|
230 |
|
231 |
def context(self):
|
231 |
def context(self):
|
232 |
result = dict(prev=None, next=None)
|
232 |
result = dict(prev=None, next=None)
|
233 |
if self.parent_ids:
|
233 |
if self.parent_ids:
|
|
... |
|
... |
357 |
return self.by_name[name]['type'] == 'blob'
|
357 |
return self.by_name[name]['type'] == 'blob'
|
358 |
|
358 |
|
359 |
mapper(Commit, CommitDoc, repository_orm_session)
|
359 |
mapper(Commit, CommitDoc, repository_orm_session)
|
360 |
mapper(Tree, TreeDoc, repository_orm_session)
|
360 |
mapper(Tree, TreeDoc, repository_orm_session)
|
361 |
|
361 |
|
362 |
def commitlog(commit_id, skip=0, limit=sys.maxint):
|
362 |
def commitlog(commit_ids, skip=0, limit=sys.maxint):
|
363 |
|
363 |
|
364 |
seen = set()
|
364 |
seen = set()
|
365 |
def _visit(commit_id):
|
365 |
def _visit(commit_id):
|
366 |
if commit_id in seen: return
|
366 |
if commit_id in seen: return
|
367 |
run = CommitRunDoc.m.get(commit_ids=commit_id)
|
367 |
run = CommitRunDoc.m.get(commit_ids=commit_id)
|
|
... |
|
... |
377 |
else:
|
377 |
else:
|
378 |
ci_parents[oid] = run.parent_commit_ids
|
378 |
ci_parents[oid] = run.parent_commit_ids
|
379 |
for oid in run.parent_commit_ids:
|
379 |
for oid in run.parent_commit_ids:
|
380 |
_visit(oid)
|
380 |
_visit(oid)
|
381 |
|
381 |
|
382 |
def _gen_ids(commit_id, skip, limit):
|
382 |
def _gen_ids(commit_ids, skip, limit):
|
383 |
# Traverse the graph in topo order, yielding commit IDs
|
383 |
# Traverse the graph in topo order, yielding commit IDs
|
384 |
commits = set([commit_id])
|
384 |
commits = set(commit_ids)
|
385 |
new_parent = None
|
385 |
new_parent = None
|
386 |
while commits and limit:
|
386 |
while commits and limit:
|
387 |
# next commit is latest commit that's valid to log
|
387 |
# next commit is latest commit that's valid to log
|
388 |
if new_parent in commits:
|
388 |
if new_parent in commits:
|
389 |
ci = new_parent
|
389 |
ci = new_parent
|
|
... |
|
... |
409 |
# Load all the runs to build a commit graph
|
409 |
# Load all the runs to build a commit graph
|
410 |
ci_times = {}
|
410 |
ci_times = {}
|
411 |
ci_parents = {}
|
411 |
ci_parents = {}
|
412 |
ci_children = defaultdict(set)
|
412 |
ci_children = defaultdict(set)
|
413 |
log.info('Build commit graph')
|
413 |
log.info('Build commit graph')
|
|
|
414 |
for cid in commit_ids:
|
414 |
_visit(commit_id)
|
415 |
_visit(cid)
|
415 |
for oid, parents in ci_parents.iteritems():
|
416 |
for oid, parents in ci_parents.iteritems():
|
416 |
for ci_parent in parents:
|
417 |
for ci_parent in parents:
|
417 |
ci_children[ci_parent].add(oid)
|
418 |
ci_children[ci_parent].add(oid)
|
418 |
|
419 |
|
419 |
return _gen_ids(commit_id, skip, limit)
|
420 |
return _gen_ids(commit_ids, skip, limit)
|