Someone committed all binaries to our bazaar trunk, and I want to get rid of it. `bzr del file' only deletes the file from the current revision, but not the history of the file.
Is there a way we can remove the file history so that we don't all have to download hundreds of MBs of data?
There is 2 ways. But you need to be ready that you will re-create the part (or even full) of your branch history, so your current (local) branches will become incompatible with new branch after deleting the file.
1) Manual way. You can create a copy of your branch to revision just before big files have added. Then you need semi-manually re-commit your further revisions and exclude big files. Use
replay
command from bzr-rewrite plugin (former bzr-rebase) to replay those revisions where no changes to big files present. And usemerge -cN
for revisions where changes to big files are present, manually delete these files and commit. Thus you will keep most of your history intact and will keep unique file ids for other files of your branch.2) Use
bzr-fastimport
plugin to export your history as fast-import stream withbzr fast-export
command. Then filter out big files withbzr fast-import-filter -x FILE
command. And in the end re-create new branch without big files withbzr fast-import
command. This method w3ill destroy all your history and all your files will get new file ids, so your new branch will be totally incompatible with old branch.In any case, if you have shared repository with big files history inside you need to create new empty shared repository and put your new filtered branch there.
I was looking for a way to get rid of CVS/ dirs that made it's way into all my bzr commits. I'm new to bzr, so at the time, I wasn't yet sure how I was going to handle them. (At work the central repo is CVS, but I use bzr locally to help me). Here is an example of what I did to get rid of some CVS dirs in my project, it's not meant to be perfect, but a quick hack :)
You have a project called 'projAAA' in dir /home/user/dev
Export the current bzr project (for bzr import)
Move that export to an empty dir (the filter for some reason looks at other dirs where it's run)
Script_1
This script takes the export and filters everything you supply with -x
Unfortunately -x doesnt seem to work with wildcards, so you have to give exact values/paths/files
It runs in ~/tmp/rewrite
Now the dir "new.import" will contain everything but what you've filtered out.
Run the following script to look through the entire revision history of that new import for stuff that might still be there, that you dont want, for which you should add another -x value in Script_1 (which I will then rerun until Im happy)
Script_2:
Run this in ~/tmp/rewrite:
If you now look inside search.out, you could see what the search has found, and then add those to the previous script until you're happy.
So, in essence, I re-do this a couple of times until I'm happy;
If the binary files were added in the last commit, you can uncommit it.
This will leave your working tree in the state it was just before you wrote "bzr commit". Then delete the files and re-commit.
Check the bazaar doc on undoing mistakes for more detail.
You can use the -r option to undo several commits in one operation:
bzr uncommit -r -4
Other option, if you do not care of the revision history:
You can do an export of your branch (
bzr export DESTINATION
) and then create a new trunk.The export command will simply export the head repository, without any history.