DVCS tools as Subversion clients (was: Best practice for bzr-svn mirror?)

Teemu Likonen tlikonen at iki.fi
Mon Feb 23 15:15:51 GMT 2009


On 2009-02-23 12:03 (UTC), Russel Winder wrote:

> On Sat, 2009-02-21 at 09:59 +0200, Teemu Likonen wrote:

>>     git log -p svn..
>> 
>> where "svn" is the remote-tracking branch that tracks Subversion
>> repository. The above command shows commits (with diffs) which will
>> be rebased on the top of the Subversion branch.
>
> I have never managed to find the right combination of things to put
> after the -p to get anything other than a full log of diffs of the
> commits to the repository.

I try to explain. Here's our example history:

    o--o--A--o--o--B  <-- master, HEAD (that is, the current branch)
           \
             o--o--C  <-- svn

Print commits from A to B (excluding A):

    git log A..B

(or 
    git log A..master
    git log A..HEAD
    git log A..                 # same as A..HEAD
)

That was probably easy. It works like <since>..<until>.

The underlying logic of range A..B is "include revisions reachable from
B but exclude those reachable from A." So "git log A..B" prints the
history as seen from B but excludes the history seen from A. In the
above example history it works like since A until B.

But what does this mean with non-linear development when <since> is not
one of the ancestors of <until>? For example:

    git log C..B                # C = svn ; B = master = HEAD

Let's read the range C..B with the logic mentioned above: "include
revisions reachable from B but exclude those reachable from C."
Effectively this means that all the history from C to A to all ancestors
of A is excluded. Only the commits after A in the master branch are
included. "git log C..B" prints the same commits as "git log A..B".

Now back to "git svn". You have a remote-tracking branch which tracks
the main branch of your upstream Subversion repository. The branch is
probably called "svn" or "trunk". You have also a local branch in which
you do your own work; it's probably called "master". To see the commits
which you have not yet pushed to the central Subversion repository you
can say

    git log svn..master         # Or trunk..master

The history as seen from master is included but the history as seen from
svn is excluded. These are exactly the commits which will be rebased on
top of svn before sending them to the central repository.

You may also find these visual history viewers useful:

    gitk master svn
    git log --graph --decorate master svn



More information about the bazaar mailing list