mercurialtortoisehghgsubversion

Pushing and pulling with hgsubversion without manual shelve step


I'm using TortoiseHg with an SVN repository using the hgsubversion extension.

I like to use hg pull --rebase when I pull, to mirror what SVN does on svn update. Because I'm using hgsubversion, I will need to rebase anyway before I push, so I may as well do it in one step.

Additionally, hg push will automatically do a rebase internally, there is no way around that.

My difficulty is that hg rebase will refuse to work if I have any uncommitted changes. So to push or pull from SVN I always need to hg shelve first and then remember to do hg unshelve after. This can get really annoying and I always forget.

Ideally I'd like to tell TortoiseHg to do this for me automatically, but I'd settle for a command-line alias. I tried putting an alias like svnpull = !hg shelve && hg pull --rebase && hg unshelve in my config as suggested here but I get an error "user: abort: response expected" instead of being asked for my password. What can I do to avoid manually shelve/unshelve steps every time I interact with the central repository?

I can't actually commit my changes locally and just avoid pushing the local change, because hgsubversion doesn't respect the secret phase and hgsubversion doesn't support designating a revision to push. So unfortunately none of the answers to this similar question will work for me. And anyway I'd need manual steps to arrange for my "local only" changeset to always be on the tip.


Solution

  • The solution was to use repository hooks. I added this to my .hg/hgrc config file:

    [hooks]
    pre-pull = hg shelve
    post-pull = hg unshelve
    pre-push = hg shelve
    post-push = hg unshelve