##// END OF EJS Templates
scmutil: make cleanupnodes delete divergent bookmarks...
Jun Wu -
r33331:4bae3c11 default
parent child Browse files
Show More
@@ -567,6 +567,16 b' def origpath(ui, repo, filepath):'
567
567
568 return fullorigpath + ".orig"
568 return fullorigpath + ".orig"
569
569
570 class _containsnode(object):
571 """proxy __contains__(node) to container.__contains__ which accepts revs"""
572
573 def __init__(self, repo, revcontainer):
574 self._torev = repo.changelog.rev
575 self._revcontains = revcontainer.__contains__
576
577 def __contains__(self, node):
578 return self._revcontains(self._torev(node))
579
570 def cleanupnodes(repo, mapping, operation):
580 def cleanupnodes(repo, mapping, operation):
571 """do common cleanups when old nodes are replaced by new nodes
581 """do common cleanups when old nodes are replaced by new nodes
572
582
@@ -583,17 +593,16 b' def cleanupnodes(repo, mapping, operatio'
583 # Move bookmarks
593 # Move bookmarks
584 bmarks = repo._bookmarks
594 bmarks = repo._bookmarks
585 bmarkchanged = False
595 bmarkchanged = False
596 allnewnodes = [n for ns in mapping.values() for n in ns]
586 for oldnode, newnodes in mapping.items():
597 for oldnode, newnodes in mapping.items():
587 oldbmarks = repo.nodebookmarks(oldnode)
598 oldbmarks = repo.nodebookmarks(oldnode)
588 if not oldbmarks:
599 if not oldbmarks:
589 continue
600 continue
601 from . import bookmarks # avoid import cycle
590 bmarkchanged = True
602 bmarkchanged = True
591 if len(newnodes) > 1:
603 if len(newnodes) > 1:
592 heads = list(repo.set('heads(%ln)', newnodes))
604 # usually a split, take the one with biggest rev number
593 if len(heads) != 1:
605 newnode = next(repo.set('max(%ln)', newnodes)).node()
594 raise error.ProgrammingError(
595 'cannot figure out bookmark movement')
596 newnode = heads[0].node()
597 elif len(newnodes) == 0:
606 elif len(newnodes) == 0:
598 # move bookmark backwards
607 # move bookmark backwards
599 roots = list(repo.set('max((::%n) - %ln)', oldnode,
608 roots = list(repo.set('max((::%n) - %ln)', oldnode,
@@ -606,8 +615,13 b' def cleanupnodes(repo, mapping, operatio'
606 newnode = newnodes[0]
615 newnode = newnodes[0]
607 repo.ui.debug('moving bookmarks %r from %s to %s\n' %
616 repo.ui.debug('moving bookmarks %r from %s to %s\n' %
608 (oldbmarks, hex(oldnode), hex(newnode)))
617 (oldbmarks, hex(oldnode), hex(newnode)))
618 # Delete divergent bookmarks being parents of related newnodes
619 deleterevs = repo.revs('parents(roots(%ln & (::%n))) - parents(%n)',
620 allnewnodes, newnode, oldnode)
621 deletenodes = _containsnode(repo, deleterevs)
609 for name in oldbmarks:
622 for name in oldbmarks:
610 bmarks[name] = newnode
623 bmarks[name] = newnode
624 bookmarks.deletedivergent(repo, deletenodes, name)
611 if bmarkchanged:
625 if bmarkchanged:
612 bmarks.recordchange(tr)
626 bmarks.recordchange(tr)
613
627
@@ -1002,6 +1002,9 b' Test high-level scmutil.cleanupnodes API'
1002 $ for i in B C D F G I Z; do
1002 $ for i in B C D F G I Z; do
1003 > hg bookmark -i -r $i b-$i
1003 > hg bookmark -i -r $i b-$i
1004 > done
1004 > done
1005 $ hg bookmark -i -r E 'b-F@divergent1'
1006 $ hg bookmark -i -r H 'b-F@divergent2'
1007 $ hg bookmark -i -r G 'b-F@divergent3'
1005 $ cp -R . ../scmutilcleanup.obsstore
1008 $ cp -R . ../scmutilcleanup.obsstore
1006
1009
1007 $ cat > $TESTTMP/scmutilcleanup.py <<EOF
1010 $ cat > $TESTTMP/scmutilcleanup.py <<EOF
@@ -1025,13 +1028,13 b' Test high-level scmutil.cleanupnodes API'
1025 saved backup bundle to $TESTTMP/scmutilcleanup/.hg/strip-backup/f585351a92f8-73fb7c03-replace.hg (glob)
1028 saved backup bundle to $TESTTMP/scmutilcleanup/.hg/strip-backup/f585351a92f8-73fb7c03-replace.hg (glob)
1026
1029
1027 $ hg log -G -T '{rev}:{node|short} {desc} {bookmarks}' -r 'sort(all(), topo)'
1030 $ hg log -G -T '{rev}:{node|short} {desc} {bookmarks}' -r 'sort(all(), topo)'
1028 o 8:1473d4b996d1 G2 b-G
1031 o 8:1473d4b996d1 G2 b-F@divergent3 b-G
1029 |
1032 |
1030 | o 7:d94e89b773b6 F2 b-F
1033 | o 7:d94e89b773b6 F2 b-F
1031 | |
1034 | |
1032 | o 5:7fe5bac4c918 H
1035 | o 5:7fe5bac4c918 H
1033 |/|
1036 |/|
1034 | o 3:7fb047a69f22 E
1037 | o 3:7fb047a69f22 E b-F@divergent1
1035 | |
1038 | |
1036 | | o 6:7c78f703e465 D2 b-D
1039 | | o 6:7c78f703e465 D2 b-D
1037 | | |
1040 | | |
@@ -1048,6 +1051,8 b' Test high-level scmutil.cleanupnodes API'
1048 b-C 0:426bada5c675
1051 b-C 0:426bada5c675
1049 b-D 6:7c78f703e465
1052 b-D 6:7c78f703e465
1050 b-F 7:d94e89b773b6
1053 b-F 7:d94e89b773b6
1054 b-F@divergent1 3:7fb047a69f22
1055 b-F@divergent3 8:1473d4b996d1
1051 b-G 8:1473d4b996d1
1056 b-G 8:1473d4b996d1
1052 b-I 0:426bada5c675
1057 b-I 0:426bada5c675
1053 b-Z -1:000000000000
1058 b-Z -1:000000000000
@@ -1066,13 +1071,13 b' we have reusable code here'
1066
1071
1067 $ rm .hg/localtags
1072 $ rm .hg/localtags
1068 $ hg log -G -T '{rev}:{node|short} {desc} {bookmarks}' -r 'sort(all(), topo)'
1073 $ hg log -G -T '{rev}:{node|short} {desc} {bookmarks}' -r 'sort(all(), topo)'
1069 o 12:1473d4b996d1 G2 b-G
1074 o 12:1473d4b996d1 G2 b-F@divergent3 b-G
1070 |
1075 |
1071 | o 11:d94e89b773b6 F2 b-F
1076 | o 11:d94e89b773b6 F2 b-F
1072 | |
1077 | |
1073 | o 8:7fe5bac4c918 H
1078 | o 8:7fe5bac4c918 H
1074 |/|
1079 |/|
1075 | o 4:7fb047a69f22 E
1080 | o 4:7fb047a69f22 E b-F@divergent1
1076 | |
1081 | |
1077 | | o 10:7c78f703e465 D2 b-D
1082 | | o 10:7c78f703e465 D2 b-D
1078 | | |
1083 | | |
General Comments 0
You need to be logged in to leave comments. Login now