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.
So my questions are
- Can I remove the largefiles directory under .hg without damaging the repo?
- If I do, will I be able to check out old code, even if some large datafiles are missing?
- Should I remove those files from all clones of that repo to avoid polluting all repos again with largefiles from another clone?
The same command to convert a plain repository to largefiles,
lfconvert
, can also be used in the other direction:So the following command will do the trick:
You will need to coordinate with your team, so that:
largefiles
extension from their$HOME/.hgrc
largefiles
extension from thehgrc
of the user offering access to the master repos (the location of thehgrc
depends on how the master repos are server, SSH or HTTP). This will make it impossible for somebody to accidentally add a largefile to a clone of the new repo and push it!Note that
lfconvert
is only available if thelargefiles
extension is enabled. What I suggest is, following point 3, to remove it from$HOME/.hgrc
and enable it on a a single command with the--config extensions.largefiles=
option, as shown in the example above.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 likehg status
. For example for a huge repository I have,hg status
went from 10 secs to 0.5 secs :-)For your first question I did an experiment:
hg update null
.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
. 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 theAppData
location, but is not hardlinked and doubles your disk usage.Once all copies of the large file were deleted, an
hg update
gave: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:
and run:
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.