This is an archive of the discontinued Mercurial Phabricator instance.

fbhistedit: add support for json input to histedit
ClosedPublic

Authored by pulkit on Oct 28 2017, 7:57 PM.
Tags
None
Subscribers

Details

Reviewers
durham
Group Reviewers
Restricted Project
Commits
rFBHGX75953fa704a2: fbhistedit: add support for json input to histedit
Summary

This patch adds support to histedit command to take input from json. The JSON
should be of following format:

{ "histedit": [

  {"action": "...", "node": "..."},
  {"action": "...", "command": "..."},
  {...}
]

}

For actions except "exec" and "execr", "node" is required and for "exec" and
"execr", "command" should be there.

The support is plugged in directly and is not hidden behind a config flag. After
this support, the parser which parses the commands file will assume that JSON is
given and will fallback to original parsing if it fails to convert the data in
the file to JSON.
In case where input is JSON but a key is missing, status message is shown and we
fallback to normal parsing.

Both small and large verbs are supported for the action part in JSON.

Diff Detail

Repository
rFBHGX Facebook Mercurial Extensions
Lint
Lint Skipped
Unit
Unit Tests Skipped

Event Timeline

pulkit created this revision.Oct 28 2017, 7:57 PM
Herald added a reviewer: Restricted Project. · View Herald TranscriptOct 28 2017, 7:57 PM
durham accepted this revision.Oct 31 2017, 2:43 PM
durham added a subscriber: durham.

Any reason this can't go upstream? Or are we just waiting because of the freeze?

hgext3rd/fbhistedit.py
217

Does histedit require that the node be a certain length? Are 40 character nodes fine? If not, do we need to trim this down to the appropriate length?

This revision is now accepted and ready to land.Oct 31 2017, 2:43 PM
pulkit updated this revision to Diff 3181.Oct 31 2017, 4:06 PM
In D1263#21153, @durham wrote:

Any reason this can't go upstream? Or are we just waiting because of the freeze?

Upstream does not has the exec and execr actions. So, if this goes upstream we need to wrap the parsing function for parsing command part in JSON.

hgext3rd/fbhistedit.py
217

Yes 40 character nodes are fine. I have updates one of the tests to use full hashes.

This revision was automatically updated to reflect the committed changes.