14

I have to work with an hg repository that has millions of lines of code and hundreds of thousands of changesets. As you can imagine, this really slows down mercurial and TortoiseHg.

Is it possible for me to create a local repository that only has the latest few thousand changesets?

Not only would this hopefully make things run snappier, but it might also save me some hard drive space.

sorin
  • 161,544
  • 178
  • 535
  • 806
PortMan
  • 4,205
  • 9
  • 35
  • 61

3 Answers3

8

No you can't, but you can optimise your local clone. Have a look at my answer to https://stackoverflow.com/a/19294645/479199.

There has been some work on shallow clones, but it's still very much a work in progress (and there doesn't seem to have been much progress):

https://www.mercurial-scm.org/wiki/ShallowClone

Community
  • 1
  • 1
Tim Delaney
  • 5,535
  • 3
  • 24
  • 18
6

It seems that Facebook released an extension that is supposed to solve this problem.

See https://bitbucket.org/facebook/remotefilelog

sorin
  • 161,544
  • 178
  • 535
  • 806
  • This has now been merged into Facebook's [hg-ext](https://bitbucket.org/facebook/hg-experimental/) repository. As of 2017-02-12 `remotefilelog` is not listed in the main README yet, but there is good documentation in the README within the `remotefilelog` directory in the source code. – Yitz Feb 12 '17 at 10:28
  • Broken link. Should probably be: https://github.com/pycontribs/remotefilelog – Elazar Mar 09 '22 at 23:31
5

No you can't. That's called a "Shallow Clone" and it's not implemented/supported. Millions of lines of code and thousands of changesets isn't particularly large, and once you've cloned it down once almost every action should be near instantaneous.

Further, the compressed binary deltas in the .hg directory are usually smaller than the entirety of the uncompressed code in the working directory, so the space savings shouldn't be substantial either.

Once you've cloned the repo once, make sure to do any further clones on the same machine from your local clone, and you'll never have to wait for the whole repo to clone again.

Ry4an Brase
  • 78,112
  • 7
  • 148
  • 169
  • 2
    The firefox repo disagrees with "millions of lines of code and thousands of changesets isn't particularly large". It disagrees to the tune of about 40GB. – Mike 'Pomax' Kamermans Sep 13 '19 at 15:49