~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/merge.py

revert out the revision spec from revision spec change

Show diffs side-by-side

added added

removed removed

Lines of Context:
15
15
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
16
16
 
17
17
 
18
 
import os.path
 
18
import os
19
19
import tempfile
20
20
import shutil
21
21
import errno
26
26
from bzrlib.merge_core import merge_flex, ApplyMerge3, BackupBeforeChange
27
27
from bzrlib.changeset import generate_changeset, ExceptionConflictHandler
28
28
from bzrlib.changeset import Inventory, Diff3Merge
29
 
from bzrlib.branch import find_branch
30
 
from bzrlib.errors import BzrCommandError, UnrelatedBranches
 
29
from bzrlib.branch import Branch
 
30
from bzrlib.errors import BzrCommandError, UnrelatedBranches, NoCommonAncestor
 
31
from bzrlib.errors import NoCommits
31
32
from bzrlib.delta import compare_trees
32
33
from bzrlib.trace import mutter, warning
33
34
from bzrlib.fetch import greedy_fetch
133
134
            
134
135
def get_tree(treespec, temp_root, label, local_branch=None):
135
136
    location, revno = treespec
136
 
    branch = find_branch(location)
 
137
    branch = Branch.open(location)
137
138
    if revno is None:
138
139
        revision = None
139
140
    elif revno == -1:
140
141
        revision = branch.last_patch()
141
142
    else:
142
 
        revision = branch.lookup_revision(revno)
 
143
        revision = branch.get_rev_id(revno)
143
144
    return branch, get_revid_tree(branch, revision, temp_root, label,
144
145
                                  local_branch)
145
146
 
196
197
            return True
197
198
        return self.tree.inventory.has_id(file_id)
198
199
 
 
200
    def has_or_had_id(self, file_id):
 
201
        if file_id == self.tree.inventory.root.file_id:
 
202
            return True
 
203
        return self.tree.inventory.has_id(file_id)
 
204
 
199
205
    def readonly_path(self, id):
200
206
        if id not in self.tree:
201
207
            return None
238
244
    try:
239
245
        if this_dir is None:
240
246
            this_dir = '.'
241
 
        this_branch = find_branch(this_dir)
 
247
        this_branch = Branch.open_containing(this_dir)
242
248
        this_rev_id = this_branch.last_patch()
243
249
        if this_rev_id is None:
244
250
            raise BzrCommandError("This branch has no commits")
251
257
                                            this_branch)
252
258
        if other_revision[1] == -1:
253
259
            other_rev_id = other_branch.last_patch()
 
260
            if other_rev_id is None:
 
261
                raise NoCommits(other_branch)
254
262
            other_basis = other_rev_id
255
263
        elif other_revision[1] is not None:
256
 
            other_rev_id = other_branch.lookup_revision(other_revision[1])
 
264
            other_rev_id = other_branch.get_rev_id(other_revision[1])
257
265
            other_basis = other_rev_id
258
266
        else:
259
267
            other_rev_id = None
260
268
            other_basis = other_branch.last_patch()
 
269
            if other_basis is None:
 
270
                raise NoCommits(other_branch)
261
271
        if base_revision == [None, None]:
262
 
            base_rev_id = common_ancestor(this_rev_id, other_basis, 
263
 
                                          this_branch)
264
 
            if base_rev_id is None:
 
272
            try:
 
273
                base_rev_id = common_ancestor(this_rev_id, other_basis, 
 
274
                                              this_branch)
 
275
            except NoCommonAncestor:
265
276
                raise UnrelatedBranches()
266
277
            base_tree = get_revid_tree(this_branch, base_rev_id, tempdir, 
267
278
                                       "base", None)
273
284
            elif base_revision[1] is None:
274
285
                base_rev_id = None
275
286
            else:
276
 
                base_rev_id = base_branch.lookup_revision(base_revision[1])
 
287
                base_rev_id = base_branch.get_rev_id(base_revision[1])
277
288
            if base_rev_id is not None:
278
289
                base_is_ancestor = is_ancestor(this_rev_id, base_rev_id, 
279
290
                                               MultipleRevisionSources(this_branch, 
299
310
        merge_inner(this_branch, other_tree, base_tree, tempdir, 
300
311
                    ignore_zero=ignore_zero, backup_files=backup_files, 
301
312
                    merge_type=merge_type, interesting_ids=interesting_ids)
302
 
        if base_is_ancestor and other_rev_id is not None:
 
313
        if base_is_ancestor and other_rev_id is not None\
 
314
            and other_rev_id not in this_branch.revision_history():
303
315
            this_branch.add_pending_merge(other_rev_id)
304
316
    finally:
305
317
        shutil.rmtree(tempdir)
351
363
            if path == '.':
352
364
                path = ''
353
365
            else:
354
 
                assert path.startswith('./'), "path is %s" % path
 
366
                assert path.startswith('.' + os.sep), "path is %s" % path
355
367
            path = path[2:]
356
368
        adjust_ids.append((path, id))
357
369
    if len(adjust_ids) > 0: