Show More
@@ -834,6 +834,7 b' def service(opts, parentfn=None, initfn=' | |||||
834 | ## facility to let extension process additional data into an import patch |
|
834 | ## facility to let extension process additional data into an import patch | |
835 | # list of identifier to be executed in order |
|
835 | # list of identifier to be executed in order | |
836 | extrapreimport = [] # run before commit |
|
836 | extrapreimport = [] # run before commit | |
|
837 | extrapostimport = [] # run after commit | |||
837 | # mapping from identifier to actual import function |
|
838 | # mapping from identifier to actual import function | |
838 | # |
|
839 | # | |
839 | # 'preimport' are run before the commit is made and are provided the following |
|
840 | # 'preimport' are run before the commit is made and are provided the following | |
@@ -846,6 +847,10 b' extrapreimport = [] # run before commit' | |||||
846 | # mutation of in memory commit and more. Feel free to rework the code to get |
|
847 | # mutation of in memory commit and more. Feel free to rework the code to get | |
847 | # there. |
|
848 | # there. | |
848 | extrapreimportmap = {} |
|
849 | extrapreimportmap = {} | |
|
850 | # 'postimport' are run after the commit is made and are provided the following | |||
|
851 | # argument: | |||
|
852 | # - ctx: the changectx created by import. | |||
|
853 | extrapostimportmap = {} | |||
849 |
|
854 | |||
850 | def tryimportone(ui, repo, hunk, parents, opts, msgs, updatefunc): |
|
855 | def tryimportone(ui, repo, hunk, parents, opts, msgs, updatefunc): | |
851 | """Utility function used by commands.import to import a single patch |
|
856 | """Utility function used by commands.import to import a single patch | |
@@ -974,6 +979,8 b' def tryimportone(ui, repo, hunk, parents' | |||||
974 | n = repo.commit(message, opts.get('user') or user, |
|
979 | n = repo.commit(message, opts.get('user') or user, | |
975 | opts.get('date') or date, match=m, |
|
980 | opts.get('date') or date, match=m, | |
976 | editor=editor, extra=extra) |
|
981 | editor=editor, extra=extra) | |
|
982 | for idfunc in extrapostimport: | |||
|
983 | extrapostimportmap[idfunc](repo[n]) | |||
977 | finally: |
|
984 | finally: | |
978 | repo.ui.restoreconfig(allowemptyback) |
|
985 | repo.ui.restoreconfig(allowemptyback) | |
979 | dsguard.close() |
|
986 | dsguard.close() |
@@ -1516,10 +1516,15 b' Importing some extra header' | |||||
1516 | > def processfoo(repo, data, extra, opts): |
|
1516 | > def processfoo(repo, data, extra, opts): | |
1517 | > if 'foo' in data: |
|
1517 | > if 'foo' in data: | |
1518 | > extra['foo'] = data['foo'] |
|
1518 | > extra['foo'] = data['foo'] | |
|
1519 | > def postimport(ctx): | |||
|
1520 | > if 'foo' in ctx.extra(): | |||
|
1521 | > ctx.repo().ui.write('imported-foo: %s\n' % ctx.extra()['foo']) | |||
1519 | > |
|
1522 | > | |
1520 | > mercurial.patch.patchheadermap.append(('Foo', 'foo')) |
|
1523 | > mercurial.patch.patchheadermap.append(('Foo', 'foo')) | |
1521 | > mercurial.cmdutil.extrapreimport.append('foo') |
|
1524 | > mercurial.cmdutil.extrapreimport.append('foo') | |
1522 | > mercurial.cmdutil.extrapreimportmap['foo'] = processfoo |
|
1525 | > mercurial.cmdutil.extrapreimportmap['foo'] = processfoo | |
|
1526 | > mercurial.cmdutil.extrapostimport.append('foo') | |||
|
1527 | > mercurial.cmdutil.extrapostimportmap['foo'] = postimport | |||
1523 | > EOF |
|
1528 | > EOF | |
1524 | $ printf "[extensions]\nparseextra=$TESTTMP/parseextra.py" >> $HGRCPATH |
|
1529 | $ printf "[extensions]\nparseextra=$TESTTMP/parseextra.py" >> $HGRCPATH | |
1525 | $ hg up -C tip |
|
1530 | $ hg up -C tip | |
@@ -1542,6 +1547,7 b' Importing some extra header' | |||||
1542 | > EOF |
|
1547 | > EOF | |
1543 | $ hg import $TESTTMP/foo.patch |
|
1548 | $ hg import $TESTTMP/foo.patch | |
1544 | applying $TESTTMP/foo.patch |
|
1549 | applying $TESTTMP/foo.patch | |
|
1550 | imported-foo: bar | |||
1545 | $ hg log --debug -r . | grep extra |
|
1551 | $ hg log --debug -r . | grep extra | |
1546 | extra: branch=default |
|
1552 | extra: branch=default | |
1547 | extra: foo=bar |
|
1553 | extra: foo=bar |
General Comments 0
You need to be logged in to leave comments.
Login now