如何安全地从Merurial存储库中禁用/删除largefiles目录? [英] How do I safely disable/remove the largefiles directory from a mercurial repository?

查看:167
本文介绍了如何安全地从Merurial存储库中禁用/删除largefiles目录?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

过去,我一直在与Mercurial的largefiles扩展一起使用,以将数据和我一直在处理的代码一起保存.我认为这是一个错误,我想删除"largefiles"目录(8GB).我们的网络用户目录限制为10 GB,我需要空间.我已经很长时间没有使用任何大文件了.他们永远消失了,我不会想念他们的.

In the past, I have been working with the largefiles extension in mercurial to save data together with the code I have been working on. I think this was a mistake and I would like to remove the "largefiles" directory (8GB). Our network user directories are limited to 10 GB, and I need space. I have not used any large files for a long time now. I will not miss them when they are gone forever.

所以我的问题是

  1. 能否在不损坏存储库的情况下删除.hg下的largefiles目录?
  2. 如果这样做,即使缺少一些大数据文件,我也能够签出旧代码吗?
  3. 我应该从该存储库的所有所有克隆中删除那些文件,以避免再次使用来自另一个克隆的大文件再次污染所有存储库吗?
  1. Can I remove the largefiles directory under .hg without damaging the repo?
  2. If I do, will I be able to check out old code, even if some large datafiles are missing?
  3. Should I remove those files from all clones of that repo to avoid polluting all repos again with largefiles from another clone?

推荐答案

对于第一个问题,我做了一个实验:

For your first question I did an experiment:

  1. 用大文件创建了一个仓库.
  2. hg update null
  3. 已删除.hg\largefiles
  4. hg update
  1. Created a repo with a large file.
  2. hg update null
  3. Deleted .hg\largefiles
  4. hg update

大文件又回来了!事实证明,至少在Windows上,大文件也缓存在%UserProfile%\AppData\Local\largefiles中.由于这是我唯一的大文件数据库,因此它仅包含我的一个大文件,因此我也删除了该文件.此缓存包含来自多个启用了本地大文件的本地数据库的大文件,因此您必须小心使用此数据库.如果拥有两个副本似乎很浪费,那么可以发现本地数据库是否与%UserProfile%位于同一驱动器上,然后将它们进行硬链接.我的系统中有两个驱动器,事实证明,如果数据库位于其他驱动器上,它仍将被复制到AppData位置,但未进行硬链接并且使磁盘使用量翻了一番.

The large files came back! It turns out, at least on Windows, the large files are also cached in %UserProfile%\AppData\Local\largefiles. Since this was my only largefile database, It only contained my one large file, so I deleted that, too. This cache contains large files from multiple local largefile-enabled databases, so you'd have to be careful with this one. If it seems wasteful to have two copies, it turns out if the local databases are on the same drive as the %UserProfile%, then they are hardlinked. I have two drives in my system, and it turns out if a database is on a different drive it is still copied to the AppData location, but is not hardlinked and doubles your disk usage.

一旦删除了大文件的所有副本,则hg update给出:

Once all copies of the large file were deleted, an hg update gave:

1 files updated, 0 files merged, 0 files removed, 0 files unresolved
getting changed largefiles
largefile.dat: can't get file locally
(no default or default-push path set in hgrc)
0 largefiles updated, 0 removed

然后我从.hg\hgrc中删除了[extensions], largefiles=以禁用扩展名.此时,存储库运行良好,但仍具有.hglf目录,该目录在过去具有大文件的变更集中具有哈希值.因此,第二个问题的答案是肯定的,您可以签出旧代码.

I then removed [extensions], largefiles= from .hg\hgrc to disable the extension. At this point the repository worked fine, but still had the .hglf directory with hashes in changesets that used to have large files. so the answer to your second question is yes, you can check out old code.

对于第三个问题,要消除所有大文件和哈希的痕迹,请使用以下命令创建文件:

For your third question, to eliminate all traces of largefiles and hashes, create a file with:

exclude .hglf

并运行:

hg convert --filemap <file> <srcrepo> <destrepo>

您的用户将不得不克隆这个经过修改的新存储库,因为convert会修改更改集,而新数据库将与旧数据库无关.

Your users will then have to clone this new, modified repository because convert modifies the changesets and the new database will be unrelated to the old one.

这篇关于如何安全地从Merurial存储库中禁用/删除largefiles目录?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