Submitter | phabricator |
---|---|
Date | Jan. 30, 2020, 12:57 a.m. |
Message ID | <differential-rev-PHID-DREV-fjlz7c3skrm7lepwh5cd-req@mercurial-scm.org> |
Download | mbox | patch |
Permalink | /patch/44762/ |
State | Superseded |
Headers | show |
Comments
pulkit added inline comments. INLINE COMMENTS > revset.py:1866 > + > + If "merge" here includes merge conflicts from e.g. 'hg rebase' or > + 'hg graft'. The sentence looks incomplete. REPOSITORY rHG Mercurial CHANGES SINCE LAST ACTION https://phab.mercurial-scm.org/D8041/new/ REVISION DETAIL https://phab.mercurial-scm.org/D8041 To: martinvonz, #hg-reviewers Cc: pulkit, mjpieters, mercurial-devel
> +@predicate(b'conflictparents()', safe=True) > +def parents(repo, subset, x): ^^^^^^^ Nit: copy-paste error?
yuja added a comment. > +@predicate(b'conflictparents()', safe=True) > +def parents(repo, subset, x): ^^^^^^^ Nit: copy-paste error? REPOSITORY rHG Mercurial CHANGES SINCE LAST ACTION https://phab.mercurial-scm.org/D8041/new/ REVISION DETAIL https://phab.mercurial-scm.org/D8041 To: martinvonz, #hg-reviewers Cc: yuja, pulkit, mjpieters, mercurial-devel
marmoute added inline comments. INLINE COMMENTS > next:3 > > + * New `conflictparents()` revset returns the commits that are being > + merged, when there are conflicts. Also works for conflicts caused Could we call this `conflict_sides`, using "parents" for things that are not actual parent might be confusing. What about having a `local_conflict_side` and `other_conflict_side` `conflict_base` revsets ? REPOSITORY rHG Mercurial CHANGES SINCE LAST ACTION https://phab.mercurial-scm.org/D8041/new/ REVISION DETAIL https://phab.mercurial-scm.org/D8041 To: martinvonz, #hg-reviewers Cc: marmoute, yuja, pulkit, mjpieters, mercurial-devel
martinvonz added a comment. In D8041#118684 <https://phab.mercurial-scm.org/D8041#118684>, @yuja wrote: >> +@predicate(b'conflictparents()', safe=True) >> +def parents(repo, subset, x): > > ^^^^^^^ > > Nit: copy-paste error? Good catch. Done. INLINE COMMENTS > pulkit wrote in revset.py:1866 > The sentence looks incomplete. It was actually just an extra "If". Fixed. > marmoute wrote in next:3 > Could we call this `conflict_sides`, using "parents" for things that are not actual parent might be confusing. > > What about having a `local_conflict_side` and `other_conflict_side` `conflict_base` revsets ? Those both sound like good ideas. I'll send an update later today. REPOSITORY rHG Mercurial CHANGES SINCE LAST ACTION https://phab.mercurial-scm.org/D8041/new/ REVISION DETAIL https://phab.mercurial-scm.org/D8041 To: martinvonz, #hg-reviewers Cc: marmoute, yuja, pulkit, mjpieters, mercurial-devel
martinvonz added inline comments. martinvonz marked an inline comment as done. INLINE COMMENTS > martinvonz wrote in next:3 > Those both sound like good ideas. I'll send an update later today. I've renamed them `conflictlocal()` and `conflictother()`. Hopefully that's clear enough and not too long. REPOSITORY rHG Mercurial CHANGES SINCE LAST ACTION https://phab.mercurial-scm.org/D8041/new/ REVISION DETAIL https://phab.mercurial-scm.org/D8041 To: martinvonz, #hg-reviewers Cc: marmoute, yuja, pulkit, mjpieters, mercurial-devel
Patch
diff --git a/tests/test-merge4.t b/tests/test-merge4.t --- a/tests/test-merge4.t +++ b/tests/test-merge4.t @@ -23,3 +23,33 @@ abort: cannot commit merge with missing files [255] + +Test conflictparents() revset + +# Bad usage + $ hg log -r 'conflictparents(foo)' + hg: parse error: conflictparents 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 'conflictparents()' +# 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 'conflictparents()' + $ 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 'conflictparents()' -T '{rev} {desc}\n' + 1 commit #1 + 3 conflicting change to b diff --git a/relnotes/next b/relnotes/next --- a/relnotes/next +++ b/relnotes/next @@ -1,5 +1,9 @@ == New Features == + * New `conflictparents()` revset returns the commits that are being + merged, when there are conflicts. Also works for conflicts caused + by e.g. `hg graft`. + == New Experimental Features == diff --git a/mercurial/revset.py b/mercurial/revset.py --- a/mercurial/revset.py +++ b/mercurial/revset.py @@ -1858,6 +1858,27 @@ return subset & ps +@predicate(b'conflictparents()', safe=True) +def parents(repo, subset, x): + """ + The two parents of the merge, if currently in an unresolved merge. + + If "merge" here includes merge conflicts from e.g. 'hg rebase' or + 'hg graft'. + """ + getargs(x, 0, 0, _(b"conflictparents takes no arguments")) + from . import merge + + mergestate = merge.mergestate.read(repo) + revs = set() + if mergestate.active(): + for n in (mergestate.local, mergestate.other): + if repo.changelog.hasnode(n): + revs.add(repo.changelog.rev(n)) + + return subset & revs + + def _phase(repo, subset, *targets): """helper to select all rev in <targets> phases""" return repo._phasecache.getrevset(repo, targets, subset)