~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/commit.py

[merge] bzr.dev 2294

Show diffs side-by-side

added added

removed removed

Lines of Context:
58
58
 
59
59
from bzrlib import (
60
60
    errors,
 
61
    inventory,
61
62
    tree,
62
63
    )
 
64
from bzrlib.branch import Branch
63
65
import bzrlib.config
64
66
from bzrlib.errors import (BzrError, PointlessCommit,
65
67
                           ConflictsInTree,
254
256
                # this is so that we still consier the master branch
255
257
                # - in a checkout scenario the tree may have no
256
258
                # 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):
261
 
                raise errors.OutOfDateTree(self.work_tree)
262
 
    
 
259
                first_tree_parent = bzrlib.revision.NULL_REVISION
 
260
            old_revno, master_last = self.master_branch.last_revision_info()
 
261
            if master_last != first_tree_parent:
 
262
                if master_last != bzrlib.revision.NULL_REVISION:
 
263
                    raise errors.OutOfDateTree(self.work_tree)
 
264
            if self.branch.repository.has_revision(first_tree_parent):
 
265
                new_revno = old_revno + 1
 
266
            else:
 
267
                # ghost parents never appear in revision history.
 
268
                new_revno = 1
263
269
            if strict:
264
270
                # raise an exception as soon as we find a single unknown.
265
271
                for unknown in self.work_tree.unknowns():
322
328
                # now the master has the revision data
323
329
                # 'commit' to the master first so a timeout here causes the local
324
330
                # branch to be out of date
325
 
                self.master_branch.append_revision(self.rev_id)
 
331
                self.master_branch.set_last_revision_info(new_revno,
 
332
                                                          self.rev_id)
326
333
 
327
334
            # and now do the commit locally.
328
 
            self.branch.append_revision(self.rev_id)
 
335
            self.branch.set_last_revision_info(new_revno, self.rev_id)
329
336
 
330
337
            rev_tree = self.builder.revision_tree()
331
338
            self.work_tree.set_parent_trees([(self.rev_id, rev_tree)])
332
339
            # now the work tree is up to date with the branch
333
340
            
334
 
            self.reporter.completed(self.branch.revno(), self.rev_id)
 
341
            self.reporter.completed(new_revno, self.rev_id)
 
342
            # old style commit hooks - should be deprecated ? (obsoleted in
 
343
            # 0.15)
335
344
            if self.config.post_commit() is not None:
336
345
                hooks = self.config.post_commit().split(' ')
337
346
                # this would be nicer with twisted.python.reflect.namedAny
340
349
                                  {'branch':self.branch,
341
350
                                   'bzrlib':bzrlib,
342
351
                                   'rev_id':self.rev_id})
 
352
            # new style commit hooks:
 
353
            if not self.bound_branch:
 
354
                hook_master = self.branch
 
355
                hook_local = None
 
356
            else:
 
357
                hook_master = self.master_branch
 
358
                hook_local = self.branch
 
359
            # With bound branches, when the master is behind the local branch,
 
360
            # the 'old_revno' and old_revid values here are incorrect.
 
361
            # XXX: FIXME ^. RBC 20060206
 
362
            if self.parents:
 
363
                old_revid = self.parents[0]
 
364
            else:
 
365
                old_revid = bzrlib.revision.NULL_REVISION
 
366
            for hook in Branch.hooks['post_commit']:
 
367
                hook(hook_local, hook_master, old_revno, old_revid, new_revno,
 
368
                    self.rev_id)
343
369
            self._emit_progress_update()
344
370
        finally:
345
371
            self._cleanup()
429
455
        #       to local.
430
456
        
431
457
        # Make sure the local branch is identical to the master
432
 
        master_rh = self.master_branch.revision_history()
433
 
        local_rh = self.branch.revision_history()
434
 
        if local_rh != master_rh:
 
458
        master_info = self.master_branch.last_revision_info()
 
459
        local_info = self.branch.last_revision_info()
 
460
        if local_info != master_info:
435
461
            raise errors.BoundBranchOutOfDate(self.branch,
436
462
                    self.master_branch)
437
463
 
500
526
        # TODO: Make sure that this list doesn't contain duplicate 
501
527
        # entries and the order is preserved when doing this.
502
528
        self.parents = self.work_tree.get_parent_ids()
503
 
        self.parent_invs = []
504
 
        for revision in self.parents:
 
529
        self.parent_invs = [self.basis_inv]
 
530
        for revision in self.parents[1:]:
505
531
            if self.branch.repository.has_revision(revision):
506
532
                mutter('commit parent revision {%s}', revision)
507
533
                inventory = self.branch.repository.get_inventory(revision)
562
588
        for path, new_ie in entries:
563
589
            self._emit_progress_update()
564
590
            file_id = new_ie.file_id
 
591
            try:
 
592
                kind = self.work_tree.kind(file_id)
 
593
                if kind != new_ie.kind:
 
594
                    new_ie = inventory.make_entry(kind, new_ie.name,
 
595
                                                  new_ie.parent_id, file_id)
 
596
            except errors.NoSuchFile:
 
597
                pass
565
598
            # mutter('check %s {%s}', path, file_id)
566
599
            if (not self.specific_files or 
567
600
                is_inside_or_parent_of_any(self.specific_files, path)):