File Locking
Sean Russell
ser at ser1.net
Thu Oct 16 08:13:20 UTC 2008
On Thursday 09 October 2008 11:10:14 Clark Hwang wrote:
> Clark Hwang wrote:
> > Hi, I'm trying to convince my office to go with Mercurial instead of
> > Subversion. One of the requirement will be to have the ability to
> > lock files so another user would not be able to check it out. Is it
> > possible to implement file locking with Mercurial? Are there sample
> > hooks are there?
> >
> > Thanks in advance.
>
> There are a number of ways that you could prevent somebody from
> modifying a given file... but not checking out the file in the first
> place is tricky. I am actually somewhat surprised that SVN could do that.
SVN can't. 'svn lock' prevents commits code, but not checkouts. I suspect
that's what OP was asking. SVN does allow limiting R/W access to specific
paths in a repository through svnaccess, but that's much more static than svn
lock.
> If you can't change the layout at all, then things become much much
> harder. You can't leave the protected files out of the normal
> changesets or nobody could access them. You can't use permissions to
> block one file since it's part of a changeset that must be pulled along
> with the rest.
On the other hand, clever use of the 'incoming' hook could reject any commit
modifying a "locked" file. They'd probably need to write an extension to make
locking less painful, but it could be accomplished without one.
There is one valid use case for locking (IMHO): editing binary files, such as
images. They aren't easy to merge, so it is more practical to say "if you're
going to change this icon, lock it to avoid edit conflicts."
--- SER
More information about the Mercurial
mailing list