Mercurial > hg
comparison mercurial/cmdutil.py @ 22370:45e02cfad4bd
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.
author | Pierre-Yves David <pierre-yves.david@fb.com> |
---|---|
date | Sat, 30 Aug 2014 02:47:59 +0200 |
parents | bdc0e04df243 |
children | 81ad62defef5 |
comparison
equal
deleted
inserted
replaced
22369:897041f6b025 | 22370:45e02cfad4bd |
---|---|
2525 (dsremoved, actions['undelete'], backup), | 2525 (dsremoved, actions['undelete'], backup), |
2526 (clean, actions['noop'], discard), | 2526 (clean, actions['noop'], discard), |
2527 (unknown, actions['unknown'], discard), | 2527 (unknown, actions['unknown'], discard), |
2528 ) | 2528 ) |
2529 | 2529 |
2530 needdata = ('revert', 'add', 'remove', 'undelete') | |
2531 _revertprefetch(repo, ctx, *[actions[name][0] for name in needdata]) | |
2532 | |
2530 for abs, (rel, exact) in sorted(names.items()): | 2533 for abs, (rel, exact) in sorted(names.items()): |
2531 # target file to be touch on disk (relative to cwd) | 2534 # target file to be touch on disk (relative to cwd) |
2532 target = repo.wjoin(abs) | 2535 target = repo.wjoin(abs) |
2533 # search the entry in the dispatch table. | 2536 # search the entry in the dispatch table. |
2534 # if the file is in any of these sets, it was touched in the working | 2537 # if the file is in any of these sets, it was touched in the working |
2562 for sub in targetsubs: | 2565 for sub in targetsubs: |
2563 ctx.sub(sub).revert(ui, ctx.substate[sub], *pats, **opts) | 2566 ctx.sub(sub).revert(ui, ctx.substate[sub], *pats, **opts) |
2564 finally: | 2567 finally: |
2565 wlock.release() | 2568 wlock.release() |
2566 | 2569 |
2570 def _revertprefetch(repo, ctx, *files): | |
2571 """Let extension changing the storage layer prefetch content""" | |
2572 pass | |
2573 | |
2567 def _performrevert(repo, parents, ctx, actions): | 2574 def _performrevert(repo, parents, ctx, actions): |
2568 """function that actually perform all the actions computed for revert | 2575 """function that actually perform all the actions computed for revert |
2569 | 2576 |
2570 This is an independent function to let extension to plug in and react to | 2577 This is an independent function to let extension to plug in and react to |
2571 the imminent revert. | 2578 the imminent revert. |