~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/commit.py

(jelmer) Switch the commit code over to use config stacks. (Bazaar
 Developers)

Show diffs side-by-side

added added

removed removed

Lines of Context:
165
165
    """
166
166
    def __init__(self,
167
167
                 reporter=None,
168
 
                 config=None):
 
168
                 config_stack=None):
169
169
        """Create a Commit object.
170
170
 
171
171
        :param reporter: the default reporter to use or None to decide later
172
172
        """
173
173
        self.reporter = reporter
174
 
        self.config = config
 
174
        self.config_stack = config_stack
175
175
 
176
176
    @staticmethod
177
177
    def update_revprops(revprops, branch, authors=None, author=None,
268
268
        operation = OperationWithCleanups(self._commit)
269
269
        self.revprops = revprops or {}
270
270
        # XXX: Can be set on __init__ or passed in - this is a bit ugly.
271
 
        self.config = config or self.config
 
271
        self.config_stack = config or self.config_stack
272
272
        return operation.run(
273
273
               message=message,
274
274
               timestamp=timestamp,
370
370
            self.reporter = reporter
371
371
        elif self.reporter is None:
372
372
            self.reporter = self._select_reporter()
373
 
        if self.config is None:
374
 
            self.config = self.branch.get_config()
 
373
        if self.config_stack is None:
 
374
            self.config_stack = self.branch.get_config_stack()
375
375
 
376
376
        self._set_specific_file_ids()
377
377
 
405
405
        self._set_progress_stage("Collecting changes", counter=True)
406
406
        self._lossy = lossy
407
407
        self.builder = self.branch.get_commit_builder(self.parents,
408
 
            self.config, timestamp, timezone, committer, self.revprops,
 
408
            self.config_stack, timestamp, timezone, committer, self.revprops,
409
409
            rev_id, lossy=lossy)
410
410
        if not self.builder.supports_record_entry_contents and self.exclude:
411
411
            self.builder.abort()
604
604
        # Process the post commit hooks, if any
605
605
        self._set_progress_stage("Running post_commit hooks")
606
606
        # old style commit hooks - should be deprecated ? (obsoleted in
607
 
        # 0.15)
608
 
        if self.config.post_commit() is not None:
609
 
            hooks = self.config.post_commit().split(' ')
 
607
        # 0.15^H^H^H^H 2.5.0)
 
608
        post_commit = self.config_stack.get('post_commit')
 
609
        if post_commit is not None:
 
610
            hooks = post_commit.split(' ')
610
611
            # this would be nicer with twisted.python.reflect.namedAny
611
612
            for hook in hooks:
612
613
                result = eval(hook + '(branch, rev_id)',