Patchwork [2,of,4,marmoute-reviewed] localrepo: add a way to get the current wlock if it's held

login
register
mail settings
Submitter Siddharth Agarwal
Date Oct. 5, 2015, 9:48 p.m.
Message ID <6ed71ec8f372f273089d.1444081682@dev6666.prn1.facebook.com>
Download mbox | patch
Permalink /patch/10815/
State Accepted
Headers show

Comments

Siddharth Agarwal - Oct. 5, 2015, 9:48 p.m.
# HG changeset patch
# User Siddharth Agarwal <sid0@fb.com>
# Date 1444080457 25200
#      Mon Oct 05 14:27:37 2015 -0700
# Node ID 6ed71ec8f372f273089dcddad5984d368c794f26
# Parent  c408266451c7b989b05f089cfa3c7b103b1c8b06
localrepo: add a way to get the current wlock if it's held

This will be useful to pass around a reference to the lock to some functions
we're going to add to scmutil. We don't want those functions to live in
localrepo to avoid bloat.

Patch

diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py
--- a/mercurial/localrepo.py
+++ b/mercurial/localrepo.py
@@ -1309,6 +1309,10 @@  class localrepository(object):
             return None
         return l
 
+    def currentwlock(self):
+        """Returns the wlock if it's held, or None if it's not."""
+        return self._currentlock(self._wlockref)
+
     def _filecommit(self, fctx, manifest1, manifest2, linkrev, tr, changelist):
         """
         commit an individual file as part of a larger transaction