Patchwork [1,of,5] revert: add a way for external extensions to prefetch file data

login
register
mail settings
Submitter Pierre-Yves David
Date Sept. 4, 2014, 6:33 p.m.
Message ID <b1ac8262fc4b3e58d920.1409855599@marginatus.alto.octopoid.net>
Download mbox | patch
Permalink /patch/5699/
State Superseded
Headers show

Comments

Pierre-Yves David - Sept. 4, 2014, 6:33 p.m.
# HG changeset patch
# User Pierre-Yves David <pierre-yves.david@fb.com>
# Date 1409359679 -7200
#      Sat Aug 30 02:47:59 2014 +0200
# Node ID b1ac8262fc4b3e58d92015ecf29edd863418b5bb
# Parent  5c153c69fdb28ff5b1bf6578e5f07c50bf25833c
revert: add a way for external extensions to prefetch file data

This will let 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 that theoretically required because the
backup code is a bit stupid. Future patches will improve that.
Pierre-Yves David - Sept. 8, 2014, 2:57 p.m.
On 09/04/2014 08:33 PM, Pierre-Yves David wrote:
> # HG changeset patch
> # User Pierre-Yves David <pierre-yves.david@fb.com>
> # Date 1409359679 -7200
> #      Sat Aug 30 02:47:59 2014 +0200
> # Node ID b1ac8262fc4b3e58d92015ecf29edd863418b5bb
> # Parent  5c153c69fdb28ff5b1bf6578e5f07c50bf25833c
> revert: add a way for external extensions to prefetch file data

I started patching such extension and realised it needed a repo object 
to performs its duty. I assume this will be a very common requirement. 
I'll send a V2 soon.

Patch

diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py
--- a/mercurial/cmdutil.py
+++ b/mercurial/cmdutil.py
@@ -2525,10 +2525,13 @@  def revert(ui, repo, ctx, parents, *pats
             (dsremoved,  actions['undelete'], backup),
             (clean,      actions['noop'],     discard),
             (unknown,    actions['unknown'],  discard),
             )
 
+        needdata = ('revert', 'add', 'remove', 'undelete')
+        _revertprefetch(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)
             # search the entry in the dispatch table.
             # if the file is in any of these sets, it was touched in the working
@@ -2562,10 +2565,14 @@  def revert(ui, repo, ctx, parents, *pats
                 for sub in targetsubs:
                     ctx.sub(sub).revert(ui, ctx.substate[sub], *pats, **opts)
     finally:
         wlock.release()
 
+def _revertprefetch(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
 
     This is an independent function to let extension to plug in and react to
     the imminent revert.