~abentley/bzrtools/bzrtools.dev

« back to all changes in this revision

Viewing changes to baz_import.py

Merge from Aaron.

Show diffs side-by-side

added added

removed removed

Lines of Context:
273
273
        # the current version is
274
274
        branch = Branch.open(output_dir)
275
275
        last_patch = get_last_revision(branch)
 
276
        if last_patch is None:
 
277
            raise NotPreviousImport(branch.base)
276
278
        if version is None:
277
279
            version = last_patch.version
278
280
    elif version is None:
346
348
    >>> def printer(message): print message
347
349
    >>> import_version('/', version, printer, fancy=False, dry_run=True)
348
350
    Traceback (most recent call last):
349
 
    UserError: / exists, but is not a bzr branch.
 
351
    NotPreviousImport: / is not the location of a previous import.
350
352
    >>> import_version(result_path, version, printer, fancy=False, dry_run=True)
351
353
    Traceback (most recent call last):
352
354
    UserError: The version test@example.com/test--test--0.1 does not exist.
375
377
        ancestors, old_revno = get_remaining_revisions(output_dir, version,
376
378
                                                       reuse_history_from)
377
379
    except NotBranchError, e:
378
 
        raise UserError("%s exists, but is not a bzr branch." % output_dir)
 
380
        raise NotPreviousImport(e.path)
379
381
    if old_revno is None and len(ancestors) == 0:
380
382
        print 'Version %s has no revisions.' % version
381
383
        return
451
453
        """
452
454
        BzrCommandError.__init__(self, message)
453
455
 
 
456
class NotPreviousImport(UserError):
 
457
    def __init__(self, path):
 
458
        UserError.__init__(self, "%s is not the location of a previous import."
 
459
                           % path)
 
460
 
 
461
 
454
462
def revision_id(arch_revision):
455
463
    """
456
464
    Generate a Bzr revision id from an Arch revision id.  'x' in the id
701
709
        if reuse_history_list is None:
702
710
            reuse_history_list = []
703
711
        import_version(to_location, from_branch, self.printer, 
704
 
                       max_count=max_count, reuse_history_from=reuse_history_list)
 
712
                       max_count=max_count, 
 
713
                       reuse_history_from=reuse_history_list)
 
714
 
 
715
 
 
716
class NotInABranch(Exception):
 
717
    def __init__(self, path):
 
718
        Exception.__init__(self, "%s is not in a branch." % path)
 
719
        self.path = path
705
720
 
706
721
 
707
722
class cmd_baz_import(Command):