~abentley/bzrtools/bzrtools.dev

« back to all changes in this revision

Viewing changes to baz_import.py

  • Committer: Aaron Bentley
  • Date: 2006-11-22 02:57:07 UTC
  • Revision ID: abentley@panoramicfeedback.com-20061122025707-igzffkp60l18fre7
implement encoding reverse-mapping

Show diffs side-by-side

added added

removed removed

Lines of Context:
290
290
        # We are starting from an existing directory, figure out what
291
291
        # the current version is
292
292
        branch = Branch.open(output_dir)
293
 
        last_patch = get_last_revision(branch)
 
293
        last_patch, last_encoding = get_last_revision(branch)
 
294
        assert encoding == last_encoding
294
295
        if last_patch is None:
295
296
            if branch.last_revision() != None:
296
297
                raise NotPreviousImport(branch.base)
417
418
            progress_bar.note('Version %s has no revisions.' % version)
418
419
            return
419
420
        if len(ancestors) == 0:
420
 
            last_revision = get_last_revision(Branch.open(output_dir))
 
421
            last_revision, last_encoding = \
 
422
                get_last_revision(Branch.open(output_dir))
421
423
            progress_bar.note('Tree is up-to-date with %s' % last_revision)
422
424
            return
423
425
 
504
506
    >>> str(arch_revision("Arch-1:jrandom@example.com%test--test--0--base-5"))
505
507
    Traceback (most recent call last):
506
508
    NotArchRevision: The revision id Arch-1:jrandom@example.com%test--test--0--base-5 does not look like it came from Arch.
507
 
    >>> str(arch_revision("Arch-1:jrandom@example.com%test--test--0--patch-5"))
508
 
    'jrandom@example.com/test--test--0--patch-5'
 
509
    >>> str(arch_revision("Arch-1:jrandom@example.com%test--test--0--patch-5")[0])
 
510
    'jrandom@example.com/test--test--0--patch-5'
 
511
    >>> str(arch_revision("Arch-1:jrandom@example.com%test--test--0--patch-5")[0])
 
512
    'jrandom@example.com/test--test--0--patch-5'
 
513
    >>> str(arch_revision("Arch-1:jrandom@example.com%test--test--0--patch-5")[1])
 
514
    'None'
 
515
    >>> str(arch_revision("Arch-1-utf-8:jrandom@example.com%test--test--0--patch-5")[1])
 
516
    'utf-8'
509
517
    """
510
518
    if revision_id is None:
511
 
        return None
512
 
    if revision_id[:7] != 'Arch-1:':
 
519
        return None, None
 
520
    if revision_id[:7] not in ('Arch-1:', 'Arch-1-'):
513
521
        raise NotArchRevision(revision_id)
514
522
    else:
515
523
        try:
516
 
            return pybaz.Revision(revision_id[7:].replace('%', '/'))
 
524
            encoding, arch_name = revision_id[6:].split(':', 1)
 
525
            arch_name = arch_name.replace('%', '/')
 
526
            if encoding == '':
 
527
                encoding = None
 
528
            else:
 
529
                encoding = encoding[1:]
 
530
            return pybaz.Revision(arch_name), encoding
517
531
        except pybaz.errors.NamespaceError, e:
518
532
            raise NotArchRevision(revision_id)
519
533