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'}], + ['merge/state', {'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(). @@ -103,10 +114,16 @@ if info is not None: pathconflicts.append(info) + cmd = _findconflictcommand(repo) formatter.startitem() formatter.write('conflicts', '%s\n', fileconflicts) formatter.write('pathconflicts', '%s\n', pathconflicts) formatter.write('command', '%s\n', _findconflictcommand(repo)) + if cmd: + formatter.write('command', '%s\n', cmd['cmd']) # Deprecated + formatter.write('command_details', '%s\n', cmd) + else: + formatter.write('command', '%s\n', None) # For BC 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 @@ -56,6 +56,7 @@ [ { "command": "merge", + "command_details": {"cmd": "merge", "to_abort": "update --clean", "to_continue": "merge --continue"}, "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"}], "pathconflicts": [] } @@ -66,6 +67,7 @@ [ { "command": "merge", + "command_details": {"cmd": "merge", "to_abort": "update --clean", "to_continue": "merge --continue"}, "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"}], "pathconflicts": [] } @@ -153,6 +155,7 @@ [ { "command": "merge", + "command_details": {"cmd": "merge", "to_abort": "update --clean", "to_continue": "merge --continue"}, "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"}], "pathconflicts": [] } @@ -195,6 +198,7 @@ [ { "command": "merge", + "command_details": {"cmd": "merge", "to_abort": "update --clean", "to_continue": "merge --continue"}, "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"}], "pathconflicts": [] } @@ -232,6 +236,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"}], "pathconflicts": [] } @@ -269,6 +274,7 @@ [ { "command": "merge", + "command_details": {"cmd": "merge", "to_abort": "update --clean", "to_continue": "merge --continue"}, "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"}], "pathconflicts": [] } @@ -306,6 +312,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"}], "pathconflicts": [] } @@ -381,6 +388,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"}], "pathconflicts": [] } @@ -457,6 +465,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"}], "pathconflicts": [] } @@ -488,11 +497,20 @@ $ hg rebase -d 2 -s 1 rebasing 1:ed93aeac6b3c "source" - abort:*: '$TESTTMP/cornercases/foo/foo/foo/foo/file' (glob) - [255] + file: path conflict - a file or link has the same name as a directory + the local file has been renamed to file~fd7d10c36158 + resolve manually then use 'hg resolve --mark file' + unresolved conflicts (see hg resolve, then hg rebase --continue) + [1] $ hg resolve --tool=internal:dumpjson --all - [abort:*: $TESTTMP/cornercases/foo/foo/foo/foo/file (glob) - [255] + [ + { + "command": "rebase", + "command_details": {"cmd": "rebase", "to_abort": "rebase --abort", "to_continue": "rebase --continue"}, + "conflicts": [], + "pathconflicts": [{"fileorigin": "local", "path": "file", "renamedto": "file~fd7d10c36158"}] + } + ] Test case 8: Source is a file, dest is a directory (base is still a file) $ cd .. $ reset @@ -520,14 +538,20 @@ $ hg rebase -d 2 -s 1 rebasing 1:ec87889f5f90 "source" - abort:*: '$TESTTMP/cornercases/foo/foo/foo/foo/file' (glob) - [255] + file: path conflict - a file or link has the same name as a directory + the remote file has been renamed to file~ec87889f5f90 + resolve manually then use 'hg resolve --mark file' + other [source] changed file~ec87889f5f90 which local [dest] deleted + use (c)hanged version, leave (d)eleted, or leave (u)nresolved? u + unresolved conflicts (see hg resolve, then hg rebase --continue) + [1] $ hg resolve --tool=internal:dumpjson --all [ { - "command": "update", - "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"}], - "pathconflicts": [] + "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~ec87889f5f90"}, "path": "file~ec87889f5f90"}], + "pathconflicts": [{"fileorigin": "remote", "path": "file", "renamedto": "file~ec87889f5f90"}] } ] Test case 9: Source is a binary file, dest is a file (base is still a file) @@ -556,7 +580,7 @@ $ hg rebase -d 2 -s 1 rebasing 1:b6e55a03a5dc "source" merging file - warning: ([^\s]+) looks like a binary file. (re) + warning: file looks like a binary file. warning: conflicts while merging file! (edit, then use 'hg resolve --mark') unresolved conflicts (see hg resolve, then hg rebase --continue) [1] @@ -566,6 +590,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"}], "pathconflicts": [] } @@ -596,7 +621,7 @@ $ hg rebase -d 2 -s 1 rebasing 1:ec87889f5f90 "source" merging file - warning: ([^\s]+) looks like a binary file. (re) + warning: file looks like a binary file. warning: conflicts while merging file! (edit, then use 'hg resolve --mark') unresolved conflicts (see hg resolve, then hg rebase --continue) [1] @@ -606,6 +631,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"}], "pathconflicts": [] } @@ -647,6 +673,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"}], "pathconflicts": [] } @@ -690,6 +717,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"}], "pathconflicts": [] }