hgext/largefiles/reposetup.py
changeset 21044 52a5eabf1f2f
parent 21042 32b3331f18eb
child 22098 2fb3c1c0b4ef
--- 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()):