Bazaar still below the radar when evaluating VCS tools

Stephen J. Turnbull stephen at xemacs.org
Sat Feb 27 08:08:00 GMT 2010


Eli Zaretskii writes:

 > > > How do you ``edit out commits'' with Bazaar?  What are the commands to
 > > > issue in that case?
 > > 
 > > I think people typically just uncommit, and go back only to the last
 > > commit they were happy with
 > 
 > But "bzr uncommit" can only remove all the revisions between N and M,
 > it cannot selectively remove some of them, a-la a kind of reverse
 > cherrypicking, can it?

Reverse cherry-picking is not what I'm talking about.  I want two
commits coalesced, ie, the record of the earlier commit removed, but
not the content.

I was just talking theory.  In practice ... in bzr, I think the
following does the trick.  Suppose you have commits 1-4 in a branch
and want to edit out 2.

# create a test branch
pushd /tmp
mkdir ugly; cd ugly; bzr init
for i in foo bar bzr quux hoge; do
  echo $i > $i;  bzr add $i;  bzr commit -m "Add $i."
done

# prepare for recovery
cd ..
bzr branch -r 2 ugly pretty
cd pretty

# do it!
bzr uncommit                    # leaves changes
bzr merge --force -c3 ../ugly
bzr commit -m "Coalesce commits 2 and 3."
for i in 4 5; do
  bzr merge -c$i ../ugly
  # Obviously we want to recover the old messages."
  bzr commit -m "Re-commit $i."
done

# clean up
rm -rf ../ugly

I couldn't figure out how to get bzr rebase to give this effect (I may
not have the latest version though, the MacPorts port is called
"bzr-rebase" not "bzr-rewrite"), and I didn't feel like messing with
fastimport.  Of course bzr pull doesn't work.

I also found that in place of the for loop, "bzr merge -r3..5 ../ugly"
does the Wrong Thing, I guess because connectedness of history is
broken by the cherrypick of revision 3.  The merged history is
flattened into one final commit, rather than appearing in parallel.
Ie, what I have after doing "bzr merge -r3..5 ../ugly" in place of the
for loop is

    1 --- 2+3 --- 4+5

where I wanted

    1 --- 2+3* --- 4* --- 5*

(the stars represent cherrypicks) and I expected something like

    1 --- 2+3 --- merge
                   /
   ... 4 --- 5 ---'

(In hindsight, it's obvious that representing that ... is a bitch -- I
originally expected the ... to be represented by ghost revisions, but
that doesn't work.)



More information about the bazaar mailing list