Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

mercurial - see changes on the branch ignoring all the merge commits

I have a branch that was developed for a long period of time. During the development default branch was merged into that branch several times. I would like now to review all the changes done on that branch ignoring merges, to decide whether it is safe to merge it to default.

I tried

hg diff -r "branch('myBranch') - merge()"

but it still shows changes introduced by merges. Also tried following this How to show the diff specific to a named branch in mercurial but

hg diff -r "branch('myBranch') - branch('default')"

still bring changes introduced by merges.

like image 962
Swiety Avatar asked Dec 21 '12 14:12

Swiety


3 Answers

You have to read about revsets syntax

Your case

hg log -r "branch('myBranch') and ! merge()"

like image 143
Lazy Badger Avatar answered Dec 08 '22 04:12

Lazy Badger


The following uses the log command but with the --patch parameter it can show the modified lines as well:

hg log --branch my-branch --no-merges --patch

Short form:

hg log -Mpb my-branch
like image 32
palacsint Avatar answered Dec 08 '22 04:12

palacsint


The problem with your commands is that when you perform a hg diff and pass it several changesets, you actually perform a diff between those changesets, hence you will see the merge result.

If you want to see just the changes made by the changesets then you could use export:

$ hg export -r "branch('mybranch') and not merge()"
// lists the changes made by each changeset

For easier reviewing, you can output these to files with names based on the revision/changeset id:

$ hg export -r "branch('mybranch') and not merge()" -o "%H.patch"

... creates a file for each non-merge changeset in mybranch, and outputs it to a file with the name "40-digit changeset id.patch". If you'd prefer the revision number (only useful for your local repository as revision id's are local), use "%R.patch".

like image 38
icabod Avatar answered Dec 08 '22 06:12

icabod