Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/obsutil.py @ 33929:34e10e09afa5
obsolete: track markers in _succs
We now also store markers in _succs. It will be useful for the obsfate template that
will use them to display more meaningful information like the list of users
that have evolved a changeset into its successors.
author | Boris Feld <boris.feld@octobus.net> |
---|---|
date | Mon, 03 Jul 2017 03:27:58 +0200 |
parents | dba493981284 |
children | e278d6d2d7d2 |
comparison
equal
deleted
inserted
replaced
33928:dba493981284 | 33929:34e10e09afa5 |
---|---|
328 return obsoleted | 328 return obsoleted |
329 | 329 |
330 class _succs(list): | 330 class _succs(list): |
331 """small class to represent a successors with some metadata about it""" | 331 """small class to represent a successors with some metadata about it""" |
332 | 332 |
333 def __init__(self, *args, **kwargs): | |
334 super(_succs, self).__init__(*args, **kwargs) | |
335 self.markers = set() | |
336 | |
333 def copy(self): | 337 def copy(self): |
334 return _succs(self) | 338 new = _succs(self) |
339 new.markers = self.markers.copy() | |
340 return new | |
335 | 341 |
336 def successorssets(repo, initialnode, closest=False, cache=None): | 342 def successorssets(repo, initialnode, closest=False, cache=None): |
337 """Return set of all latest successors of initial nodes | 343 """Return set of all latest successors of initial nodes |
338 | 344 |
339 The successors set of a changeset A are the group of revisions that succeed | 345 The successors set of a changeset A are the group of revisions that succeed |
525 # duplicated entry and successors set that are strict subset of | 531 # duplicated entry and successors set that are strict subset of |
526 # another one. | 532 # another one. |
527 succssets = [] | 533 succssets = [] |
528 for mark in sorted(succmarkers[current]): | 534 for mark in sorted(succmarkers[current]): |
529 # successors sets contributed by this marker | 535 # successors sets contributed by this marker |
530 markss = [_succs()] | 536 base = _succs() |
537 base.markers.add(mark) | |
538 markss = [base] | |
531 for suc in mark[1]: | 539 for suc in mark[1]: |
532 # cardinal product with previous successors | 540 # cardinal product with previous successors |
533 productresult = [] | 541 productresult = [] |
534 for prefix in markss: | 542 for prefix in markss: |
535 for suffix in cache[suc]: | 543 for suffix in cache[suc]: |
536 newss = prefix.copy() | 544 newss = prefix.copy() |
545 newss.markers.update(suffix.markers) | |
537 for part in suffix: | 546 for part in suffix: |
538 # do not duplicated entry in successors set | 547 # do not duplicated entry in successors set |
539 # first entry wins. | 548 # first entry wins. |
540 if part not in newss: | 549 if part not in newss: |
541 newss.append(part) | 550 newss.append(part) |
546 seen = [] | 555 seen = [] |
547 final = [] | 556 final = [] |
548 candidate = sorted(((set(s), s) for s in succssets if s), | 557 candidate = sorted(((set(s), s) for s in succssets if s), |
549 key=lambda x: len(x[1]), reverse=True) | 558 key=lambda x: len(x[1]), reverse=True) |
550 for setversion, listversion in candidate: | 559 for setversion, listversion in candidate: |
551 for seenset in seen: | 560 for seenset, seensuccs in seen: |
552 if setversion.issubset(seenset): | 561 if setversion.issubset(seenset): |
562 seensuccs.markers.update(listversion.markers) | |
553 break | 563 break |
554 else: | 564 else: |
555 final.append(listversion) | 565 final.append(listversion) |
556 seen.append(setversion) | 566 seen.append((setversion, listversion)) |
557 final.reverse() # put small successors set first | 567 final.reverse() # put small successors set first |
558 cache[current] = final | 568 cache[current] = final |
559 return cache[initialnode] | 569 return cache[initialnode] |