| 1 | #!/usr/bin/env python |
|---|
| 2 | # -*- coding: utf-8 -*- |
|---|
| 3 | # |
|---|
| 4 | # Copyright (c) 2008 the NxOS developers |
|---|
| 5 | # |
|---|
| 6 | # See AUTHORS for a full list of the developers. |
|---|
| 7 | # |
|---|
| 8 | # Redistribution of this file is permitted under |
|---|
| 9 | # the terms of the GNU Public License (GPL) version 2. |
|---|
| 10 | # |
|---|
| 11 | # Sets up a freshly cloned repository with a few useful things. |
|---|
| 12 | |
|---|
| 13 | import os |
|---|
| 14 | import sys |
|---|
| 15 | import ConfigParser |
|---|
| 16 | |
|---|
| 17 | REPOS_URL='https://ssl.natulte.net/nxos/%s' |
|---|
| 18 | |
|---|
| 19 | def main(): |
|---|
| 20 | if not os.path.isdir('.hg'): |
|---|
| 21 | print 'Please run from the root of your repository.' |
|---|
| 22 | return 1 |
|---|
| 23 | |
|---|
| 24 | conf = ConfigParser.SafeConfigParser() |
|---|
| 25 | conf.read('.hg/hgrc') |
|---|
| 26 | |
|---|
| 27 | # Add shorthands for the mainstream repo, as well as all crew |
|---|
| 28 | # repos. |
|---|
| 29 | if not conf.has_section('paths'): |
|---|
| 30 | conf.add_section('paths') |
|---|
| 31 | conf.set('paths', 'devel', REPOS_URL % 'devel') |
|---|
| 32 | for crew in ('alexandre', 'dave', 'fleurda', 'jflesch', 'sam', 'sarah'): |
|---|
| 33 | conf.set('paths', crew, REPOS_URL % 'crew/'+crew) |
|---|
| 34 | |
|---|
| 35 | # Add a pre-commit hook that checks for insertion of trailing |
|---|
| 36 | # whitespace, and another to validate copyrights. |
|---|
| 37 | if not conf.has_section('hooks'): |
|---|
| 38 | conf.add_section('hooks') |
|---|
| 39 | conf.set('hooks', 'pretxncommit.whitespace', |
|---|
| 40 | 'hg export tip | ./scripts/trailing_whitespace_report.py') |
|---|
| 41 | conf.set('hooks', 'pretxncommit.copyright', |
|---|
| 42 | 'hg export tip | ./scripts/copyright_report.py') |
|---|
| 43 | conf.set('hooks', 'pretxncommit.metadata', './scripts/metadata_report.sh') |
|---|
| 44 | |
|---|
| 45 | conf.write(open('.hg/hgrc', 'w')) |
|---|
| 46 | |
|---|
| 47 | return 0 |
|---|
| 48 | |
|---|
| 49 | if __name__ == '__main__': |
|---|
| 50 | sys.exit(main()) |
|---|