Locks and transactions for dummies

Greg Ward greg-hg at gerg.ca
Mon Jul 20 19:27:23 CDT 2009

Hi all --

I'm plugging away at adding a new Mercurial backend to cvs2svn,
creating a real cvs2hg in the process.  Since this is my first attempt
to write to a repo, I have all sorts of beginner questions about locks
and transactions.  Reading the code is somewhat helpful, but not
helpful enough.  ("How?" is not the same as "Why?".)  I've searched
the wiki and am not turning up much.

So: have I missed something?  Here are my main questions right now, to
give you an idea of what's stumping me.

1) How do you commit a transaction?  I've copied the "finally: del tr"
pattern from localrepository.addchangegroup(), so every transaction is
successfully aborted.  Great.  Now what if there was no error and I
want to commit it?

2) How many transactions should I have?  I could do one giant
transaction for the whole cvs->hg conversion, or one per changeset.
Which is better and why?

3) Presumably I need to do locking: don't want anyone committing to my
conversion target while the conversion is running.  But how many
locks, i.e. one for the whole conversion or one per changeset?  And
what's the difference between repo.lock() and repo.wlock(), anyways?

Thanks --


More information about the Mercurial-devel mailing list