progging - To wander about and beg; to seek food or other supplies by low arts; to seek for advantage by mean shift or tricks.
progging - Programmer slang for writing computer code.

torsdag 11. august 2011

Bazaar: copy file from one branch to another unrelated branch

Bazaar was set up so that each program was it's own branch


So moving a file (Statistics.pas) from the display program to the common source was not possible since you can't bzr move from one branch to another. So the solution was to use the export/import merge solution.

..DisplayProgram>bzr fast-export . > full-branch.fi
..DisplayProgram>bzr fast-import-filter -i Statistics.pas full-branch.fi > Statistics.fi
..DisplayProgram>mkdir ..\Temp
..DisplayProgram>bzr init ..\Temp
..DisplayProgram>bzr fast-import Statistics.fi ..\Temp
..DisplayProgram>cd ..\CommonSource
..CommonSource>bzr merge ..\Temp -r0..-1
..CommonSource>bzr commit -m "Moved file from SourceDisplay using export/import then merge"

As a final step, after you are done moving the file, you probably want to remove the file from it's original branch.
..DisplayProgram>bzr rm Statistics.pas
..DisplayProgram>bzr commit -m "Final step of moving file to common place"

When I tried to do this a second time on another file (same directories involved), I got a problem. The old file, Statistics.pas, appeared in the temporary directory. I created a brand spanking new directory, even with a different name, but the old file seem to appear magically....
Then I read the bzr fast-import help...
Restarting an import:
 At checkpoints and on completion, the commit-id -> revision-id
 map is saved to a file called 'fastimport-id-map' in the control
 directory for the repository (e.g. .bzr/repository). If the import
 is interrupted or unexpectedly crashes, it can be started again
 and this file will be used to skip over already loaded revisions.
 As long as subsequent exports from the original source begin
 with exactly the same revisions, you can use this feature to
 maintain a mirror of a repository managed by a foreign tool.
 If and when Bazaar is used to manage the repository, this file
 can be safely deleted.
So, remove the fastimport-id-map file in the .bzr/repository directory when you are done with the import! Then you are ready to do another one :)

Ingen kommentarer:

Legg inn en kommentar