3
# Copyright (C) 2005 Aaron Bentley
4
# <aaron.bentley@utoronto.ca>
6
# This program is free software; you can redistribute it and/or modify
7
# it under the terms of the GNU General Public License as published by
8
# the Free Software Foundation; either version 2 of the License, or
9
# (at your option) any later version.
11
# This program is distributed in the hope that it will be useful,
12
# but WITHOUT ANY WARRANTY; without even the implied warranty of
13
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
# GNU General Public License for more details.
16
# You should have received a copy of the GNU General Public License
17
# along with this program; if not, write to the Free Software
18
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20
from baz_import import import_version, UserError
26
"""Just the main() function for this script.
28
By separating it into a function, this can be called as a child from some other
31
:param args: The arguments to this script. Essentially sys.argv[1:]
34
parser = optparse.OptionParser(usage='%prog [options] [VERSION] OUTDIR'
35
'\n VERSION is the arch version to import.'
36
'\n OUTDIR can be an existing directory to be updated'
37
'\n or a new directory which will be created from scratch.')
38
parser.add_option('--verbose', action='store_true'
41
parser.add_option('--skip-symlinks', action="store_true",
43
help="Ignore any symlinks present in the Arch tree.")
45
g = optparse.OptionGroup(parser, 'Test options', 'Options useful while testing process.')
46
g.add_option('--test', action='store_true'
47
, help='Run the self-tests and exit.')
48
g.add_option('--dry-run', action='store_true'
49
, help='Do the update, but don\'t copy the result to OUTDIR')
50
g.add_option('--max-count', type='int', metavar='COUNT', default=None
51
, help='At most, add COUNT patches.')
52
g.add_option('--safe', action='store_false', dest='fast')
53
g.add_option('--fast', action='store_true', default=False
54
, help='By default the .bzr control directory will be copied, so that an error'
55
' does not modify the original. --fast allows the directory to be renamed instead.')
56
parser.add_option_group(g)
58
(opts, args) = parser.parse_args(args)
62
import doctest, baz_import
63
nfail, ntests = doctest.testmod(baz_import, verbose=opts.verbose)
69
version,output_dir = args[1]
75
print 'Invalid number of arguments, try --help for more info'
78
output_dir = os.path.realpath(output_dir)
79
if version is not None:
81
version = pybaz.Version(version)
82
except pybaz.errors.NamespaceError:
83
print "%s is not a valid Arch branch." % version
87
import_version(output_dir, version,
88
verbose=opts.verbose, fast=opts.fast,
89
dry_run=opts.dry_run, max_count=opts.max_count,
90
skip_symlinks=opts.skip_symlinks)
95
except KeyboardInterrupt:
101
if __name__ == '__main__':
102
sys.exit(main(sys.argv[1:]))