Sanitizing a branch
Andrew Bennetts
andrew.bennetts at canonical.com
Mon Mar 16 22:48:47 GMT 2009
Erik de Castro Lopo wrote:
[...]
> I'd now like to make a public branch of this repo with the public
> branch having none of the cruft but keeping the cruft in my
> private branch and still have the ability to merge between the
> two relatively painlessly.
>
> Is this possible? Any clues on how to do it?
This answer probably isn't suitable for you, but here it is just in case I'm
wrong :)
Another option to the ones already given is to keep the original history in
the public branch, but construct a new mainline history for it without the
cruft. The cruft would still be in the history, but not on the mainline.
Depending on why you want to remove the cruft this may be enough. If you
really don't want to publish the cruft in any form, even buried in
non-mainline history, then this is not for you. But if you just want to
present a clean default view of the history, this would be fine.
You can construct a new history with commands like (assuming A,B,C,D,E is
your existing history, like in John's ASCII art):
bzr init clean
cd clean
bzr merge ../original -r 0..C
bzr ci -m "Initial working code."
bzr merge ../original -r ..E
bzr ci -m "Added useful thing X"
[etc]
(Obviously "C" and "E" aren't real revision specifiers; use real revnos or
whatever)
This will give you a graph like (to borrow John-style ASCII art):
A
|
B
|
C
/|
/ D
M |
| E
| /|
|/ :
N
|
:
Where M and N are your new mainline history, i.e. revno 1 and 2
respectively. Because your original branch (A..E) is a part of this
history, merging any new revisions made on/from the original branch will
work just fine.
So this gives you the easy merging you're after, and a newly synthesised
mainline, but doesn't actually remove any cruft from the broader history.
-Andrew.
More information about the bazaar
mailing list