/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 bzr.dev

Show diffs side-by-side

added added

removed removed

Lines of Context:
265
265
            self._check_bound_branch()
266
266
 
267
267
            # Check that the working tree is up to date
268
 
            old_revno,new_revno = self._check_out_of_date_tree()
 
268
            old_revno, new_revno = self._check_out_of_date_tree()
269
269
 
270
270
            if self.config is None:
271
271
                self.config = self.branch.get_config()
286
286
            # information in the progress bar during the relevant stages.
287
287
            self.pb_stage_name = ""
288
288
            self.pb_stage_count = 0
289
 
            self.pb_stage_total = 4
 
289
            self.pb_stage_total = 5
290
290
            if self.bound_branch:
291
291
                self.pb_stage_total += 1
292
292
            self.pb.show_pct = False
307
307
                    entries_title="Directory")
308
308
            self.builder = self.branch.get_commit_builder(self.parents,
309
309
                self.config, timestamp, timezone, committer, revprops, rev_id)
 
310
            
310
311
            try:
311
312
                self._update_builder_with_changes()
312
313
                self._check_pointless()
326
327
 
327
328
                # Add revision data to the local branch
328
329
                self.rev_id = self.builder.commit(self.message)
 
330
 
329
331
            except:
330
332
                self.builder.abort()
331
333
                raise
332
334
 
 
335
            self._process_pre_hooks(old_revno, new_revno)
 
336
 
333
337
            # Upload revision data to the master.
334
338
            # this will propagate merged revisions too if needed.
335
339
            if self.bound_branch:
350
354
            rev_tree = self.builder.revision_tree()
351
355
            self.work_tree.set_parent_trees([(self.rev_id, rev_tree)])
352
356
            self.reporter.completed(new_revno, self.rev_id)
353
 
            self._process_hooks(old_revno, new_revno)
 
357
            self._process_post_hooks(old_revno, new_revno)
354
358
        finally:
355
359
            self._cleanup()
356
360
        return self.rev_id
485
489
            new_revno = 1
486
490
        return old_revno,new_revno
487
491
 
488
 
    def _process_hooks(self, old_revno, new_revno):
489
 
        """Process any registered commit hooks."""
 
492
    def _process_pre_hooks(self, old_revno, new_revno):
 
493
        """Process any registered pre commit hooks."""
 
494
        self._set_progress_stage("Running pre_commit hooks")
 
495
        self._process_hooks("pre_commit", old_revno, new_revno)
 
496
 
 
497
    def _process_post_hooks(self, old_revno, new_revno):
 
498
        """Process any registered post commit hooks."""
490
499
        # Process the post commit hooks, if any
491
 
        self._set_progress_stage("Running post commit hooks")
 
500
        self._set_progress_stage("Running post_commit hooks")
492
501
        # old style commit hooks - should be deprecated ? (obsoleted in
493
502
        # 0.15)
494
503
        if self.config.post_commit() is not None:
499
508
                              {'branch':self.branch,
500
509
                               'bzrlib':bzrlib,
501
510
                               'rev_id':self.rev_id})
 
511
        # process new style post commit hooks
 
512
        self._process_hooks("post_commit", old_revno, new_revno)
 
513
 
 
514
    def _process_hooks(self, hook_name, old_revno, new_revno):
 
515
        if not Branch.hooks[hook_name]:
 
516
            return
 
517
        
502
518
        # new style commit hooks:
503
519
        if not self.bound_branch:
504
520
            hook_master = self.branch
513
529
            old_revid = self.parents[0]
514
530
        else:
515
531
            old_revid = bzrlib.revision.NULL_REVISION
516
 
        for hook in Branch.hooks['post_commit']:
 
532
        
 
533
        if hook_name == "pre_commit":
 
534
            future_tree = self.builder.revision_tree()
 
535
            tree_delta = future_tree.changes_from(self.basis_tree,
 
536
                                             include_root=True)
 
537
        
 
538
        for hook in Branch.hooks[hook_name]:
517
539
            # show the running hook in the progress bar. As hooks may
518
540
            # end up doing nothing (e.g. because they are not configured by
519
541
            # the user) this is still showing progress, not showing overall
520
542
            # actions - its up to each plugin to show a UI if it want's to
521
543
            # (such as 'Emailing diff to foo@example.com').
522
 
            self.pb_stage_name = "Running post commit hooks [%s]" % \
523
 
                Branch.hooks.get_hook_name(hook)
 
544
            self.pb_stage_name = "Running %s hooks [%s]" % \
 
545
                (hook_name, Branch.hooks.get_hook_name(hook))
524
546
            self._emit_progress()
525
547
            if 'hooks' in debug.debug_flags:
526
548
                mutter("Invoking commit hook: %r", hook)
527
 
            hook(hook_local, hook_master, old_revno, old_revid, new_revno,
528
 
                self.rev_id)
 
549
            if hook_name == "post_commit":
 
550
                hook(hook_local, hook_master, old_revno, old_revid, new_revno,
 
551
                     self.rev_id)
 
552
            elif hook_name == "pre_commit":
 
553
                hook(hook_local, hook_master,
 
554
                     old_revno, old_revid, new_revno, self.rev_id,
 
555
                     tree_delta, future_tree)
529
556
 
530
557
    def _cleanup(self):
531
558
        """Cleanup any open locks, progress bars etc."""