Differences between revisions 4 and 5
Revision 4 as of 2006-12-01 23:38:32
Size: 1436
Editor: BrendanCully
Comment: removed URL - transplant is bundled now.
Revision 5 as of 2006-12-01 23:39:12
Size: 1433
Editor: BrendanCully
Comment: Removed obsolete -n option.
Deletions are marked like this. Additions are marked like this.
Line 43: Line 43:
{{{hg transplant -n -s ../transplant --filter import.sh 0:tip}}} {{{hg transplant -s ../transplant --filter import.sh 0:tip}}}

This extension allows you to transplant patches from another branch. It records the original changeset ID in the transplanted changeset, and avoids transplanting previously-transplanted patches. It can also be used to rebase a branch against upstream changes (including dropping changesets that have been adopted upstream).

Using transplant to rewrite changesets

The transplant extension accepts a --filter option, which lets you edit the changelog message and patch before applying it to its destination (they are supplied to the script as $1 and $2, respectively). For example, you could add a "Signed-off-by: " header to each changeset with a script like this:

cat <<EOF >> "$1"

Signed-off-by: Me
EOF

As a slightly more complicated example, I used the following script to import my transplant extension from a standalone repository into mercurial's hgext folder (transplant uses git-style patches, so a little extra work was required):

import.sh:

MESSAGE="$1"
PATCH="$2"

sed -e's,^\(--- a/\)\|\(+++ b/\),&hgext/,' \
    -e'/^diff --git/s,a/\(.*\) b/\(.*\),a/hgext/\1 b/hgext/\2,' \
    -e's,^\(rename\|copy\) \(from\|to\) ,&hgext/', \
    -i "$PATCH"

I then did the import like so:

hg transplant -s ../transplant --filter import.sh 0:tip


CategoryExtension

TransplantExtension (last edited 2015-05-29 19:43:43 by mpm)