diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py --- a/mercurial/cmdutil.py +++ b/mercurial/cmdutil.py @@ -786,6 +786,7 @@ unfinishedmsg = attr.ib() inmergestate = attr.ib() unresolvedpaths = attr.ib() + adddataitem = attr.ib() _label = b'status.morestatus' def formatfile(self, path, fm): @@ -797,6 +798,11 @@ ) % self.unfinishedop fm.plain(b'%s\n' % _commentlines(statemsg), label=self._label) + if self.adddataitem: + fm.startitem() + fm.data(itemtype=b'morestatus', unfinished=self.unfinishedop, + unfinishedmsg=self.unfinishedmsg) + self._formatconflicts(fm) if self.unfinishedmsg: fm.plain(b'%s\n' % _commentlines(self.unfinishedmsg), @@ -841,8 +847,9 @@ unresolved = None if mergestate.active(): unresolved = sorted(mergestate.unresolved()) + dataitem = repo.ui.config(b'commands', b'status.morestatus-item') return morestatus(repo.root, unfinishedop, unfinishedmsg, - unresolved is not None, unresolved) + unresolved is not None, unresolved, dataitem) def findpossible(cmd, table, strict=False): diff --git a/mercurial/commands.py b/mercurial/commands.py --- a/mercurial/commands.py +++ b/mercurial/commands.py @@ -6884,7 +6884,7 @@ for f in files: fm.startitem() fm.context(ctx=ctx2) - fm.data(path=f) + fm.data(itemtype=b'file', path=f) fm.condwrite(showchar, b'status', b'%s ', char, label=label) fm.plain(fmt % uipathfn(f), label=label) if f in copy: diff --git a/mercurial/configitems.py b/mercurial/configitems.py --- a/mercurial/configitems.py +++ b/mercurial/configitems.py @@ -244,6 +244,9 @@ b'commands', b'show.aliasprefix', default=list, ) coreconfigitem( + b'commands', b'status.morestatus-item', default=False, +) +coreconfigitem( b'commands', b'status.relative', default=False, ) coreconfigitem( diff --git a/tests/test-conflict.t b/tests/test-conflict.t --- a/tests/test-conflict.t +++ b/tests/test-conflict.t @@ -63,16 +63,38 @@ $ hg status -Tjson [ { + "itemtype": "file", "path": "a", "status": "M", "unresolved": true }, { + "itemtype": "file", "path": "a.orig", "status": "?" } ] + $ hg status -Tjson --config commands.status.morestatus-item=1 + [ + { + "itemtype": "file", + "path": "a", + "status": "M", + "unresolved": true + }, + { + "itemtype": "file", + "path": "a.orig", + "status": "?" + }, + { + "itemtype": "morestatus", + "unfinished": "merge", + "unfinishedmsg": "To continue: hg commit\nTo abort: hg merge --abort" + } + ] + $ cat a Small Mathematical Series. 1 diff --git a/tests/test-status.t b/tests/test-status.t --- a/tests/test-status.t +++ b/tests/test-status.t @@ -254,35 +254,43 @@ $ hg status -A -Tjson [ { + "itemtype": "file", "path": "added", "status": "A" }, { + "itemtype": "file", "path": "copied", "source": "modified", "status": "A" }, { + "itemtype": "file", "path": "removed", "status": "R" }, { + "itemtype": "file", "path": "deleted", "status": "!" }, { + "itemtype": "file", "path": "unknown", "status": "?" }, { + "itemtype": "file", "path": "ignored", "status": "I" }, { + "itemtype": "file", "path": ".hgignore", "status": "C" }, { + "itemtype": "file", "path": "modified", "status": "C" } @@ -558,6 +566,7 @@ $ hg status --config ui.formatdebug=True --rev 1 1 status = [ { + 'itemtype': 'file', 'path': '1/2/3/4/5/b.txt', 'status': 'R' },