infinitepush: only open a transaction when deleting bookmarks

Summary: There is no need to open a transaction otherwise.

Reviewed By: DurhamG

Differential Revision: D20109840

fbshipit-source-id: e47adaaeea2d7565f3629701d8de4a67d4b55182
This commit is contained in:
Xavier Deguillard 2020-02-26 10:24:03 -08:00 committed by Facebook Github Bot
parent f6d95a9977
commit 76dd52a310

View File

@ -277,20 +277,21 @@ def _bookmarks(orig, ui, repo, *names, **opts):
delete = opts.get("delete")
remotepath = opts.get("remote_path")
path = ui.paths.getpath(remotepath or None, default=("default"))
with repo.wlock(), repo.lock(), repo.transaction("bookmarks"):
if pattern:
destpath = path.pushloc or path.loc
other = hg.peer(repo, opts, destpath)
if not names:
raise error.Abort(
"--list-remote requires a bookmark pattern",
hint='use "hg book" to get a list of your local bookmarks',
)
else:
fetchedbookmarks = other.listkeyspatterns("bookmarks", patterns=names)
_showbookmarks(ui, fetchedbookmarks, **opts)
return
elif delete and "remotenames" in extensions._extensions:
if pattern:
destpath = path.pushloc or path.loc
other = hg.peer(repo, opts, destpath)
if not names:
raise error.Abort(
"--list-remote requires a bookmark pattern",
hint='use "hg book" to get a list of your local bookmarks',
)
else:
fetchedbookmarks = other.listkeyspatterns("bookmarks", patterns=names)
_showbookmarks(ui, fetchedbookmarks, **opts)
return
elif delete and "remotenames" in extensions._extensions:
with repo.wlock(), repo.lock(), repo.transaction("bookmarks"):
existing_local_bms = set(repo._bookmarks.keys())
scratch_bms = []
other_bms = []
@ -310,8 +311,8 @@ def _bookmarks(orig, ui, repo, *names, **opts):
if len(other_bms) > 0 or len(scratch_bms) == 0:
return orig(ui, repo, *other_bms, **opts)
else:
return orig(ui, repo, *names, **opts)
else:
return orig(ui, repo, *names, **opts)
def _showbookmarks(ui, remotebookmarks, **opts):