Purging parts of a branch's history?

John Arbash Meinel john at arbash-meinel.com
Tue Aug 12 15:53:53 BST 2008


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

Staffan Gimåker wrote:
> On Thursday 31 July 2008 17:36:52 John Arbash Meinel wrote:
>> | Is it possible to remove parts of the history from a bzr branch? I
> 
> [snip]
> 
>> Yes, you generally would have to use 'bzr-rebase' to prune bits of history.
>>
>> I don't have an exact recipe for you, but something like:
>>
>> bzr init new_branch
>> cd new_branch
>> bzr pull -r XX ../old_branch (pull whatever you think is *good* to keep)
>> bzr rebase -r YY..ZZ ../old_branch
>>
>> Or something along those lines.
> 
> I still can't figure out how to do what I want. Just to clarify, I only want 
> to remove parts of the history, not the actual content - i.e. I want to loose 
> the first X commit message (they are total nonsense).
> 
> After re-reading the documentation of rebase, AFAIK, it can only "move" the 
> changesets around, not remove history metadata while preserving the content. 
> Correct?
> 
> That made me think that this would work (assuming I want to kill of the first 
> 100 revisions):
> 
> $ bzr init new_branch
> $ cd new_branch
> $ bzr diff -r0..100 ../old_branch | bzr patch
> $ bzr add; bzr ci -m "Initial import." 
> (new_branch is now identical to old_branch at rev. 100)
> $ cd ../old_branch/
> $ bzr rebase -r101.. --onto=1 ../new_branch
> 
> Obviously, I'm not groking it since I get a bunch of conflicts at once:
>   Conflict adding files to src.  Created directory.
>   Conflict because src is not versioned, but has versioned children. Versioned 
> directory.
>   Conflict adding file src.  Moved existing file to src.moved.
>   Contents conflict in src/Connection.cc
> 
> Any ideas?
> 
> 
>> I would question the real need to do the pruning. I won't say you
>> shouldn't, just that the effort to prune is probably not worth as much
>> as putting your effort towards improving the project :)
> 
> I was kind of hoping it would be a quick and painless... guess not.
> 

The problem is the plain "bzr add" which is creating new file-ids for
each entry, rather than re-using the ones from your source branch.

Instead, you should be able to do:

bzr add --file-ids-from ../old_branch

Which I think will solve the issue.

John
=:->

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

iEYEARECAAYFAkihpAEACgkQJdeBCYSNAAMZSgCfeAOhX+FZ/xag2Vi8gfJtUKge
bLIAoMpcYxbEd1tCt1WC4uCwr4mika0Y
=soZy
-----END PGP SIGNATURE-----



More information about the bazaar mailing list