fixtests: fixes some incorrect tests relating to treemanifest

The previous commits added treemanifest integration, but the tests weren't
actually accurate. By enabling treemanifest.server=True before making any
commits, it turns out we were creating trees during commit. So all the backfill
and replay logic wasn't actually doing anything.

This patch fixes the tests by moving the treemanifest.server=True bit to later
on, and fixes a bug in the code around needing to not validate that the added
revision linkrevs are newer than tip, since backfilltree and sqlreplay are meant
to add old data.
This commit is contained in:
Durham Goode 2017-03-30 13:36:37 -07:00
parent baca6adcbf
commit b420424f78
2 changed files with 27 additions and 21 deletions

View File

@ -228,7 +228,11 @@ def backfilltree(orig, ui, repo, *args, **kwargs):
if issqlrepo(repo):
def _helper():
return orig(ui, repo, *args, **kwargs)
return executewithsql(repo, _helper, True)
try:
repo.sqlreplaytransaction = True
return executewithsql(repo, _helper, True)
finally:
repo.sqlreplaytransaction = False
else:
return orig(ui, repo, *args, **kwargs)
@ -987,10 +991,12 @@ def wraprepo(repo):
raise CorruptionException(("multiple tips for %s in " +
" the database") % reponame)
minlinkrev = min(self.pendingrevs, key= lambda x: x[1])[1]
if maxlinkrev == None or maxlinkrev != minlinkrev - 1:
raise CorruptionException("attempting to write non-sequential " +
"linkrev %s, expected %s" % (minlinkrev, maxlinkrev + 1))
if (not util.safehasattr(self, 'sqlreplaytransaction')
or not self.sqlreplaytransaction):
minlinkrev = min(self.pendingrevs, key= lambda x: x[1])[1]
if maxlinkrev == None or maxlinkrev != minlinkrev - 1:
raise CorruptionException("attempting to write non-sequential " +
"linkrev %s, expected %s" % (minlinkrev, maxlinkrev + 1))
# Clean up excess revisions left from interrupted commits.
# Since MySQL can only hold so much data in a transaction, we allow
@ -1652,6 +1658,7 @@ def _sqlreplay(repo, startrev, endrev):
transaction = repo.transaction("sqlreplay")
try:
repo.sqlreplaytransaction = True
queue = Queue.Queue()
abort = threading.Event()
@ -1667,6 +1674,7 @@ def _sqlreplay(repo, startrev, endrev):
transaction.close()
finally:
transaction.release()
repo.sqlreplaytransaction = False
finally:
if lock:
lock.release()

View File

@ -15,12 +15,6 @@ Test that treemanifest backfill populates the database
$ initserver master-alreadysynced master
$ initserver master-new master
$ cd master
$ cat >> .hg/hgrc <<EOF
> [extensions]
> treemanifest=
> [treemanifest]
> server = True
> EOF
$ touch a && hg ci -Aqm a
$ mkdir dir
$ touch dir/b && hg ci -Aqm b
@ -37,7 +31,13 @@ Test that treemanifest backfill populates the database
1
$ cd ../master
$ hg backfilltree
$ cat >> .hg/hgrc <<EOF
> [extensions]
> treemanifest=
> [treemanifest]
> server = True
> EOF
$ DBGD=1 hg backfilltree
$ ls .hg/store/meta/dir
00manifest.i
@ -55,9 +55,15 @@ Test that an empty repo syncs the tree revlogs
$ ls .hg/store/meta/dir
00manifest.i
Test that we can replay backfills into an existing repo
$ cd ../master-alreadysynced
$ hg sqlreplay
$ ls .hg/store/meta/dir
00manifest.i
$ cd ..
Test that trees created during push are synced to the db
$ cd ..
$ initclient client
$ cd client
$ hg pull -q ssh://user@dummy/master
@ -81,11 +87,3 @@ Test that trees created during push are synced to the db
$ hg debugdata .hg/store/meta/dir/00manifest.i 1
b\x00b80de5d138758541c5f05265ad144ab9fa86d1db (esc)
c\x00b80de5d138758541c5f05265ad144ab9fa86d1db (esc)
Test that we can replay backfills into an existing repo
$ cd ../master-alreadysynced
$ hg sqlreplay
$ ls .hg/store/meta/dir
00manifest.i
$ cd ..