diff mercurial/changegroup.py @ 23748:4ab66de46a96

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.
author Mads Kiilerich <madski@unity3d.com>
date Fri, 15 Aug 2014 19:43:32 +0200
parents a81c76106d90
children 7817059917d0
line wrap: on
line diff
--- 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