# HG changeset patch # User Pierre-Yves David # Date 1458062817 0 # Node ID 58cdf061d49aee54a674ee7b7a82c22cd387f344 # Parent 93cf0ddb52340a53b6e74820b7c87be3c77a03ef topic: don't take topic into account when pushing to non-topic repo Previously, pushing to a non-publishing repository without topic support would wrongfully use topic when searching for new heads. diff --git a/hgext3rd/topic/__init__.py b/hgext3rd/topic/__init__.py --- a/hgext3rd/topic/__init__.py +++ b/hgext3rd/topic/__init__.py @@ -94,6 +94,12 @@ if not isinstance(repo, localrepo.localrepository): return # this can be a peer in the ssh case (puzzling) class topicrepo(repo.__class__): + + def _restrictcapabilities(self, caps): + caps = super(topicrepo, self)._restrictcapabilities(caps) + caps.add('topics') + return caps + def commit(self, *args, **kwargs): backup = self.ui.backupconfig('ui', 'allowemptycommit') try: @@ -324,6 +330,7 @@ extensions.wrapfunction(merge, 'update', mergeupdatewrap) extensions.wrapfunction(discoverymod, '_headssummary', discovery._headssummary) extensions.wrapfunction(wireproto, 'branchmap', discovery.wireprotobranchmap) +extensions.wrapfunction(wireproto, '_capabilities', discovery.wireprotocaps) extensions.wrapfunction(bundle2, 'handlecheckheads', discovery.handlecheckheads) bundle2.handlecheckheads.params = frozenset() # we need a proper wrape b2 part stuff bundle2.parthandlermapping['check:heads'] = bundle2.handlecheckheads diff --git a/hgext3rd/topic/discovery.py b/hgext3rd/topic/discovery.py --- a/hgext3rd/topic/discovery.py +++ b/hgext3rd/topic/discovery.py @@ -8,7 +8,7 @@ def _headssummary(orig, repo, remote, outgoing): publishing = ('phases' not in remote.listkeys('namespaces') or bool(remote.listkeys('phases').get('publishing', False))) - if publishing: + if publishing or not remote.capable('topics'): return orig(repo, remote, outgoing) oldgetitem = repo.__getitem__ oldrepo = repo.__class__ @@ -102,5 +102,10 @@ exchange._pushb2ctxcheckheads(pushop, bundler) return orig(pushop, bundler) +def wireprotocaps(orig, repo, proto): + caps = orig(repo, proto) + if repo.peer().capable('topics'): + caps.append('topics') + return caps diff --git a/tests/test-topic-push.t b/tests/test-topic-push.t --- a/tests/test-topic-push.t +++ b/tests/test-topic-push.t @@ -200,8 +200,34 @@ o 0 default public CA +Pushing a new topic to a non publishing server without topic -> new head + + $ cat << EOF >> ../draft/.hg/hgrc + > [extensions] + > topic=! + > EOF + $ hg push ssh://user@dummy/draft + pushing to ssh://user@dummy/draft + searching for changes + abort: push creates new remote head 84eaf32db6c3! + (merge or see "hg help push" for details about pushing new heads) + [255] + $ hg log -G + @ 6 default celeste draft CE + | + | o 5 default babar draft CD + |/ + | o 4 mountain public CC + |/ + | o 1 default public CB + |/ + o 0 default public CA + + Pushing a new topic to a non publishing server should not be seen as a new head + $ printf "topic=" >> ../draft/.hg/hgrc + $ hg config extensions.topic >> ../draft/.hg/hgrc $ hg push ssh://user@dummy/draft pushing to ssh://user@dummy/draft searching for changes