##// END OF EJS Templates
scmutil: make cleanupnodes handle filtered node...
Jun Wu -
r33330:ba43e5ee default
parent child Browse files
Show More
@@ -619,9 +619,12 def cleanupnodes(repo, mapping, operatio
619 # Also sort the node in topology order, that might be useful for
619 # Also sort the node in topology order, that might be useful for
620 # some obsstore logic.
620 # some obsstore logic.
621 # NOTE: the filtering and sorting might belong to createmarkers.
621 # NOTE: the filtering and sorting might belong to createmarkers.
622 isobs = repo.obsstore.successors.__contains__
622 # Unfiltered repo is needed since nodes in mapping might be hidden.
623 sortfunc = lambda ns: repo.changelog.rev(ns[0])
623 unfi = repo.unfiltered()
624 rels = [(repo[n], (repo[m] for m in s))
624 isobs = unfi.obsstore.successors.__contains__
625 torev = unfi.changelog.rev
626 sortfunc = lambda ns: torev(ns[0])
627 rels = [(unfi[n], (unfi[m] for m in s))
625 for n, s in sorted(mapping.items(), key=sortfunc)
628 for n, s in sorted(mapping.items(), key=sortfunc)
626 if s or not isobs(n)]
629 if s or not isobs(n)]
627 obsolete.createmarkers(repo, rels, operation=operation)
630 obsolete.createmarkers(repo, rels, operation=operation)
@@ -10,6 +10,8 Enable obsolete
10 > logtemplate = {rev}:{node|short} {desc}\n
10 > logtemplate = {rev}:{node|short} {desc}\n
11 > [experimental]
11 > [experimental]
12 > evolution=createmarkers
12 > evolution=createmarkers
13 > [extensions]
14 > drawdag=$TESTDIR/drawdag.py
13 > [alias]
15 > [alias]
14 > debugobsolete = debugobsolete -d '0 0'
16 > debugobsolete = debugobsolete -d '0 0'
15 > [phases]
17 > [phases]
@@ -617,3 +619,48 successors-set. (report [A,B] not [A] +
617 82623d38b9ba 392fd25390da
619 82623d38b9ba 392fd25390da
618
620
619 $ cd ..
621 $ cd ..
622
623 Use scmutil.cleanupnodes API to create divergence
624
625 $ hg init cleanupnodes
626 $ cd cleanupnodes
627 $ hg debugdrawdag <<'EOS'
628 > B1 B3 B4
629 > | \|
630 > A Z
631 > EOS
632
633 $ hg update -q B1
634 $ echo 3 >> B
635 $ hg commit --amend -m B2
636 $ cat > $TESTTMP/scmutilcleanup.py <<EOF
637 > from mercurial import registrar, scmutil
638 > cmdtable = {}
639 > command = registrar.command(cmdtable)
640 > @command('cleanup')
641 > def cleanup(ui, repo):
642 > def node(expr):
643 > unfi = repo.unfiltered()
644 > rev = unfi.revs(expr).first()
645 > return unfi.changelog.node(rev)
646 > with repo.wlock(), repo.lock(), repo.transaction('delayedstrip'):
647 > mapping = {node('desc(B1)'): [node('desc(B3)')],
648 > node('desc(B3)'): [node('desc(B4)')]}
649 > scmutil.cleanupnodes(repo, mapping, 'test')
650 > EOF
651
652 $ rm .hg/localtags
653 $ hg cleanup --config extensions.t=$TESTTMP/scmutilcleanup.py
654 $ hg log -G -T '{rev}:{node|short} {desc} {troubles}' -r 'sort(all(), topo)'
655 @ 5:1a2a9b5b0030 B2 divergent
656 |
657 | o 4:70d5a63ca112 B4 divergent
658 | |
659 | o 1:48b9aae0607f Z
660 |
661 o 0:426bada5c675 A
662
663 $ hg debugobsolete
664 a178212c3433c4e77b573f6011e29affb8aefa33 1a2a9b5b0030632400aa78e00388c20f99d3ec44 0 (Thu Jan 01 00:00:00 1970 +0000) {'user': 'test'}
665 a178212c3433c4e77b573f6011e29affb8aefa33 ad6478fb94ecec98b86daae98722865d494ac561 0 (Thu Jan 01 00:00:00 1970 +0000) {'user': 'test'}
666 ad6478fb94ecec98b86daae98722865d494ac561 70d5a63ca112acb3764bc1d7320ca90ea688d671 0 (Thu Jan 01 00:00:00 1970 +0000) {'user': 'test'}
General Comments 0
You need to be logged in to leave comments. Login now