Patchwork [03,of,10] largefiles: use "checkoutgoing()" to avoid redundant "findcommonoutgoing()"

login
register
mail settings
Submitter Katsunori FUJIWARA
Date March 5, 2014, 12:12 p.m.
Message ID <b666a143d9d1958ee35a.1394021528@juju>
Download mbox | patch
Permalink /patch/3844/
State Superseded
Headers show

Comments

Katsunori FUJIWARA - March 5, 2014, 12:12 p.m.
# HG changeset patch
# User FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
# Date 1394019743 -32400
#      Wed Mar 05 20:42:23 2014 +0900
# Node ID b666a143d9d1958ee35a66d66354f4fdab81967e
# Parent  202d835ca3a173f808262677fccc796257945268
largefiles: use "checkoutgoing()" to avoid redundant "findcommonoutgoing()"

Before this patch, "hg push" invokes "findcommonoutgoing()" not only
in "exchange.push()" but also in "lfilesrepo.push()", when largefiles
is enabled. The latter is redundant.

This patch overrides "checkoutgoing()" in "lfilesrepo" class to avoid
redundant "findcommonoutgoing()" invocation, because "checkoutgoing()"
is invoked with the result of "findcommonoutgoing()" from
"exchange.push()".

Patch

diff --git a/hgext/largefiles/reposetup.py b/hgext/largefiles/reposetup.py
--- a/hgext/largefiles/reposetup.py
+++ b/hgext/largefiles/reposetup.py
@@ -10,7 +10,7 @@ 
 import copy
 import os
 
-from mercurial import error, manifest, match as match_, util, discovery
+from mercurial import error, manifest, match as match_, util
 from mercurial.i18n import _
 from mercurial import localrepo
 
@@ -413,17 +413,17 @@ 
                             " supported in the destination:"
                             " %s") % (', '.join(sorted(missing)))
                     raise util.Abort(msg)
-
-            outgoing = discovery.findcommonoutgoing(repo, remote.peer(),
-                                                    force=force)
-            if outgoing.missing:
-                o = self.changelog.nodesbetween(outgoing.missing, revs)[0]
-                mapfunc = lambda f, ctx: ctx[f].data().strip()
-                toupload = lfutil.getlfilestoupload(self, o, mapfunc)
-                lfcommands.uploadlfiles(ui, self, remote, toupload)
             return super(lfilesrepo, self).push(remote, force=force, revs=revs,
                 newbranch=newbranch)
 
+        def checkoutgoing(self, remote, outgoing):
+            if outgoing.missing:
+                mapfunc = lambda f, ctx: ctx[f].data().strip()
+                toupload = lfutil.getlfilestoupload(self, outgoing.missing,
+                                                    mapfunc)
+                lfcommands.uploadlfiles(ui, self, remote, toupload)
+            super(lfilesrepo, self).checkoutgoing(remote, outgoing)
+
         def _subdirlfs(self, files, lfiles):
             '''
             Adjust matched file list
diff --git a/tests/test-largefiles.t b/tests/test-largefiles.t
--- a/tests/test-largefiles.t
+++ b/tests/test-largefiles.t
@@ -1593,7 +1593,6 @@ 
   $ hg push ../dest
   pushing to ../dest
   searching for changes
-  searching for changes
   adding changesets
   adding manifests
   adding file changes
@@ -1687,7 +1686,6 @@ 
   $ hg push -R r7 http://localhost:$HGPORT1
   pushing to http://localhost:$HGPORT1/
   searching for changes
-  searching for changes
   remote: adding changesets
   remote: adding manifests
   remote: adding file changes
@@ -1711,7 +1709,6 @@ 
   $ hg push -R r8 http://localhost:$HGPORT2/#default
   pushing to http://localhost:$HGPORT2/
   searching for changes
-  searching for changes
   remote: adding changesets
   remote: adding manifests
   remote: adding file changes