1 # Copyright (C) 2005-2009 Aaron Bentley and Panometrics, Inc.
2 # Gianluca Montecchi <gian@grys.it>
3 # W. Trevor King <wking@drexel.edu>
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 along
16 # with this program; if not, write to the Free Software Foundation, Inc.,
17 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
26 class Init (libbe.command.Command):
27 """Create an on-disk bug repository
30 >>> import libbe.storage.vcs
31 >>> import libbe.storage.vcs.base
32 >>> import libbe.util.utility
34 >>> cmd._setup_io = lambda i_enc,o_enc : None
35 >>> cmd.stdout = sys.stdout
37 >>> dir = libbe.util.utility.Dir()
38 >>> vcs = libbe.storage.vcs.vcs_by_name('None')
39 >>> vcs.repo = dir.path
42 ... except libbe.storage.ConnectionError:
46 No revision control detected.
47 BE repository initialized.
48 >>> bd = libbe.bugdir.BugDir(vcs)
53 >>> dir = libbe.util.utility.Dir()
54 >>> vcs = libbe.storage.vcs.installed_vcs()
55 >>> vcs.repo = dir.path
56 >>> vcs._vcs_init(vcs.repo)
57 >>> if vcs.name in libbe.storage.vcs.base.VCS_ORDER:
58 ... cmd.run(vcs) # doctest: +ELLIPSIS
62 ... print 'Using ... for revision control.\\nDirectory initialized.'
63 Using ... for revision control.
64 BE repository initialized.
71 def __init__(self, *args, **kwargs):
72 libbe.command.Command.__init__(self, *args, **kwargs)
73 self.requires_unconnected_storage = True
75 def _run(self, storage, bugdir=None, **params):
76 if not os.path.isdir(storage.repo):
77 raise libbe.command.UserError(
78 'No such directory: %s' % storage.repo)
81 raise libbe.command.UserError(
82 'Directory already initialized: %s' % storage.repo)
83 except libbe.storage.ConnectionError:
87 bd = libbe.bugdir.BugDir(storage, from_storage=False)
89 if bd.storage.name is not 'None':
90 print >> self.stdout, \
91 'Using %s for revision control.' % storage.name
93 print >> self.stdout, 'No revision control detected.'
94 print >> self.stdout, 'BE repository initialized.'
98 This command initializes Bugs Everywhere support for the specified directory
99 and all its subdirectories. It will auto-detect any supported revision control
100 system. You can use "be set vcs_name" to change the vcs being used.
102 The directory defaults to your current working directory, but you can
103 change that by passing the --repo option to be
104 $ be --repo path/to/new/bug/root init
106 When initialized in a version-controlled directory, BE sinks to the
107 version-control root. In that case, the BE repository will be created
108 under that directory, rather than the current directory or the one
109 passed in --repo. Consider the following tree, versioned in Git.
115 ~$ be --repo ./projectX/src init
116 will create the BE repository rooted in projectX: