[PATCH 2 of 3] cmdutil: do not unlink lockpath if it's empty

Jun Wu quark at fb.com
Tue Feb 16 06:12:01 EST 2016

# HG changeset patch
# User Jun Wu <quark at fb.com>
# Date 1455619460 0
#      Tue Feb 16 10:44:20 2016 +0000
# Node ID 0ce18cbc108990527291701bb0e857f1e05288ef
# Parent  3fc701a86323ae896371ec3df375a52bce06b748
cmdutil: do not unlink lockpath if it's empty

Sometimes we want the effect of --daemon-pipe-fds but do not need the server
to unlink a lock file, because we may use other lock such as flock and the
lock may be held longer. This patch makes it possible by ignoring empty path.
Otherwise, we have to create a useless dummy file.

diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py
--- a/mercurial/cmdutil.py
+++ b/mercurial/cmdutil.py
@@ -804,7 +804,8 @@
         except AttributeError:
-        os.unlink(lockpath)
+        if lockpath:
+            os.unlink(lockpath)

More information about the Mercurial-devel mailing list