/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

Merge 2.0 into 2.1 resolving conflicts

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2006-2010 Canonical Ltd
 
1
# Copyright (C) 2006, 2007 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,
258
259
            return False
259
260
 
260
261
    @needs_read_lock
261
 
    def check_changed_or_out_of_date(self, strict, opt_name,
262
 
                                     more_error, more_warning):
263
 
        """Check the tree for uncommitted changes and branch synchronization.
264
 
 
265
 
        If strict is None and not set in the config files, a warning is issued.
266
 
        If strict is True, an error is raised.
267
 
        If strict is False, no checks are done and no warning is issued.
268
 
 
269
 
        :param strict: True, False or None, searched in branch config if None.
270
 
 
271
 
        :param opt_name: strict option name to search in config file.
272
 
 
273
 
        :param more_error: Details about how to avoid the check.
274
 
 
275
 
        :param more_warning: Details about what is happening.
276
 
        """
277
 
        if strict is None:
278
 
            strict = self.branch.get_config().get_user_option_as_bool(opt_name)
279
 
        if strict is not False:
280
 
            err_class = None
281
 
            if (self.has_changes()):
282
 
                err_class = errors.UncommittedChanges
283
 
            elif self.last_revision() != self.branch.last_revision():
284
 
                # The tree has lost sync with its branch, there is little
285
 
                # chance that the user is aware of it but he can still force
286
 
                # the action with --no-strict
287
 
                err_class = errors.OutOfDateTree
288
 
            if err_class is not None:
289
 
                if strict is None:
290
 
                    err = err_class(self, more=more_warning)
291
 
                    # We don't want to interrupt the user if he expressed no
292
 
                    # preference about strict.
293
 
                    trace.warning('%s', err._format())
294
 
                else:
295
 
                    err = err_class(self, more=more_error)
296
 
                    raise err
297
 
 
298
 
    @needs_read_lock
299
262
    def last_revision(self):
300
263
        """Return the revision id of the last commit performed in this tree.
301
264
 
400
363
        This is designed more towards DWIM for humans than API clarity.
401
364
        For the specific behaviour see the help for cmd_add().
402
365
 
 
366
        :param file_list: List of zero or more paths.  *NB: these are 
 
367
            interpreted relative to the process cwd, not relative to the 
 
368
            tree.*  (Add and most other tree methods use tree-relative
 
369
            paths.)
403
370
        :param action: A reporter to be called with the inventory, parent_ie,
404
371
            path and kind of the path being added. It may return a file_id if
405
372
            a specific one should be used.
418
385
 
419
386
        if not file_list:
420
387
            # no paths supplied: add the entire tree.
421
 
            # FIXME: this assumes we are running in a working tree subdir :-/
422
 
            # -- vila 20100208
423
388
            file_list = [u'.']
424
389
        # mutter("smart add of %r")
425
390
        inv = self.inventory
427
392
        ignored = {}
428
393
        dirs_to_add = []
429
394
        user_dirs = set()
430
 
        conflicts_related = set()
431
 
        # Not all mutable trees can have conflicts
432
 
        if getattr(self, 'conflicts', None) is not None:
433
 
            # Collect all related files without checking whether they exist or
434
 
            # are versioned. It's cheaper to do that once for all conflicts
435
 
            # than trying to find the relevant conflict for each added file.
436
 
            for c in self.conflicts():
437
 
                conflicts_related.update(c.associated_filenames())
 
395
 
 
396
        # expand any symlinks in the directory part, while leaving the
 
397
        # filename alone
 
398
        file_list = map(osutils.normalizepath, file_list)
438
399
 
439
400
        # validate user file paths and convert all paths to tree
440
401
        # relative : it's cheaper to make a tree relative path an abspath
501
462
            if illegalpath_re.search(directory.raw_path):
502
463
                trace.warning("skipping %r (contains \\n or \\r)" % abspath)
503
464
                continue
504
 
            if directory.raw_path in conflicts_related:
505
 
                # If the file looks like one generated for a conflict, don't
506
 
                # add it.
507
 
                trace.warning(
508
 
                    'skipping %s (generated to help resolve conflicts)',
509
 
                    abspath)
510
 
                continue
511
465
 
512
466
            if parent_ie is not None:
513
467
                versioned = directory.base_path in parent_ie.children
740
694
        file_id or None to generate a new file id
741
695
    :returns: None
742
696
    """
 
697
    # if the parent exists, but isn't a directory, we have to do the
 
698
    # kind change now -- really the inventory shouldn't pretend to know
 
699
    # the kind of wt files, but it does.
 
700
    if parent_ie.kind != 'directory':
 
701
        # nb: this relies on someone else checking that the path we're using
 
702
        # doesn't contain symlinks.
 
703
        new_parent_ie = inventory.make_entry('directory', parent_ie.name,
 
704
            parent_ie.parent_id, parent_ie.file_id)
 
705
        del inv[parent_ie.file_id]
 
706
        inv.add(new_parent_ie)
 
707
        parent_ie = new_parent_ie
743
708
    file_id = file_id_callback(inv, parent_ie, path, kind)
744
709
    entry = inv.make_entry(kind, path.base_path, parent_ie.file_id,
745
710
        file_id=file_id)