hgext3rd/topic/discovery.py
author Pierre-Yves David <pierre-yves.david@octobus.net>
Wed, 28 Jun 2017 18:18:59 +0200
changeset 2674 9585fac76d2d
parent 2673 1014341c637b
child 2675 304232cc14b6
permissions -rw-r--r--
topic: adjust head checking wrapping to not interfere with concurrent push In the previous form, the new topic head was detected as affected and the push was rejected. We introduce a of 'test-topic-push.t' using the new race checker as there have been many compatibility issue with this new checkers.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1934
9d6d30e36cdd discovery: move to new style import
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 1921
diff changeset
     1
from __future__ import absolute_import
9d6d30e36cdd discovery: move to new style import
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 1921
diff changeset
     2
1887
68125d026b07 push: hackish handeling of new branch head from phase move
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 1886
diff changeset
     3
import weakref
1934
9d6d30e36cdd discovery: move to new style import
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 1921
diff changeset
     4
1887
68125d026b07 push: hackish handeling of new branch head from phase move
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 1886
diff changeset
     5
from mercurial.i18n import _
1934
9d6d30e36cdd discovery: move to new style import
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 1921
diff changeset
     6
from mercurial import (
1944
daad8249d5cf discovery: move all setup into a 'modsetup' function
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 1934
diff changeset
     7
    bundle2,
daad8249d5cf discovery: move all setup into a 'modsetup' function
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 1934
diff changeset
     8
    discovery,
1934
9d6d30e36cdd discovery: move to new style import
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 1921
diff changeset
     9
    error,
9d6d30e36cdd discovery: move to new style import
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 1921
diff changeset
    10
    exchange,
1944
daad8249d5cf discovery: move all setup into a 'modsetup' function
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 1934
diff changeset
    11
    extensions,
daad8249d5cf discovery: move all setup into a 'modsetup' function
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 1934
diff changeset
    12
    wireproto,
1934
9d6d30e36cdd discovery: move to new style import
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 1921
diff changeset
    13
)
9d6d30e36cdd discovery: move to new style import
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 1921
diff changeset
    14
2558
65cf338258d2 fix: fix _headssummary api
Boris Feld <boris.feld@octobus.net>
parents: 1965
diff changeset
    15
def _headssummary(orig, *args):
65cf338258d2 fix: fix _headssummary api
Boris Feld <boris.feld@octobus.net>
parents: 1965
diff changeset
    16
    # In mercurial < 4.2, we receive repo, remote and outgoing as arguments
65cf338258d2 fix: fix _headssummary api
Boris Feld <boris.feld@octobus.net>
parents: 1965
diff changeset
    17
    if len(args) == 3:
2653
13313d0cab71 topicmap: massive rework
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 2567
diff changeset
    18
        pushoparg = False
2558
65cf338258d2 fix: fix _headssummary api
Boris Feld <boris.feld@octobus.net>
parents: 1965
diff changeset
    19
        repo, remote, outgoing = args
65cf338258d2 fix: fix _headssummary api
Boris Feld <boris.feld@octobus.net>
parents: 1965
diff changeset
    20
65cf338258d2 fix: fix _headssummary api
Boris Feld <boris.feld@octobus.net>
parents: 1965
diff changeset
    21
    # In mercurial > 4.3, we receive the pushop as arguments
65cf338258d2 fix: fix _headssummary api
Boris Feld <boris.feld@octobus.net>
parents: 1965
diff changeset
    22
    elif len(args) == 1:
2653
13313d0cab71 topicmap: massive rework
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 2567
diff changeset
    23
        pushoparg = True
2558
65cf338258d2 fix: fix _headssummary api
Boris Feld <boris.feld@octobus.net>
parents: 1965
diff changeset
    24
        pushop = args[0]
65cf338258d2 fix: fix _headssummary api
Boris Feld <boris.feld@octobus.net>
parents: 1965
diff changeset
    25
        repo = pushop.repo.unfiltered()
65cf338258d2 fix: fix _headssummary api
Boris Feld <boris.feld@octobus.net>
parents: 1965
diff changeset
    26
        remote = pushop.remote
65cf338258d2 fix: fix _headssummary api
Boris Feld <boris.feld@octobus.net>
parents: 1965
diff changeset
    27
    else:
