Patchwork [3,of,5,(4,more,to,go)] localrepo: move the changegroupinfo method in changegroup module

login
register
mail settings
Submitter Pierre-Yves David
Date April 2, 2014, 5:59 p.m.
Message ID <b5bc4afcee8a99dc6c54.1396461544@marginatus.alto.octopoid.net>
Download mbox | patch
Permalink /patch/4196/
State Accepted
Commit 7c1ed40e3325b373ac5e501cd96b08a2124b6e5b
Headers show

Comments

Pierre-Yves David - April 2, 2014, 5:59 p.m.
# HG changeset patch
# User Pierre-Yves David <pierre-yves.david@fb.com>
# Date 1396386814 25200
#      Tue Apr 01 14:13:34 2014 -0700
# Node ID b5bc4afcee8a99dc6c5480c293a9557ca4234ca6
# Parent  51dedd9e405716d7818dcf0f2636b51da5165243
localrepo: move the changegroupinfo method in changegroup module

This is a gratuitous code move aimed at reducing the localrepo bloatness.

The method had a single caller... already in this changegroup module.

Patch

diff --git a/mercurial/changegroup.py b/mercurial/changegroup.py
--- a/mercurial/changegroup.py
+++ b/mercurial/changegroup.py
@@ -427,10 +427,19 @@  class bundle10(object):
         yield delta
     def builddeltaheader(self, node, p1n, p2n, basenode, linknode):
         # do nothing with basenode, it is implicitly the previous one in HG10
         return struct.pack(self.deltaheader, node, p1n, p2n, linknode)
 
+def _changegroupinfo(repo, nodes, source):
+    if repo.ui.verbose or source == 'bundle':
+        repo.ui.status(_("%d changesets found\n") % len(nodes))
+    if repo.ui.debugflag:
+        repo.ui.debug("list of changesets:\n")
+        for node in nodes:
+            repo.ui.debug("%s\n" % hex(node))
+
+
 def getsubset(repo, outgoing, bundler, source, fastpath=False):
     repo = repo.unfiltered()
     commonrevs = outgoing.common
     csets = outgoing.missing
     heads = outgoing.missingheads
@@ -440,8 +449,8 @@  def getsubset(repo, outgoing, bundler, s
     heads.sort()
     fastpathlinkrev = fastpath or (
             repo.filtername is None and heads == sorted(repo.heads()))
 
     repo.hook('preoutgoing', throw=True, source=source)
-    repo.changegroupinfo(csets, source)
+    _changegroupinfo(repo, csets, source)
     gengroup = bundler.generate(commonrevs, csets, fastpathlinkrev, source)
     return unbundle10(util.chunkbuffer(gengroup), 'UN')
diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py
--- a/mercurial/localrepo.py
+++ b/mercurial/localrepo.py
@@ -1677,18 +1677,10 @@  class localrepository(object):
         pass
 
     def push(self, remote, force=False, revs=None, newbranch=False):
         return exchange.push(self, remote, force, revs, newbranch)
 
-    def changegroupinfo(self, nodes, source):
-        if self.ui.verbose or source == 'bundle':
-            self.ui.status(_("%d changesets found\n") % len(nodes))
-        if self.ui.debugflag:
-            self.ui.debug("list of changesets:\n")
-            for node in nodes:
-                self.ui.debug("%s\n" % hex(node))
-
     def changegroupsubset(self, roots, heads, source):
         """Compute a changegroup consisting of all the nodes that are
         descendants of any of the roots and ancestors of any of the heads.
         Return a chunkbuffer object whose read() method will return
         successive changegroup chunks.