Skip to content

Instantly share code, notes, and snippets.

@kyhau
Created March 1, 2016 10:43
Show Gist options
  • Save kyhau/940a5c7e456bade3bb89 to your computer and use it in GitHub Desktop.
Save kyhau/940a5c7e456bade3bb89 to your computer and use it in GitHub Desktop.
Mercurial with Largefile extension

Mercurial with Largefile extension

E.g. Repo root: /var/lib/mercurial-server/repos

Enable Mercurial Largefile extension

  1. Go to your home directory (C:\Users<username> on Windows)
  2. Edit the mercurial config file (mercurial.ini on windows, .hgrc on linux)
  3. If no [extensions] section exists in the config file, add it
  4. In the [extensions] section, add the line largefiles = .
  5. Save your changes & quit your editor

For example

[extensions]
progress =
convert =
largefiles =

Enable Mercurial Largefile extension on SourceTree

  1. Open Sourcetree
  2. Open the general sourcetree settings
  3. Open the mercurial tab. You should see a list of extensions with checkboxes. Check the "largefiles" box, and save your changes

Creating new repo

cd new_repo
hg init
hg add --large .
hg commit -m "Init commit"
hg clone . ssh://hg@servername.example.com/new_repo

Cloning a repo

hg clone ssh://hg@servername.example/existing_repo

Adding files

To add files to the repo you need to use the --large argument, or they'll just go into the repo as a normal files (which is what you don't want). You can get the initial setup going by moving the files you want to track into place and add them all like so:

C:\repos\new_repo> hg add --large .

Remember that the repo will store revisions of your files, so it's best not to use directories to segregate data versions. Lay out the data as you want to use it, and use commits and tagging to manage revisions. Once you have a batch of files set up you can commit them just like in any other repo:

C:\repos\new_repo> hg commit -m "some commit message goes here"

Once you have added the files, you can modify them like as you will and they will automatically be included in the next commit, just like you would with source files. And to upload them to the server you just push like normal:

C:\repos\new_repo> hg push

Retrieving files

To retrieve files, you can either clone the repository as described above, or just pull the changes like in a normal repository:

C:\repos\new_repo> hg pull

Hg largefiles is set up so that it will only pull down the large files that you actually need for the revision you're using, so that if you have half a dozen revisions of the file it will only get the copy of the file referenced by the commit rather than all the revisions, which is nice.

Further Reading:

http://mercurial.selenic.com/wiki/LargefilesExtension

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment