Rev 299: Use Option() magic. in http://people.samba.org/bzr/jelmer/bzr-svn/bzr.dev

Jelmer Vernooij jelmer at samba.org
Tue Dec 26 00:51:26 GMT 2006


------------------------------------------------------------
revno: 299
revision-id: jelmer at samba.org-20061226005109-o98yfqhsc113z0vq
parent: jelmer at samba.org-20061226004354-6ky4mphocf8qe6cp
committer: Jelmer Vernooij <jelmer at samba.org>
branch nick: main
timestamp: Tue 2006-12-26 01:51:09 +0100
message:
  Use Option() magic.
modified:
  __init__.py                    __init__.py-20051008155114-eae558e6cf149e1d
=== modified file '__init__.py'
--- a/__init__.py	2006-12-26 00:43:54 +0000
+++ b/__init__.py	2006-12-26 00:51:09 +0000
@@ -97,6 +97,18 @@
 
 from bzrlib.commands import Command, register_command, display_command, Option
 
+
+def get_scheme(schemename):
+    """Parse scheme identifier and return a branching scheme."""
+    from scheme import BranchingScheme
+    from bzrlib.errors import BzrCommandError
+    
+    ret = BranchingScheme.find_scheme(schemename)
+    if ret is None:
+        raise BzrCommandError('No such branching scheme %r' % schemename)
+    return ret
+
+
 class cmd_svn_import(Command):
     """Convert a Subversion repository to a Bazaar repository.
     
@@ -104,19 +116,14 @@
     takes_args = ['url', 'output_dir']
     takes_options = [Option('trees', help='Create working trees'),
                      Option('shared', help='Create shared repository'),
-                     Option('scheme', help='Branching scheme (none, trunk, or trunk-INT)')]
+                     Option('scheme', type=get_scheme,
+                         help='Branching scheme (none, trunk, or trunk-INT)')]
 
     @display_command
     def run(self, url, output_dir, trees=False, shared=False, scheme="trunk"):
         from convert import convert_repository
-        from scheme import BranchingScheme
-
-        scheme_ = BranchingScheme.find_scheme(scheme)
-        if scheme_ is None:
-            raise BzrError('No such branching scheme %r' % scheme)
-
-        convert_repository(url, output_dir, scheme_, shared, 
-                           trees)
+
+        convert_repository(url, output_dir, scheme_, shared, trees)
 
 
 register_command(cmd_svn_import)




More information about the bazaar-commits mailing list