mirror of
https://github.com/facebook/sapling.git
synced 2024-10-10 00:45:18 +03:00
bookmarks: remove use of bookmark.write()
Summary: Upstream has moved almost all bookmark writes to use bookmark.recordchange() instead of write, which works inside a transaction. For hgsql, we need to perform our bookmark writes inside a transaction now. Additionally, we need to check self.disablesync inside committodb. disablesync is used to allow us to write bookmarks during a syncdb without triggering the bookmark writes to the db (since that would be a infinite loop). Previously we only needed the syncdb check for bookmark writes, but since that has moved to transactions, we need to do the check there too (committodb fires on pretxnclose). Lastly, in theory we could remove our wrapping of bookmark.write now, since nothing should use it. But since upstream still has code for bookmark.write to write bookmarks when outside a transaction, we can't remove our code just yet, in case some extension still uses bookmark.write. Test Plan: Ran the tests Reviewers: ttung, lcharignon, #sourcecontrol, mitrandir Reviewed By: mitrandir Differential Revision: https://phabricator.fb.com/D2808601 Signature: t1:2808601:1452116992:ed34107a97ac633281ad8934266b35e3375cb247
This commit is contained in:
parent
2ef0e253f8
commit
9bf82a7d92
8
hgsql.py
8
hgsql.py
@ -562,6 +562,7 @@ def wraprepo(repo):
|
||||
raise CorruptionException("tip doesn't match after sync")
|
||||
|
||||
self.disablesync = True
|
||||
transaction = self.transaction("syncdb_bookmarks")
|
||||
try:
|
||||
bm = self._bookmarks
|
||||
bm.clear()
|
||||
@ -572,8 +573,10 @@ def wraprepo(repo):
|
||||
node = bin(node)
|
||||
if node in self:
|
||||
bm[name] = node
|
||||
bm.write()
|
||||
bm.recordchange(transaction)
|
||||
transaction.close()
|
||||
finally:
|
||||
transaction.release()
|
||||
self.disablesync = False
|
||||
|
||||
if bm != sqlbookmarks:
|
||||
@ -659,6 +662,9 @@ def wraprepo(repo):
|
||||
if not self.pendingrevs and not 'bookmark_moved' in tr.hookargs:
|
||||
return
|
||||
|
||||
if self.disablesync:
|
||||
return
|
||||
|
||||
reponame = self.sqlreponame
|
||||
cursor = self.sqlcursor
|
||||
maxcommitsize = self.maxcommitsize
|
||||
|
Loading…
Reference in New Issue
Block a user