Mercurial > public > mercurial-scm > hg
comparison mercurial/obsutil.py @ 33941:c0bbaefc2c5a
obsolete: move merge logic on the smaller object
Refactor some logic in _succs in order to clean successorssets code.
Differential Revision: https://phab.mercurial-scm.org/D530
author | Boris Feld <boris.feld@octobus.net> |
---|---|
date | Mon, 03 Jul 2017 03:54:24 +0200 |
parents | e278d6d2d7d2 |
children | 54c21114e41d |
comparison
equal
deleted
inserted
replaced
33940:2a37459aedf2 | 33941:c0bbaefc2c5a |
---|---|
336 | 336 |
337 def copy(self): | 337 def copy(self): |
338 new = _succs(self) | 338 new = _succs(self) |
339 new.markers = self.markers.copy() | 339 new.markers = self.markers.copy() |
340 return new | 340 return new |
341 | |
342 @util.propertycache | |
343 def _set(self): | |
344 # immutable | |
345 return set(self) | |
346 | |
347 def canmerge(self, other): | |
348 return self._set.issubset(other._set) | |
341 | 349 |
342 def successorssets(repo, initialnode, closest=False, cache=None): | 350 def successorssets(repo, initialnode, closest=False, cache=None): |
343 """Return set of all latest successors of initial nodes | 351 """Return set of all latest successors of initial nodes |
344 | 352 |
345 The successors set of a changeset A are the group of revisions that succeed | 353 The successors set of a changeset A are the group of revisions that succeed |
552 markss = productresult | 560 markss = productresult |
553 succssets.extend(markss) | 561 succssets.extend(markss) |
554 # remove duplicated and subset | 562 # remove duplicated and subset |
555 seen = [] | 563 seen = [] |
556 final = [] | 564 final = [] |
557 candidate = sorted(((set(s), s) for s in succssets if s), | 565 candidate = sorted((s for s in succssets if s), |
558 key=lambda x: len(x[1]), reverse=True) | 566 key=len, reverse=True) |
559 for setversion, listversion in candidate: | 567 for cand in candidate: |
560 for seenset, seensuccs in seen: | 568 for seensuccs in seen: |
561 if setversion.issubset(seenset): | 569 if cand.canmerge(seensuccs): |
562 seensuccs.markers.update(listversion.markers) | 570 seensuccs.markers.update(cand.markers) |
563 break | 571 break |
564 else: | 572 else: |
565 final.append(listversion) | 573 final.append(cand) |
566 seen.append((setversion, listversion)) | 574 seen.append(cand) |
567 final.reverse() # put small successors set first | 575 final.reverse() # put small successors set first |
568 cache[current] = final | 576 cache[current] = final |
569 return cache[initialnode] | 577 return cache[initialnode] |
570 | 578 |
571 def successorsandmarkers(repo, ctx): | 579 def successorsandmarkers(repo, ctx): |