bundle: when verbose, show what takes up the space in the generated bundle
authorMads Kiilerich <madski@unity3d.com>
Fri, 15 Aug 2014 19:43:32 +0200
changeset 23748 4ab66de46a96
parent 23747 f82173a90c2c
child 23749 a387b0390082
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.
mercurial/changegroup.py
tests/test-commit-amend.t
tests/test-debugbundle.t
tests/test-largefiles.t
tests/test-phases-exchange.t
tests/test-push-warn.t
tests/test-rebase-mq-skip.t
tests/test-rebase-newancestor.t
--- a/mercurial/changegroup.py	Tue Jan 06 16:30:52 2015 -0800
+++ b/mercurial/changegroup.py	Fri Aug 15 19:43:32 2014 +0200
@@ -258,6 +258,11 @@
         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 @@
             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 @@
             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 @@
             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
--- a/tests/test-commit-amend.t	Tue Jan 06 16:30:52 2015 -0800
+++ b/tests/test-commit-amend.t	Fri Aug 15 19:43:32 2014 +0200
@@ -109,8 +109,16 @@
   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 @@
   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 @@
   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
--- a/tests/test-debugbundle.t	Tue Jan 06 16:30:52 2015 -0800
+++ b/tests/test-debugbundle.t	Fri Aug 15 19:43:32 2014 +0200
@@ -6,8 +6,13 @@
   $ 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:
 
--- a/tests/test-largefiles.t	Tue Jan 06 16:30:52 2015 -0800
+++ b/tests/test-largefiles.t	Fri Aug 15 19:43:32 2014 +0200
@@ -1097,6 +1097,17 @@
   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
--- a/tests/test-phases-exchange.t	Tue Jan 06 16:30:52 2015 -0800
+++ b/tests/test-phases-exchange.t	Fri Aug 15 19:43:32 2014 +0200
@@ -764,6 +764,10 @@
   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
--- a/tests/test-push-warn.t	Tue Jan 06 16:30:52 2015 -0800
+++ b/tests/test-push-warn.t	Fri Aug 15 19:43:32 2014 +0200
@@ -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
--- a/tests/test-rebase-mq-skip.t	Tue Jan 06 16:30:52 2015 -0800
+++ b/tests/test-rebase-mq-skip.t	Fri Aug 15 19:43:32 2014 +0200
@@ -64,8 +64,18 @@
   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
--- a/tests/test-rebase-newancestor.t	Tue Jan 06 16:30:52 2015 -0800
+++ b/tests/test-rebase-newancestor.t	Fri Aug 15 19:43:32 2014 +0200
@@ -294,8 +294,16 @@
   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