diff --git a/hgext3rd/undo.py b/hgext3rd/undo.py --- a/hgext3rd/undo.py +++ b/hgext3rd/undo.py @@ -21,6 +21,7 @@ smartset, transaction, util, + vfs as vfsmod, ) from mercurial.node import ( @@ -58,6 +59,19 @@ # Write: Log control +def undovfs(repo): + """return vfs used for writing undo logs + + Avoid using repo.svfs directly since it has extra locking checks that are + not applicable to us. We have our own locking and transaction control that + do not dependent on repo transaction or locks. + """ + if not util.safehasattr(repo, '_undovfs'): + vfs = vfsmod.vfs(repo.svfs.join('undolog')) + vfs.makedirs() + repo._undovfs = vfs + return repo._undovfs + def safelog(repo, command): '''boilerplate for log command @@ -73,8 +87,7 @@ # allows running command during other commands when # otherwise legal. Could cause weird undolog states, # which gap handling generally covers. - with lockmod.lock(repo.vfs, "undologlock", - desc="undolog"): + with lockmod.lock(undovfs(repo), "undologlock", desc="undolog"): # developer config: undo._duringundologlock if repo.ui.configbool('undo', '_duringundologlock'): repo.hook("duringundologlock") @@ -93,8 +106,8 @@ # executed, doesn't check repo locks, doesn't check # abandoned tr's (since we only record info) and doesn't # do any tag handling - vfsmap = {'plain': repo.vfs} - tr = transaction.transaction(repo.ui.warn, repo.svfs, vfsmap, + vfsmap = {'plain': undovfs(repo)} + tr = transaction.transaction(repo.ui.warn, undovfs(repo), vfsmap, "_undojournal", "_undolog") return tr @@ -137,7 +150,6 @@ raise error.ProgrammingError # the transaction code doesn't work with vfs # specifically, repo.recover() assumes svfs? - repo.svfs.makedirs('undolog') rlog = _getrevlog(repo, name) node = rlog.addrevision(revstring, tr, 1, nullid, nullid) return hex(node) @@ -315,5 +327,4 @@ return len(rlog) - 1 - indexorreverseindex def _getrevlog(repo, filename): - path = 'undolog/' + filename - return revlog.revlog(repo.svfs, path) + return revlog.revlog(undovfs(repo), filename)