comparison tests/test-import.t @ 26561:1f14920a892c

import: allow processing of extra part header during 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 points to alter the changeset (especially extra) before we commit. There would be more to do for a full featured hooking, but this currently fit my needs.
author Pierre-Yves David <pierre-yves.david@fb.com>
date Tue, 06 Oct 2015 09:51:24 -0700
parents 2748bf78a5bf
children dd2f5e014806
comparison
equal deleted inserted replaced
26560:75d448d56a9d 26561:1f14920a892c
1503 four 1503 four
1504 1504
1505 $ hg status -c . 1505 $ hg status -c .
1506 C a 1506 C a
1507 C b 1507 C b
1508
1509 Importing some extra header
1510 ===========================
1511
1512 $ cat > $TESTTMP/parseextra.py <<EOF
1513 > import mercurial.patch
1514 > import mercurial.cmdutil
1515 >
1516 > def processfoo(repo, data, extra, opts):
1517 > if 'foo' in data:
1518 > extra['foo'] = data['foo']
1519 >
1520 > mercurial.patch.patchheadermap.append(('Foo', 'foo'))
1521 > mercurial.cmdutil.extrapreimport.append('foo')
1522 > mercurial.cmdutil.extrapreimportmap['foo'] = processfoo
1523 > EOF
1524 $ printf "[extensions]\nparseextra=$TESTTMP/parseextra.py" >> $HGRCPATH
1525 $ hg up -C tip
1526 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
1527 $ cat > $TESTTMP/foo.patch <<EOF
1528 > # HG changeset patch
1529 > # User Rataxes
1530 > # Date 0 0
1531 > # Thu Jan 01 00:00:00 1970 +0000
1532 > # Foo bar
1533 > height
1534 >
1535 > --- a/a Thu Jan 01 00:00:00 1970 +0000
1536 > +++ b/a Wed Oct 07 09:17:44 2015 +0000
1537 > @@ -5,3 +5,4 @@
1538 > five
1539 > six
1540 > seven
1541 > +heigt
1542 > EOF
1543 $ hg import $TESTTMP/foo.patch
1544 applying $TESTTMP/foo.patch
1545 $ hg log --debug -r . | grep extra
1546 extra: branch=default
1547 extra: foo=bar