Submitter | phabricator |
---|---|
Date | Feb. 13, 2020, 6:37 a.m. |
Message ID | <differential-rev-PHID-DREV-ckiq7e6jvoxb2qq7t7tl-req@mercurial-scm.org> |
Download | mbox | patch |
Permalink | /patch/45195/ |
State | Superseded |
Headers | show |
Comments
durin42 added a comment. Why can't we add templater support to `debugmergestate` instead? REPOSITORY rHG Mercurial CHANGES SINCE LAST ACTION https://phab.mercurial-scm.org/D8113/new/ REVISION DETAIL https://phab.mercurial-scm.org/D8113 To: martinvonz, #hg-reviewers Cc: durin42, mercurial-devel
martinvonz added a comment.
In D8113#120695 <https://phab.mercurial-scm.org/D8113#120695>, @durin42 wrote:
> Why can't we add templater support to `debugmergestate` instead?
Sorry, I should have explained that in the commit message. The reason I didn't was because the current command seems to try to make the output be true to the on-disk format. Maybe that's not something we care much about, so I can just rewrite it by defining a default template. I'll try that.
REPOSITORY
rHG Mercurial
CHANGES SINCE LAST ACTION
https://phab.mercurial-scm.org/D8113/new/
REVISION DETAIL
https://phab.mercurial-scm.org/D8113
To: martinvonz, #hg-reviewers
Cc: durin42, mercurial-devel
pulkit added a comment. Will be nice to add some release notes either in BC section or in features section stating `debugmergestate` now supports templates and can be used by scripts/editors. REPOSITORY rHG Mercurial CHANGES SINCE LAST ACTION https://phab.mercurial-scm.org/D8113/new/ REVISION DETAIL https://phab.mercurial-scm.org/D8113 To: martinvonz, #hg-reviewers, durin42 Cc: pulkit, durin42, mercurial-devel
martinvonz added a comment.
In D8113#120745 <https://phab.mercurial-scm.org/D8113#120745>, @pulkit wrote:
> Will be nice to add some release notes either in BC section or in features section stating `debugmergestate` now supports templates and can be used by scripts/editors.
Ah, good point, will do.
REPOSITORY
rHG Mercurial
CHANGES SINCE LAST ACTION
https://phab.mercurial-scm.org/D8113/new/
REVISION DETAIL
https://phab.mercurial-scm.org/D8113
To: martinvonz, #hg-reviewers, durin42
Cc: pulkit, durin42, mercurial-devel
martinvonz added a comment. In D8113#120746 <https://phab.mercurial-scm.org/D8113#120746>, @martinvonz wrote: > In D8113#120745 <https://phab.mercurial-scm.org/D8113#120745>, @pulkit wrote: > >> Will be nice to add some release notes either in BC section or in features section stating `debugmergestate` now supports templates and can be used by scripts/editors. > > Ah, good point, will do. I did both :) REPOSITORY rHG Mercurial CHANGES SINCE LAST ACTION https://phab.mercurial-scm.org/D8113/new/ REVISION DETAIL https://phab.mercurial-scm.org/D8113 To: martinvonz, #hg-reviewers, durin42 Cc: pulkit, durin42, mercurial-devel
martinvonz added a comment. I was worried that the new version might be crashing in some cases (I specifically worried about indexes out of range in the `state` list). To test that, I added `hg debugmergestate` before every `hg resolve` call in the test suite. That showed two different bugs. Feel free to de-queue this patch or I'll send updates later (maybe tomorrow). Sorry that I didn't think to test that before the patch got accepted. REPOSITORY rHG Mercurial CHANGES SINCE LAST ACTION https://phab.mercurial-scm.org/D8113/new/ REVISION DETAIL https://phab.mercurial-scm.org/D8113 To: martinvonz, #hg-reviewers, durin42, pulkit Cc: pulkit, durin42, mercurial-devel
martinvonz added a comment.
In D8113#120803 <https://phab.mercurial-scm.org/D8113#120803>, @martinvonz wrote:
> I was worried that the new version might be crashing in some cases (I specifically worried about indexes out of range in the `state` list). To test that, I added `hg debugmergestate` before every `hg resolve` call in the test suite. That showed two different bugs. Feel free to de-queue this patch or I'll send updates later (maybe tomorrow). Sorry that I didn't think to test that before the patch got accepted.
I'll just de-queue the patch myself. I'll send a replacement for this one later.
REPOSITORY
rHG Mercurial
CHANGES SINCE LAST ACTION
https://phab.mercurial-scm.org/D8113/new/
REVISION DETAIL
https://phab.mercurial-scm.org/D8113
To: martinvonz, #hg-reviewers, durin42, pulkit
Cc: pulkit, durin42, mercurial-devel
Patch
diff --git a/tests/test-resolve.t b/tests/test-resolve.t --- a/tests/test-resolve.t +++ b/tests/test-resolve.t @@ -327,6 +327,20 @@ R file1 U file2 +test debugmergestatetemplate + + $ hg debugmergestatetemplated + abort: template required + [255] + $ hg debugmergestatetemplated -T json + [ + { + "commits": [{"label": "working copy", "name": "local", "node": "57653b9f834a4493f7240b0681efcb9ae7cab745"}, {"label": "merge rev", "name": "other", "node": "dc77451844e37f03f5c559e3b8529b2b48d381d1"}], + "files": [{"extras": [{"key": "ancestorlinknode", "value": "99726c03216e233810a2564cbc0adfe395007eac"}], "name": "file1", "state": "r"}, {"ancestor_node": "2ed2a3912a0b24502043eae84ee4b279c18b90dd", "ancestor_path": "file2", "extras": [{"key": "ancestorlinknode", "value": "99726c03216e233810a2564cbc0adfe395007eac"}], "local_flags": "", "local_key": "cb99b709a1978bd205ab9dfd4c5aaa1fc91c7523", "local_path": "file2", "name": "file2", "other_node": "6f4310b00b9a147241b071a60c28a650827fb03d", "other_path": "file2", "state": "u"}] + } + ] + + insert unsupported mandatory merge record $ hg --config extensions.fakemergerecord=$TESTDIR/fakemergerecord.py fakemergerecord -X diff --git a/tests/test-help.t b/tests/test-help.t --- a/tests/test-help.t +++ b/tests/test-help.t @@ -1022,6 +1022,8 @@ cache debugmergestate print merge state + debugmergestatetemplated + templated output about the merge state debugnamecomplete complete "names" - tags, open branch names, bookmark names debugnodemap write and inspect on disk nodemap diff --git a/tests/test-completion.t b/tests/test-completion.t --- a/tests/test-completion.t +++ b/tests/test-completion.t @@ -106,6 +106,7 @@ debuglocks debugmanifestfulltextcache debugmergestate + debugmergestatetemplated debugnamecomplete debugnodemap debugobsolete @@ -290,6 +291,7 @@ debuglocks: force-lock, force-wlock, set-lock, set-wlock debugmanifestfulltextcache: clear, add debugmergestate: + debugmergestatetemplated: style, template debugnamecomplete: debugnodemap: dump-new, dump-disk, check, metadata debugobsolete: flags, record-parents, rev, exclusive, index, delete, date, user, template diff --git a/mercurial/debugcommands.py b/mercurial/debugcommands.py --- a/mercurial/debugcommands.py +++ b/mercurial/debugcommands.py @@ -2060,6 +2060,62 @@ printrecords(2) +@command(b'debugmergestatetemplated', [] + cmdutil.templateopts, b'') +def debugmergestatetemplated(ui, repo, *args, **opts): + """templated output about the merge state + + This command requires a template (such as '-T json'). + """ + + opts = pycompat.byteskwargs(opts) + if not opts[b'template']: + raise error.Abort(_(b'template required')) + + ms = mergemod.mergestate.read(repo) + if not ms.active(): + return + + fm = ui.formatter(b'debugmergestatetemplated', opts) + fm.startitem() + + fm_commits = fm.nested(b'commits') + for name, node, label_index in ( + (b'local', ms.local, 0), + (b'other', ms.other, 1), + ): + fm_commits.startitem() + fm_commits.data(name=name) + fm_commits.data(node=hex(node)) + if ms._labels and len(ms._labels) > label_index: + fm_commits.data(label=ms._labels[label_index]) + fm_commits.end() + + fm_files = fm.nested(b'files') + for f in ms: + fm_files.startitem() + fm_files.data(name=f) + state = ms._state[f] + fm_files.data(state=state[0]) + if state[0] == mergemod.MERGE_RECORD_UNRESOLVED: + fm_files.data(local_key=state[1]) + fm_files.data(local_path=state[2]) + fm_files.data(ancestor_path=state[3]) + fm_files.data(ancestor_node=state[4]) + fm_files.data(other_path=state[5]) + fm_files.data(other_node=state[6]) + fm_files.data(local_flags=state[7]) + fm_extras = fm_files.nested(b'extras') + for k, v in ms.extras(f).items(): + fm_extras.startitem() + fm_extras.data(key=k) + fm_extras.data(value=v) + fm_extras.end() + + fm_files.end() + + fm.end() + + @command(b'debugnamecomplete', [], _(b'NAME...')) def debugnamecomplete(ui, repo, *args): '''complete "names" - tags, open branch names, bookmark names'''