How Do You Move Files Between Branches
Neil Martinsen-Burrell
nmb at wartburg.edu
Thu May 29 16:45:40 BST 2008
Kenneth Loafman <kenneth <at> loafman.com> writes:
> I have the following situation (all separate branches):
>
> +---demo1
> +---demo2
> +---tech
>
> Demo1 and Demo2 are two demonstrations for shared 'tech'. Late one
> night I created and checked in a file to demo1 that contained routines
> that should be in tech. It has since been modified a couple of times.
>
> Is there a clean way in bzr to move that file from demo1 to tech so that
> the history is maintained?
There is not a simple way to move files between branches with history. In fact,
there isn't a way to copy files within a branch with history (although the
latter capability is on the drawing board). It is possible that someone may be
able to suggest a solution based around rebase (which seems to make all
operations possible) but I don't know how to do it. You could of course fake it
with a sequence (how many revisions of the file are we talking about?) of ``bzr
cat`` calls such as:
export ADDED=5 # added in revision 5 to tech
bzr cat -r $ADDED demo1/file > tech/file
bzr ci -m 'first log message' tech/file
bzr cat -r $(($ADDED+1)) demo1/file > tech/file
bzr ci -m 'will error harmlessly if file didnt change in that revision' tech/file
[etc.]
The appropriate bash for-loop is left as an exercise for the reader :)
-Neil
More information about the bazaar
mailing list