diff options
author | mcrute <devnull@localhost> | 2011-02-24 00:11:42 -0500 |
---|---|---|
committer | mcrute <devnull@localhost> | 2011-02-24 00:11:42 -0500 |
commit | 82aaff86a5aefbadc0e520949976ec11e312d2b6 (patch) | |
tree | 660a6a2ef9dabc1bb25959b048cde435a8f175c8 /lock-repo.py | |
download | hg_hosting-82aaff86a5aefbadc0e520949976ec11e312d2b6.tar.bz2 hg_hosting-82aaff86a5aefbadc0e520949976ec11e312d2b6.tar.xz hg_hosting-82aaff86a5aefbadc0e520949976ec11e312d2b6.zip |
Initial import
Diffstat (limited to 'lock-repo.py')
-rwxr-xr-x | lock-repo.py | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/lock-repo.py b/lock-repo.py new file mode 100755 index 0000000..f651d3a --- /dev/null +++ b/lock-repo.py | |||
@@ -0,0 +1,37 @@ | |||
1 | #!/usr/bin/env python | ||
2 | # vim: set filencoding=utf8 | ||
3 | """ | ||
4 | Mercurial Shared SSH Repo Lock Script | ||
5 | |||
6 | @author: Mike Crute (mcrute@gmail.com) | ||
7 | @organization: SoftGroup Hosting | ||
8 | @date: February 23, 2011 | ||
9 | """ | ||
10 | |||
11 | import os | ||
12 | import repolib | ||
13 | |||
14 | def main(argv): | ||
15 | log = repolib.get_logger('validate-login') | ||
16 | |||
17 | if ('SSH_HG_REPO' not in os.environ or | ||
18 | 'SSH_HG_USER' not in os.environ): | ||
19 | log.error("Failed to execute pre-lock checks") | ||
20 | return 1 | ||
21 | |||
22 | try: | ||
23 | repo = repolib.Repository(os.environ['SSH_HG_REPO']) | ||
24 | repo.load_from_hgrc() | ||
25 | except IOError: | ||
26 | log.error("Could not load repository config") | ||
27 | return 1 | ||
28 | |||
29 | if not repo.can_be_written_by(os.environ['SSH_HG_USER']): | ||
30 | log.error("You can not write to this repository") | ||
31 | return 1 | ||
32 | |||
33 | return 0 | ||
34 | |||
35 | if __name__ == "__main__": | ||
36 | import sys | ||
37 | sys.exit(main(sys.argv[1:])) | ||