621 # - "troubles" method on changectx |
621 # - "troubles" method on changectx |
622 # - function to travel throught the obsolescence graph |
622 # - function to travel throught the obsolescence graph |
623 # - function to find useful changeset to stabilize |
623 # - function to find useful changeset to stabilize |
624 |
624 |
625 ### Marker Create |
625 ### Marker Create |
626 |
626 # NOW IN CORE f85816af6294 |
627 def createmarkers(repo, relations, metadata=None, flag=0): |
627 try: |
628 """Add obsolete markers between changeset in a repo |
628 createmarkers = obsolete.createmarkers |
629 |
629 except AttributeError: |
630 <relations> must be an iterable of (<old>, (<new>, ...)) tuple. |
630 def createmarkers(repo, relations, metadata=None, flag=0): |
631 `old` and `news` are changectx. |
631 """Add obsolete markers between changeset in a repo |
632 |
632 |
633 Current user and date are used except if specified otherwise in the |
633 <relations> must be an iterable of (<old>, (<new>, ...)) tuple. |
634 metadata attribute. |
634 `old` and `news` are changectx. |
635 |
635 |
636 /!\ assume the repo have been locked by the user /!\ |
636 Current user and date are used except if specified otherwise in the |
637 """ |
637 metadata attribute. |
638 # prepare metadata |
638 |
639 if metadata is None: |
639 /!\ assume the repo have been locked by the user /!\ |
640 metadata = {} |
640 """ |
641 if 'date' not in metadata: |
641 # prepare metadata |
642 metadata['date'] = '%i %i' % util.makedate() |
642 if metadata is None: |
643 if 'user' not in metadata: |
643 metadata = {} |
644 metadata['user'] = repo.ui.username() |
644 if 'date' not in metadata: |
645 # check future marker |
645 metadata['date'] = '%i %i' % util.makedate() |
646 tr = repo.transaction('add-obsolescence-marker') |
646 if 'user' not in metadata: |
647 try: |
647 metadata['user'] = repo.ui.username() |
648 for prec, sucs in relations: |
648 # check future marker |
649 if not prec.mutable(): |
649 tr = repo.transaction('add-obsolescence-marker') |
650 raise util.Abort("Cannot obsolete immutable changeset: %s" % prec) |
650 try: |
651 nprec = prec.node() |
651 for prec, sucs in relations: |
652 nsucs = tuple(s.node() for s in sucs) |
652 if not prec.mutable(): |
653 if nprec in nsucs: |
653 raise util.Abort("cannot obsolete immutable changeset: %s" % prec) |
654 raise util.Abort("Changeset %s cannot obsolete himself" % prec) |
654 nprec = prec.node() |
655 repo.obsstore.create(tr, nprec, nsucs, flag, metadata) |
655 nsucs = tuple(s.node() for s in sucs) |
656 clearobscaches(repo) |
656 if nprec in nsucs: |
657 tr.close() |
657 raise util.Abort("changeset %s cannot obsolete himself" % prec) |
658 finally: |
658 repo.obsstore.create(tr, nprec, nsucs, flag, metadata) |
659 tr.release() |
659 clearobscaches(repo) |
|
660 tr.close() |
|
661 finally: |
|
662 tr.release() |
660 |
663 |
661 |
664 |
662 ### Useful alias |
665 ### Useful alias |
663 |
666 |
664 @eh.uisetup |
667 @eh.uisetup |