Bitbucket is a code hosting site with unlimited public and private repositories. We're also free for small teams!

Close

# Copyright 2012 Vladimir Legeza <vladimir.legeza@gmail.com> # # This software may be used and distributed according to the terms # of the GNU General Public License, incorporated herein by reference.

HgLock-LE - is the extension for SCM Mercurial that allow users to
inform each other in case of parallel file modification in one local repository.
REASONS:

LE in ext. name means "Local (Extension)". "Local" because we have anothe project with the similar name that store locks on a remote server.

https://bitbucket.org/aragost/hglock

"Extension" because originally, functionality of this extension was implemented as a bash script in late 2008 that still available at

https://github.com/legeza/HgLock

Current version was born in early 2012 during the process of learning python programming.

Some times developers, especially web developers, perform code modification directly in place where this code is working. And usually they like to do it much more then get their own copy from repo, edit, put changes back and update working instance. And this extension was developed especially for these guys.

Another example of extension usage is that sume you are a SysAdmin and you didn't got enought servers to deploy and use such systems like 'cfengine' and 'puppet' but you'd like to supervise you configuration files in the same strong way without making large amount of garbled files like:

cf.conf cf.conf.bak cf.conf.old

Dozens or even hundreds of such files can be replaced my one SCM which will trace all changes and versions (especially when change related to several files).

HgLock-LE - is the tool that will help you to not to loose your changes in case of some one else is able to edit the same bunch of files in the same time (and hence avoid possible service downtime).

INSTALL:

To enable extension you need to add following line into "extension" section of preferred hgrc file:

[extensions] hglock = /path/to/hglock.py

Also, if you would like to send email notifications about breaking locks you need to configure "email" section. As minimal configuration you may use these two lines:

[email] method = /usr/sbin/sendmail

and set environment 'EMAIL' variable. (Should be compatible with RFC 2822) Example:

$ EMAIL="Vladimir Legeza <vladimir.legeza@gmail.com>" $ export EMAIL

it will use sendmail to inform your colleague in case you break his or her locks (use -f option to do so). Also possible to send emails directly to server over SMTP. See additional information about this in Mercurial documentation.

USAGE:
Set lock:

$ hg lock [-v] <file ...>

If no file specified, the list of already locked files and lock owners will displayed.
-v Will display a bit more information then usual.
Release Lock:

$ hg unlock [-f] [-v] <file ...>

If no file specified, unlock would try to relaes all availble locks.
-f Force unlock. Allows you to break others locks. Owner will be notified about this.
-v Will display a bit more information then usual.
HOOKS:

HgLock-LE performs some sort of automation: When you add a file to repository, it will be locked automaticaly. and after commit locked files will be automaticaly released.

If you prefer to do all the tasks manually, just comment out these tree lines in hglock.py file (on the buttom).

def uisetup(ui):
ui.setconfig("hooks", "post-add.hglock", lock) ui.setconfig("hooks", "pre-commit.hglock", unlock)

Recent activity

qwe

Commits by qwe were pushed to legeza/HgLock-LE

072ee55 - Remove: Unnecessary part from the hook handler that cause a problems with partial commit of added files (not all at once).
root

Commits by root were pushed to legeza/HgLock-LE

cb39d39 - Fix: cover dispatching way changes (regardless version number)
legeza

Commits by legeza were pushed to legeza/HgLock-LE

4e601c6 - Fix: Do not try to poceed post-add hook if add was failed. Add: Work with wildcards in post-add hook.
legeza

Commits by legeza were pushed to legeza/HgLock-LE

65e220b - Change: Hook handlers a reoganized Fix: Locking over the hook if repository is located in a filesystem root.
legeza

Commits by legeza were pushed to legeza/HgLock-LE

bd00ae3 - Add: Handler erros in case a file is outside the repo. Add: Example of hglock.rc .
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.