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

login
register
mail settings
Submitter Katsunori FUJIWARA
Date July 8, 2015, 8:08 a.m.
Message ID <a3f47d16a56c9c64f45b.1436342923@feefifofum>
Download mbox | patch
Permalink /patch/9921/
State Accepted
Commit c5dfa47ad7ee618e8e5cec825de66e2c7349d5e8
Headers show

Comments

Katsunori FUJIWARA - July 8, 2015, 8:08 a.m.
# HG changeset patch
# User FUJIWARA Katsunori <foozy@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".

Patch

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):
     """