# HG changeset patch # User FUJIWARA Katsunori # Date 2014-04-15 15:37:24 # Node ID 52a5eabf1f2f90cfb5b0fa844c244df6fe1178cf # Parent 6c383c871fdb247d705f613f98def01ccdb94ea0 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 @@ def reposetup(ui, repo): " 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 @@ def reposetup(ui, repo): 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 @@ largefiles can be pushed locally (issue3 $ hg push ../dest pushing to ../dest searching for changes - searching for changes adding changesets adding manifests adding file changes @@ -1687,7 +1686,6 @@ Push of file that exists on server but i $ 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 @@ Push a largefiles repository to a served $ 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