/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 breezy/workingtree.py

  • Committer: Breezy landing bot
  • Author(s): Jelmer Vernooij
  • Date: 2018-09-14 22:58:47 UTC
  • mfrom: (7104.3.4 brz-git-renames)
  • Revision ID: breezy.the.bot@gmail.com-20180914225847-0qnfeylaf94259b0
Some refactoring around get_canonical_inventory_paths.

* Drop the 'inventory' bit since it doesn't apply to non-inventory trees
* Move to working trees; canonicalization currently only matters there, where
  files can be stored on case-insensitive (VFAT) or normalizing filesystems
  (i.e. Mac OS X)
* Run tests against all working tree formats, including Git, not just InventoryTree ones

This fixes 'bzr mv' and 'bzr rename' for Git.

Merged from https://code.launchpad.net/~jelmer/brz/brz-git-renames/+merge/354952

Show diffs side-by-side

added added

removed removed

Lines of Context:
1337
1337
        """Return the ShelfManager for this WorkingTree."""
1338
1338
        raise NotImplementedError(self.get_shelf_manager)
1339
1339
 
 
1340
    def get_canonical_paths(self, paths):
 
1341
        """Like get_canonical_path() but works on multiple items.
 
1342
 
 
1343
        :param paths: A sequence of paths relative to the root of the tree.
 
1344
        :return: A list of paths, with each item the corresponding input path
 
1345
            adjusted to account for existing elements that match case
 
1346
            insensitively.
 
1347
        """
 
1348
        with self.lock_read():
 
1349
            for path in paths:
 
1350
                yield path
 
1351
 
 
1352
    def get_canonical_path(self, path):
 
1353
        """Returns the first item in the tree that matches a path.
 
1354
 
 
1355
        This is meant to allow case-insensitive path lookups on e.g.
 
1356
        FAT filesystems.
 
1357
 
 
1358
        If a path matches exactly, it is returned. If no path matches exactly
 
1359
        but more than one path matches according to the underlying file system,
 
1360
        it is implementation defined which is returned.
 
1361
 
 
1362
        If no path matches according to the file system, the input path is
 
1363
        returned, but with as many path entries that do exist changed to their
 
1364
        canonical form.
 
1365
 
 
1366
        If you need to resolve many names from the same tree, you should
 
1367
        use get_canonical_paths() to avoid O(N) behaviour.
 
1368
 
 
1369
        :param path: A paths relative to the root of the tree.
 
1370
        :return: The input path adjusted to account for existing elements
 
1371
        that match case insensitively.
 
1372
        """
 
1373
        with self.lock_read():
 
1374
            return next(self.get_canonical_paths([path]))
 
1375
 
1340
1376
 
1341
1377
class WorkingTreeFormatRegistry(controldir.ControlComponentFormatRegistry):
1342
1378
    """Registry for working tree formats."""