/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to foreign/__init__.py

Merge new bzr-foreign.

Show diffs side-by-side

added added

removed removed

Lines of Context:
42
42
        """Pull deltas from another branch.
43
43
 
44
44
        :note: This does not, like pull, retain the revision ids from 
45
 
        the source branch and will, rather than adding bzr-specific metadata,
46
 
        push only those semantics of the revision that can be natively 
47
 
        represented in this branch.
 
45
            the source branch and will, rather than adding bzr-specific 
 
46
            metadata, push only those semantics of the revision that can be 
 
47
            natively represented in this branch.
48
48
 
49
49
        :param source: Source branch
50
50
        :param stop_revision: Revision to pull, defaults to last revision.
 
51
        :return: Revision id map and file id map
51
52
        """
52
53
        raise NotImplementedError(self.dpull)
53
54
 
91
92
        from bzrlib.errors import BzrCommandError, NoWorkingTree
92
93
        from bzrlib.trace import info
93
94
        from bzrlib.workingtree import WorkingTree
 
95
        from upgrade import update_workingtree_fileids
94
96
 
95
97
        if directory is None:
96
98
            directory = "."
113
115
        bzrdir = BzrDir.open(location)
114
116
        target_branch = bzrdir.open_branch()
115
117
        target_branch.lock_write()
116
 
        if not isinstance(target_branch, ForeignBranch):
117
 
            info("target branch is not a foreign branch, using regular push.")
118
 
            target_branch.pull(source_branch)
119
 
            no_rebase = True
120
 
        else:
121
 
            revid_map = target_branch.dpull(source_branch)
122
 
        # We successfully created the target, remember it
123
 
        if source_branch.get_push_location() is None or remember:
124
 
            source_branch.set_push_location(target_branch.base)
125
 
        if not no_rebase:
126
 
            _, old_last_revid = source_branch.last_revision_info()
127
 
            new_last_revid = revid_map[old_last_revid]
128
 
            if source_wt is not None:
129
 
                source_wt.pull(target_branch, overwrite=True, 
130
 
                               stop_revision=new_last_revid)
 
118
        try:
 
119
            if not isinstance(target_branch, ForeignBranch):
 
120
                info("target branch is not a foreign branch, using regular push.")
 
121
                target_branch.pull(source_branch)
 
122
                no_rebase = True
131
123
            else:
132
 
                source_branch.pull(target_branch, overwrite=True, 
 
124
                revid_map = target_branch.dpull(source_branch)
 
125
            # We successfully created the target, remember it
 
126
            if source_branch.get_push_location() is None or remember:
 
127
                source_branch.set_push_location(target_branch.base)
 
128
            if not no_rebase:
 
129
                _, old_last_revid = source_branch.last_revision_info()
 
130
                new_last_revid = revid_map[old_last_revid]
 
131
                if source_wt is not None:
 
132
                    source_wt.pull(target_branch, overwrite=True, 
133
133
                                   stop_revision=new_last_revid)
 
134
                    source_wt.lock_write()
 
135
                    try:
 
136
                        update_workingtree_fileids(source_wt, 
 
137
                            source_wt.branch.repository.revision_tree(old_last_revid),
 
138
                            source_wt.branch.repository.revision_tree(new_last_revid))
 
139
                    finally:
 
140
                        source_wt.unlock()
 
141
                else:
 
142
                    source_branch.pull(target_branch, overwrite=True, 
 
143
                                       stop_revision=new_last_revid)
 
144
        finally:
 
145
            target_branch.unlock()
134
146
 
135
147
def test_suite():
136
148
    from unittest import TestSuite