Mercurial > evolve
diff src/topic/__init__.py @ 1886:0504e76bfbd9
push: allow pushing new topic to non-publishing server by default
This improves and fix the behavior change introduced by the new "topicmap".
* Topics are properly ignored when pushing to a publishing server,
* pushing new topics is allowed without --force a non-publishing server,
* Pushing extra heads on a topic requires --force.
Create of new head on a branch by phase movement is not properly detected for
now. We'll improve that part in a later changesets.
There is more awful monkey patching going on. We'll have to refactor core to get
rid of them.
author | Pierre-Yves David <pierre-yves.david@fb.com> |
---|---|
date | Sat, 12 Mar 2016 18:19:27 +0000 |
parents | d49f75eab6a3 |
children | 68125d026b07 |
line wrap: on
line diff
--- a/src/topic/__init__.py Sat Mar 12 15:36:17 2016 +0000 +++ b/src/topic/__init__.py Sat Mar 12 18:19:27 2016 +0000 @@ -13,11 +13,14 @@ import functools from mercurial.i18n import _ +from mercurial import branchmap from mercurial import cmdutil from mercurial import commands from mercurial import context +from mercurial import discovery as discoverymod from mercurial import error from mercurial import extensions +from mercurial import localrepo from mercurial import lock from mercurial import merge from mercurial import namespaces @@ -26,12 +29,13 @@ from mercurial import patch from mercurial import phases from mercurial import util -from mercurial import branchmap +from mercurial import wireproto from . import constants from . import revset as topicrevset from . import destination from . import topicmap +from . import discovery cmdtable = {} command = cmdutil.command(cmdtable) @@ -58,6 +62,8 @@ def reposetup(ui, repo): orig = repo.__class__ + if not isinstance(repo, localrepo.localrepository): + return # this can be a peer in the ssh case (puzzling) class topicrepo(repo.__class__): def commit(self, *args, **kwargs): backup = self.ui.backupconfig('ui', 'allowemptycommit') @@ -117,6 +123,17 @@ if '_topiccaches' in vars(self.unfiltered()): self.unfiltered()._topiccaches.clear() + def peer(self): + peer = super(topicrepo, self).peer() + if getattr(peer, '_repo', None) is not None: # localpeer + class topicpeer(peer.__class__): + def branchmap(self): + usetopic = not self._repo.publishing() + return self._repo.branchmap(topic=usetopic) + peer.__class__ = topicpeer + return peer + + repo.__class__ = topicrepo if util.safehasattr(repo, 'names'): repo.names.addnamespace(namespaces.namespace( @@ -276,6 +293,8 @@ extensions.wrapfunction(cmdutil, 'buildcommittext', committextwrap) extensions.wrapfunction(merge, 'update', mergeupdatewrap) +extensions.wrapfunction(discoverymod, '_headssummary', discovery._headssummary) +extensions.wrapfunction(wireproto, 'branchmap', discovery.wireprotobranchmap) topicrevset.modsetup() cmdutil.summaryhooks.add('topic', summaryhook)