mirror of
https://github.com/facebook/sapling.git
synced 2024-10-11 17:27:53 +03:00
treemanifest: sort trees by linkrev before inserting
Summary: Previously we sorted the trees topologically before inserting them. On a revlog-backed server, this may mean that trees are written in a different order from the actual commits. hgsql-backed servers rely on the data being written in linkrev order so they can be replayed in linkrev order on other machines, so this broke hgsql replication. Let's instead sort by linkrev, which will be both topological and satisfy hgsql's requirements. Reviewed By: quark-zju Differential Revision: D15437953 fbshipit-source-id: d4aaaa03b392a6cb6cf1be478aed2583ecb757c5
This commit is contained in:
parent
9d35dc6f3d
commit
148e70118a
@ -1838,6 +1838,7 @@ def _registerbundle2parts():
|
||||
if category != PACK_CATEGORY:
|
||||
raise error.Abort(_("invalid treegroup pack category: %s") % category)
|
||||
|
||||
cl = repo.changelog
|
||||
mfl = repo.manifestlog
|
||||
if isinstance(mfl, hybridmanifestlog):
|
||||
mfl = repo.manifestlog.treemanifestlog
|
||||
@ -1857,13 +1858,13 @@ def _registerbundle2parts():
|
||||
datastore = unioncontentstore(wirepackstore, mfl.datastore)
|
||||
tr = op.gettransaction()
|
||||
|
||||
# Sort the trees so they are added in topological
|
||||
def parents(node):
|
||||
p1, p2 = wirepackstore.getnodeinfo("", node)[:2]
|
||||
return p1, p2
|
||||
|
||||
# Sort the trees so they are added in the same order as the commits.
|
||||
# This requires that the changegroup be processed first so we can
|
||||
# compare the linkrevs.
|
||||
rootnodes = (node for name, node in wirepackstore if name == "")
|
||||
rootnodes = shallowutil.sortnodes(rootnodes, parents)
|
||||
rootnodes = sorted(
|
||||
rootnodes, key=lambda n: cl.rev(wirepackstore.getnodeinfo("", n)[2])
|
||||
)
|
||||
|
||||
for node in rootnodes:
|
||||
p1, p2, linknode, copyfrom = wirepackstore.getnodeinfo("", node)
|
||||
|
@ -281,11 +281,11 @@ Test that trees are written in linkrev order
|
||||
$ hg push --config extensions.pushrebase=! --to master -q ssh://user@dummy/ordermaster --create
|
||||
|
||||
$ cd ../ordermaster
|
||||
# BUGBUG: These should be in linkrev order after pushing to hgsql
|
||||
# These should be in linkrev order after pushing to hgsql
|
||||
$ hg debugindex .hg/store/00manifesttree.i
|
||||
rev offset length delta linkrev nodeid p1 p2
|
||||
0 0 44 -1 1 23226e7a252c 000000000000 000000000000
|
||||
1 44 44 -1 2 86d7088ee657 000000000000 000000000000
|
||||
2 88 44 -1 0 a0c8bcbbb45c 000000000000 000000000000
|
||||
3 132 55 2 3 6c51dc0bfc37 a0c8bcbbb45c 86d7088ee657
|
||||
4 187 55 3 4 d2c02f8cb06c 6c51dc0bfc37 23226e7a252c
|
||||
0 0 44 -1 0 a0c8bcbbb45c 000000000000 000000000000
|
||||
1 44 44 -1 1 23226e7a252c 000000000000 000000000000
|
||||
2 88 44 -1 2 86d7088ee657 000000000000 000000000000
|
||||
3 132 54 2 3 6c51dc0bfc37 a0c8bcbbb45c 86d7088ee657
|
||||
4 186 55 3 4 d2c02f8cb06c 6c51dc0bfc37 23226e7a252c
|
||||
|
Loading…
Reference in New Issue
Block a user