~abentley/bzrtools/bzrtools.dev

« back to all changes in this revision

Viewing changes to baz_import.py

  • Committer: Aaron Bentley
  • Date: 2005-10-06 18:37:16 UTC
  • mto: (147.2.17)
  • mto: This revision was merged to the branch mainline in revision 324.
  • Revision ID: abentley@panoramicfeedback.com-20051006183716-334d1a75d9da732d
Improved error handling, esp when invoking on wrong branch

Show diffs side-by-side

added added

removed removed

Lines of Context:
14
14
# along with this program; if not, write to the Free Software
15
15
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
16
16
 
17
 
from bzrlib.errors import NotBranchError
 
17
from bzrlib.errors import NotBranchError, BzrCommandError
18
18
from bzrlib.branch import Branch
19
19
from bzrlib.commit import Commit, NullCommitReporter
20
 
from bzrlib.commands import Command
 
20
from bzrlib.commands import Command, OPTIONS
21
21
from errors import NoPyBaz
22
22
try:
23
23
    import pybaz
233
233
    except NotArchRevision:
234
234
        raise UserError(
235
235
            "Directory \"%s\" already exists, and the last revision is not"
236
 
            " an Arch revision (%s)" % (output_dir, last_patch))
 
236
            " an Arch revision (%s)" % (branch.base, last_patch))
237
237
 
238
238
 
239
239
def get_remaining_revisions(output_dir, version):
366
366
        shutil.rmtree(tempdir)
367
367
    printer("Import complete.")
368
368
            
369
 
class UserError(Exception):
 
369
class UserError(BzrCommandError):
370
370
    def __init__(self, message):
371
371
        """Exception to throw when a user makes an impossible request
372
372
        :param message: The message to emit when printing this exception
373
373
        :type message: string
374
374
        """
375
 
        Exception.__init__(self, message)
 
375
        BzrCommandError.__init__(self, message)
376
376
 
377
377
def revision_id(arch_revision):
378
378
    """
593
593
    bzr_inv.sort()
594
594
    return bzr_inv
595
595
 
596
 
 
 
596
OPTIONS['max-count'] = int
597
597
class cmd_baz_import_branch(Command):
598
598
    """Import an Arch or Baz branch into a bzr branch"""
599
599
    takes_args = ['to_location', 'from_branch?']
600
 
    takes_options = ['verbose']
 
600
    takes_options = ['verbose', 'max-count']
601
601
 
602
602
    def printer(self, name):
603
603
        print name
611
611
            except pybaz.errors.NamespaceError:
612
612
                print "%s is not a valid Arch branch." % from_branch
613
613
                return 1
614
 
        import_version(to_location, from_branch, self.printer)
 
614
        import_version(to_location, from_branch, self.printer, 
 
615
                       max_count=max_count)
615
616
 
616
617
 
617
618
class cmd_baz_import(Command):