/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

Merge from bzr.dev

Show diffs side-by-side

added added

removed removed

Lines of Context:
247
247
            self._check_bound_branch()
248
248
 
249
249
            # check for out of date working trees
250
 
            # if we are bound, then self.branch is the master branch and this
251
 
            # test is thus all we need.
252
 
            if self.work_tree.last_revision() != self.master_branch.last_revision():
 
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
 
258
            master_last = self.master_branch.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:
281
289
            if len(self.parents) > 1 and self.specific_files:
282
290
                raise NotImplementedError('selected-file commit of merges is not supported yet: files %r',
283
291
                        self.specific_files)
284
 
            self._check_parents_present()
 
292
            
285
293
            self.builder = self.branch.get_commit_builder(self.parents, 
286
294
                self.config, timestamp, timezone, committer, revprops, rev_id)
287
295
            
319
327
            # and now do the commit locally.
320
328
            self.branch.append_revision(self.rev_id)
321
329
 
322
 
            self.work_tree.set_pending_merges([])
323
 
            self.work_tree.set_last_revision(self.rev_id)
 
330
            # if the builder gave us the revisiontree it created back, we
 
331
            # could use it straight away here.
 
332
            # TODO: implement this.
 
333
            self.work_tree.set_parent_trees([(self.rev_id,
 
334
                self.branch.repository.revision_tree(self.rev_id))])
324
335
            # now the work tree is up to date with the branch
325
336
            
326
337
            self.reporter.completed(self.branch.revno(), self.rev_id)
440
451
        self.parent_invs = []
441
452
        for revision in self.parents:
442
453
            if self.branch.repository.has_revision(revision):
 
454
                mutter('commit parent revision {%s}', revision)
443
455
                inventory = self.branch.repository.get_inventory(revision)
444
456
                self.parent_invs.append(inventory)
 
457
            else:
 
458
                mutter('commit parent ghost revision {%s}', revision)
445
459
 
446
 
    def _check_parents_present(self):
447
 
        for parent_id in self.parents:
448
 
            mutter('commit parent revision {%s}', parent_id)
449
 
            if not self.branch.repository.has_revision(parent_id):
450
 
                if parent_id == self.branch.last_revision():
451
 
                    warning("parent is missing %r", parent_id)
452
 
                    raise BzrCheckError("branch %s is missing revision {%s}"
453
 
                            % (self.branch, parent_id))
454
 
            
455
460
    def _remove_deleted(self):
456
461
        """Remove deleted files from the working inventories.
457
462
 
465
470
        """
466
471
        specific = self.specific_files
467
472
        deleted_ids = []
 
473
        deleted_paths = set()
468
474
        for path, ie in self.work_inv.iter_entries():
 
475
            if is_inside_any(deleted_paths, path):
 
476
                # The tree will delete the required ids recursively.
 
477
                continue
469
478
            if specific and not is_inside_any(specific, path):
470
479
                continue
471
480
            if not self.work_tree.has_filename(path):
 
481
                deleted_paths.add(path)
472
482
                self.reporter.missing(path)
473
 
                deleted_ids.append((path, ie.file_id))
474
 
        if deleted_ids:
475
 
            deleted_ids.sort(reverse=True)
476
 
            for path, file_id in deleted_ids:
477
 
                del self.work_inv[file_id]
478
 
            self.work_tree._write_inventory(self.work_inv)
 
483
                deleted_ids.append(ie.file_id)
 
484
        self.work_tree.unversion(deleted_ids)
479
485
 
480
486
    def _populate_new_inv(self):
481
487
        """Build revision inventory.