comparison mercurial/templatekw.py @ 44345:14d0e89520a2

graphlog: use '%' for other context in merge conflict This lets the user more easily find the commit that is involved in the conflict, such as the source of `hg update -m` or the commit being grafted by `hg graft`. Differential Revision: https://phab.mercurial-scm.org/D8043
author Martin von Zweigbergk <martinvonz@google.com>
date Tue, 28 Jan 2020 21:49:50 -0800
parents d783f945a701
children fc1fa3a07af6
comparison
equal deleted inserted replaced
44344:ab632e27f296 44345:14d0e89520a2
394 """ 394 """
395 ctx = context.resource(mapping, b'ctx') 395 ctx = context.resource(mapping, b'ctx')
396 return templateutil.compatfileslist(context, mapping, b'file', ctx.files()) 396 return templateutil.compatfileslist(context, mapping, b'file', ctx.files())
397 397
398 398
399 @templatekeyword(b'graphnode', requires={b'repo', b'ctx'}) 399 @templatekeyword(b'graphnode', requires={b'repo', b'ctx', b'cache'})
400 def showgraphnode(context, mapping): 400 def showgraphnode(context, mapping):
401 """String. The character representing the changeset node in an ASCII 401 """String. The character representing the changeset node in an ASCII
402 revision graph.""" 402 revision graph."""
403 repo = context.resource(mapping, b'repo') 403 repo = context.resource(mapping, b'repo')
404 ctx = context.resource(mapping, b'ctx') 404 ctx = context.resource(mapping, b'ctx')
405 return getgraphnode(repo, ctx) 405 cache = context.resource(mapping, b'cache')
406 406 return getgraphnode(repo, ctx, cache)
407 407
408 def getgraphnode(repo, ctx): 408
409 return getgraphnodecurrent(repo, ctx) or getgraphnodesymbol(ctx) 409 def getgraphnode(repo, ctx, cache):
410 410 return getgraphnodecurrent(repo, ctx, cache) or getgraphnodesymbol(ctx)
411 411
412 def getgraphnodecurrent(repo, ctx): 412
413 def getgraphnodecurrent(repo, ctx, cache):
413 wpnodes = repo.dirstate.parents() 414 wpnodes = repo.dirstate.parents()
414 if wpnodes[1] == nullid: 415 if wpnodes[1] == nullid:
415 wpnodes = wpnodes[:1] 416 wpnodes = wpnodes[:1]
416 if ctx.node() in wpnodes: 417 if ctx.node() in wpnodes:
417 return b'@' 418 return b'@'
418 else: 419 else:
420 merge_nodes = cache.get(b'merge_nodes', ())
421 if not merge_nodes:
422 from . import merge
423
424 mergestate = merge.mergestate.read(repo)
425 if mergestate.active():
426 merge_nodes = (mergestate.local, mergestate.other)
427 cache[b'merge_nodes'] = merge_nodes
428
429 if ctx.node() in merge_nodes:
430 return b'%'
419 return b'' 431 return b''
420 432
421 433
422 def getgraphnodesymbol(ctx): 434 def getgraphnodesymbol(ctx):
423 if ctx.obsolete(): 435 if ctx.obsolete():