Differences between revisions 1 and 5 (spanning 4 versions)
Revision 1 as of 2006-08-19 03:49:20
Size: 554
Editor: BrendanCully
Comment:
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 6: Line 6:
                                                                                               You can find it at [http://hg.kublai.com/mercurial/transplant/]
=== 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:

{{{
#!/bin/sh

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:
{{{
#!/bin/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}}}

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)