diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py index 1f14920a892c99183b36458a329ebb30d1e99a2d_bWVyY3VyaWFsL2NtZHV0aWwucHk=..dd2f5e01480624a2fd75e4702ef7ec7fd97e831f_bWVyY3VyaWFsL2NtZHV0aWwucHk= 100644 --- a/mercurial/cmdutil.py +++ b/mercurial/cmdutil.py @@ -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() diff --git a/tests/test-import.t b/tests/test-import.t index 1f14920a892c99183b36458a329ebb30d1e99a2d_dGVzdHMvdGVzdC1pbXBvcnQudA==..dd2f5e01480624a2fd75e4702ef7ec7fd97e831f_dGVzdHMvdGVzdC1pbXBvcnQudA== 100644 --- a/tests/test-import.t +++ b/tests/test-import.t @@ -1516,7 +1516,10 @@ > def processfoo(repo, data, extra, opts): > if 'foo' in data: > extra['foo'] = data['foo'] + > def postimport(ctx): + > if 'foo' in ctx.extra(): + > ctx.repo().ui.write('imported-foo: %s\n' % ctx.extra()['foo']) > > mercurial.patch.patchheadermap.append(('Foo', 'foo')) > mercurial.cmdutil.extrapreimport.append('foo') > mercurial.cmdutil.extrapreimportmap['foo'] = processfoo @@ -1519,7 +1522,9 @@ > > mercurial.patch.patchheadermap.append(('Foo', 'foo')) > mercurial.cmdutil.extrapreimport.append('foo') > mercurial.cmdutil.extrapreimportmap['foo'] = processfoo + > mercurial.cmdutil.extrapostimport.append('foo') + > mercurial.cmdutil.extrapostimportmap['foo'] = postimport > EOF $ printf "[extensions]\nparseextra=$TESTTMP/parseextra.py" >> $HGRCPATH $ hg up -C tip @@ -1542,6 +1547,7 @@ > EOF $ hg import $TESTTMP/foo.patch applying $TESTTMP/foo.patch + imported-foo: bar $ hg log --debug -r . | grep extra extra: branch=default extra: foo=bar