Allows for hg undo --preview to see smartlog like preview of what undo will do.
This will be neccesery before a general roll-out so users can see what undo will
do. This first iteration only shows what "hg undo" will do, not redo and not
--index.
Details
- Reviewers
stash quark - Group Reviewers
Restricted Project - Commits
- rFBHGX883372ac2468: undo: basic --preview
Diff Detail
- Repository
- rFBHGX Facebook Mercurial Extensions
- Lint
Automatic diff as part of commit; lint not applicable. - Unit
Automatic diff as part of commit; unit tests not applicable.
Event Timeline
So in current implementation hg undo -p prints combined smartlog output of current state and state after undo, right?
I imagined that hg undo --preview would just show only state after undo, but your approach seems better.
As for the tests:
I've added
> [templatealias] > undopreview = '{if(undonecommits, "Undone")}' > EOF
to the $HGRCPATH and then ran
$ hg undo -p + @ Undone + | + o + | + o + | + o + | + o + | + | o + |/ + o + | + o + | + | o + |/ + o + | + o +
So this is basically what you've already done but with actually testing hg undo -p, not hg log.
Using this you can test all of your templates.
hgext3rd/undo.py | ||
---|---|---|
446–447 | BTW, in https://phab.mercurial-scm.org/D184 @quark suggested to use 'if{revset...}' instead of templates. Have you considered it? I'm not saying this is necessarily better, just want to make sure you've considered this option too. |
Thats a creative way to test this. Awesome, thank you!
hgext3rd/undo.py | ||
---|---|---|
446–447 | That seems like a cool approach. I hadn't considered it, I'll look into what the pros and cons are. |
I think undo --preview should not depend on smartlog. So users do not need smartlog enabled to use undo preview.
hg smartlog is basically (although there are some minor differences):
hg log -G -T '{sl}' -r 'ancestor(master, draft())+draft()'
What we need here are:
- a revset selecting commits to show
- a template to beautify the output
Thinking about external users, the best practice is to make the above config options (ex. undo.preview.revset, undo.preview.template) and provide a minimal default.
We can define local (only available in undo command) revsets (see 4672db164) like UNDODEL, UNDOADD which contains commits to hide and unhide. A default undo.preview.revset could be UNDODEL + UNDOADD + ancestor(UNDODEL+UNDOADD). Internally we can customize it so it also includes remote/master.
The template could be something like {if(revset("{rev} and UNDODEL"), "-")}{if(revset("{rev} and UNDOADD"), "+")} {node|shortest} {author|emailuser} {desc|firstline} {bookmarks...}. It does not need to have colors. Internally we can customize it to fit the smartlog style.
hgext3rd/undo.py | ||
---|---|---|
416 | This has issues:
| |
905 | This is a no-op. You might want repo = repo.filtered('visible'). With the change I proposed, it seems we don't need to change the filter here. |
{if(revset("{rev} and UNDODEL"), "-")} type stuff is on the facebook.rc side, so there isn't much to address about it here. The revsets/templates to do it exist and I've tested it.
hgext3rd/undo.py | ||
---|---|---|
427 | It's still the (relative) last command. In 207 we just lie about what the last command is. Which really means I should fix 207. |
Be sure to remove smartlog config before landing.
hgext3rd/undo.py | ||
---|---|---|
457 | I see this is a global state on filesystem. Per discussion we could make it better - move the global state from filesystem to ui, as demostrated by P57852191. Let's do that in a follow-up. | |
892 | I didn't see the definition of undopreview template. Maybe provide a fallback in the code. That could be a follow up. |
This has issues: