Multiple undo again...

Jason Harris jason at jasonfharris.com
Fri Jun 4 08:24:42 CDT 2010


Hi All,

I'll raise this issue again since Martin asked about it indirectly... Ie why does MacHg have its own copy of Mercurial.

Basically I want to be able to roll back multiple steps when doing something dangerous, eg some mq operations, histedit operations, etc... Multiple undo and redo is eg listed under "Caracteristics of great software in the Apple human interface guidelines." It should be supported in MacHg.

In fact I often before doing something dangerous have learnt to clone my repository. This leads to a proliferation of junk repositories which I have just cloned "just in case" something goes wrong with me editing history, or reordering the commits before pushing them. In fact I regularly go through and delete these junk repositories... Usually when I hit 9 of them... eg MacHgClone1, MacHgClone2, MacHgClone3, ... MacHgClone9, then go through and delete these safety clones. 

My model of working, is work away on something, then I see some email about some issue or something then wonder, ohh yeah I go off and look at it, and before I realize it I have played with some changes and maybe fixed it or done something to fix it. I realize I didn't first clone the repository or anything, and now I am sitting on a repository with changes which shouldn't be committed and then on top of those I have changes which should be committed. So I simply want to reorder my local changes and push the good changes and keep going... hence histedit, and hence the proliferation of junk clones "just in case".

Now of course one might say "just be careful" when you do changes like reordering changesets, collapsing them etc. But the thing is, I *don't* want to be careful. I am likely thinking about a zillion other things and I am using MacHg or Mercurial on "auto-pilot" I want to do my changes and get back to what I was working on...  A good system should be forgiving and so allow me to mess up and recover if I did mess up. Hopefully this is enough motivation to see why one wants multiple undo and redo in a system.

I think multiple undo should be part of core Mercurial. It would make for a smoother user experience.

Until such time as multiple undo is part of core Mercurial I have to work around this in MacHg, Previously I posted: http://www.selenic.com/pipermail/mercurial/2010-May/032348.html as a way to do this. However MacHg is multi threaded so making sure all the threads which are accessing the .hg directory are finished before issuing the command to switch the .hg directory out for a .hgbackup meta data directory is problematic. Instead I wondered about the possibility of changing Mercurial so there is an environment variable HGDIRNAME which could specify the name of the '.hg' directory. ie I could rung

export HGDIRNAME='.hgbackup'

hg init
hg addremove
hg status

etc... 

and all these commands would work with the meta-data directory being named '.hgbackup' instead of '.hg' I made these changes (about 20 or so) to the 1.4.2 sources and they seemed fine in testing them. I am about to do this for the 1.5.4 sources. basically I introduce in util.py:

def hgdirname():
    """return name of the .hg directory which is used to store the repository meta-data.

    Defaults to '.hg'.
    """
    if 'HGDIRNAME' in os.environ:
        return os.environ['HGDIRNAME']
    return ".hg"

and then where-ever I see '.hg' or ".hg" in the sources I replace this with util.hgdirname()

I doubt this will be done for core Mercurial.  I am of course more than happy to send my changes along but from what I am guessing core Mercurial would not want this addition.  Also some of the guru's would have to look this over, since for me most of the time I would just be setting this environment variable to '.hgbackup' for a few commands, eg 'init', 'addremove', 'update', 'commit', and 'status'. Which is all I need in MacHg for the backup to do multiple undo's.

But anyway to get back to Martins original point... I need the Mercurial in MacHg to be modified by these changes. Multiple undo is part of making "great" software and I want it myself. There are other changes which might be necessary in the future as well. I publish these changes to a fork on bitbucket so everyone can see them copy them / work with them.

Cheers,
  Jas


More information about the Mercurial-devel mailing list