##// END OF EJS Templates
strip: add a delayedstrip method that works in a transaction...
strip: add a delayedstrip method that works in a transaction For long, the fact that strip does not work inside a transaction and some code has to work with both obsstore and fallback to strip lead to duplicated code like: with repo.transaction(): .... if obsstore: obsstore.createmarkers(...) if not obsstore: repair.strip(...) Things get more complex when you want to call something which may call strip under the hood. Like you cannot simply write: with repo.transaction(): .... rebasemod.rebase(...) # may call "strip", so this doesn't work But you do want rebase to run inside a same transaction if possible, so the code may look like: with repo.transaction(): .... if obsstore: rebasemod.rebase(...) obsstore.createmarkers(...) if not obsstore: rebasemod.rebase(...) repair.strip(...) That's ugly and error-prone. Ideally it's possible to just write: with repo.transaction(): rebasemod.rebase(...) saferemovenodes(...) This patch is the first step towards that. It adds a "delayedstrip" method to repair.py which maintains a postclose callback in the transaction object.

File last commit:

r32879:1858fc23 default
r33087:fcd1c483 default
Show More
obsutil.py
36 lines | 1.0 KiB | text/x-python | PythonLexer
# obsutil.py - utility functions for obsolescence
#
# Copyright 2017 Boris Feld <boris.feld@octobus.net>
#
# This software may be used and distributed according to the terms of the
# GNU General Public License version 2 or any later version.
from __future__ import absolute_import
def closestpredecessors(repo, nodeid):
"""yield the list of next predecessors pointing on visible changectx nodes
This function respect the repoview filtering, filtered revision will be
considered missing.
"""
precursors = repo.obsstore.precursors
stack = [nodeid]
seen = set(stack)
while stack:
current = stack.pop()
currentpreccs = precursors.get(current, ())
for prec in currentpreccs:
precnodeid = prec[0]
# Basic cycle protection
if precnodeid in seen:
continue
seen.add(precnodeid)
if precnodeid in repo:
yield precnodeid
else:
stack.append(precnodeid)