[PATCH 2 of 2] relink: use context manager for lock management
Matt Harbison
mharbison72 at gmail.com
Sat Jun 23 03:36:37 UTC 2018
# HG changeset patch
# User Matt Harbison <matt_harbison at yahoo.com>
# Date 1490330015 14400
# Fri Mar 24 00:33:35 2017 -0400
# Node ID d0df45902a8ce983a2f55a0c4e4acb5d41c753fe
# Parent c68fcc8aa06b71d87439efceeea3c0ac55b93614
relink: use context manager for lock management
diff --git a/hgext/relink.py b/hgext/relink.py
--- a/hgext/relink.py
+++ b/hgext/relink.py
@@ -70,17 +70,10 @@ def relink(ui, repo, origin=None, **opts
# No point in continuing
raise error.Abort(_('source and destination are on different devices'))
- locallock = repo.lock()
- try:
- remotelock = src.lock()
- try:
- candidates = sorted(collect(src, ui))
- targets = prune(candidates, src.store.path, repo.store.path, ui)
- do_relink(src.store.path, repo.store.path, targets, ui)
- finally:
- remotelock.release()
- finally:
- locallock.release()
+ with repo.lock(), src.lock():
+ candidates = sorted(collect(src, ui))
+ targets = prune(candidates, src.store.path, repo.store.path, ui)
+ do_relink(src.store.path, repo.store.path, targets, ui)
def collect(src, ui):
seplen = len(os.path.sep)
More information about the Mercurial-devel
mailing list