Mercurial > public > mercurial-scm > hg
comparison mercurial/scmutil.py @ 34793:3df59451cdec
scmutil: add capability to cleanupnodes to take obsmarker metadata
This patch adds a metadata argument to cleanupnodes() which will be dict and can
be passed to obsmarker.createmarkers() and can be stored on the obsmarker.
In cases when obsolescence is not enabled, the metadata argument is useless.
This is a step towards storing a note in amend.
Differential Revision: https://phab.mercurial-scm.org/D1093
author | Pulkit Goyal <7895pulkit@gmail.com> |
---|---|
date | Sun, 15 Oct 2017 14:34:24 +0530 |
parents | 0c06875e7755 |
children | 39b094e4ae2c |
comparison
equal
deleted
inserted
replaced
34792:3b4b38130689 | 34793:3df59451cdec |
---|---|
611 self._revcontains = revcontainer.__contains__ | 611 self._revcontains = revcontainer.__contains__ |
612 | 612 |
613 def __contains__(self, node): | 613 def __contains__(self, node): |
614 return self._revcontains(self._torev(node)) | 614 return self._revcontains(self._torev(node)) |
615 | 615 |
616 def cleanupnodes(repo, replacements, operation, moves=None): | 616 def cleanupnodes(repo, replacements, operation, moves=None, metadata=None): |
617 """do common cleanups when old nodes are replaced by new nodes | 617 """do common cleanups when old nodes are replaced by new nodes |
618 | 618 |
619 That includes writing obsmarkers or stripping nodes, and moving bookmarks. | 619 That includes writing obsmarkers or stripping nodes, and moving bookmarks. |
620 (we might also want to move working directory parent in the future) | 620 (we might also want to move working directory parent in the future) |
621 | 621 |
623 but 'moves' can be used to override that. Also, 'moves' may include | 623 but 'moves' can be used to override that. Also, 'moves' may include |
624 additional bookmark moves that should not have associated obsmarkers. | 624 additional bookmark moves that should not have associated obsmarkers. |
625 | 625 |
626 replacements is {oldnode: [newnode]} or a iterable of nodes if they do not | 626 replacements is {oldnode: [newnode]} or a iterable of nodes if they do not |
627 have replacements. operation is a string, like "rebase". | 627 have replacements. operation is a string, like "rebase". |
628 | |
629 metadata is dictionary containing metadata to be stored in obsmarker if | |
630 obsolescence is enabled. | |
628 """ | 631 """ |
629 if not replacements and not moves: | 632 if not replacements and not moves: |
630 return | 633 return |
631 | 634 |
632 # translate mapping's other forms | 635 # translate mapping's other forms |
693 sortfunc = lambda ns: torev(ns[0]) | 696 sortfunc = lambda ns: torev(ns[0]) |
694 rels = [(unfi[n], tuple(unfi[m] for m in s)) | 697 rels = [(unfi[n], tuple(unfi[m] for m in s)) |
695 for n, s in sorted(replacements.items(), key=sortfunc) | 698 for n, s in sorted(replacements.items(), key=sortfunc) |
696 if s or not isobs(n)] | 699 if s or not isobs(n)] |
697 if rels: | 700 if rels: |
698 obsolete.createmarkers(repo, rels, operation=operation) | 701 obsolete.createmarkers(repo, rels, operation=operation, |
702 metadata=metadata) | |
699 else: | 703 else: |
700 from . import repair # avoid import cycle | 704 from . import repair # avoid import cycle |
701 tostrip = list(replacements) | 705 tostrip = list(replacements) |
702 if tostrip: | 706 if tostrip: |
703 repair.delayedstrip(repo.ui, repo, tostrip, operation) | 707 repair.delayedstrip(repo.ui, repo, tostrip, operation) |