Add vcs-load-dirs project to thirdparty directory.
[Melange.git] / thirdparty / vcs-load-dirs / vcs_support / init.py
blobdd62fd29ce82bef5479482662115effc990c2195
1 # Copyright (C) 2003-2007 John Goerzen
2 # <jgoerzen@complete.org>
4 # This program is free software; you can redistribute it and/or modify
5 # it under the terms of the GNU General Public License as published by
6 # the Free Software Foundation; either version 2 of the License, or
7 # (at your option) any later version.
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
14 # You should have received a copy of the GNU General Public License
15 # along with this program; if not, write to the Free Software
16 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 from optparse import OptionParser
20 from vcs_support import util, commandver
21 import sys
23 def run(darcsdefault):
24 version = '1.1.4'
26 parser = OptionParser(usage="usage: %prog [options] vendor_source_dir",
27 version=version)
28 parser.add_option("-w", "--wc", dest="wc", default=".",
29 help="Set working copy to WC (defaults to current directory)", metavar="WC")
30 parser.add_option("-l", "--log", dest="changelog", metavar="FILE", default=None,
31 help="Get changelog text from FILE")
32 parser.add_option("-L", "--log-message", dest="logtext", metavar="TEXT",
33 default='', help="Log with TEXT")
34 parser.add_option("-s", "--summary", dest="summary", metavar="MSG",
35 default=None, help="Set log summary message to MSG, overriding the default")
36 parser.add_option("-v", "--verbose", action="store_true", dest="verbose",
37 default=False, help="Show more status information")
38 parser.add_option("-f", "--fs-changes-only", action="store_true",
39 dest="fsonly", default=False,
40 help="Disable interactivity and issue no add/rm/mv commands to VCS, use with -n")
41 parser.add_option("-n", "--no-commit", action="store_false", dest="docommit",
42 default=True, help="Do not commit the changes.")
44 (options, args) = parser.parse_args()
45 util.verbose = options.verbose
47 log = options.logtext + "\n"
48 if options.changelog:
49 fd = open(options.changelog, "r")
50 log += fd.read()
51 fd.close()
53 if len(args) != 1:
54 parser.error("Failed to specify a path to import.")
56 commandver.setscm(darcsdefault)
58 from vcs_support import vcs_wc, vcs_interact
60 wc = vcs_wc.wc(options.wc, verbose = options.verbose,
61 fsonly = options.fsonly)
62 if not wc.gettaggingmethod() in ['explicit', 'tagline']:
63 print "Working directory uses unsupported tagging method %s" % \
64 wc.gettaggingmethod()
65 sys.exit(1)
68 iobj = vcs_interact.interaction(wc, args[0], options.docommit, log = log,
69 verbose = options.verbose,
70 summary = options.summary)
71 try:
72 iobj.main()
73 finally:
74 iobj.cleanup()