# HG changeset patch # User Boris Feld # Date 1546402327 -3600 # Node ID c9a2c4d0e80f681a56935cddb6520b117ef5fcaa # Parent f04e0ca0409964ec10d35f69e2a1a22208fb4272 strip: extract bookmark movement into a separate function We will need it for the soft-strip case. diff -r f04e0ca04099 -r c9a2c4d0e80f mercurial/repair.py --- a/mercurial/repair.py Wed Jan 02 05:07:03 2019 +0100 +++ b/mercurial/repair.py Wed Jan 02 05:12:07 2019 +0100 @@ -153,22 +153,7 @@ stripobsidx = [i for i, m in enumerate(repo.obsstore) if m in obsmarkers] - # compute necessary bookmark movement - bm = repo._bookmarks - updatebm = [] - for m in bm: - rev = repo[bm[m]].rev() - if rev in tostrip: - updatebm.append(m) - newbmtarget = None - if updatebm: # don't compute anything is there is no bookmark to move anyway - # For a set s, max(parents(s) - s) is the same as max(heads(::s - s)), - # but is much faster - newbmtarget = repo.revs('max(parents(%ld) - (%ld))', tostrip, tostrip) - if newbmtarget: - newbmtarget = repo[newbmtarget.first()].node() - else: - newbmtarget = '.' + newbmtarget, updatebm = _bookmarkmovements(repo, tostrip) backupfile = None node = nodelist[-1] @@ -235,7 +220,7 @@ with repo.transaction('repair') as tr: bmchanges = [(m, repo[newbmtarget].node()) for m in updatebm] - bm.applychanges(repo, tr, bmchanges) + repo._bookmarks.applychanges(repo, tr, bmchanges) # remove undo files for undovfs, undofile in repo.undofiles(): @@ -267,6 +252,25 @@ # extensions can use it return backupfile +def _bookmarkmovements(repo, tostrip): + # compute necessary bookmark movement + bm = repo._bookmarks + updatebm = [] + for m in bm: + rev = repo[bm[m]].rev() + if rev in tostrip: + updatebm.append(m) + newbmtarget = None + if updatebm: # don't compute anything is there is no bookmark to move anyway + # For a set s, max(parents(s) - s) is the same as max(heads(::s - s)), + # but is much faster + newbmtarget = repo.revs('max(parents(%ld) - (%ld))', tostrip, tostrip) + if newbmtarget: + newbmtarget = repo[newbmtarget.first()].node() + else: + newbmtarget = '.' + return newbmtarget, updatebm + def _createstripbackup(repo, stripbases, node, topic): # backup the changeset we are about to strip vfs = repo.vfs