~abentley/bzrtools/bzrtools.dev

« back to all changes in this revision

Viewing changes to baz_import.py

  • Committer: Aaron Bentley
  • Date: 2008-04-10 22:41:55 UTC
  • Revision ID: aaron@aaronbentley.com-20080410224155-wcevbg1c1p4bj8ym
Make patch a nice BzrError

Show diffs side-by-side

added added

removed removed

Lines of Context:
30
30
from bzrlib.commands import Command
31
31
from bzrlib.option import _global_option, Option
32
32
from bzrlib.merge import merge_inner
33
 
from bzrlib.revision import NULL_REVISION
 
33
from bzrlib.revision import NULL_REVISION, is_null
34
34
import bzrlib.ui
35
35
import bzrlib.ui.text
36
36
from bzrlib.workingtree import WorkingTree
42
42
    from pybaz.backends.baz import null_cmd
43
43
except ImportError:
44
44
    raise NoPyBaz
45
 
from fai import iter_new_merges, direct_merges
 
45
from baz_helper import iter_new_merges, direct_merges
46
46
import tempfile
47
47
import os
48
48
import os.path
293
293
        last_patch, last_encoding = get_last_revision(branch)
294
294
        assert encoding == last_encoding
295
295
        if last_patch is None:
296
 
            if branch.last_revision() != None:
 
296
            if not is_null(branch.last_revision()):
297
297
                raise NotPreviousImport(branch.base)
298
298
        elif version is None:
299
299
            version = last_patch.version
449
449
            if wt is not None:
450
450
                wt.set_last_revision(wt.branch.last_revision())
451
451
                wt.set_root_id(BAZ_IMPORT_ROOT)
452
 
                wt.revert([])
 
452
                wt.revert()
453
453
 
454
454
        finally:
455
455
 
514
514
    'None'
515
515
    >>> str(arch_revision("Arch-1-utf-8:jrandom@example.com%test--test--0--patch-5")[1])
516
516
    'utf-8'
 
517
    >>> str(arch_revision('null:'))
 
518
    '(None, None)'
517
519
    """
518
 
    if revision_id is None:
 
520
    if is_null(revision_id):
519
521
        return None, None
520
522
    if revision_id[:7] not in ('Arch-1:', 'Arch-1-'):
521
523
        raise NotArchRevision(revision_id)
607
609
        else:
608
610
            target_branch = create_branch(output_dir)
609
611
 
610
 
    for i in range(len(ancestors)):
611
 
        revision = ancestors[i]
 
612
    for i, revision in enumerate(ancestors):
612
613
        rev_id = revision_id(revision, encoding)
613
614
        direct_merges = []
614
615
        if verbose:
621
622
            yield Progress("revisions", i, len(ancestors))
622
623
 
623
624
        if target_branch.repository.has_revision(rev_id):
624
 
            target_branch.append_revision(rev_id)
 
625
            target_branch.set_last_revision_info(i+1, rev_id)
625
626
            continue
626
627
        if revdir is None:
627
628
            revdir = os.path.join(tempdir, "rd")