/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/mutabletree.py

  • Committer: Andrew Bennetts
  • Date: 2010-04-21 07:52:31 UTC
  • mto: This revision was merged to the branch mainline in revision 5176.
  • Revision ID: andrew.bennetts@canonical.com-20100421075231-2n8pfxbhlhqxic6w
Add example merge_file_content hook based on my answer to <https://answers.edge.launchpad.net/bzr/+question/103163>.

Show diffs side-by-side

added added

removed removed

Lines of Context:
182
182
               **kwargs):
183
183
        # avoid circular imports
184
184
        from bzrlib import commit
 
185
        if revprops is None:
 
186
            revprops = {}
185
187
        possible_master_transports=[]
186
 
        revprops = commit.Commit.update_revprops(
187
 
                revprops,
188
 
                self.branch,
189
 
                kwargs.pop('authors', None),
190
 
                kwargs.pop('author', None),
 
188
        if not 'branch-nick' in revprops:
 
189
            revprops['branch-nick'] = self.branch._get_nick(
191
190
                kwargs.get('local', False),
192
191
                possible_master_transports)
 
192
        authors = kwargs.pop('authors', None)
 
193
        author = kwargs.pop('author', None)
 
194
        if authors is not None:
 
195
            if author is not None:
 
196
                raise AssertionError('Specifying both author and authors '
 
197
                        'is not allowed. Specify just authors instead')
 
198
            if 'author' in revprops or 'authors' in revprops:
 
199
                # XXX: maybe we should just accept one of them?
 
200
                raise AssertionError('author property given twice')
 
201
            if authors:
 
202
                for individual in authors:
 
203
                    if '\n' in individual:
 
204
                        raise AssertionError('\\n is not a valid character '
 
205
                                'in an author identity')
 
206
                revprops['authors'] = '\n'.join(authors)
 
207
        if author is not None:
 
208
            symbol_versioning.warn('The parameter author was deprecated'
 
209
                   ' in version 1.13. Use authors instead',
 
210
                   DeprecationWarning)
 
211
            if 'author' in revprops or 'authors' in revprops:
 
212
                # XXX: maybe we should just accept one of them?
 
213
                raise AssertionError('author property given twice')
 
214
            if '\n' in author:
 
215
                raise AssertionError('\\n is not a valid character '
 
216
                        'in an author identity')
 
217
            revprops['authors'] = author
193
218
        # args for wt.commit start at message from the Commit.commit method,
194
219
        args = (message, ) + args
195
220
        for hook in MutableTree.hooks['start_commit']:
233
258
            return False
234
259
 
235
260
    @needs_read_lock
236
 
    def check_changed_or_out_of_date(self, strict, opt_name,
237
 
                                     more_error, more_warning):
 
261
    def warn_if_changed_or_out_of_date(self, strict, opt_name, more_msg):
238
262
        """Check the tree for uncommitted changes and branch synchronization.
239
263
 
240
264
        If strict is None and not set in the config files, a warning is issued.
245
269
 
246
270
        :param opt_name: strict option name to search in config file.
247
271
 
248
 
        :param more_error: Details about how to avoid the check.
249
 
 
250
 
        :param more_warning: Details about what is happening.
 
272
        :param more_msg: Details about how to avoid the warnings.
251
273
        """
252
274
        if strict is None:
253
275
            strict = self.branch.get_config().get_user_option_as_bool(opt_name)
254
276
        if strict is not False:
255
 
            err_class = None
 
277
            err = None
256
278
            if (self.has_changes()):
257
 
                err_class = errors.UncommittedChanges
 
279
                err = errors.UncommittedChanges(self, more=more_msg)
258
280
            elif self.last_revision() != self.branch.last_revision():
259
281
                # The tree has lost sync with its branch, there is little
260
282
                # chance that the user is aware of it but he can still force
261
283
                # the action with --no-strict
262
 
                err_class = errors.OutOfDateTree
263
 
            if err_class is not None:
 
284
                err = errors.OutOfDateTree(self, more=more_msg)
 
285
            if err is not None:
264
286
                if strict is None:
265
 
                    err = err_class(self, more=more_warning)
266
287
                    # We don't want to interrupt the user if he expressed no
267
288
                    # preference about strict.
268
289
                    trace.warning('%s', err._format())
269
290
                else:
270
 
                    err = err_class(self, more=more_error)
271
291
                    raise err
272
292
 
273
293
    @needs_read_lock