~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/merge.py

  • Committer: Martin Pool
  • Date: 2005-08-26 02:31:37 UTC
  • Revision ID: mbp@sourcefrog.net-20050826023137-eb4b101cc92f9792
- ignore tags files

Show diffs side-by-side

added added

removed removed

Lines of Context:
19
19
import tempfile
20
20
import shutil
21
21
import errno
22
 
from fetch import greedy_fetch
23
22
 
24
23
import bzrlib.osutils
25
24
import bzrlib.revision
196
195
            return True
197
196
        return self.tree.inventory.has_id(file_id)
198
197
 
199
 
    def has_or_had_id(self, file_id):
200
 
        if file_id == self.tree.inventory.root.file_id:
201
 
            return True
202
 
        return self.tree.inventory.has_id(file_id)
203
 
 
204
198
    def readonly_path(self, id):
205
199
        if id not in self.tree:
206
200
            return None
226
220
    """Merge changes into a tree.
227
221
 
228
222
    base_revision
229
 
        tuple(path, revision) Base for three-way merge.
 
223
        Base for three-way merge.
230
224
    other_revision
231
 
        tuple(path, revision) Other revision for three-way merge.
 
225
        Other revision for three-way merge.
232
226
    this_dir
233
227
        Directory to merge changes into; '.' by default.
234
228
    check_clean
264
258
            other_rev_id = None
265
259
            other_basis = other_branch.last_patch()
266
260
        if base_revision == [None, None]:
267
 
            base_rev_id = common_ancestor(this_rev_id, other_basis, 
268
 
                                          this_branch)
269
 
            if base_rev_id is None:
 
261
            if other_revision[1] == -1:
 
262
                o_revno = None
 
263
            else:
 
264
                o_revno = other_revision[1]
270
265
                raise UnrelatedBranches()
271
 
            base_tree = get_revid_tree(this_branch, base_rev_id, tempdir, 
272
 
                                       "base", None)
 
266
            try:
 
267
                base_revision = this_branch.get_revision(base_rev_id)
 
268
                base_branch = this_branch
 
269
            except NoSuchRevision:
 
270
                base_branch = other_branch
 
271
            base_tree = get_revid_tree(base_branch, base_rev_id, tempdir, 
 
272
                                       "base")
273
273
            base_is_ancestor = True
274
274
        else:
275
275
            base_branch, base_tree = get_tree(base_revision, tempdir, "base")
304
304
        merge_inner(this_branch, other_tree, base_tree, tempdir, 
305
305
                    ignore_zero=ignore_zero, backup_files=backup_files, 
306
306
                    merge_type=merge_type, interesting_ids=interesting_ids)
307
 
        if base_is_ancestor and other_rev_id is not None\
308
 
            and other_rev_id not in this_branch.revision_history():
 
307
        if base_is_ancestor and other_rev_id is not None:
309
308
            this_branch.add_pending_merge(other_rev_id)
310
309
    finally:
311
310
        shutil.rmtree(tempdir)