Closed Bug 796513 Opened 12 years ago Closed 12 years ago

exiting editor should abort

Categories

(Developer Services :: Mercurial: bzexport, defect)

defect
Not set
normal

Tracking

(Not tracked)

RESOLVED FIXED

People

(Reporter: sfink, Assigned: sfink)

Details

Attachments

(1 file)

It would be very convenient if you exited without modifying anything that it would abort the operation. This might be a little weird if you fill in everything necessary using the command line, and just -e as a spot-check.
njn requested this on irc.

(so I filed with:

% hg newbug -C bzexport 'exiting editor should abort' 'It would be very convenient if you exited without modifying anything that it would abort the operation. This might be a little weird if you fill in everything necessary using the command line, and just -e as a spot-check.'

)

:-)
This is what |hg commit| does, for example.  Strictly speaking, it's not just "without modifying anything", but rather "force exit without saving changes".  E.g. |:q!| in vim.
(In reply to Nicholas Nethercote [:njn] from comment #2)
> This is what |hg commit| does, for example.

Right, but that works by creating a temporary file with just the HG: comments, and then checking whether you filled in a comment. So an exit without filling anything in is detectable, regardless of the exact mechanism for exiting.

With bzexport, you could provide everything via the command line, and if you exit without modifying anything, it's ambiguous whether you mean to accept it unchanged or abort.

> Strictly speaking, it's not
> just "without modifying anything", but rather "force exit without saving
> changes".  E.g. |:q!| in vim.

I can't detect that. It produces a status code of zero (success). I could detect it if it were creating a new file (because then I could check whether the file exists), but then I couldn't seed it with anything. Seeding it without creating the file initially could be done, but it would be editor-specific, and that way lies madness.

I could add a dummy "Commit:" or "Accept:" header that you have to set to 'yes' if there aren't any required fields to fill in, but that seems clunky.

Modification time doesn't help.

Hm. Since most of the time you won't be providing everything on the command line, maybe I should just prompt "Continue/abort?" in the unchanged case. That seems reasonable.
Ok, this isn't optimal, but it at least prevents accidents from doing :q! and having bzexport continue on and post anyway.

This just throws in a prompt whenever you exit the editor without changing anything (either from killing the editor, aborting, or just exiting without typing). It skips the one easy case where it knows there'll be a prompt anyway. There are other cases, but the control flow makes them trickier to catch, so I'm not bothering for now.

Part of the problem is that if you don't fill everything in via the edited form, bzexport will prompt you for the missing values. It is possible that that just isn't all that helpful, in which case I could remove that functionality when you use -e, and this change check would be more likely to be accurate.
Attachment #667089 - Flags: review?(josh)
Assignee: nobody → sphink
Comment on attachment 667089 [details] [diff] [review]
Allow canceling if user did not make any edits

The |import sys| is placed oddly.
Attachment #667089 - Flags: review?(josh) → review+
Status: NEW → RESOLVED
Closed: 12 years ago
Resolution: --- → FIXED
Product: Other Applications → Developer Services
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: