Mercurial > hg
changeset 41102:c9a2c4d0e80f
strip: extract bookmark movement into a separate function
We will need it for the soft-strip case.
author | Boris Feld <boris.feld@octobus.net> |
---|---|
date | Wed, 02 Jan 2019 05:12:07 +0100 |
parents | f04e0ca04099 |
children | 86f0ed7ac688 |
files | mercurial/repair.py |
diffstat | 1 files changed, 21 insertions(+), 17 deletions(-) [+] |
line wrap: on
line diff
--- 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