mirror of
https://github.com/facebook/sapling.git
synced 2024-10-10 00:45:18 +03:00
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:
parent
baca6adcbf
commit
b420424f78
18
hgsql.py
18
hgsql.py
@ -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()
|
||||
|
@ -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 ..
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user