Delete file history with bazaar

Someone transferred all the binaries to our luggage and I want to get rid of it. `bzr del file 'deletes only the file from the current version, but not the file history.

Is there a way to delete file history so that we don’t all have to download hundreds of MB of data?

+6
repository bazaar
source share
3 answers

There are 2 ways. But you should be prepared for the fact that you will re-create part (or even full) of the history of your branch, so your current (local) branches will become incompatible with the new branch after deleting the file.

1) Manual method. You can create a copy of your branch for revision just before adding large files. Then you need to semi-manually re-commit your further changes and exclude large files. Use the replay command from the bzr-rewrite plugin (formerly bzr-rebase) to play those versions where there are no changes in large files. And use merge -cN for patches that contain changes to large files, manually delete these files and commit them. This way you will keep most of your history intact and keep unique file identifiers for other files in your branch.

2) Use the bzr-fastimport to export history as a stream with quick import using the bzr fast-export command. Then filter large files with the bzr fast-import-filter -x FILE command. Finally, re-create a new branch without large files using the bzr fast-import command. This w3ill method will destroy your entire history and all your files will receive new file identifiers, so your new branch will be completely incompatible with the old branch.

In any case, if you have a shared repository with a large history of files inside, you need to create a new empty shared repository and place your new filtered branch there.

+6
source share

If the binaries were added to the last commit, you can disable it.

 bzr uncommit 

This will leave your working tree in the state it was before writing "bzr commit". Then delete the files and commit again.

Check out the bazaar doc cancel document for more details.

You can use the -r option to cancel multiple commits in a single operation: bzr uncommit -r -4

Another option if you do not care about the change history:
You can export your branch ( bzr export DESTINATION ), and then create a new trunk.
The export command simply exports the main repository without any history.

+3
source share

I was looking for a way to get rid of CVS / dirs that did this in all my commit bzr. I am new to bzr, so at that time I was still not sure how to deal with 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 disks in my project, it was not ideal, but a quick hack :)

You have a project called 'projAAA' in the dir / home / user / dev directory

Export current bzr project (for bzr import)

 cd /home/user/dev bzr fast-export --no-plain projAAA export.gz 

Move this export to an empty directory (for some reason, the filter looks at other disks where it starts)

 cp export.gz ~/tmp/rewrite/ cd ~/tmp/rewrite 

Script_1

This script accepts export and filters everything you supply with -x
Unfortunately, -x doesn't seem to work with wildcards, so you need to give exact values ​​/ paths / files
It works in ~ / tmp / rewrite

 #!/bin/bash rm -r new.import/ out.filtered bzr fast-import-filter -x gradle/wrapper/CVS -x gradle/CVS -x .cvsignore* -x .cvsignore -x ChangeFile -x src/main/groovy/cvs/util/CVS -x src/main/groovy/cvs/CVS -x src/main/groovy/CVS -x src/main/java/cvs/util/CVS -x src/main/java/cvs/CVS -x src/main/java/CVS -x src/main/resources/CVS -x src/main/CVS -x src/test/groovy/cvs/util/CVS -x src/test/groovy/cvs/CVS -x src/test/groovy/CVS -x src/test/resources/CVS -x src/test/CVS -x src/CVS -x CVS export.gz > out.filtered bzr fast-import out.filtered new.import 

Now the dir directory "new.import" will contain everything except what you filtered.
Run the following script to view the entire change history of this new import for things that may still be there that you don't need, for which you have to add another -x value to Script_1 (after which I ran again while Im happy)

Script_2:

Run this in ~ / tmp / rewrite:

 #!/bin/bash THISDIR=$(pwd) pushd new.import/trunk/ #clean file echo `date` > $THISDIR/search.out # I manually enter the revisions that exist here, if you only have 1 to 19, change this accordingly: for i in `seq 1 70`; do echo $i printf "\n============== rev $i =================\n" >> $THISDIR/search.out bzr revert -r$i # Change this find to look for things you want to filter out find . -name CVS -type d >> $THISDIR/search.out 2>&1 done popd 

If you now look at search.out, you will see that you have found the search, and then add them to the previous script until you are happy.

So, essentially, I do it a couple of times until I am happy;

  • Run Script_1 to export, filter, rewrite the branch.
  • Then Script_2, to look for a new branch, to make sure everything went well, if not, add more -x entries
  • Restart the corrected script_1.
  • Repeat
0
source share

All Articles