# HG changeset patch # User Pierre-Yves David # Date 2014-08-30 00:47:59 # Node ID 45e02cfad4bd15ff0f62ab1d49a2b69a8b2f22fe # Parent 897041f6b025778193c6da5b9795da09a91c866e revert: add a way for external extensions to prefetch file data This allow extensions that mess with the storage layer (remotefilelog, largefile) to prefetch any data that will be accessed during the revert operation. We are currently fetching more data than theoretically required because the backup code is a bit stupid. Future patches will improve that. diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py --- a/mercurial/cmdutil.py +++ b/mercurial/cmdutil.py @@ -2527,6 +2527,9 @@ def revert(ui, repo, ctx, parents, *pats (unknown, actions['unknown'], discard), ) + needdata = ('revert', 'add', 'remove', 'undelete') + _revertprefetch(repo, ctx, *[actions[name][0] for name in needdata]) + for abs, (rel, exact) in sorted(names.items()): # target file to be touch on disk (relative to cwd) target = repo.wjoin(abs) @@ -2564,6 +2567,10 @@ def revert(ui, repo, ctx, parents, *pats finally: wlock.release() +def _revertprefetch(repo, ctx, *files): + """Let extension changing the storage layer prefetch content""" + pass + def _performrevert(repo, parents, ctx, actions): """function that actually perform all the actions computed for revert