~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/clone.py

Tags: bzr-0.1
- testament symlink support

- more testament tests

Show diffs side-by-side

added added

removed removed

Lines of Context:
52
52
from bzrlib.branch import Branch
53
53
from bzrlib.trace import mutter, note
54
54
from bzrlib.store import copy_all
55
 
from bzrlib.errors import InvalidRevisionId
56
55
 
57
56
def copy_branch(branch_from, to_location, revision=None, basis_branch=None):
58
57
    """Copy branch_from into the existing directory to_location.
87
86
            os.mkdir(to_location)
88
87
        branch_to = Branch.initialize(to_location)
89
88
        mutter("copy branch from %s to %s", branch_from, branch_to)
90
 
        branch_to.working_tree().set_root_id(branch_from.get_root_id())
 
89
        branch_to.set_root_id(branch_from.get_root_id())
 
90
        branch_to.append_revision(*history)
91
91
        _copy_control_weaves(branch_from, branch_to)
92
92
        _copy_text_weaves(branch_from, branch_to)
93
93
        _copy_revision_store(branch_from, branch_to)
 
94
        build_working_dir(to_location)
94
95
        branch_to.set_parent(branch_from.base)
95
 
        # must be done *after* history is copied across
96
 
        branch_to.append_revision(*history)
97
 
        build_working_dir(to_location)
98
96
        mutter("copied")
99
97
        return branch_to
100
98
    finally:
101
99
        branch_from.unlock()
102
100
 
103
101
 
104
 
def _get_truncated_history(branch_from, revision_id):
 
102
def _get_truncated_history(branch_from, revision):
105
103
    history = branch_from.revision_history()
106
 
    if revision_id is None:
 
104
    if revision is None:
107
105
        return history
108
106
    try:
109
 
        idx = history.index(revision_id)
 
107
        idx = history.index(revision)
110
108
    except ValueError:
111
 
        raise InvalidRevisionId(revision_id=revision, branch=branch_from)
 
109
        raise InvalidRevisionId('revision {%s} is not on the mainline of %s' 
 
110
                                % (revision, branch_from))
112
111
    return history[:idx+1]
113
112
 
114
113
def _copy_text_weaves(branch_from, branch_to):
152
151
    mutter("copy branch from %s to %s", branch_from, br_to)
153
152
    if basis_branch is not None:
154
153
        basis_branch.push_stores(br_to)
155
 
    br_to.working_tree().set_root_id(branch_from.get_root_id())
 
154
    br_to.set_root_id(branch_from.get_root_id())
156
155
    if revision is None:
157
156
        revision = branch_from.last_revision()
158
157
    br_to.update_revisions(branch_from, stop_revision=revision)