mirror of
https://github.com/facebook/sapling.git
synced 2024-10-10 00:45:18 +03:00
Fix incremental updating of heads and bookmarks
Summary: We had tried to be smart about incrementally updating only the heads and bookmarks that actually changed, but the old logic was broken. It compared binary and hex nodes against each other, and therefore didn't actually do anything incrementally. This patch makes us convert the Mercurial data to hex at the very beginning, so the incremental check uses hex as well. Test Plan: Inserted print statements around the insert/delets and verified they changed before and after Reviewers: #mercurial Differential Revision: https://phabricator.intern.facebook.com/D4012317
This commit is contained in:
parent
145b3a59b8
commit
27925e5fef
9
hgsql.py
9
hgsql.py
@ -823,7 +823,7 @@ def wraprepo(repo):
|
||||
self.sqlconn.commit()
|
||||
|
||||
# Compute new heads, and delete old heads
|
||||
newheads = set(self.heads())
|
||||
newheads = set(hex(n) for n in self.heads())
|
||||
oldheads = []
|
||||
cursor.execute(
|
||||
"SELECT value FROM revision_references "
|
||||
@ -848,7 +848,8 @@ def wraprepo(repo):
|
||||
)
|
||||
|
||||
# Compute new bookmarks, and delete old bookmarks
|
||||
newbookmarks = self._bookmarks.copy()
|
||||
newbookmarks = dict((k, hex(v)) for k, v in
|
||||
self._bookmarks.iteritems())
|
||||
oldbookmarks = []
|
||||
cursor.execute(
|
||||
"SELECT name, value FROM revision_references "
|
||||
@ -876,13 +877,13 @@ def wraprepo(repo):
|
||||
for head in newheads:
|
||||
tmpl.append("(%s, 'heads', NULL, %s)")
|
||||
values.append(reponame)
|
||||
values.append(hex(head))
|
||||
values.append(head)
|
||||
|
||||
for k, v in newbookmarks.iteritems():
|
||||
tmpl.append("(%s, 'bookmarks', %s, %s)")
|
||||
values.append(repo.sqlreponame)
|
||||
values.append(k)
|
||||
values.append(hex(v))
|
||||
values.append(v)
|
||||
|
||||
if tmpl:
|
||||
cursor.execute("INSERT INTO revision_references(repo, namespace, name, value) " +
|
||||
|
@ -75,7 +75,9 @@
|
||||
|
||||
# Verify that --forcesync works
|
||||
|
||||
$ cd ../master
|
||||
$ cd ../
|
||||
$ cp $HGRCPATH backup.hgrc
|
||||
$ cd master
|
||||
$ echo '[hooks]' >> $HGRCPATH
|
||||
$ echo 'presyncdb=$TESTTMP/hook.sh' >> $HGRCPATH
|
||||
$ echo 'sleep 2' > $TESTTMP/hook.sh
|
||||
@ -92,3 +94,32 @@
|
||||
3 a
|
||||
got lock after ? seconds (glob)
|
||||
3 a
|
||||
$ cd ..
|
||||
$ cp backup.hgrc $HGRCPATH
|
||||
|
||||
# Update one bookmark but not the other
|
||||
$ cat >> $TESTTMP/inspectsql.py <<EOF
|
||||
> import os, sys
|
||||
> from mercurial import demandimport, extensions
|
||||
> with demandimport.deactivated():
|
||||
> import mysql.connector
|
||||
> watchstrings = os.environ.get("INSPECTSQL")
|
||||
> if watchstrings:
|
||||
> watchstrings = watchstrings.split(',')
|
||||
> def printsql(orig, *args, **kwargs):
|
||||
> if not watchstrings or any(s for s in watchstrings if s in args[1]):
|
||||
> print >> sys.stderr, args[1] % args[2]
|
||||
> return orig(*args, **kwargs)
|
||||
> extensions.wrapfunction(mysql.connector.cursor.MySQLCursor, "execute", printsql)
|
||||
> EOF
|
||||
$ cat >> $HGRCPATH <<EOF
|
||||
> [extensions]
|
||||
> inspectsql=$TESTTMP/inspectsql.py
|
||||
> EOF
|
||||
$ cd master
|
||||
$ INSPECTSQL=DELETE,INSERT hg book mybook2
|
||||
INSERT INTO revision_references(repo, namespace, name, value) VALUES (masterrepo, 'bookmarks', mybook2, 0000000000000000000000000000000000000000)
|
||||
INSERT INTO revision_references(repo, namespace, name, value)
|
||||
VALUES(masterrepo, 'tip', 'tip', 3) ON DUPLICATE KEY UPDATE value=3
|
||||
$ cd ..
|
||||
$ cp backup.hgrc $HGRCPATH
|
||||
|
Loading…
Reference in New Issue
Block a user