~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/mutabletree.py

  • Committer: Vincent Ladeuil
  • Date: 2011-01-20 21:15:10 UTC
  • mfrom: (5050.62.4 2.2)
  • mto: (5609.2.4 2.3)
  • mto: This revision was merged to the branch mainline in revision 5628.
  • Revision ID: v.ladeuil+lp@free.fr-20110120211510-9dl4tbl77dad86pl
Merge 2.2 into 2.3 including bugfix for #701940

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2006-2010 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
32
32
    hooks,
33
33
    osutils,
34
34
    revisiontree,
 
35
    inventory,
35
36
    symbol_versioning,
36
37
    trace,
37
38
    tree,
182
183
               **kwargs):
183
184
        # avoid circular imports
184
185
        from bzrlib import commit
185
 
        if revprops is None:
186
 
            revprops = {}
187
186
        possible_master_transports=[]
188
 
        if not 'branch-nick' in revprops:
189
 
            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),
190
192
                kwargs.get('local', False),
191
193
                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
218
194
        # args for wt.commit start at message from the Commit.commit method,
219
195
        args = (message, ) + args
220
196
        for hook in MutableTree.hooks['start_commit']:
400
376
        This is designed more towards DWIM for humans than API clarity.
401
377
        For the specific behaviour see the help for cmd_add().
402
378
 
 
379
        :param file_list: List of zero or more paths.  *NB: these are 
 
380
            interpreted relative to the process cwd, not relative to the 
 
381
            tree.*  (Add and most other tree methods use tree-relative
 
382
            paths.)
403
383
        :param action: A reporter to be called with the inventory, parent_ie,
404
384
            path and kind of the path being added. It may return a file_id if
405
385
            a specific one should be used.
436
416
            for c in self.conflicts():
437
417
                conflicts_related.update(c.associated_filenames())
438
418
 
 
419
        # expand any symlinks in the directory part, while leaving the
 
420
        # filename alone
 
421
        # only expanding if symlinks are supported avoids windows path bugs
 
422
        if osutils.has_symlinks():
 
423
            file_list = map(osutils.normalizepath, file_list)
 
424
 
439
425
        # validate user file paths and convert all paths to tree
440
426
        # relative : it's cheaper to make a tree relative path an abspath
441
427
        # than to convert an abspath to tree relative, and it's cheaper to
561
547
                        this_ie = None
562
548
                    else:
563
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)
564
557
 
565
558
                for subf in sorted(os.listdir(abspath)):
566
559
                    # here we could use TreeDirectory rather than
740
733
        file_id or None to generate a new file id
741
734
    :returns: None
742
735
    """
 
736
    # if the parent exists, but isn't a directory, we have to do the
 
737
    # kind change now -- really the inventory shouldn't pretend to know
 
738
    # the kind of wt files, but it does.
 
739
    if parent_ie.kind != 'directory':
 
740
        # nb: this relies on someone else checking that the path we're using
 
741
        # doesn't contain symlinks.
 
742
        new_parent_ie = inventory.make_entry('directory', parent_ie.name,
 
743
            parent_ie.parent_id, parent_ie.file_id)
 
744
        del inv[parent_ie.file_id]
 
745
        inv.add(new_parent_ie)
 
746
        parent_ie = new_parent_ie
743
747
    file_id = file_id_callback(inv, parent_ie, path, kind)
744
748
    entry = inv.make_entry(kind, path.base_path, parent_ie.file_id,
745
749
        file_id=file_id)