sqlreplay: add start and end rev options

To enable incremental replays, let's add start and end args to the sqlreplay
command.
This commit is contained in:
Durham Goode 2017-03-30 15:51:59 -07:00
parent b420424f78
commit b081b91010
2 changed files with 18 additions and 2 deletions

View File

@ -1627,6 +1627,8 @@ class CustomConverter(mysql.connector.conversion.MySQLConverter):
return str(value)
@command('^sqlreplay', [
('', 'start', '', _('the rev to start with'), ''),
('', 'end', '', _('the rev to end with'), ''),
], _('hg sqlreplay'))
def sqlreplay(ui, repo, *args, **opts):
"""goes through the entire sql history and performs missing revlog writes
@ -1637,9 +1639,14 @@ def sqlreplay(ui, repo, *args, **opts):
revlogs from things being appended out of order.
"""
maxrev = len(repo.changelog) - 1
startrev = int(opts.get('start') or '0')
endrev = int(opts.get('end') or str(maxrev))
startrev = max(startrev, 0)
endrev = min(endrev, maxrev)
def _helper():
_sqlreplay(repo, 0, maxrev)
_sqlreplay(repo, startrev, endrev)
executewithsql(repo, _helper, False)
def _sqlreplay(repo, startrev, endrev):
@ -1652,7 +1659,6 @@ def _sqlreplay(repo, startrev, endrev):
# technically already commited.
for name, value in repo.ui.configitems("hooks"):
if name.startswith("pretxnclose"):
configbackups.append(repo.ui.backupconfig("hooks", name))
repo.ui.setconfig("hooks", name, None)
transaction = repo.transaction("sqlreplay")

View File

@ -60,6 +60,16 @@ Test that we can replay backfills into an existing repo
$ hg sqlreplay
$ ls .hg/store/meta/dir
00manifest.i
$ rm -rf .hg/store/00manifesttree* .hg/store/meta
$ hg sqlreplay --start 0 --end 0
$ hg debugindex .hg/store/00manifesttree.i
rev offset length delta linkrev nodeid p1 p2
0 0 44 -1 0 8515d4bfda76 000000000000 000000000000
$ hg sqlreplay --start 1 --end 2
$ hg debugindex .hg/store/00manifesttree.i
rev offset length delta linkrev nodeid p1 p2
0 0 44 -1 0 8515d4bfda76 000000000000 000000000000
1 44 58 0 1 898d94054864 8515d4bfda76 000000000000
$ cd ..
Test that trees created during push are synced to the db