~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/commit.py

Merge bzr.dev

Show diffs side-by-side

added added

removed removed

Lines of Context:
61
61
 
62
62
# TODO: If commit fails, leave the message in a file somewhere.
63
63
 
 
64
# TODO: Change the parameter 'rev_id' to 'revision_id' to be consistent with
 
65
# the rest of the code; add a deprecation of the old name.
64
66
 
65
67
import os
66
68
import re
245
247
            self._check_bound_branch()
246
248
 
247
249
            # 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.
 
250
            try:
 
251
                first_tree_parent = self.work_tree.get_parent_ids()[0]
 
252
            except IndexError:
 
253
                # if there are no parents, treat our parent as 'None'
 
254
                # this is so that we still consier the master branch
 
255
                # - in a checkout scenario the tree may have no
 
256
                # parents but the branch may do.
 
257
                first_tree_parent = None
250
258
            master_last = self.master_branch.last_revision()
251
 
            if (master_last is not None and 
252
 
                master_last != self.work_tree.last_revision()):
 
259
            if (master_last is not None and
 
260
                master_last != first_tree_parent):
253
261
                raise errors.OutOfDateTree(self.work_tree)
254
262
    
255
263
            if strict:
289
297
            self._populate_new_inv()
290
298
            self._report_deletes()
291
299
 
292
 
            if not (self.allow_pointless
293
 
                    or len(self.parents) > 1
294
 
                    or self.builder.new_inventory != self.basis_inv):
295
 
                raise PointlessCommit()
 
300
            self._check_pointless()
296
301
 
297
302
            self._emit_progress_update()
298
303
            # TODO: Now the new inventory is known, check for conflicts and
340
345
            self._cleanup()
341
346
        return self.rev_id
342
347
 
 
348
    def _check_pointless(self):
 
349
        if self.allow_pointless:
 
350
            return
 
351
        # A merge with no effect on files
 
352
        if len(self.parents) > 1:
 
353
            return
 
354
        # work around the fact that a newly-initted tree does differ from its
 
355
        # basis
 
356
        if len(self.builder.new_inventory) != len(self.basis_inv):
 
357
            return
 
358
        if (len(self.builder.new_inventory) != 1 and
 
359
            self.builder.new_inventory != self.basis_inv):
 
360
            return
 
361
        raise PointlessCommit()
 
362
 
343
363
    def _check_bound_branch(self):
344
364
        """Check to see if the local branch is bound.
345
365
 
462
482
        """
463
483
        specific = self.specific_files
464
484
        deleted_ids = []
 
485
        deleted_paths = set()
465
486
        for path, ie in self.work_inv.iter_entries():
 
487
            if is_inside_any(deleted_paths, path):
 
488
                # The tree will delete the required ids recursively.
 
489
                continue
466
490
            if specific and not is_inside_any(specific, path):
467
491
                continue
468
492
            if not self.work_tree.has_filename(path):
 
493
                deleted_paths.add(path)
469
494
                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)
 
495
                deleted_ids.append(ie.file_id)
 
496
        self.work_tree.unversion(deleted_ids)
476
497
 
477
498
    def _populate_new_inv(self):
478
499
        """Build revision inventory.