/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: John Arbash Meinel
  • Date: 2011-04-20 09:46:28 UTC
  • mfrom: (5609.33.4 2.3)
  • mto: (5609.33.5 2.3)
  • mto: This revision was merged to the branch mainline in revision 5811.
  • Revision ID: john@arbash-meinel.com-20110420094628-l0bafq1lwb6ib1v2
Merge lp:bzr/2.3 @ 5640 so we can update the release notes (aka NEWS)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2006, 2007 Canonical Ltd
 
1
# Copyright (C) 2006-2011 Canonical Ltd
2
2
#
3
3
# This program is free software; you can redistribute it and/or modify
4
4
# it under the terms of the GNU General Public License as published by
183
183
               **kwargs):
184
184
        # avoid circular imports
185
185
        from bzrlib import commit
186
 
        if revprops is None:
187
 
            revprops = {}
188
186
        possible_master_transports=[]
189
 
        if not 'branch-nick' in revprops:
190
 
            revprops['branch-nick'] = self.branch._get_nick(
 
187
        revprops = commit.Commit.update_revprops(
 
188
                revprops,
 
189
                self.branch,
 
190
                kwargs.pop('authors', None),
 
191
                kwargs.pop('author', None),
191
192
                kwargs.get('local', False),
192
193
                possible_master_transports)
193
 
        authors = kwargs.pop('authors', None)
194
 
        author = kwargs.pop('author', None)
195
 
        if authors is not None:
196
 
            if author is not None:
197
 
                raise AssertionError('Specifying both author and authors '
198
 
                        'is not allowed. Specify just authors instead')
199
 
            if 'author' in revprops or 'authors' in revprops:
200
 
                # XXX: maybe we should just accept one of them?
201
 
                raise AssertionError('author property given twice')
202
 
            if authors:
203
 
                for individual in authors:
204
 
                    if '\n' in individual:
205
 
                        raise AssertionError('\\n is not a valid character '
206
 
                                'in an author identity')
207
 
                revprops['authors'] = '\n'.join(authors)
208
 
        if author is not None:
209
 
            symbol_versioning.warn('The parameter author was deprecated'
210
 
                   ' in version 1.13. Use authors instead',
211
 
                   DeprecationWarning)
212
 
            if 'author' in revprops or 'authors' in revprops:
213
 
                # XXX: maybe we should just accept one of them?
214
 
                raise AssertionError('author property given twice')
215
 
            if '\n' in author:
216
 
                raise AssertionError('\\n is not a valid character '
217
 
                        'in an author identity')
218
 
            revprops['authors'] = author
219
194
        # args for wt.commit start at message from the Commit.commit method,
220
195
        args = (message, ) + args
221
196
        for hook in MutableTree.hooks['start_commit']:
259
234
            return False
260
235
 
261
236
    @needs_read_lock
 
237
    def check_changed_or_out_of_date(self, strict, opt_name,
 
238
                                     more_error, more_warning):
 
239
        """Check the tree for uncommitted changes and branch synchronization.
 
240
 
 
241
        If strict is None and not set in the config files, a warning is issued.
 
242
        If strict is True, an error is raised.
 
243
        If strict is False, no checks are done and no warning is issued.
 
244
 
 
245
        :param strict: True, False or None, searched in branch config if None.
 
246
 
 
247
        :param opt_name: strict option name to search in config file.
 
248
 
 
249
        :param more_error: Details about how to avoid the check.
 
250
 
 
251
        :param more_warning: Details about what is happening.
 
252
        """
 
253
        if strict is None:
 
254
            strict = self.branch.get_config().get_user_option_as_bool(opt_name)
 
255
        if strict is not False:
 
256
            err_class = None
 
257
            if (self.has_changes()):
 
258
                err_class = errors.UncommittedChanges
 
259
            elif self.last_revision() != self.branch.last_revision():
 
260
                # The tree has lost sync with its branch, there is little
 
261
                # chance that the user is aware of it but he can still force
 
262
                # the action with --no-strict
 
263
                err_class = errors.OutOfDateTree
 
264
            if err_class is not None:
 
265
                if strict is None:
 
266
                    err = err_class(self, more=more_warning)
 
267
                    # We don't want to interrupt the user if he expressed no
 
268
                    # preference about strict.
 
269
                    trace.warning('%s', err._format())
 
270
                else:
 
271
                    err = err_class(self, more=more_error)
 
272
                    raise err
 
273
 
 
274
    @needs_read_lock
262
275
    def last_revision(self):
263
276
        """Return the revision id of the last commit performed in this tree.
264
277
 
385
398
 
386
399
        if not file_list:
387
400
            # no paths supplied: add the entire tree.
 
401
            # FIXME: this assumes we are running in a working tree subdir :-/
 
402
            # -- vila 20100208
388
403
            file_list = [u'.']
389
404
        # mutter("smart add of %r")
390
405
        inv = self.inventory
392
407
        ignored = {}
393
408
        dirs_to_add = []
394
409
        user_dirs = set()
 
410
        conflicts_related = set()
 
411
        # Not all mutable trees can have conflicts
 
412
        if getattr(self, 'conflicts', None) is not None:
 
413
            # Collect all related files without checking whether they exist or
 
414
            # are versioned. It's cheaper to do that once for all conflicts
 
415
            # than trying to find the relevant conflict for each added file.
 
416
            for c in self.conflicts():
 
417
                conflicts_related.update(c.associated_filenames())
395
418
 
396
419
        # expand any symlinks in the directory part, while leaving the
397
420
        # filename alone
464
487
            if illegalpath_re.search(directory.raw_path):
465
488
                trace.warning("skipping %r (contains \\n or \\r)" % abspath)
466
489
                continue
 
490
            if directory.raw_path in conflicts_related:
 
491
                # If the file looks like one generated for a conflict, don't
 
492
                # add it.
 
493
                trace.warning(
 
494
                    'skipping %s (generated to help resolve conflicts)',
 
495
                    abspath)
 
496
                continue
467
497
 
468
498
            if parent_ie is not None:
469
499
                versioned = directory.base_path in parent_ie.children
517
547
                        this_ie = None
518
548
                    else:
519
549
                        this_ie = inv[this_id]
 
550
                        # Same as in _add_one below, if the inventory doesn't
 
551
                        # think this is a directory, update the inventory
 
552
                        if this_ie.kind != 'directory':
 
553
                            this_ie = inventory.make_entry('directory',
 
554
                                this_ie.name, this_ie.parent_id, this_id)
 
555
                            del inv[this_id]
 
556
                            inv.add(this_ie)
520
557
 
521
558
                for subf in sorted(os.listdir(abspath)):
522
559
                    # here we could use TreeDirectory rather than