hgext3rd/topic/topicmap.py
branchmercurial-4.3
changeset 3418 85cdce113c2c
parent 3397 f7129e3d5a38
child 4187 49d442a2207f
equal deleted inserted replaced
3380:62f742d144da 3418:85cdce113c2c
     1 import contextlib
     1 import contextlib
     2 import hashlib
     2 import hashlib
     3 
     3 
       
     4 from mercurial.i18n import _
     4 from mercurial.node import nullid
     5 from mercurial.node import nullid
     5 from mercurial import (
     6 from mercurial import (
     6     branchmap,
     7     branchmap,
     7     changegroup,
     8     changegroup,
     8     cmdutil,
     9     cmdutil,
    92     # wrap commit status use the topic branch heads
    93     # wrap commit status use the topic branch heads
    93     ctx = repo[node]
    94     ctx = repo[node]
    94     if ctx.topic() and ctx.branch() == branch:
    95     if ctx.topic() and ctx.branch() == branch:
    95         subbranch = "%s:%s" % (branch, ctx.topic())
    96         subbranch = "%s:%s" % (branch, ctx.topic())
    96         bheads = repo.branchheads("%s:%s" % (subbranch, ctx.topic()))
    97         bheads = repo.branchheads("%s:%s" % (subbranch, ctx.topic()))
    97     return orig(repo, node, branch, bheads=bheads, opts=opts)
    98 
       
    99     ret = orig(repo, node, branch, bheads=bheads, opts=opts)
       
   100 
       
   101     # logic copy-pasted from cmdutil.commitstatus()
       
   102     if opts is None:
       
   103         opts = {}
       
   104     ctx = repo[node]
       
   105     if ctx.topic():
       
   106         return ret
       
   107     parents = ctx.parents()
       
   108 
       
   109     if (not opts.get('amend') and bheads and node not in bheads and not
       
   110         [x for x in parents if x.node() in bheads and x.branch() == branch]):
       
   111         repo.ui.status(_("(consider using topic for lightweight branches."
       
   112                          " See 'hg help topic')\n"))
       
   113 
       
   114     return ret
    98 
   115 
    99 def _wrapbmcache(ui):
   116 def _wrapbmcache(ui):
   100     class topiccache(_topiccache, branchmap.branchcache):
   117     class topiccache(_topiccache, branchmap.branchcache):
   101         pass
   118         pass
   102     branchmap.branchcache = topiccache
   119     branchmap.branchcache = topiccache