diff hgext/largefiles/reposetup.py @ 21044:52a5eabf1f2f

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()".
author FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
date Wed, 16 Apr 2014 00:37:24 +0900
parents 32b3331f18eb
children 2fb3c1c0b4ef
line wrap: on
line diff
--- a/hgext/largefiles/reposetup.py	Wed Apr 16 00:37:24 2014 +0900
+++ b/hgext/largefiles/reposetup.py	Wed Apr 16 00:37:24 2014 +0900
@@ -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()):