[英]How do I safely disable/remove the largefiles directory from a mercurial repository?
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. 在过去,我一直在使用mercurial中的largefiles扩展来将数据与我一直在处理的代码一起保存。 I think this was a mistake and I would like to remove the "largefiles" directory (8GB). 我认为这是一个错误,我想删除“largefiles”目录(8GB)。 Our network user directories are limited to 10 GB, and I need space. 我们的网络用户目录限制为10 GB,我需要空间。 I have not used any large files for a long time now. 我很久没有使用任何大文件了。 I will not miss them when they are gone forever. 当他们永远消失时,我不会想念他们。
So my questions are 所以我的问题是
For your first question I did an experiment: 对于你的第一个问题,我做了一个实验:
hg update null
.hg\\largefiles
已删除.hg\\largefiles
hg update
The large files came back! 大文件回来了! It turns out, at least on Windows, the large files are also cached in %UserProfile%\\AppData\\Local\\largefiles
. 事实证明,至少在Windows上,大文件也缓存在%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. 如果有两个副本似乎很浪费,事实证明,如果本地数据库与%UserProfile%
位于同一驱动器上,则它们是硬链接的。 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. 我的系统中有两个驱动器,事实证明,如果数据库位于不同的驱动器上,它仍然会复制到AppData
位置,但不会硬连接,并且会使磁盘使用量翻倍。
Once all copies of the large file were deleted, an hg update
gave: 删除大文件的所有副本后, hg update
给出:
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
I then removed [extensions], largefiles=
from .hg\\hgrc
to disable the extension. 然后我删除了[extensions], largefiles=
from .hg\\hgrc
来禁用扩展名。 At this point the repository worked fine, but still had the .hglf
directory with hashes in changesets that used to have large files. 此时,存储库工作正常,但仍然具有.hglf
目录,其中包含更改.hglf
哈希值,这些哈希值曾经包含大文件。 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
and run: 并运行:
hg convert --filemap <file> <srcrepo> <destrepo>
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. 然后,您的用户必须克隆这个新的,已修改的存储库,因为convert会修改更改集,并且新数据库将与旧数据库无关。
The same command to convert a plain repository to largefiles, lfconvert
, can also be used in the other direction: 将普通存储库转换为大文件lfconvert
命令也可以用于另一个方向:
$ hg --config extensions.largefiles= help lfconvert
hg lfconvert SOURCE DEST [FILE ...]
convert a normal repository to a largefiles repository
Convert repository SOURCE to a new repository DEST, identical to SOURCE
except that certain files will be converted as largefiles [...]
Use --to-normal to convert largefiles back to normal files; after this,
the DEST repository can be used without largefiles at all.
So the following command will do the trick: 所以以下命令将起到作用:
$ hg --config extensions.largefiles= lfconvert --to-normal <LARGEFILE_REPO> <PLAIN_REPO>
You will need to coordinate with your team, so that: 您需要与您的团队协调,以便:
largefiles
extension from their $HOME/.hgrc
每个人都从$HOME/.hgrc
删除了largefiles
扩展名 largefiles
extension from the hgrc
of the user offering access to the master repos (the location of the hgrc
depends on how the master repos are server, SSH or HTTP). 除去largefiles
从延伸hgrc
的用户提供访问主回购(的位置hgrc
依赖于主回购如何服务器,SSH或HTTP)。 This will make it impossible for somebody to accidentally add a largefile to a clone of the new repo and push it! 这将使某人不可能意外地将一个大文件添加到新repo的克隆并推送它! Note that lfconvert
is only available if the largefiles
extension is enabled. 请注意,仅当启用了largefiles
扩展时, lfconvert
才可用。 What I suggest is, following point 3, to remove it from $HOME/.hgrc
and enable it on aa single command with the --config extensions.largefiles=
option, as shown in the example above. 我建议在第3点之后将其从$HOME/.hgrc
删除,并使用--config extensions.largefiles=
选项在单个命令上启用它,如上例所示。
Note also that converting to a plain repo will enable the usage of the recent fsmonitor
extension , that uses the kernel inotify mechanism (or equivalent on MacOSX) to dramatically speed up certain operations like hg status
. 另请注意,转换为普通存储库将允许使用最近的fsmonitor
扩展 ,该扩展使用内核inotify机制(或MacOSX上的等效机制)来显着加速某些操作,如hg status
。 For example for a huge repository I have, hg status
went from 10 secs to 0.5 secs :-) 例如,对于我拥有的巨大存储库, hg status
从10秒到0.5秒:-)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.