diff --git a/hgext3rd/conflictinfo.py b/hgext3rd/conflictinfo.py --- a/hgext3rd/conflictinfo.py +++ b/hgext3rd/conflictinfo.py @@ -46,13 +46,24 @@ # a help string) # Note: order matters (consider rebase v. merge). CONFLICTSTATES = [ - ['graft', 'graftstate'], - ['update', 'updatestate'], - ['evolve', 'evolvestate'], - ['rebase', 'rebasestate'], - ['histedit', 'histedit-state'], - ['unshelve', 'shelvedstate'], - ['merge', 'merge/state'], + ['graftstate', {'cmd': 'graft', + 'to_continue': 'graft --continue', + 'to_abort': 'graft --abort'}], + ['updatestate', {'cmd': 'update', + 'to_continue': 'update', + 'to_abort': 'update --clean'}], + ['rebasestate', {'cmd': 'rebase', + 'to_continue': 'rebase --continue', + 'to_abort': 'rebase --abort'}], + ['mergestate', {'cmd': 'merge', + 'to_continue': 'merge --continue', + 'to_abort': 'update --clean'}], + ['shelvedstate', {'cmd': 'unshelve', + 'to_continue': 'unshelve --continue', + 'to_abort': 'unshelve --abort'}], + ['histedit-state', {'cmd': 'histedit', + 'to_continue': 'histedit --continue', + 'to_abort': 'histedit --abort'}], ] def extsetup(ui): @@ -62,9 +73,9 @@ # states are mutually exclusive, we can use the existence of any one statefile # as proof of culpability. def _findconflictcommand(repo): - for name, path in CONFLICTSTATES: + for path, data in CONFLICTSTATES: if repo.vfs.exists(path): - return name + return data return None # To become a block in commands.py/resolve(). @@ -98,9 +109,12 @@ if val is not None: paths.append(val) + cmd = _findconflictcommand(repo) formatter.startitem() formatter.write('conflicts', '%s\n', paths) - formatter.write('command', '%s\n', _findconflictcommand(repo)) + if cmd: + formatter.write('command', '%s\n', cmd['cmd']) # Deprecated + formatter.write('command_details', '%s\n', cmd) formatter.end() return 0 diff --git a/tests/test-merge-conflictinfo.t b/tests/test-merge-conflictinfo.t --- a/tests/test-merge-conflictinfo.t +++ b/tests/test-merge-conflictinfo.t @@ -55,7 +55,6 @@ $ hg resolve --tool internal:dumpjson --all [ { - "command": "merge", "conflicts": [{"base": {"contents": "Unconflicted base, F1\n", "exists": true, "isexec": false, "issymlink": false}, "local": {"contents": "Second conflicted version, F1\n", "exists": true, "isexec": false, "issymlink": false}, "other": {"contents": "First conflicted version, F1\n", "exists": true, "isexec": false, "issymlink": false}, "output": {"contents": "<<<<<<< working copy: 13124abb51b9 b - test: second version, b\nSecond conflicted version, F1\n=======\nFirst conflicted version, F1\n>>>>>>> merge rev: 6dd692b7db4a a - test: first version, a\n", "exists": true, "isexec": false, "issymlink": false, "path": "$TESTTMP/basic/F1"}, "path": "F1"}, {"base": {"contents": "Unconflicted base, F2\n", "exists": true, "isexec": false, "issymlink": false}, "local": {"contents": "Second conflicted version, F2\n", "exists": true, "isexec": false, "issymlink": false}, "other": {"contents": "First conflicted version, F2\n", "exists": true, "isexec": false, "issymlink": false}, "output": {"contents": "<<<<<<< working copy: 13124abb51b9 b - test: second version, b\nSecond conflicted version, F2\n=======\nFirst conflicted version, F2\n>>>>>>> merge rev: 6dd692b7db4a a - test: first version, a\n", "exists": true, "isexec": false, "issymlink": false, "path": "$TESTTMP/basic/F2"}, "path": "F2"}] } ] @@ -64,7 +63,6 @@ $ hg resolve --tool internal:dumpjson F2 [ { - "command": "merge", "conflicts": [{"base": {"contents": "Unconflicted base, F2\n", "exists": true, "isexec": false, "issymlink": false}, "local": {"contents": "Second conflicted version, F2\n", "exists": true, "isexec": false, "issymlink": false}, "other": {"contents": "First conflicted version, F2\n", "exists": true, "isexec": false, "issymlink": false}, "output": {"contents": "<<<<<<< working copy: 13124abb51b9 b - test: second version, b\nSecond conflicted version, F2\n=======\nFirst conflicted version, F2\n>>>>>>> merge rev: 6dd692b7db4a a - test: first version, a\n", "exists": true, "isexec": false, "issymlink": false, "path": "$TESTTMP/basic/F2"}, "path": "F2"}] } ] @@ -150,7 +148,6 @@ $ hg resolve --tool=internal:dumpjson --all [ { - "command": "merge", "conflicts": [{"base": {"contents": "base\n", "exists": true, "isexec": false, "issymlink": false}, "local": {"contents": "some local changes\n", "exists": true, "isexec": false, "issymlink": false}, "other": {"contents": "other change\n", "exists": true, "isexec": false, "issymlink": false}, "output": {"contents": "<<<<<<< working copy: fd7d10c36158 - test: dest\nsome local changes\n=======\nother change\n>>>>>>> merge rev: 9b65ba2922f0 - test: source\n", "exists": true, "isexec": false, "issymlink": false, "path": "$TESTTMP/cornercases/foo/file"}, "path": "file"}] } ] @@ -191,7 +188,6 @@ $ hg resolve --tool=internal:dumpjson --all [ { - "command": "merge", "conflicts": [{"base": {"contents": "base\n", "exists": true, "isexec": false, "issymlink": false}, "local": {"contents": "some local changes\n", "exists": true, "isexec": true, "issymlink": false}, "other": {"contents": null, "exists": false, "isexec": null, "issymlink": null}, "output": {"contents": "some local changes\n", "exists": true, "isexec": true, "issymlink": false, "path": "$TESTTMP/cornercases/foo/foo/file"}, "path": "file"}] } ] @@ -228,6 +224,7 @@ [ { "command": "rebase", + "command_details": {"cmd": "rebase", "to_abort": "rebase --abort", "to_continue": "rebase --continue"}, "conflicts": [{"base": {"contents": "base\n", "exists": true, "isexec": false, "issymlink": false}, "local": {"contents": "change\n", "exists": true, "isexec": false, "issymlink": false}, "other": {"contents": null, "exists": false, "isexec": null, "issymlink": null}, "output": {"contents": "change\n", "exists": true, "isexec": false, "issymlink": false, "path": "$TESTTMP/cornercases/foo/foo/foo/file"}, "path": "file"}] } ] @@ -263,7 +260,6 @@ $ hg resolve --tool=internal:dumpjson --all [ { - "command": "merge", "conflicts": [{"base": {"contents": "base\n", "exists": true, "isexec": false, "issymlink": false}, "local": {"contents": "some local changes\n", "exists": true, "isexec": false, "issymlink": false}, "other": {"contents": null, "exists": false, "isexec": null, "issymlink": null}, "output": {"contents": "some local changes\n", "exists": true, "isexec": false, "issymlink": false, "path": "$TESTTMP/cornercases/foo/foo/foo/foo/file"}, "path": "file"}] } ] @@ -300,6 +296,7 @@ [ { "command": "rebase", + "command_details": {"cmd": "rebase", "to_abort": "rebase --abort", "to_continue": "rebase --continue"}, "conflicts": [{"base": {"contents": "base\n", "exists": true, "isexec": false, "issymlink": false}, "local": {"contents": null, "exists": false, "isexec": null, "issymlink": null}, "other": {"contents": "change\n", "exists": true, "isexec": false, "issymlink": false}, "output": {"contents": null, "exists": false, "isexec": null, "issymlink": null, "path": "$TESTTMP/cornercases/foo/foo/foo/foo/file"}, "path": "file"}] } ] @@ -336,7 +333,6 @@ $ hg resolve --tool=internal:dumpjson --all [ { - "command": null, "conflicts": [] } ] @@ -373,6 +369,7 @@ [ { "command": "rebase", + "command_details": {"cmd": "rebase", "to_abort": "rebase --abort", "to_continue": "rebase --continue"}, "conflicts": [{"base": {"contents": "base\n", "exists": true, "isexec": false, "issymlink": false}, "local": {"contents": null, "exists": false, "isexec": null, "issymlink": null}, "other": {"contents": "change\n", "exists": true, "isexec": false, "issymlink": false}, "output": {"contents": null, "exists": false, "isexec": null, "issymlink": null, "path": "$TESTTMP/cornercases/foo/foo/foo/foo/file"}, "path": "file"}] } ] @@ -410,7 +407,6 @@ $ hg resolve --tool=internal:dumpjson --all [ { - "command": null, "conflicts": [] } ] @@ -447,6 +443,7 @@ [ { "command": "rebase", + "command_details": {"cmd": "rebase", "to_abort": "rebase --abort", "to_continue": "rebase --continue"}, "conflicts": [{"base": {"contents": "base\n", "exists": true, "isexec": false, "issymlink": false}, "local": {"contents": "change\n", "exists": true, "isexec": false, "issymlink": false}, "other": {"contents": null, "exists": false, "isexec": null, "issymlink": null}, "output": {"contents": "change\n", "exists": true, "isexec": false, "issymlink": false, "path": "$TESTTMP/cornercases/foo/foo/foo/foo/file"}, "path": "file"}] } ] @@ -483,6 +480,7 @@ [ { "command": "update", + "command_details": {"cmd": "update", "to_abort": "update --clean", "to_continue": "update"}, "conflicts": [] } ] @@ -519,6 +517,7 @@ [ { "command": "update", + "command_details": {"cmd": "update", "to_abort": "update --clean", "to_continue": "update"}, "conflicts": [] } ] @@ -558,6 +557,7 @@ [ { "command": "rebase", + "command_details": {"cmd": "rebase", "to_abort": "rebase --abort", "to_continue": "rebase --continue"}, "conflicts": [{"base": {"contents": "base\n", "exists": true, "isexec": false, "issymlink": false}, "local": {"contents": "change\n", "exists": true, "isexec": false, "issymlink": false}, "other": {"contents": "\u0000", "exists": true, "isexec": false, "issymlink": false}, "output": {"contents": "change\n", "exists": true, "isexec": false, "issymlink": false, "path": "$TESTTMP/cornercases/foo/foo/foo/foo/file"}, "path": "file"}] } ] @@ -597,6 +597,7 @@ [ { "command": "rebase", + "command_details": {"cmd": "rebase", "to_abort": "rebase --abort", "to_continue": "rebase --continue"}, "conflicts": [{"base": {"contents": "base\n", "exists": true, "isexec": false, "issymlink": false}, "local": {"contents": "\u0000", "exists": true, "isexec": false, "issymlink": false}, "other": {"contents": "change\n", "exists": true, "isexec": false, "issymlink": false}, "output": {"contents": "\u0000", "exists": true, "isexec": false, "issymlink": false, "path": "$TESTTMP/cornercases/foo/foo/foo/foo/file"}, "path": "file"}] } ] @@ -637,6 +638,7 @@ [ { "command": "rebase", + "command_details": {"cmd": "rebase", "to_abort": "rebase --abort", "to_continue": "rebase --continue"}, "conflicts": [{"base": {"contents": "base\n", "exists": true, "isexec": false, "issymlink": false}, "local": {"contents": "change\n", "exists": true, "isexec": false, "issymlink": false}, "other": {"contents": "somepath", "exists": true, "isexec": false, "issymlink": true}, "output": {"contents": "change\n", "exists": true, "isexec": false, "issymlink": false, "path": "$TESTTMP/cornercases/foo/foo/foo/foo/file"}, "path": "file"}] } ] @@ -679,6 +681,7 @@ [ { "command": "rebase", + "command_details": {"cmd": "rebase", "to_abort": "rebase --abort", "to_continue": "rebase --continue"}, "conflicts": [{"base": {"contents": "base\n", "exists": true, "isexec": false, "issymlink": false}, "local": {"contents": "somepath", "exists": true, "isexec": false, "issymlink": true}, "other": {"contents": "change\n", "exists": true, "isexec": false, "issymlink": false}, "output": {"contents": "somepath", "exists": true, "isexec": false, "issymlink": true, "path": "$TESTTMP/cornercases/foo/foo/foo/foo/file"}, "path": "file"}] } ]