~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/clone.py

  • Committer: Robert Collins
  • Date: 2005-10-10 08:27:26 UTC
  • mfrom: (1185.15.9)
  • Revision ID: robertc@robertcollins.net-20051010082726-b709d6577691ba69
mergeĀ fromĀ upstream

Show diffs side-by-side

added added

removed removed

Lines of Context:
75
75
    assert isinstance(to_location, basestring)
76
76
    if basis_branch is not None:
77
77
        note("basis_branch is not supported for fast weave copy yet.")
78
 
    if not (branch_from.weave_store.listable()
79
 
            and branch_from.revision_store.listable()):
80
 
        return copy_branch_slower(branch_from, to_location, revision,
81
 
                                  basis_branch)
82
 
    history = _get_truncated_history(branch_from, revision)
83
 
    if not bzrlib.osutils.lexists(to_location):
84
 
        os.mkdir(to_location)
85
 
    branch_to = Branch.initialize(to_location)
86
 
    mutter("copy branch from %s to %s", branch_from, branch_to)
87
 
    branch_to.set_root_id(branch_from.get_root_id())
88
 
    branch_to.append_revision(*history)
89
 
    _copy_control_weaves(branch_from, branch_to)
90
 
    _copy_text_weaves(branch_from, branch_to)
91
 
    _copy_revision_store(branch_from, branch_to)
92
 
    build_working_dir(to_location)
93
 
    branch_to.set_parent(branch_from.base)
94
 
    mutter("copied")
95
 
    return branch_to
 
78
    branch_from.lock_read()
 
79
    try:
 
80
        if not (branch_from.weave_store.listable()
 
81
                and branch_from.revision_store.listable()):
 
82
            return copy_branch_slower(branch_from, to_location, revision,
 
83
                                      basis_branch)
 
84
        history = _get_truncated_history(branch_from, revision)
 
85
        if not bzrlib.osutils.lexists(to_location):
 
86
            os.mkdir(to_location)
 
87
        branch_to = Branch.initialize(to_location)
 
88
        mutter("copy branch from %s to %s", branch_from, branch_to)
 
89
        branch_to.set_root_id(branch_from.get_root_id())
 
90
        branch_to.append_revision(*history)
 
91
        _copy_control_weaves(branch_from, branch_to)
 
92
        _copy_text_weaves(branch_from, branch_to)
 
93
        _copy_revision_store(branch_from, branch_to)
 
94
        build_working_dir(to_location)
 
95
        branch_to.set_parent(branch_from.base)
 
96
        mutter("copied")
 
97
        return branch_to
 
98
    finally:
 
99
        branch_from.unlock()
96
100
 
97
101
 
98
102
def _get_truncated_history(branch_from, revision):