~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/clone.py

  • Committer: Robert Collins
  • Date: 2005-10-16 08:29:16 UTC
  • mto: This revision was merged to the branch mainline in revision 1459.
  • Revision ID: robertc@lifelesslap.robertcollins.net-20051016082916-dae075fdf18af47e
unify has() implementations for TransportStore classes

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())
91
 
        branch_to.set_revision_history(history)
 
89
        branch_to.set_root_id(branch_from.get_root_id())
 
90
        branch_to.append_revision(*history)
92
91
        _copy_control_weaves(branch_from, branch_to)
93
92
        _copy_text_weaves(branch_from, branch_to)
94
93
        _copy_revision_store(branch_from, branch_to)
100
99
        branch_from.unlock()
101
100
 
102
101
 
103
 
def _get_truncated_history(branch_from, revision_id):
 
102
def _get_truncated_history(branch_from, revision):
104
103
    history = branch_from.revision_history()
105
 
    if revision_id is None:
 
104
    if revision is None:
106
105
        return history
107
106
    try:
108
 
        idx = history.index(revision_id)
 
107
        idx = history.index(revision)
109
108
    except ValueError:
110
 
        raise InvalidRevisionId(revision_id=revision, branch=branch_from)
 
109
        raise InvalidRevisionId('revision {%s} is not on the mainline of %s' 
 
110
                                % (revision, branch_from))
111
111
    return history[:idx+1]
112
112
 
113
113
def _copy_text_weaves(branch_from, branch_to):
151
151
    mutter("copy branch from %s to %s", branch_from, br_to)
152
152
    if basis_branch is not None:
153
153
        basis_branch.push_stores(br_to)
154
 
    br_to.working_tree().set_root_id(branch_from.get_root_id())
 
154
    br_to.set_root_id(branch_from.get_root_id())
155
155
    if revision is None:
156
156
        revision = branch_from.last_revision()
157
157
    br_to.update_revisions(branch_from, stop_revision=revision)