diff mercurial/cmdutil.py @ 26562:dd2f5e014806

import: allow processing of extra part header after import As we have a way for extension to add more header, we need a way for them to actually process them. We add a basic hook point to do extra work after the import have been committed.
author Pierre-Yves David <pierre-yves.david@fb.com>
date Wed, 07 Oct 2015 13:05:25 -0700
parents 1f14920a892c
children 8bd2759f1fa7
line wrap: on
line diff
--- a/mercurial/cmdutil.py	Tue Oct 06 09:51:24 2015 -0700
+++ b/mercurial/cmdutil.py	Wed Oct 07 13:05:25 2015 -0700
@@ -834,6 +834,7 @@
 ## facility to let extension process additional data into an import patch
 # list of identifier to be executed in order
 extrapreimport = []  # run before commit
+extrapostimport = [] # run after commit
 # mapping from identifier to actual import function
 #
 # 'preimport' are run before the commit is made and are provided the following
@@ -846,6 +847,10 @@
 # mutation of in memory commit and more. Feel free to rework the code to get
 # there.
 extrapreimportmap = {}
+# 'postimport' are run after the commit is made and are provided the following
+# argument:
+# - ctx: the changectx created by import.
+extrapostimportmap = {}
 
 def tryimportone(ui, repo, hunk, parents, opts, msgs, updatefunc):
     """Utility function used by commands.import to import a single patch
@@ -974,6 +979,8 @@
                     n = repo.commit(message, opts.get('user') or user,
                                     opts.get('date') or date, match=m,
                                     editor=editor, extra=extra)
+                    for idfunc in extrapostimport:
+                        extrapostimportmap[idfunc](repo[n])
                 finally:
                     repo.ui.restoreconfig(allowemptyback)
             dsguard.close()