[PATCH 03 of 12 V2] largefiles: reuse "findcommonoutgoing()" result at "hg push"

FUJIWARA Katsunori foozy at lares.dti.ne.jp
Tue Apr 15 10:52:24 CDT 2014


# HG changeset patch
# User FUJIWARA Katsunori <foozy at lares.dti.ne.jp>
# Date 1397576244 -32400
#      Wed Apr 16 00:37:24 2014 +0900
# Node ID 15a3e3a74654616426e6170c79a0f9d6cd575b22
# Parent  5d2bfff9bd3381e8f2513fdd5cf1211de84a72b1
largefiles: reuse "findcommonoutgoing()" result at "hg push"

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 registers own "prepushoutgoinghook" function into
"prepushoutgoinghooks" of "localrepository" to reuse
"findcommonoutgoing()" result.

"prepushoutgoinghook" omits "changelog.nodesbetween()" invocation,
because "findcommonoutgoing()" invocation in "exchange.push()" takes
"onlyheads" argument and it considers "nodesbetween()".

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
 
@@ -412,15 +412,6 @@
                             " supported in the destination:"
                             " %s") % (', '.join(sorted(missing)))
                     raise util.Abort(msg)
-
-            outgoing = discovery.findcommonoutgoing(repo, remote.peer(),
-                                                    force=force)
-            if outgoing.missing:
-                toupload = set()
-                o = self.changelog.nodesbetween(outgoing.missing, revs)[0]
-                addfunc = lambda fn, lfhash: toupload.add(lfhash)
-                lfutil.getlfilestoupload(self, o, addfunc)
-                lfcommands.uploadlfiles(ui, self, remote, toupload)
             return super(lfilesrepo, self).push(remote, force=force, revs=revs,
                 newbranch=newbranch)
 
@@ -480,6 +471,14 @@
 
     repo.__class__ = lfilesrepo
 
+    def prepushoutgoinghook(local, remote, outgoing):
+        if outgoing.missing:
+            toupload = set()
+            addfunc = lambda fn, lfhash: toupload.add(lfhash)
+            lfutil.getlfilestoupload(local, outgoing.missing, addfunc)
+            lfcommands.uploadlfiles(ui, local, remote, toupload)
+    repo.prepushoutgoinghooks.add("largefiles", prepushoutgoinghook)
+
     def checkrequireslfiles(ui, repo, **kwargs):
         if 'largefiles' not in repo.requirements and util.any(
                 lfutil.shortname+'/' in f[0] for f in repo.store.datafiles()):
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


More information about the Mercurial-devel mailing list