Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to find out the size of a mercurial repository?

So, for example, if there's a mercurial repository https://code.google.com/p/potentiallyLarge is there a command which would allow me to find out its size before cloning it? Something like

hg size https://code.google.com/p/potentiallyLarge

Also, is there a command for doing this for subversion repositories?

like image 736
shafty Avatar asked Aug 31 '12 16:08

shafty


People also ask

What is a Mercurial repository?

Strictly speaking, the term repository refers to the directory named . hg (dot hg) in the repository root directory. The repository root directory is the parent directory of the . hg directory. Mercurial stores its internal data structures – the metadata – inside that .

How does Mercurial work?

Mercurial groups related changes to multiple files into single atomic changesets, which are revisions of the whole project. These each get a sequential revision number. Because Mercurial allows distributed parallel development, these revision numbers may disagree between users.

How do I create a remote repository in Mercurial?

Clone a remote Mercurial repositoryFrom the main menu, select Hg | Get from Version Control. The Get from Version Control dialog opens. In the dialog that opens, select Mercurial from the Version control list and specify the URL of the remote repository you want to clone. Click Clone.


2 Answers

The size used on disk is different from the bandwidth used to make a clone. Some hosting sites (such as Bitbucket) display the size on disk so that you know upfront how much space you'll need on your system before cloning. But I can see that Google Code doesn't, so it wont help you here.

The Mercurial wire protocol doesn't expose any commands that can tell you how big a repository is. When you make a normal clone, the client doesn't know upfront how much data it will receive, it just receives a stream of data. After receiving the changelog, the client knows how many manifests and filelogs to expect, but it doesn't know the size of them.

In fact, it's difficult for the server to compute how much data a clone will use: the network bandwidth used is less than the disk space since the compression used is different (bzip2 vs gzip). However, if you use --uncompressed with your clone (which Google Code doesn't support) then there is a trick, see below.

The only way to know much bandwidth a clone uses is to make one. If you have a clone already you can use hg bundle to simulate a clone:

$ hg bundle --all my-bundle.hg

The size of the bundle will tell you how much data there is in the repository.

A trick: If Google Code had supported hg clone --uncompressed, then you could use that to learn the size of a remote repository! When you use --uncompressed, the client asks the server to send the content of the .hg/ directory as-is — without re-compressing it with bzip2. Conveniently, the server starts the stream by telling the client the size of the repository. So you can start such a clone and then abort it (with Control-C) when your client has printed the line telling you the size of the repo.

like image 162
Martin Geisler Avatar answered Sep 25 '22 11:09

Martin Geisler


Update: My answer below is wrong, but I'm leaving it here since MG provided some good info in response. It looks like the right answer is "no".

Not a great way, but a work-around sort of way. A hg clone URL is really just hg init ; hg pull URL And the command hg incoming tells you what you'd get if you did a pull, so you could do:

hg init theproject
cd theproject
hg incoming --stat URL_TO_THE_PROJECT

and get a pretty decent guess of how much data you'll be pulling down if you follow up with:

hg pull URL_TO_THE_PROJECT

I'm not sure about the network efficiency of hg incoming but I don't think it downloads everything from all the changesets, though I could be wrong about that. It offers a --bundle option that saves whatever incoming pulls down to a file from which you can later pull to avoid double downloading.

like image 29
Ry4an Brase Avatar answered Sep 24 '22 11:09

Ry4an Brase