/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 bzrlib/commit.py

  • Committer: Aaron Bentley
  • Date: 2006-09-09 18:52:57 UTC
  • mfrom: (1996 +trunk)
  • mto: This revision was merged to the branch mainline in revision 1997.
  • Revision ID: aaron.bentley@utoronto.ca-20060909185257-ce0ee03ee5125ff1
Merge bzr.dev

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.
250
 
            if self.work_tree.last_revision() != self.master_branch.last_revision():
 
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
 
256
            master_last = self.master_branch.last_revision()
 
257
            if (master_last is not None and
 
258
                master_last != first_tree_parent):
251
259
                raise errors.OutOfDateTree(self.work_tree)
252
260
    
253
261
            if strict:
279
287
            if len(self.parents) > 1 and self.specific_files:
280
288
                raise NotImplementedError('selected-file commit of merges is not supported yet: files %r',
281
289
                        self.specific_files)
282
 
            self._check_parents_present()
 
290
            
283
291
            self.builder = self.branch.get_commit_builder(self.parents, 
284
292
                self.config, timestamp, timezone, committer, revprops, rev_id)
285
293
            
314
322
            # and now do the commit locally.
315
323
            self.branch.append_revision(self.rev_id)
316
324
 
317
 
            self.work_tree.set_pending_merges([])
318
 
            self.work_tree.set_last_revision(self.rev_id)
 
325
            # if the builder gave us the revisiontree it created back, we
 
326
            # could use it straight away here.
 
327
            # TODO: implement this.
 
328
            self.work_tree.set_parent_trees([(self.rev_id,
 
329
                self.branch.repository.revision_tree(self.rev_id))])
319
330
            # now the work tree is up to date with the branch
320
331
            
321
332
            self.reporter.completed(self.branch.revno(), self.rev_id)
450
461
        self.parent_invs = []
451
462
        for revision in self.parents:
452
463
            if self.branch.repository.has_revision(revision):
 
464
                mutter('commit parent revision {%s}', revision)
453
465
                inventory = self.branch.repository.get_inventory(revision)
454
466
                self.parent_invs.append(inventory)
 
467
            else:
 
468
                mutter('commit parent ghost revision {%s}', revision)
455
469
 
456
 
    def _check_parents_present(self):
457
 
        for parent_id in self.parents:
458
 
            mutter('commit parent revision {%s}', parent_id)
459
 
            if not self.branch.repository.has_revision(parent_id):
460
 
                if parent_id == self.branch.last_revision():
461
 
                    warning("parent is missing %r", parent_id)
462
 
                    raise BzrCheckError("branch %s is missing revision {%s}"
463
 
                            % (self.branch, parent_id))
464
 
            
465
470
    def _remove_deleted(self):
466
471
        """Remove deleted files from the working inventories.
467
472
 
475
480
        """
476
481
        specific = self.specific_files
477
482
        deleted_ids = []
 
483
        deleted_paths = set()
478
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
479
488
            if specific and not is_inside_any(specific, path):
480
489
                continue
481
490
            if not self.work_tree.has_filename(path):
 
491
                deleted_paths.add(path)
482
492
                self.reporter.missing(path)
483
 
                deleted_ids.append((path, ie.file_id))
484
 
        if deleted_ids:
485
 
            deleted_ids.sort(reverse=True)
486
 
            for path, file_id in deleted_ids:
487
 
                del self.work_inv[file_id]
488
 
            self.work_tree._write_inventory(self.work_inv)
 
493
                deleted_ids.append(ie.file_id)
 
494
        self.work_tree.unversion(deleted_ids)
489
495
 
490
496
    def _populate_new_inv(self):
491
497
        """Build revision inventory.