How to get diff for local revisions and parent revisions?

John Arbash Meinel john at arbash-meinel.com
Thu Sep 16 15:16:02 BST 2010


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1


1) if you can do this via the python api, it may be easier to get
   exactly what you want. However,

2) Let's define some terms:
   a) trunk => mainline branch
   b) proposed => current branch you are proposing for merge
   c) proposed-merged => something that was merged into your proposed
                         branch

   d) Further, I'm assuming that all of these branches are available at
      the above paths. There are other tricks you can do if the
      revisions are only in the ancestry.

   (I think 'proposed' is your "grand-child" and "proposed-merged" is
    your "child", but I'm not positive)

  As a graph, with time going down:

  trunk  proposed-merged
      proposed
    A
    |
    B
    |\
    C D
    | |\
    E F G
    | |/
    | H
    |/
    I

You are looking to create I, and you want to get the diffs for H vs B
(proposed vs trunk) and for H vs G (proposed vs proposed-merged).


H vs B is:

  cd proposed
  bzr diff -r ancestor:../trunk

H vs G is:
  cd proposed
  bzr diff -r ancestor:../proposed-merged


Note that if you change the graph to:

    A
    |
    B
    |\
    C D
    |/|\
    E F G
    | |/
    | H
    |/
    I

Then "bzr diff -r ancestor:../trunk" should select 'D' as the common
base, rather than B (since D is in the ancestry of Trunk). And if you have:

    A
    |
    B
    |\
    C D
    | |\
    E G F
    |/ \|
    X   H
    |  /
    | /
    |/
    I

(proposed-merged was already merged into trunk) then "G" is the common
ancestor and both diffs should be identical.


> So, for example, "trunk" is the mainline development branch and it has
> one branch, called "child". "child" has revisions that haven't been
> merged into "trunk". Then a branch of "child" is created and it's called
> "grand-child", and more revisions are added to "grand-child". Later,
> some new revisions in "child" are merged into "grand-child". In this
> situation, I'd like to get two diffs:
> 
>     * All the changes that happened in "grand-child", excluding the
>       merges from "child".
>     * All the changes that happened in "child" and are present in
>       "grand-child", excluding revisions that haven't been merged into
>       "grand-child".
> 
> Now, I also have to consider what would happen if "trunk" had another
> descendant called "child2" and it's merged into "grand-child". In that
> case, the two diffs should be:
> 
>     * All the changes that happened in "grand-child", excluding the
>       merges from "child" and "child2".
>     * All the changes that happened in "child" and "child2", and have
>       been merged into "grand-child".
> 
> Put simply, I need to separate the changes that happened in a branch
> from the changes they depend on with respect to trunk.
> 
> How can I do this?
> 
> Thanks in advance.

Note that if you need the difference in proposed-merged vs trunk, then
you can certainly do:

  cd proposed-merged
  bzr diff -r ancestor:../trunk

If you don't have "proposed-merged" available, then you could always
switch to dotted-revno information. The other syntax would possibly be:

  cd proposed
  bzr diff -r ancestor:../trunk..ancestor:../proposed-merged

(diff the common ancestor of me with trunk vs the common ancestor of me
vs proposed merged)

Unfortunately, ancestor: doesn't take a revision or a revision spec as
an argument, so you have to actually have proposed-merge as an available
branch. Again, if you can use bzrlib apis, you can get all the common
ancestor information you want, with just the repository revision graph,
and some tip revision-ids.

John
=:->
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (Cygwin)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAkySJqIACgkQJdeBCYSNAANYOwCfViiCWySSkkw80MsulGShd4sn
63cAnRGQjWjQCTKS1lE0z1ppflqZvOFR
=K05L
-----END PGP SIGNATURE-----



More information about the bazaar mailing list