St.Antario
St.Antario

Reputation: 27385

Creating diff patch for all changes in a branch?

I created some branch (call it brnch) from default and made some commits there. Now there is a need to cherry-pick all diffs from the branch to some release branch for hotfix. Is something like that possible in mercurial?

    ^  ^ 
    |  |<--- brnch
    |  - commit3
    |  |
    |  - commit2
    -  |
    |  |
    |  - commit1
    -  |
    |  |
    |  |
    |--
    |
    -
 default

Is it possible to create a patch from all commmits in the branch brnch (commit1, commit2, commit3) and apply to some another branch (release hot-fix in my case)?

Upvotes: 1

Views: 747

Answers (2)

planetmaker
planetmaker

Reputation: 6044

You can simply achieve that by means of hg rebase.

For simplicity I will assume that you want to see everything from commit1 onward in your brnch see put into your release branch. Thus checkout the release branch and then rebase your brnch commits:

hg update release
hg rebase --source commit1 --collapse --keep --dest . --message "bla bla something fixed"

Alternatively you can give a revision range. If the commits you want to see collapsed are non-linear in the brnch branch, then you will need to resort to graft (which is cherry-picking individual commits) - and you can collapse (hg fold) all grafted changesets subsequently in your release branch, provided you keep them initially in phase draft.

Upvotes: 2

Mark Tolonen
Mark Tolonen

Reputation: 177674

See hg help export and hg help import.

Examples:

hg export branch(brnch) -o brnch.patch               # export everything on brnch
hg export -r commit1 -r commit2 -o cherrypick.patch  # cherrypick two changesets

hg update <somewhere_else>
hg import brnch.patch   # import the revisions in the patch

hg import --no-commit brnch.patch # import (but don't commit) revisions.
hg commit -m hotfix               # commit changes as one commit with "hotfix" description.

Upvotes: 3

Related Questions