1 # Copyright (C) 2005-2009 Aaron Bentley and Panometrics, Inc.
2 # W. Trevor King <wking@drexel.edu>
3 # <abentley@panoramicfeedback.com>
5 # This program is free software; you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; either version 2 of the License, or
8 # (at your option) any later version.
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
15 # You should have received a copy of the GNU General Public License
16 # along with this program; if not, write to the Free Software
17 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 """Assign the root directory for bug tracking"""
20 from libbe import cmdutil, bugdir
23 def execute(args, test=False):
25 >>> from libbe import utility, rcs
27 >>> dir = utility.Dir()
29 ... bugdir.BugDir(dir.path)
30 ... except bugdir.NoBugDir, e:
33 >>> execute([dir.path], test=True)
34 No revision control detected.
35 Directory initialized.
38 >>> dir = utility.Dir()
39 >>> os.chdir(dir.path)
40 >>> rcs = rcs.installed_rcs()
44 >>> execute([], test=True)
45 Using Arch for revision control.
46 Directory initialized.
50 ... execute(['.'], test=True)
51 ... except cmdutil.UserError, e:
52 ... str(e).startswith("Directory already initialized: ")
54 >>> execute(['/highly-unlikely-to-exist'], test=True)
55 Traceback (most recent call last):
56 UserError: No such directory: /highly-unlikely-to-exist
60 options, args = parser.parse_args(args)
61 cmdutil.default_complete(options, args, parser)
63 raise cmdutil.UsageError
69 bd = bugdir.BugDir(basedir, from_disk=False, sink_to_existing_root=False, assert_new_BugDir=True,
70 manipulate_encodings=not test)
71 except bugdir.NoRootEntry:
72 raise cmdutil.UserError("No such directory: %s" % basedir)
73 except bugdir.AlreadyInitialized:
74 raise cmdutil.UserError("Directory already initialized: %s" % basedir)
76 if bd.rcs.name is not "None":
77 print "Using %s for revision control." % bd.rcs.name
79 print "No revision control detected."
80 print "Directory initialized."
83 parser = cmdutil.CmdOptionParser("be init [DIRECTORY]")
87 This command initializes Bugs Everywhere support for the specified directory
88 and all its subdirectories. It will auto-detect any supported revision control
89 system. You can use "be set rcs_name" to change the rcs being used.
91 The directory defaults to your current working directory.
93 It is usually a good idea to put the Bugs Everywhere root at the source code
94 root, but you can put it anywhere. If you run "be init" in a subdirectory,
95 then only bugs created in that subdirectory (and its children) will appear
100 return get_parser().help_str() + longhelp