Mercurial > evolve
changeset 1903:58cdf061d49a
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.
author | Pierre-Yves David <pierre-yves.david@fb.com> |
---|---|
date | Tue, 15 Mar 2016 17:26:57 +0000 |
parents | 93cf0ddb5234 |
children | f52c02bf47b7 |
files | hgext3rd/topic/__init__.py hgext3rd/topic/discovery.py tests/test-topic-push.t |
diffstat | 3 files changed, 39 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/hgext3rd/topic/__init__.py Wed Mar 16 12:14:20 2016 -0700 +++ b/hgext3rd/topic/__init__.py Tue Mar 15 17:26:57 2016 +0000 @@ -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
--- a/hgext3rd/topic/discovery.py Wed Mar 16 12:14:20 2016 -0700 +++ b/hgext3rd/topic/discovery.py Tue Mar 15 17:26:57 2016 +0000 @@ -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
--- a/tests/test-topic-push.t Wed Mar 16 12:14:20 2016 -0700 +++ b/tests/test-topic-push.t Tue Mar 15 17:26:57 2016 +0000 @@ -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