~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/commit.py

  • Committer: Robert Collins
  • Date: 2007-02-06 02:33:42 UTC
  • mto: This revision was merged to the branch mainline in revision 2274.
  • Revision ID: robertc@robertcollins.net-20070206023342-hv5o5qh6pdktiwbc
New branch hooks: post_push, post_pull, post_commit, post_uncommit. These
complement the set_rh hook by allowing different actions, and awareness of
the prior state of the branch, for operations where this matters.

Fix the inability to do a bzr pull --overwrite of a heavyweight checkout.

Add branch implementation tests for uncommit and commit.

(Robert Collins)

Show diffs side-by-side

added added

removed removed

Lines of Context:
60
60
    errors,
61
61
    tree,
62
62
    )
 
63
from bzrlib.branch import Branch
63
64
import bzrlib.config
64
65
from bzrlib.errors import (BzrError, PointlessCommit,
65
66
                           ConflictsInTree,
331
332
            # now the work tree is up to date with the branch
332
333
            
333
334
            self.reporter.completed(self.branch.revno(), self.rev_id)
 
335
            # old style commit hooks - should be deprecated ? (obsoleted in
 
336
            # 0.15)
334
337
            if self.config.post_commit() is not None:
335
338
                hooks = self.config.post_commit().split(' ')
336
339
                # this would be nicer with twisted.python.reflect.namedAny
339
342
                                  {'branch':self.branch,
340
343
                                   'bzrlib':bzrlib,
341
344
                                   'rev_id':self.rev_id})
 
345
            # new style commit hooks:
 
346
            if not self.bound_branch:
 
347
                hook_master = self.branch
 
348
                hook_local = None
 
349
            else:
 
350
                hook_master = self.master_branch
 
351
                hook_local = self.branch
 
352
            new_revno = self.branch.revno()
 
353
            # With bound branches, when the master is behind the local branch,
 
354
            # the 'old_revno' and old_revid values here are incorrect.
 
355
            # XXX: FIXME ^. RBC 20060206
 
356
            old_revno = new_revno - 1
 
357
            if self.parents:
 
358
                old_revid = self.parents[0]
 
359
            else:
 
360
                old_revid = bzrlib.revision.NULL_REVISION
 
361
            for hook in Branch.hooks['post_commit']:
 
362
                hook(hook_local, hook_master, old_revno, old_revid, new_revno,
 
363
                    self.rev_id)
342
364
            self._emit_progress_update()
343
365
        finally:
344
366
            self._cleanup()