Patchwork [4,of,8] cmdutil: add "autoupdate" to create the hook point for automated updating

login
register
mail settings
Submitter Katsunori FUJIWARA
Date Sept. 9, 2014, 6:18 p.m.
Message ID <6ae359a9f2d2625b001f.1410286728@feefifofum>
Download mbox | patch
Permalink /patch/5751/
State Changes Requested
Headers show

Comments

Katsunori FUJIWARA - Sept. 9, 2014, 6:18 p.m.
# HG changeset patch
# User FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
# Date 1410286453 -32400
#      Wed Sep 10 03:14:13 2014 +0900
# Node ID 6ae359a9f2d2625b001fcec58ee04a3a250de679
# Parent  0fc224b5f3f12b6459453ac8e809039ae3a9603e
cmdutil: add "autoupdate" to create the hook point for automated updating

Before this patch, code paths extending update behavior (largefiles
extension, for example) does below for automated updating:

  - wrap "merge.update" or so

    This may not be enough to know about updating. For example, it is
    impossible to know whether an invocation is an automated one or
    not via wrapping.

  - wrap functions implying "merge.update" or so

    This may conflict with "cmdutil.autocommit" framework introduced
    by previous patch (e.g. "hg graft" implies both committing and
    updating).

    In addition to it, wrapper and wrappee are associated tightly by
    this kind of wrapping. This increases maintenace cost at changing
    wrapper and/or wrappee.

This patch adds "autoupdate" to create the hook point for automated
updating and avoid problems above.

Patch

diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py
--- a/mercurial/cmdutil.py
+++ b/mercurial/cmdutil.py
@@ -2064,6 +2064,24 @@ 
 
     return commitfunc
 
+def autoupdate(commandname, repo, updatefunc):
+    """create the hook point for automated updating the working directory
+
+    'updatefunc' must be the function to update the working directory
+    (= 'merge.update', 'patch.patch' and so on, or ones indirectly
+    invoking them).
+
+    Code paths implying automated updating are expected to use the
+    function returned by 'autoupdaet' instead of 'updatefunc' itself.
+
+    Then, code paths extending update behavior can hook automated
+    updating by wrapping 'autoupdate'.
+
+    'commandname' may be used to identify the scope of hooking.
+    """
+
+    return updatefunc
+
 def amend(ui, repo, commitfunc, old, extra, pats, opts):
     ui.note(_('amending changeset %s\n') % old)
     base = old.p1()