[PATCH 1 of 3] localrepo: refactor prepushoutgoinghook to take a pushop
Mads Kiilerich
mads at kiilerich.com
Wed Apr 13 00:37:37 UTC 2016
# HG changeset patch
# User Mads Kiilerich <madski at unity3d.com>
# Date 1460502551 -7200
# Wed Apr 13 01:09:11 2016 +0200
# Node ID 340c6083f091e64c13e63e8342ae80632c96d26f
# Parent 16255662446d2ce08bd0a4210df30afe3d6377f6
localrepo: refactor prepushoutgoinghook to take a pushop
prepushoutgoinghook was introduced in 6c383c871fdb and largefiles is the only
in-tree use of it. Refactor it to be more useful for other use cases in
largefiles.
diff --git a/hgext/largefiles/reposetup.py b/hgext/largefiles/reposetup.py
--- a/hgext/largefiles/reposetup.py
+++ b/hgext/largefiles/reposetup.py
@@ -352,12 +352,13 @@ def reposetup(ui, repo):
# is used to write status out.
repo._lfstatuswriters = [ui.status]
- def prepushoutgoinghook(local, remote, outgoing):
- if outgoing.missing:
+ def prepushoutgoinghook(pushop):
+ if pushop.outgoing.missing:
toupload = set()
addfunc = lambda fn, lfhash: toupload.add(lfhash)
- lfutil.getlfilestoupload(local, outgoing.missing, addfunc)
- lfcommands.uploadlfiles(ui, local, remote, toupload)
+ lfutil.getlfilestoupload(pushop.repo, pushop.outgoing.missing,
+ addfunc)
+ lfcommands.uploadlfiles(ui, pushop.repo, pushop.remote, toupload)
repo.prepushoutgoinghooks.add("largefiles", prepushoutgoinghook)
def checkrequireslfiles(ui, repo, **kwargs):
diff --git a/mercurial/exchange.py b/mercurial/exchange.py
--- a/mercurial/exchange.py
+++ b/mercurial/exchange.py
@@ -694,9 +694,7 @@ def _pushb2ctx(pushop, bundler):
# Send known heads to the server for race detection.
if not _pushcheckoutgoing(pushop):
return
- pushop.repo.prepushoutgoinghooks(pushop.repo,
- pushop.remote,
- pushop.outgoing)
+ pushop.repo.prepushoutgoinghooks(pushop)
_pushb2ctxcheckheads(pushop, bundler)
@@ -884,9 +882,7 @@ def _pushchangeset(pushop):
pushop.stepsdone.add('changesets')
if not _pushcheckoutgoing(pushop):
return
- pushop.repo.prepushoutgoinghooks(pushop.repo,
- pushop.remote,
- pushop.outgoing)
+ pushop.repo.prepushoutgoinghooks(pushop)
outgoing = pushop.outgoing
unbundle = pushop.remote.capable('unbundle')
# TODO: get bundlecaps from remote
diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py
--- a/mercurial/localrepo.py
+++ b/mercurial/localrepo.py
@@ -1887,8 +1887,8 @@ class localrepository(object):
@unfilteredpropertycache
def prepushoutgoinghooks(self):
- """Return util.hooks consists of "(repo, remote, outgoing)"
- functions, which are called before pushing changesets.
+ """Return util.hooks consists of a pushop with repo, remote, outgoing
+ methods, which are called before pushing changesets.
"""
return util.hooks()
More information about the Mercurial-devel
mailing list