65cf338258d2 fix: fix _headssummary api
Boris Feld <boris.feld@octobus.net>
parents: 1965
diff changeset
    28
        msg = 'topic-ext _headssummary() takes 1 or 3 arguments (%d given)'
65cf338258d2 fix: fix _headssummary api
Boris Feld <boris.feld@octobus.net>
parents: 1965
diff changeset
    29
        raise TypeError(msg % len(args))
65cf338258d2 fix: fix _headssummary api
Boris Feld <boris.feld@octobus.net>
parents: 1965
diff changeset
    30
1886
0504e76bfbd9 push: allow pushing new topic to non-publishing server by default
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
    31
    publishing = ('phases' not in remote.listkeys('namespaces')
0504e76bfbd9 push: allow pushing new topic to non-publishing server by default
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
    32
                  or bool(remote.listkeys('phases').get('publishing', False)))
1903
58cdf061d49a topic: don't take topic into account when pushing to non-topic repo
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 1901
diff changeset
    33
    if publishing or not remote.capable('topics'):
2567
6eb87513024b fix: fix _headssummary call to orig
Boris Feld <boris.feld@octobus.net>
parents: 2558
diff changeset
    34
        return orig(*args)
2653
13313d0cab71 topicmap: massive rework
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 2567
diff changeset
    35
13313d0cab71 topicmap: massive rework
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 2567
diff changeset
    36
    class repocls(repo.__class__):
13313d0cab71 topicmap: massive rework
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 2567
diff changeset
    37
        def __getitem__(self, key):
13313d0cab71 topicmap: massive rework
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 2567
diff changeset
    38
            ctx = super(repocls, self).__getitem__(key)
13313d0cab71 topicmap: massive rework
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 2567
diff changeset
    39
            oldbranch = ctx.branch
13313d0cab71 topicmap: massive rework
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 2567
diff changeset
    40
13313d0cab71 topicmap: massive rework
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 2567
diff changeset
    41
            def branch():
13313d0cab71 topicmap: massive rework
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 2567
diff changeset
    42
                branch = oldbranch()
13313d0cab71 topicmap: massive rework
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 2567
diff changeset
    43
                topic = ctx.topic()
13313d0cab71 topicmap: massive rework
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 2567
diff changeset
    44
                if topic:
13313d0cab71 topicmap: massive rework
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 2567
diff changeset
    45
                    branch = "%s:%s" % (branch, topic)
13313d0cab71 topicmap: massive rework
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 2567
diff changeset
    46
                return branch
1965
0421772a9c30 discovery: flake8
Sean Farley <sean@farley.io>
parents: 1944
diff changeset
    47
2653
13313d0cab71 topicmap: massive rework
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 2567
diff changeset
    48
            ctx.branch = branch
13313d0cab71 topicmap: massive rework
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 2567
diff changeset
    49
            return ctx
1965
0421772a9c30 discovery: flake8
Sean Farley <sean@farley.io>
parents: 1944
diff changeset
    50
2653
13313d0cab71 topicmap: massive rework
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 2567
diff changeset
    51
    oldrepo = repo.__class__
13313d0cab71 topicmap: massive rework
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 2567
diff changeset
    52
    try:
1886
0504e76bfbd9 push: allow pushing new topic to non-publishing server by default
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
    53
        repo.__class__ = repocls
2653
13313d0cab71 topicmap: massive rework
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 2567
diff changeset
    54
        unxx = repo.filtered('unfiltered-topic')
13313d0cab71 topicmap: massive rework
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 2567
diff changeset
    55
        repo.unfiltered = lambda: unxx
13313d0cab71 topicmap: massive rework
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 2567
diff changeset
    56
        if pushoparg:
13313d0cab71 topicmap: massive rework
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 2567
diff changeset
    57
            try:
13313d0cab71 topicmap: massive rework
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 2567
diff changeset
    58
                pushop.repo = repo
13313d0cab71 topicmap: massive rework
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 2567
diff changeset
    59
                summary = orig(pushop)
13313d0cab71 topicmap: massive rework
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 2567
diff changeset
    60
            finally:
13313d0cab71 topicmap: massive rework
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 2567
diff changeset
    61
                pushop.repo = repo
