Proposal: backup hook, trash, and multiple undo

Matt Mackall mpm at selenic.com
Mon Jun 7 09:23:43 CDT 2010


Jens' mention of the OS X trash can got me thinking about how we'd
implement such a thing, and here's what I came up with:

Backup hook:

A standard hook called "backup" that gets called whenever a destructive
operation gets called. It operates in a couple different modes:

type=file
operation=rm|update|merge|revert|qdelete|...
path=/path/to/file/being/clobbered

type=bundle
operation=strip|rebase|...
path=/path/to/bundle/being/stripped

type=dirstate
operation=...
path=/path/to/dirstate/being/changed

Trash extension:

To implement trash can support, we simply need to make a trash.py
extension that hooks into the type=file operation and moves the file to
an operating system-appropriate directory (or whatever directory is
configured in hgrc).

Undo extension:

A second extension that also hooks into backup and tracks all three
types in .hg/undo/. It records a log of commands so a user can see what
operation an undo is going to back out with undo -l. There's a lot more
to undo than simply copying/unbundling the files, but all the necessary
data is saved.

(Volunteers needed.)

-- 
Mathematics is the supreme nostalgia of our time.




More information about the Mercurial-devel mailing list