Commit 8561ad49915 by Martin von Zweigbergk

revset: add a revset for parents in merge state

This may be particularly useful soon, when I'm going to change how `hg
rebase` sets its parents during conflict resolution.

Differential Revision: https://phab.mercurial-scm.org/D8041
parent 7f7c8521e9b
......@@ -769,6 +769,38 @@ def commonancestors(repo, subset, x):
return subset
@predicate(b'conflictlocal()', safe=True)
def conflictlocal(repo, subset, x):
"""The local side of the merge, if currently in an unresolved merge.
"merge" here includes merge conflicts from e.g. 'hg rebase' or 'hg graft'.
"""
getargs(x, 0, 0, _(b"conflictlocal takes no arguments"))
from . import merge
mergestate = merge.mergestate.read(repo)
if mergestate.active() and repo.changelog.hasnode(mergestate.local):
return subset & {repo.changelog.rev(mergestate.local)}
return baseset()
@predicate(b'conflictother()', safe=True)
def conflictother(repo, subset, x):
"""The other side of the merge, if currently in an unresolved merge.
"merge" here includes merge conflicts from e.g. 'hg rebase' or 'hg graft'.
"""
getargs(x, 0, 0, _(b"conflictother takes no arguments"))
from . import merge
mergestate = merge.mergestate.read(repo)
if mergestate.active() and repo.changelog.hasnode(mergestate.other):
return subset & {repo.changelog.rev(mergestate.other)}
return baseset()
@predicate(b'contains(pattern)', weight=100)
def contains(repo, subset, x):
"""The revision's manifest contains a file matching pattern (but might not
......
......@@ -3,6 +3,11 @@
* `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
commits that are being merged, when there are conflicts. Also works
for conflicts caused by e.g. `hg graft`.
== New Experimental Features ==
......
......@@ -23,3 +23,37 @@ Test hg behaves when committing with a missing file added by a merge
abort: cannot commit merge with missing files
[255]
Test conflict*() revsets
# Bad usage
$ hg log -r 'conflictlocal(foo)'
hg: parse error: conflictlocal takes no arguments
[255]
$ hg log -r 'conflictother(foo)'
hg: parse error: conflictother takes no arguments
[255]
$ hg co -C .
1 files updated, 0 files merged, 0 files removed, 0 files unresolved
# No merge parents when not merging
$ hg log -r 'conflictlocal() + conflictother()'
# No merge parents when there is no conflict
$ hg merge 1
1 files updated, 0 files merged, 0 files removed, 0 files unresolved
(branch merge, don't forget to commit)
$ hg log -r 'conflictlocal() + conflictother()'
$ hg co -C .
0 files updated, 0 files merged, 1 files removed, 0 files unresolved
$ echo conflict > b
$ hg ci -Aqm 'conflicting change to b'
$ hg merge 1
merging b
warning: conflicts while merging b! (edit, then use 'hg resolve --mark')
0 files updated, 0 files merged, 0 files removed, 1 files unresolved
use 'hg resolve' to retry unresolved file merges or 'hg merge --abort' to abandon
[1]
# Shows merge parents when there is a conflict
$ hg log -r 'conflictlocal()' -T '{rev} {desc}\n'
3 conflicting change to b
$ hg log -r 'conflictother()' -T '{rev} {desc}\n'
1 commit #1
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