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

Changes from review

Show diffs side-by-side

added added

removed removed

Lines of Context:
336
336
            yield (old_name, new_name)
337
337
            
338
338
 
339
 
def specified_file_ids(filenames, trees, require_versioned=True):
340
 
    """Find the ids corresponding to specified filenames.
341
 
    
 
339
def find_ids_across_trees(filenames, trees, require_versioned=True):
 
340
    """Find the ids corresponding to specified filenames.
 
341
    
 
342
    All matches in all trees will be used, and all children of matched
 
343
    directories will be used.
 
344
 
 
345
    :param filenames: The filenames to find file_ids for
 
346
    :param trees: The trees to find file_ids within
 
347
    :param require_versioned: if true, all specified filenames must occur in
 
348
    at least one tree.
 
349
    :return: a set of file ids for the specified filenames and their children.
 
350
    """
 
351
    if not filenames:
 
352
        return None
 
353
    specified_ids = _find_filename_ids_across_trees(filenames, trees, 
 
354
                                                    require_versioned)
 
355
    return _find_children_across_trees(specified_ids, trees)
 
356
 
 
357
 
 
358
def _find_filename_ids_across_trees(filenames, trees, require_versioned):
 
359
    """Find the ids corresponding to specified filenames.
 
360
    
 
361
    All matches in all trees will be used.
 
362
 
342
363
    :param filenames: The filenames to find file_ids for
343
364
    :param trees: The trees to find file_ids within
344
365
    :param require_versioned: if true, all specified filenames must occur in
345
366
    at least one tree.
346
367
    :return: a set of file ids for the specified filenames
347
368
    """
348
 
    if not filenames:
349
 
        return None
350
369
    not_versioned = []
351
370
    interesting_ids = set()
352
371
    for tree_path in filenames:
358
377
                not_found = False
359
378
        if not_found:
360
379
            not_versioned.append(tree_path)
 
380
    if len(not_versioned) > 0 and require_versioned:
 
381
        raise errors.PathsNotVersionedError(not_versioned)
 
382
    return interesting_ids
 
383
 
 
384
 
 
385
def _find_children_across_trees(specified_ids, trees):
 
386
    """Return a set including specified ids and their children
361
387
    
 
388
    All matches in all trees will be used.
 
389
 
 
390
    :param trees: The trees to find file_ids within
 
391
    :return: a set containing all specified ids and their children 
 
392
    """
 
393
    interesting_ids = set(specified_ids)
362
394
    pending = interesting_ids
363
395
    # now handle children of interesting ids
364
396
    # we loop so that we handle all children of each id in both trees
374
406
                        new_pending.add(child.file_id)
375
407
        interesting_ids.update(new_pending)
376
408
        pending = new_pending
377
 
    if len(not_versioned) > 0 and require_versioned:
378
 
        raise errors.PathsNotVersionedError(not_versioned)
379
409
    return interesting_ids