# HG changeset patch # User Siddharth Agarwal # Date 1443155197 25200 # Node ID 0fceb34806e16e99722d1cdb5c08310e70a5e37d # Parent b673e89affc9d252d1e237cc95bd56c6a8be145f lock: add a wrapper to os.getpid() to make testing easier This will allow us to fake locks across processes more easily. diff -r b673e89affc9 -r 0fceb34806e1 mercurial/lock.py --- a/mercurial/lock.py Thu Sep 24 19:52:34 2015 -0700 +++ b/mercurial/lock.py Thu Sep 24 21:26:37 2015 -0700 @@ -51,7 +51,7 @@ self._parentheld = False self._inherited = False self.postrelease = [] - self.pid = os.getpid() + self.pid = self._getpid() self.delay = self.lock() if self.acquirefn: self.acquirefn() @@ -68,6 +68,10 @@ self.release() + def _getpid(self): + # wrapper around os.getpid() to make testing easier + return os.getpid() + def lock(self): timeout = self.timeout while True: @@ -197,7 +201,7 @@ self.held -= 1 elif self.held == 1: self.held = 0 - if os.getpid() != self.pid: + if self._getpid() != self.pid: # we forked, and are not the parent return try: