SoftRebase Extension

This extension is not distributed with Mercurial.

Author: Patrick Mezard <patrick@mezard.eu>

Repository: https://bitbucket.org/pmezard/softrebase/

Overview

Softrebase extension is a thin wrapper on top of rebase command which recomputes the destination node so reaching the desired destination will take several softrebase runs but each of them should cause simpler and more meaningful merges.

Say you want to rebase a set of revisions REVS on top of a changeset X. A regular rebase call would merge each changeset in REVS with X and the common ancestor of X and REVS. If many changes were made to content touched by REVS you will have to know all the changes which happened to successfully rebase your revisions. A softrebase call will instead find the first changeset Y on the path between REVS and X which changes intersect the changes in REVS and rebase on it. Obviously, you will need several calls to softrebase to reach X but each of them will require you to know only about the changes brought by the intermediate Y to resolve the merge.

Note: softrebase interface may be improved and change in the future.

Example

Initialize a test repository

    $ hg init repo
    $ cd repo
    $ echo a > a
    $ hg ci -Am 'add a'
    adding a
    $ echo b >> a
    $ hg ci -Am 'append b'
    $ echo c >> a
    $ hg ci -Am 'append c'
    $ hg log -G --template '{rev}:{node|short} {desc}\n'
    @  2:5a9aaaa34af0 append c
    |
    o  1:7415b0fde5c7 append b
    |
    o  0:27b53ea0b53c add a

Add a conflicting branch

    $ hg up -C 0
    1 files updated, 0 files merged, 0 files removed, 0 files unresolved
    $ echo d >> a
    $ hg ci -m 'append d'
    created new head

Call softrebase. Use a nodeidentifier as the revision numbers are going to change between each rebase calls. Note that despite asking a rebase onto the other branch head, softrebase actually targets an intermediate changeset.

    $ hg sreb -d 5a9aaaa34af0
    rebasing onto:
    changeset:   1:7415b0fde5c7
    user:        Patrick Mezard <patrick@mezard.eu>
    date:        Sun Oct 21 17:41:12 2012 +0200
    summary:     append b

    merging a
    $ hg log -G --template '{rev}:{node|short} {desc}\n'
    @  4:25ee841b4a7b append d
    |
    | o  2:5a9aaaa34af0 append c
    |/
    o  1:7415b0fde5c7 append b
    |
    o  0:27b53ea0b53c add a

Repeat the previous command. This time we reach destination.

    $ hg sreb -d 5a9aaaa34af0
    merging a
    $ hg log -G --template '{rev}:{node|short} {desc}\n'
    @  5:7938250c4792 append d
    |
    o  2:5a9aaaa34af0 append c
    |
    o  1:7415b0fde5c7 append b
    |
    o  0:27b53ea0b53c add a


CategoryExtensionsByOthers

SoftRebaseExtension (last edited 2012-10-21 16:09:03 by PatrickMézard)