[PATCH 7 of 8 V2] cmdutil: put recordfunc invocation into wlock scope for consistency

FUJIWARA Katsunori foozy at lares.dti.ne.jp
Wed Jul 8 03:08:43 CDT 2015


# HG changeset patch
# User FUJIWARA Katsunori <foozy at lares.dti.ne.jp>
# Date 1436342469 -32400
#      Wed Jul 08 17:01:09 2015 +0900
# Node ID a3f47d16a56c9c64f45b928749de85386b8a5dc9
# Parent  1e4c4d9736bb1051f963a9624320265d91703622
cmdutil: put recordfunc invocation into wlock scope for consistency

Before this patch, `recordfunc()` for interactive hunk selection does
below outside wlock scope at `hg commit -i` and so on:

  - backup files, which may be partially changed
  - apply selected hunks on files
  - restore files from backup-ed ones

These should be executed inside wlock scope for consistency.

To put them into wlock scope without largely changing indents in
`recordfunc()`, this patch adds another wrapper function.

This patch is also a preparation for subsequent patch fixing the issue
to correctly recognize partially committed files as "modified".

diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py
--- a/mercurial/cmdutil.py
+++ b/mercurial/cmdutil.py
@@ -220,7 +220,14 @@
             except OSError:
                 pass
 
-    return commit(ui, repo, recordfunc, pats, opts)
+    def recordinwlock(ui, repo, message, match, opts):
+        wlock = repo.wlock()
+        try:
+            return recordfunc(ui, repo, message, match, opts)
+        finally:
+            wlock.release()
+
+    return commit(ui, repo, recordinwlock, pats, opts)
 
 def findpossible(cmd, table, strict=False):
     """


More information about the Mercurial-devel mailing list