13313d0cab71 topicmap: massive rework
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 2567
diff changeset
    62
        else:
13313d0cab71 topicmap: massive rework
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 2567
diff changeset
    63
            summary = orig(repo, remote, outgoing)
1886
0504e76bfbd9 push: allow pushing new topic to non-publishing server by default
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
    64
        for key, value in summary.iteritems():
0504e76bfbd9 push: allow pushing new topic to non-publishing server by default
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
    65
            if ':' in key: # This is a topic
0504e76bfbd9 push: allow pushing new topic to non-publishing server by default
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
    66
                if value[0] is None and value[1]:
2674
9585fac76d2d topic: adjust head checking wrapping to not interfere with concurrent push
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 2673
diff changeset
    67
                    summary[key] = ([value[1][0]], ) + value[1:]
1886
0504e76bfbd9 push: allow pushing new topic to non-publishing server by default
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
    68
        return summary
0504e76bfbd9 push: allow pushing new topic to non-publishing server by default
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
    69
    finally:
2653
13313d0cab71 topicmap: massive rework
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 2567
diff changeset
    70
        if 'unfiltered' in vars(repo):
13313d0cab71 topicmap: massive rework
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 2567
diff changeset
    71
            del repo.unfiltered
1886
0504e76bfbd9 push: allow pushing new topic to non-publishing server by default
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
    72
        repo.__class__ = oldrepo
0504e76bfbd9 push: allow pushing new topic to non-publishing server by default
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
    73
0504e76bfbd9 push: allow pushing new topic to non-publishing server by default
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
    74
def wireprotobranchmap(orig, repo, proto):
0504e76bfbd9 push: allow pushing new topic to non-publishing server by default
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
    75
    oldrepo = repo.__class__
0504e76bfbd9 push: allow pushing new topic to non-publishing server by default
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
    76
    try:
0504e76bfbd9 push: allow pushing new topic to non-publishing server by default
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
    77
        class repocls(repo.__class__):
0504e76bfbd9 push: allow pushing new topic to non-publishing server by default
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
    78
            def branchmap(self):
0504e76bfbd9 push: allow pushing new topic to non-publishing server by default
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
    79
                usetopic = not self.publishing()
0504e76bfbd9 push: allow pushing new topic to non-publishing server by default
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
    80
                return super(repocls, self).branchmap(topic=usetopic)
0504e76bfbd9 push: allow pushing new topic to non-publishing server by default
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
    81
        repo.__class__ = repocls
0504e76bfbd9 push: allow pushing new topic to non-publishing server by default
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
    82
        return orig(repo, proto)
0504e76bfbd9 push: allow pushing new topic to non-publishing server by default
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
    83
    finally:
0504e76bfbd9 push: allow pushing new topic to non-publishing server by default
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
    84
        repo.__class__ = oldrepo
1887
68125d026b07 push: hackish handeling of new branch head from phase move
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 1886
diff changeset
    85
68125d026b07 push: hackish handeling of new branch head from phase move
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 1886
diff changeset
    86
68125d026b07 push: hackish handeling of new branch head from phase move
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 1886
diff changeset
    87
# Discovery have deficiency around phases, branch can get new heads with pure
68125d026b07 push: hackish handeling of new branch head from phase move
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 1886
diff changeset
    88
# phases change. This happened with a changeset was allowed to be pushed
68125d026b07 push: hackish handeling of new branch head from phase move
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 1886
diff changeset
    89
# because it had a topic, but it later become public and create a new branch
68125d026b07 push: hackish handeling of new branch head from phase move
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 1886
diff changeset
    90
# head.
68125d026b07 push: hackish handeling of new branch head from phase move
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 1886
diff changeset
    91
#
68125d026b07 push: hackish handeling of new branch head from phase move
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 1886
diff changeset
    92
# Handle this by doing an extra check for new head creation server side
68125d026b07 push: hackish handeling of new branch head from phase move
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 1886
diff changeset
    93
def _nbheads(repo):
68125d026b07 push: hackish handeling of new branch head from phase move
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 1886
diff changeset
    94
    data = {}
68125d026b07 push: hackish handeling of new branch head from phase move
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 1886
diff changeset
    95
    for b in repo.branchmap().iterbranches():
