284
def get_remaining_revisions(output_dir, version, reuse_history_from=[]):
284
def get_remaining_revisions(output_dir, version, encoding,
285
reuse_history_from=[]):
285
286
last_patch = None
287
288
output_exists = os.path.exists(output_dir)
314
315
map_namespace(ancestor.version))
316
317
source = Branch.open(possible_source)
317
rev_id = revision_id(ancestor)
318
rev_id = revision_id(ancestor, encoding)
318
319
if rev_id in source.revision_history():
319
320
do_branch(source, output_dir, rev_id)
320
321
last_patch = ancestor
358
def import_version(output_dir, version, fast=False,
359
def import_version(output_dir, version, encoding, fast=False,
359
360
verbose=False, dry_run=False, max_count=None,
360
361
reuse_history_from=[], standalone=True):
373
374
>>> bzrlib.ui.ui_factory = bzrlib.ui.text.TextUIFactory(
374
375
... bar_type=bzrlib.progress.DotsProgressBar)
376
>>> import_version('/', version, dry_run=True)
377
>>> import_version('/', version, None, dry_run=True)
377
378
Traceback (most recent call last):
378
379
NotPreviousImport: / is not the location of a previous import.
379
>>> import_version(result_path, version, dry_run=True)
380
>>> import_version(result_path, version, None, dry_run=True)
380
381
Traceback (most recent call last):
381
382
UserError: The version test@example.com/test--test--0.1 does not exist.
382
383
>>> version = pybaz.Version("test@example.com/test--test--0")
383
>>> import_version(result_path, version, dry_run=True) #doctest: +ELLIPSIS
384
>>> import_version(result_path, version, None, dry_run=True) #doctest: +ELLIPSIS
384
385
importing test@example.com/test--test--0 into ...
386
387
revisions: ..........................................
387
388
Dry run, not modifying output_dir
389
>>> import_version(result_path, version) #doctest: +ELLIPSIS
390
>>> import_version(result_path, version, None) #doctest: +ELLIPSIS
390
391
importing test@example.com/test--test--0 into ...
392
393
revisions: .....................................................................
395
>>> import_version(result_path, version) #doctest: +ELLIPSIS
396
>>> import_version(result_path, version, None) #doctest: +ELLIPSIS
396
397
Tree is up-to-date with test@example.com/test--test--0--patch-2
397
398
>>> commit_more_test_revisions()
398
>>> import_version(result_path, version) #doctest: +ELLIPSIS
399
>>> import_version(result_path, version, None) #doctest: +ELLIPSIS
399
400
importing test@example.com/test--test--0 into ...
400
401
revisions: ....................................................
431
433
for result in iter_import_version(output_dir, ancestors, tempdir,
433
fast=fast, verbose=verbose, dry_run=dry_run,
434
max_count=max_count, standalone=standalone):
434
pb=progress_bar, encoding=encoding, fast=fast,
435
verbose=verbose, dry_run=dry_run, max_count=max_count,
436
standalone=standalone):
435
437
show_progress(progress_bar, result)
437
439
progress_bar.note('Dry run, not modifying output_dir')
478
480
:param arch_revision: The Arch revision to generate an ID for.
480
>>> revision_id(pybaz.Revision("you@example.com/cat--br--0--base-0"))
482
>>> revision_id(pybaz.Revision("you@example.com/cat--br--0--base-0"), None)
481
483
'Arch-1:you@example.com%cat--br--0--base-0'
484
>>> revision_id(pybaz.Revision("you@example.com/cat--br--0--base-0"), 'utf-8')
485
'Arch-1-utf-8:you@example.com%cat--br--0--base-0'
483
return "Arch-1:%s" % str(arch_revision).replace('/', '%')
490
encoding = '-' + encoding
491
return "Arch-1%s:%s" % (encoding, str(arch_revision).replace('/', '%'))
485
493
class NotArchRevision(Exception):
486
494
def __init__(self, revision_id):
539
def iter_import_version(output_dir, ancestors, tempdir, pb, fast=False,
540
verbose=False, dry_run=False, max_count=None,
547
def iter_import_version(output_dir, ancestors, tempdir, pb, encoding,
548
fast=False, verbose=False, dry_run=False,
549
max_count=None, standalone=False):
544
552
# Uncomment this for testing, it basically just has baz2bzr only update
632
640
if missing_ancestor:
633
641
# if we want it to be in revision-history, do that here.
634
target_tree.set_parent_ids([revision_id(missing_ancestor)],
635
allow_leftmost_as_ghost=True)
642
target_tree.set_parent_ids(
643
[revision_id(missing_ancestor, encoding)],
644
allow_leftmost_as_ghost=True)
636
645
missing_ancestor = None
637
646
for merged_rev in direct_merges:
638
target_tree.add_pending_merge(revision_id(merged_rev))
647
target_tree.add_pending_merge(revision_id(merged_rev,
639
649
target_tree.set_root_id(BAZ_IMPORT_ROOT)
640
650
target_tree.set_inventory(baz_inv)
641
651
commitobj = Commit(reporter=ImportCommitReporter())
733
743
def baz_import_branch(to_location, from_branch, fast, max_count, verbose,
734
dry_run, reuse_history_list):
744
encoding, dry_run, reuse_history_list):
735
745
to_location = os.path.realpath(str(to_location))
736
746
if from_branch is not None:
742
752
if reuse_history_list is None:
743
753
reuse_history_list = []
744
import_version(to_location, from_branch,
754
import_version(to_location, from_branch, encoding, max_count=max_count,
746
755
reuse_history_from=reuse_history_list)
756
def baz_import(to_root_dir, from_archive, verbose=False, reuse_history_list=[],
765
def baz_import(to_root_dir, from_archive, encoding, verbose=False,
766
reuse_history_list=[], prefixes=None):
758
767
if reuse_history_list is None:
759
768
reuse_history_list = []
760
769
to_root = str(os.path.realpath(to_root_dir))
762
771
os.mkdir(to_root)
763
772
if prefixes is not None:
764
773
prefixes = prefixes.split(':')
765
import_archive(to_root, from_archive, verbose,
774
import_archive(to_root, from_archive, verbose, encoding,
766
775
reuse_history_list, prefixes=prefixes)
769
778
def import_archive(to_root, from_archive, verbose,
770
reuse_history_from=[], standalone=False,
779
encoding, reuse_history_from=[], standalone=False,
772
781
def selected(version):
773
782
if prefixes is None:
799
808
if not os.path.exists(os.path.dirname(target)):
800
809
os.makedirs(os.path.dirname(target))
802
import_version(target, version,
811
import_version(target, version, encoding,
803
812
reuse_history_from=reuse_history_from,
804
813
standalone=standalone)
805
814
except pybaz.errors.ExecProblem,e: