Commit 14d0e89520a by Martin von Zweigbergk

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
parent ab632e27f29
......@@ -71,6 +71,8 @@ def getprettygraphnode(orig, *args, **kwargs):
return b'\xE2\x97\x8B' # U+25CB ○
if node == b'@':
return b'\xE2\x97\x8D' # U+25CD ◍
if node == b'%':
return b'\xE2\x97\x8D' # U+25CE ◎
if node == b'*':
return b'\xE2\x88\x97' # U+2217 ∗
if node == b'x':
......
......@@ -936,5 +936,5 @@ def getwebsubs(repo):
def getgraphnode(repo, ctx):
return templatekw.getgraphnodecurrent(
repo, ctx
repo, ctx, {}
) + templatekw.getgraphnodesymbol(ctx)
......@@ -1004,7 +1004,7 @@ def _graphnodeformatter(ui, displayer):
ui, spec, defaults=templatekw.keywords, resources=tres
)
def formatnode(repo, ctx):
def formatnode(repo, ctx, cache):
props = {b'ctx': ctx, b'repo': repo}
return templ.renderdefault(props)
......@@ -1038,8 +1038,9 @@ def displaygraph(ui, repo, dag, displayer, edgefn, getcopies=None, props=None):
# experimental config: experimental.graphshorten
state.graphshorten = ui.configbool(b'experimental', b'graphshorten')
formatnode_cache = {}
for rev, type, ctx, parents in dag:
char = formatnode(repo, ctx)
char = formatnode(repo, ctx, formatnode_cache)
copies = getcopies(ctx) if getcopies else None
edges = edgefn(type, char, state, rev, parents)
firstedge = next(edges)
......
......@@ -396,26 +396,38 @@ def showfiles(context, mapping):
return templateutil.compatfileslist(context, mapping, b'file', ctx.files())
@templatekeyword(b'graphnode', requires={b'repo', b'ctx'})
@templatekeyword(b'graphnode', requires={b'repo', b'ctx', b'cache'})
def showgraphnode(context, mapping):
"""String. The character representing the changeset node in an ASCII
revision graph."""
repo = context.resource(mapping, b'repo')
ctx = context.resource(mapping, b'ctx')
return getgraphnode(repo, ctx)
cache = context.resource(mapping, b'cache')
return getgraphnode(repo, ctx, cache)
def getgraphnode(repo, ctx):
return getgraphnodecurrent(repo, ctx) or getgraphnodesymbol(ctx)
def getgraphnode(repo, ctx, cache):
return getgraphnodecurrent(repo, ctx, cache) or getgraphnodesymbol(ctx)
def getgraphnodecurrent(repo, ctx):
def getgraphnodecurrent(repo, ctx, cache):
wpnodes = repo.dirstate.parents()
if wpnodes[1] == nullid:
wpnodes = wpnodes[:1]
if ctx.node() in wpnodes:
return b'@'
else:
merge_nodes = cache.get(b'merge_nodes', ())
if not merge_nodes:
from . import merge
mergestate = merge.mergestate.read(repo)
if mergestate.active():
merge_nodes = (mergestate.local, mergestate.other)
cache[b'merge_nodes'] = merge_nodes
if ctx.node() in merge_nodes:
return b'%'
return b''
......
......@@ -3,7 +3,12 @@
* `hg purge`/`hg clean` can now delete ignored files instead of
untracked files, with the new -i flag.
* New `conflictlocal()` and `conflictother()` revsets returns the
* `hg log` now defaults to using an '%' symbol for commits involved
in unresolved merge conflicts. That includes unresolved conflicts
caused by e.g. `hg update --merge` and `hg graft`. '@' still takes
precedence, so what used to be marked '@' still is.
* New `conflictlocal()` and `conflictother()` revsets return the
commits that are being merged, when there are conflicts. Also works
for conflicts caused by e.g. `hg graft`.
......
......@@ -103,7 +103,7 @@ commit option
| date: Thu Jan 01 00:00:02 1970 +0000
| summary: grapes
|
o changeset: 1:22cb4f70d813
% changeset: 1:22cb4f70d813
| user: test
| date: Thu Jan 01 00:00:01 1970 +0000
| summary: chair
......@@ -748,7 +748,7 @@ Test usage of `hg resolve` in case of conflict
| date: Thu Jan 01 00:00:00 1970 +0000
| summary: capital three
|
o changeset: 0:a30dd8addae3
% changeset: 0:a30dd8addae3
user: test
date: Thu Jan 01 00:00:00 1970 +0000
summary: initial
......
......@@ -431,7 +431,7 @@ when some of the changesets became public
$ hg log -GT "{rev}:{node|short} {desc}"
@ 6:6ec71c037d94 added x
|
| o 5:36b793615f78 added foo to c
| % 5:36b793615f78 added foo to c
| |
| | o 4:863a25e1a9ea added x
| |/
......@@ -622,7 +622,7 @@ Resolve conflict:
$ hg log -GT "{rev}:{node|short} {desc}\n"
@ 4:2aa9ad1006ff B in file a
|
| o 3:09e253b87e17 A in file a
| % 3:09e253b87e17 A in file a
| |
| o 2:d36c0562f908 c
| |
......@@ -669,7 +669,7 @@ Resolve conflict:
$ hg log -GT "{rev}:{node|short} {desc}\n"
@ 4:2aa9ad1006ff B in file a
|
| o 3:09e253b87e17 A in file a
| % 3:09e253b87e17 A in file a
| |
| o 2:d36c0562f908 c
| |
......@@ -712,7 +712,7 @@ When there is conflict:
$ hg log -GT "{rev}:{node|short} {desc}\n"
@ 4:2aa9ad1006ff B in file a
|
| o 3:09e253b87e17 A in file a
| % 3:09e253b87e17 A in file a
| |
| o 2:d36c0562f908 c
| |
......
......@@ -762,7 +762,7 @@ Test aborted editor on final message
abort: edit failed: false exited with status 1
[255]
$ hg tglog
o 3: 63668d570d21 'C'
% 3: 63668d570d21 'C'
|
| @ 2: 82b8abf9c185 'D'
| |
......
......@@ -598,7 +598,7 @@ Verify strip protects against stripping wc parent when there are uncommitted mod
| date: Thu Jan 01 00:00:00 1970 +0000
| summary: b
|
o changeset: 0:9ab35a2d17cb
% changeset: 0:9ab35a2d17cb
user: test
date: Thu Jan 01 00:00:00 1970 +0000
summary: a
......
......@@ -254,7 +254,7 @@ Cases are run as shown in that table, row by row.
|
@ 4:d047485b3896 0:60829823a42a b1
|
| o 3:6efa171f091b 1:0786582aa4b1
| % 3:6efa171f091b 1:0786582aa4b1
| |
| | o 2:bd10386d478c
| |/
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment