[PATCH 1 of 2] bundle: when verbose, show what takes up the space in the generated bundle
Mads Kiilerich
mads at kiilerich.com
Wed Jan 7 03:59:00 UTC 2015
# HG changeset patch
# User Mads Kiilerich <madski at unity3d.com>
# Date 1408124612 -7200
# Fri Aug 15 19:43:32 2014 +0200
# Node ID 4f0c879d0aade3702856305fac3ecfd90fcdfd6c
# Parent b9d06fa10ef29c012d48bd4f3c93fd7bf1347d40
bundle: when verbose, show what takes up the space in the generated bundle
This is kind of similar to the debugbundle command but gives summarized actual
uncompressed number of bytes when creating the bundle. The numbers are as
usable as the bundle format is efficient. Hopefully bundle2 will make it a
better indicator of actual entropy.
This is useful when accepting pull requests to assess whether the repo size
increase seems reasonable for the diff before pushing stuff upstream, It has
helped me catching large files that should have been committed as largefiles
but was committed as regular files in intermediate changesets.
This output doesn't combine well with debug output so we only enable it when
verbose without debug.
diff --git a/mercurial/changegroup.py b/mercurial/changegroup.py
--- a/mercurial/changegroup.py
+++ b/mercurial/changegroup.py
@@ -258,6 +258,11 @@ class cg1packer(object):
self._repo = repo
self._reorder = reorder
self._progress = repo.ui.progress
+ if self._repo.ui.verbose and not self._repo.ui.debugflag:
+ self._verbosenote = self._repo.ui.note
+ else:
+ self._verbosenote = lambda s: None
+
def close(self):
return closechunk()
@@ -341,9 +346,13 @@ class cg1packer(object):
mfs.setdefault(c[0], x)
return x
+ self._verbosenote(_('uncompressed size of bundle content:\n'))
+ size = 0
for chunk in self.group(clnodes, cl, lookupcl, units=_('changesets'),
reorder=reorder):
+ size += len(chunk)
yield chunk
+ self._verbosenote(_('%8.i (changelog)\n') % size)
progress(msgbundling, None)
# Callback for the manifest, used to collect linkrevs for filelog
@@ -364,9 +373,12 @@ class cg1packer(object):
return clnode
mfnodes = self.prune(mf, mfs, commonrevs, source)
+ size = 0
for chunk in self.group(mfnodes, mf, lookupmf, units=_('manifests'),
reorder=reorder):
+ size += len(chunk)
yield chunk
+ self._verbosenote(_('%8.i (manifests)\n') % size)
progress(msgbundling, None)
mfs.clear()
@@ -417,10 +429,14 @@ class cg1packer(object):
if filenodes:
progress(msgbundling, i + 1, item=fname, unit=msgfiles,
total=total)
- yield self.fileheader(fname)
+ h = self.fileheader(fname)
+ size = len(h)
+ yield h
for chunk in self.group(filenodes, filerevlog, lookupfilelog,
reorder=reorder):
+ size += len(chunk)
yield chunk
+ self._verbosenote(_('%8.i %s\n') % (size, fname))
def deltaparent(self, revlog, rev, p1, p2, prev):
return prev
diff --git a/tests/test-commit-amend.t b/tests/test-commit-amend.t
--- a/tests/test-commit-amend.t
+++ b/tests/test-commit-amend.t
@@ -109,8 +109,16 @@ No changes, just a different message:
a
stripping amended changeset 74609c7f506e
1 changesets found
+ uncompressed size of bundle content:
+ 250 (changelog)
+ 143 (manifests)
+ 109 a
saved backup bundle to $TESTTMP/.hg/strip-backup/74609c7f506e-amend-backup.hg (glob)
1 changesets found
+ uncompressed size of bundle content:
+ 246 (changelog)
+ 143 (manifests)
+ 109 a
adding branch
adding changesets
adding manifests
@@ -236,8 +244,16 @@ then, test editing custom commit message
a
stripping amended changeset 5f357c7560ab
1 changesets found
+ uncompressed size of bundle content:
+ 238 (changelog)
+ 143 (manifests)
+ 111 a
saved backup bundle to $TESTTMP/.hg/strip-backup/5f357c7560ab-amend-backup.hg (glob)
1 changesets found
+ uncompressed size of bundle content:
+ 246 (changelog)
+ 143 (manifests)
+ 111 a
adding branch
adding changesets
adding manifests
@@ -265,8 +281,16 @@ Same, but with changes in working dir (d
stripping intermediate changeset a0ea9b1a4c8c
stripping amended changeset 7ab3bf440b54
2 changesets found
+ uncompressed size of bundle content:
+ 450 (changelog)
+ 282 (manifests)
+ 209 a
saved backup bundle to $TESTTMP/.hg/strip-backup/7ab3bf440b54-amend-backup.hg (glob)
1 changesets found
+ uncompressed size of bundle content:
+ 246 (changelog)
+ 143 (manifests)
+ 113 a
adding branch
adding changesets
adding manifests
diff --git a/tests/test-debugbundle.t b/tests/test-debugbundle.t
--- a/tests/test-debugbundle.t
+++ b/tests/test-debugbundle.t
@@ -6,8 +6,13 @@ Create a test repository:
$ touch a ; hg add a ; hg ci -ma
$ touch b ; hg add b ; hg ci -mb
$ touch c ; hg add c ; hg ci -mc
- $ hg bundle --base 0 --rev tip bundle.hg
+ $ hg bundle --base 0 --rev tip bundle.hg -v
2 changesets found
+ uncompressed size of bundle content:
+ 332 (changelog)
+ 282 (manifests)
+ 105 b
+ 105 c
Terse output:
diff --git a/tests/test-largefiles.t b/tests/test-largefiles.t
--- a/tests/test-largefiles.t
+++ b/tests/test-largefiles.t
@@ -1097,6 +1097,17 @@ redo pull with --lfrev and check it pull
all local heads known remotely
6 changesets found
adding changesets
+ uncompressed size of bundle content:
+ 1213 (changelog)
+ 1479 (manifests)
+ 234 .hglf/large1
+ 504 .hglf/large3
+ 512 .hglf/sub/large4
+ 162 .hglf/sub2/large6
+ 162 .hglf/sub2/large7
+ 192 normal1
+ 397 normal3
+ 405 sub/normal4
adding manifests
adding file changes
added 6 changesets with 16 changes to 8 files
diff --git a/tests/test-phases-exchange.t b/tests/test-phases-exchange.t
--- a/tests/test-phases-exchange.t
+++ b/tests/test-phases-exchange.t
@@ -764,6 +764,10 @@ Bare push with next changeset and common
pushing to ../alpha
searching for changes
1 changesets found
+ uncompressed size of bundle content:
+ 172 (changelog)
+ 145 (manifests)
+ 111 a-H
adding changesets
adding manifests
adding file changes
diff --git a/tests/test-push-warn.t b/tests/test-push-warn.t
--- a/tests/test-push-warn.t
+++ b/tests/test-push-warn.t
@@ -142,6 +142,10 @@
pushing to ../c
searching for changes
2 changesets found
+ uncompressed size of bundle content:
+ 308 (changelog)
+ 286 (manifests)
+ 213 foo
adding changesets
adding manifests
adding file changes
diff --git a/tests/test-rebase-mq-skip.t b/tests/test-rebase-mq-skip.t
--- a/tests/test-rebase-mq-skip.t
+++ b/tests/test-rebase-mq-skip.t
@@ -64,8 +64,18 @@ already has one local mq patch
updating mq patch p0.patch to 5:9ecc820b1737
$TESTTMP/a/.hg/patches/p0.patch (glob)
2 changesets found
+ uncompressed size of bundle content:
+ 344 (changelog)
+ 284 (manifests)
+ 109 p0
+ 109 p1
saved backup bundle to $TESTTMP/a/.hg/strip-backup/13a46ce44f60-backup.hg (glob)
2 changesets found
+ uncompressed size of bundle content:
+ 399 (changelog)
+ 284 (manifests)
+ 109 p0
+ 109 p1
adding branch
adding changesets
adding manifests
diff --git a/tests/test-rebase-newancestor.t b/tests/test-rebase-newancestor.t
--- a/tests/test-rebase-newancestor.t
+++ b/tests/test-rebase-newancestor.t
@@ -294,8 +294,16 @@ rebase of merge of ancestors
other
rebase merging completed
1 changesets found
+ uncompressed size of bundle content:
+ 193 (changelog)
+ 196 (manifests)
+ 162 other
saved backup bundle to $TESTTMP/parentorder/.hg/strip-backup/4c5f12f25ebe-backup.hg (glob)
1 changesets found
+ uncompressed size of bundle content:
+ 252 (changelog)
+ 147 (manifests)
+ 162 other
adding branch
adding changesets
adding manifests
More information about the Mercurial-devel
mailing list