使用bazaar删除文件历史记录

发布于 2024-08-21 21:50:15 字数 122 浏览 11 评论 0原文

有人将所有二进制文件提交到我们的集市主干中,我想摆脱它。 `bzr del file' 仅删除当前修订版中的文件,但不删除文件的历史记录。

有没有一种方法可以删除文件历史记录,这样我们就不必下载数百 MB 的数据?

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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

挽袖吟 2024-08-28 21:50:15

有两种方法。但是您需要准备好重新创建部分(甚至完整)分支历史记录,因此删除文件后当前(本地)分支将与新分支不兼容。

1)手动方式。您可以在添加大文件之前创建分支的副本以进行修订。然后,您需要半手动地重新提交进一步的修订并排除大文件。使用 bzr-rewrite 插件(以前的 bzr-rebase)中的 replay 命令来重播那些没有对大文件进行更改的修订。并使用 merge -cN 进行大文件更改的修订,手动删除这些文件并提交。因此,您将保持大部分历史记录完好无损,并为分支的其他文件保留唯一的文件 ID。

2) 使用 bzr-fastimport 插件通过 bzr fast-export 命令将历史记录导出为快速导入流。然后使用 bzr fast-import-filter -x FILE 命令过滤掉大文件。最后使用 bzr fast-import 命令重新创建没有大文件的新分支。此方法将破坏您的所有历史记录,并且您的所有文件将获得新的文件 ID,因此您的新分支将与旧分支完全不兼容。

无论如何,如果您的共享存储库内部包含大文件历史记录,则需要创建新的空共享存储库并将新的过滤分支放在那里。

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 use merge -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 with bzr fast-export command. Then filter out big files with bzr fast-import-filter -x FILE command. And in the end re-create new branch without big files with bzr 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.

〆一缕阳光ご 2024-08-28 21:50:15

如果二进制文件是在上次提交中添加的,您可以取消提交。

bzr uncommit

这将使您的工作树处于您编写“bzr commit”之前的状态。然后删除文件并重新提交。

有关更多详细信息,请查看关于撤消错误的集市文档。

您可以使用 -r 选项在一次操作中撤消多次提交:bzr uncommit -r -4

如果您不关心修订历史记录,则可以使用其他选项:
您可以导出分支 (bzr export DESTINATION),然后创建新的主干。
导出命令将仅导出头存储库,没有任何历史记录。

If the binary files were added in the last commit, you can uncommit it.

bzr uncommit

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.

宫墨修音 2024-08-28 21:50:15

我正在寻找一种方法来摆脱 CVS/ 目录,这些目录使其成为我所有 bzr 提交的方式。我是 bzr 的新手,所以当时我还不确定如何处理它们。 (在工作中,中央存储库是 CVS,但我在本地使用 bzr 来帮助我)。
这是我为摆脱项目中的一些 CVS 目录所做的示例,它并不意味着完美,而是一个快速破解:)

你在 dir /home/user/dev 中有一个名为“projAAA”的项目

导出当前 bzr 项目(用于 bzr 导入)

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

将该导出移至空目录(由于某种原因,过滤器会查看其运行的其他目录)

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

Script_1

该脚本采用导出并过滤您使用 -x 提供的所有内容
不幸的是 -x 似乎不适用于通配符,因此您必须给出准确的值/路径/文件
它在 ~/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

现在目录“new.import”将包含除您过滤掉的内容之外的所有内容。
运行以下脚本来查看该新导入的整个修订历史记录,以查找可能仍然存在但您不想要的内容,您应该在 Script_1 中添加另一个 -x 值(然后我将重新运行该值,直到我满意为止)

Script_2 :

在 ~/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

如果您现在查看 search.out 内部,您可以看到搜索找到的内容,然后将它们添加到之前的脚本中,直到您满意为止。

所以,本质上,我会重复这样做几次,直到我满意为止;

  • 运行 Script_1 导出、过滤、重写分支。
  • 然后 Script_2 搜索新分支以确保它全部消失,如果没有,添加更多 -x
    条目
  • 重新运行修改后的 Script_1。
  • 重复

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)

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

Move that export to an empty dir (the filter for some reason looks at other dirs where it's run)

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

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

#!/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 "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:

#!/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 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;

  • Run Script_1 to export, filter, rewrite a branch.
  • Then Script_2 to search the new branch to be sure it's all gone, if not, add more -x
    entries
  • Re-run ammended Script_1.
  • Repeat
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文