68125d026b07 push: hackish handeling of new branch head from phase move
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 1886
diff changeset
    96
        if ':' in b[0]:
68125d026b07 push: hackish handeling of new branch head from phase move
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 1886
diff changeset
    97
            continue
68125d026b07 push: hackish handeling of new branch head from phase move
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 1886
diff changeset
    98
        data[b[0]] = len(b[1])
68125d026b07 push: hackish handeling of new branch head from phase move
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 1886
diff changeset
    99
    return data
68125d026b07 push: hackish handeling of new branch head from phase move
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 1886
diff changeset
   100
68125d026b07 push: hackish handeling of new branch head from phase move
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 1886
diff changeset
   101
def handlecheckheads(orig, op, inpart):
68125d026b07 push: hackish handeling of new branch head from phase move
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 1886
diff changeset
   102
    orig(op, inpart)
68125d026b07 push: hackish handeling of new branch head from phase move
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 1886
diff changeset
   103
    if op.repo.publishing():
68125d026b07 push: hackish handeling of new branch head from phase move
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 1886
diff changeset
   104
        return
68125d026b07 push: hackish handeling of new branch head from phase move
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 1886
diff changeset
   105
    tr = op.gettransaction()
68125d026b07 push: hackish handeling of new branch head from phase move
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 1886
diff changeset
   106
    if tr.hookargs['source'] not in ('push', 'serve'): # not a push
68125d026b07 push: hackish handeling of new branch head from phase move
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 1886
diff changeset
   107
        return
68125d026b07 push: hackish handeling of new branch head from phase move
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 1886
diff changeset
   108
    tr._prepushheads = _nbheads(op.repo)
68125d026b07 push: hackish handeling of new branch head from phase move
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 1886
diff changeset
   109
    reporef = weakref.ref(op.repo)
68125d026b07 push: hackish handeling of new branch head from phase move
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 1886
diff changeset
   110
    oldvalidator = tr.validator
1921
4898296d7d25 discovery: whitespace
Sean Farley <sean@farley.io>
parents: 1920
diff changeset
   111
1887
68125d026b07 push: hackish handeling of new branch head from phase move
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 1886
diff changeset
   112
    def validator(tr):
68125d026b07 push: hackish handeling of new branch head from phase move
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 1886
diff changeset
   113
        repo = reporef()
68125d026b07 push: hackish handeling of new branch head from phase move
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 1886
diff changeset
   114
        if repo is not None:
68125d026b07 push: hackish handeling of new branch head from phase move
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 1886
diff changeset
   115
            repo.invalidatecaches()
68125d026b07 push: hackish handeling of new branch head from phase move
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 1886
diff changeset
   116
            finalheads = _nbheads(repo)
68125d026b07 push: hackish handeling of new branch head from phase move
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 1886
diff changeset
   117
            for branch, oldnb in tr._prepushheads.iteritems():
68125d026b07 push: hackish handeling of new branch head from phase move
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 1886
diff changeset
   118
                newnb = finalheads.pop(branch, 0)
68125d026b07 push: hackish handeling of new branch head from phase move
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 1886
diff changeset
   119
                if oldnb < newnb:
68125d026b07 push: hackish handeling of new branch head from phase move
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 1886
diff changeset
   120
                    msg = _('push create a new head on branch "%s"' % branch)
68125d026b07 push: hackish handeling of new branch head from phase move
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 1886
diff changeset
   121
                    raise error.Abort(msg)
68125d026b07 push: hackish handeling of new branch head from phase move
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 1886
diff changeset
   122
            for branch, newnb in finalheads.iteritems():
68125d026b07 push: hackish handeling of new branch head from phase move
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 1886
diff changeset
   123
                if 1 < newnb:
1921
4898296d7d25 discovery: whitespace
Sean Farley <sean@farley.io>
parents: 1920
diff changeset
   124
                    msg = _('push create more than 1 head on new branch "%s"'
4898296d7d25 discovery: whitespace
Sean Farley <sean@farley.io>
parents: 1920
diff changeset
   125
                            % branch)
1887
68125d026b07 push: hackish handeling of new branch head from phase move
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 1886
diff changeset
   126
                    raise error.Abort(msg)
