Mercurial > hg
changeset 20487:f715cc0b5107
pull: make pulled subset a propertycache of the pull object
The computation of the subset is simple operation using two useful pull
information (1) the set of common changeset before the pull (2) the set of
pulled changeset. We move this data into the `pulloperation` object since some
phase will need them. And we turn the pulled subset computation behind a
property case as multiple pull phase will need it.
author | Pierre-Yves David <pierre-yves.david@logilab.fr> |
---|---|
date | Fri, 31 Jan 2014 01:34:00 -0800 |
parents | 0c469df6e914 |
children | 76e66654f74e |
files | mercurial/exchange.py |
diffstat | 1 files changed, 24 insertions(+), 18 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/exchange.py Fri Jan 31 01:25:56 2014 -0800 +++ b/mercurial/exchange.py Fri Jan 31 01:34:00 2014 -0800 @@ -395,8 +395,23 @@ self._trname = 'pull\n' + util.hidepassword(remote.url()) # hold the transaction once created self._tr = None - # heads of the set of changeset target by the pull - self.pulledsubset = None + # set of common changeset between local and remote before pull + self.common = None + # set of pulled head + self.rheads = None + + @util.propertycache + def pulledsubset(self): + """heads of the set of changeset target by the pull""" + # compute target subset + if self.heads is None: + # We pulled every thing possible + # sync on everything common + return self.common + self.rheads + else: + # We pulled a specific subset + # sync on this subset + return self.heads def gettransaction(self): """get appropriate pull transaction, creating it if needed""" @@ -430,7 +445,7 @@ pullop.remote, heads=pullop.heads, force=force) - common, fetch, rheads = tmp + pullop.common, fetch, pullop.rheads = tmp if not fetch: pullop.repo.ui.status(_("no changes found\n")) result = 0 @@ -439,17 +454,19 @@ # don't open transaction for nothing or you break future useful # rollback call pullop.gettransaction() - if pullop.heads is None and list(common) == [nullid]: + if pullop.heads is None and list(pullop.common) == [nullid]: pullop.repo.ui.status(_("requesting all changes\n")) elif (pullop.heads is None and pullop.remote.capable('changegroupsubset')): # issue1320, avoid a race if remote changed after discovery - pullop.heads = rheads + pullop.heads = pullop.rheads if pullop.remote.capable('getbundle'): # TODO: get bundlecaps from remote - cg = pullop.remote.getbundle('pull', common=common, - heads=pullop.heads or rheads) + cg = pullop.remote.getbundle('pull', + common=pullop.common, + heads=(pullop.heads + or pullop.rheads)) elif pullop.heads is None: cg = pullop.remote.changegroup(fetch, 'pull') elif not pullop.remote.capable('changegroupsubset'): @@ -462,17 +479,6 @@ result = pullop.repo.addchangegroup(cg, 'pull', pullop.remote.url()) - # compute target subset - if pullop.heads is None: - # We pulled every thing possible - # sync on everything common - subset = common + rheads - else: - # We pulled a specific subset - # sync on this subset - subset = pullop.heads - pullop.pulledsubset = subset - _pullphase(pullop) _pullobsolete(pullop) pullop.closetransaction()