~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/commit.py

merge

Show diffs side-by-side

added added

removed removed

Lines of Context:
245
245
            self._check_bound_branch()
246
246
 
247
247
            # check for out of date working trees
248
 
            # if we are bound, then self.branch is the master branch and this
249
 
            # test is thus all we need.
 
248
            try:
 
249
                first_tree_parent = self.work_tree.get_parent_ids()[0]
 
250
            except IndexError:
 
251
                # if there are no parents, treat our parent as 'None'
 
252
                # this is so that we still consier the master branch
 
253
                # - in a checkout scenario the tree may have no
 
254
                # parents but the branch may do.
 
255
                first_tree_parent = None
250
256
            master_last = self.master_branch.last_revision()
251
 
            if (master_last is not None and 
252
 
                master_last != self.work_tree.last_revision()):
 
257
            if (master_last is not None and
 
258
                master_last != first_tree_parent):
253
259
                raise errors.OutOfDateTree(self.work_tree)
254
260
    
255
261
            if strict:
289
295
            self._populate_new_inv()
290
296
            self._report_deletes()
291
297
 
292
 
            if not (self.allow_pointless
293
 
                    or len(self.parents) > 1
294
 
                    or self.builder.new_inventory != self.basis_inv):
295
 
                raise PointlessCommit()
 
298
            self._check_pointless()
296
299
 
297
300
            self._emit_progress_update()
298
301
            # TODO: Now the new inventory is known, check for conflicts and
340
343
            self._cleanup()
341
344
        return self.rev_id
342
345
 
 
346
    def _check_pointless(self):
 
347
        if self.allow_pointless:
 
348
            return
 
349
        # A merge with no effect on files
 
350
        if len(self.parents) > 1:
 
351
            return
 
352
        # work around the fact that a newly-initted tree does differ from its
 
353
        # basis
 
354
        if len(self.builder.new_inventory) != len(self.basis_inv):
 
355
            return
 
356
        if (len(self.builder.new_inventory) != 1 and
 
357
            self.builder.new_inventory != self.basis_inv):
 
358
            return
 
359
        raise PointlessCommit()
 
360
 
343
361
    def _check_bound_branch(self):
344
362
        """Check to see if the local branch is bound.
345
363
 
462
480
        """
463
481
        specific = self.specific_files
464
482
        deleted_ids = []
 
483
        deleted_paths = set()
465
484
        for path, ie in self.work_inv.iter_entries():
 
485
            if is_inside_any(deleted_paths, path):
 
486
                # The tree will delete the required ids recursively.
 
487
                continue
466
488
            if specific and not is_inside_any(specific, path):
467
489
                continue
468
490
            if not self.work_tree.has_filename(path):
 
491
                deleted_paths.add(path)
469
492
                self.reporter.missing(path)
470
 
                deleted_ids.append((path, ie.file_id))
471
 
        if deleted_ids:
472
 
            deleted_ids.sort(reverse=True)
473
 
            for path, file_id in deleted_ids:
474
 
                del self.work_inv[file_id]
475
 
            self.work_tree._write_inventory(self.work_inv)
 
493
                deleted_ids.append(ie.file_id)
 
494
        self.work_tree.unversion(deleted_ids)
476
495
 
477
496
    def _populate_new_inv(self):
478
497
        """Build revision inventory.