68125d026b07 push: hackish handeling of new branch head from phase move
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 1886
diff changeset
   127
        return oldvalidator(tr)
68125d026b07 push: hackish handeling of new branch head from phase move
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 1886
diff changeset
   128
    tr.validator = validator
68125d026b07 push: hackish handeling of new branch head from phase move
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 1886
diff changeset
   129
handlecheckheads.params = frozenset()
68125d026b07 push: hackish handeling of new branch head from phase move
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 1886
diff changeset
   130
68125d026b07 push: hackish handeling of new branch head from phase move
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 1886
diff changeset
   131
def _pushb2phases(orig, pushop, bundler):
2673
1014341c637b topic: also detect head checking using the concurrent part
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 2653
diff changeset
   132
    checktypes = ('check:heads', 'check:updated-heads')
1014341c637b topic: also detect head checking using the concurrent part
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 2653
diff changeset
   133
    hascheck = any(p.type in checktypes for p in bundler._parts)
1014341c637b topic: also detect head checking using the concurrent part
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 2653
diff changeset
   134
    if not hascheck and pushop.outdatedphases:
1887
68125d026b07 push: hackish handeling of new branch head from phase move
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 1886
diff changeset
   135
        exchange._pushb2ctxcheckheads(pushop, bundler)
68125d026b07 push: hackish handeling of new branch head from phase move
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 1886
diff changeset
   136
    return orig(pushop, bundler)
68125d026b07 push: hackish handeling of new branch head from phase move
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 1886
diff changeset
   137
1903
58cdf061d49a topic: don't take topic into account when pushing to non-topic repo
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 1901
diff changeset
   138
def wireprotocaps(orig, repo, proto):
58cdf061d49a topic: don't take topic into account when pushing to non-topic repo
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 1901
diff changeset
   139
    caps = orig(repo, proto)
58cdf061d49a topic: don't take topic into account when pushing to non-topic repo
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 1901
diff changeset
   140
    if repo.peer().capable('topics'):
58cdf061d49a topic: don't take topic into account when pushing to non-topic repo
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 1901
diff changeset
   141
        caps.append('topics')
58cdf061d49a topic: don't take topic into account when pushing to non-topic repo
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 1901
diff changeset
   142
    return caps
1944
daad8249d5cf discovery: move all setup into a 'modsetup' function
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 1934
diff changeset
   143
daad8249d5cf discovery: move all setup into a 'modsetup' function
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 1934
diff changeset
   144
def modsetup(ui):
daad8249d5cf discovery: move all setup into a 'modsetup' function
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 1934
diff changeset
   145
    """run at uisetup time to install all destinations wrapping"""
daad8249d5cf discovery: move all setup into a 'modsetup' function
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 1934
diff changeset
   146
    extensions.wrapfunction(discovery, '_headssummary', _headssummary)
daad8249d5cf discovery: move all setup into a 'modsetup' function
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 1934
diff changeset
   147
    extensions.wrapfunction(wireproto, 'branchmap', wireprotobranchmap)
daad8249d5cf discovery: move all setup into a 'modsetup' function
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 1934
diff changeset
   148
    extensions.wrapfunction(wireproto, '_capabilities', wireprotocaps)
daad8249d5cf discovery: move all setup into a 'modsetup' function
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 1934
diff changeset
   149
    extensions.wrapfunction(bundle2, 'handlecheckheads', handlecheckheads)
daad8249d5cf discovery: move all setup into a 'modsetup' function
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 1934
diff changeset
   150
    # we need a proper wrap b2 part stuff
daad8249d5cf discovery: move all setup into a 'modsetup' function
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 1934
diff changeset
   151
    bundle2.handlecheckheads.params = frozenset()
daad8249d5cf discovery: move all setup into a 'modsetup' function
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 1934
diff changeset
   152
    bundle2.parthandlermapping['check:heads'] = bundle2.handlecheckheads
daad8249d5cf discovery: move all setup into a 'modsetup' function
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 1934
diff changeset
   153
    extensions.wrapfunction(exchange, '_pushb2phases', _pushb2phases)
daad8249d5cf discovery: move all setup into a 'modsetup' function
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 1934
diff changeset
   154
    exchange.b2partsgenmapping['phase'] = exchange._pushb2phases