3

How to find the size of a mercurial deposit?

 3 years ago
source link: https://www.codesd.com/item/how-to-find-the-size-of-a-mercurial-deposit.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

How to find the size of a mercurial deposit?

advertisements

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?


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.


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK