Arek
Arek

Reputation: 1336

How to review a complete feature branch before merging

How can I review changes in a feature branch / named branch, seeing all changes made in this branch?

I know I can review all individual commits one by one, but this leads to reviewing some code in one commit, which is the maybe modified or removed few commits later.

I also know about comparing any revisions of the repository (Visual Diff in TortoiseHg) and use this to compare last commit of the named branch with its starting point. This fails however, if the named branch was integrating changes from default in between.

Any other way?

Upvotes: 2

Views: 73

Answers (1)

andref
andref

Reputation: 750

I suppose you have something like this:

             x + y   x + y + z
               |         |
   x       y   |    z    |     t
------|--------|---------|------------> default
       \        \         \
        \        \         \
         +--------+---------+---------> topic
             a    |    b    |    c    |
                  |         |          \
              x + a + y     |           x + a + y + b + z + c
                            |
                    x + a + y + b + z

To see only a + b + c you should compare the P2 of the last merge with the tip of topic. The command you should use is hg diff -r 'p2(last(merge())):.'.

Below, there is a test case that corresponds to the previous diagram:

#!/bin/bash

cd /tmp
hg init view-abc
cd view-abc
echo x > x
hg commit -Am x

hg branch topic
echo a > a
hg commit -Am a

hg up default
echo y > y
hg commit -Am y

hg up topic
hg merge default
hg commit -m merge
echo b > b
hg commit -Am b

hg up default
echo z > z
hg commit -Am z

hg up topic
hg merge default
hg commit -m merge

hg up default
echo t > t
hg commit -Am t

hg up topic
echo c > c
hg commit -Am c

hg diff -r 'p2(last(merge())):.'

Upvotes: 1

Related Questions