/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/plugins/grep/grep.py

  • Committer: Breezy landing bot
  • Author(s): Jelmer Vernooij
  • Date: 2018-03-24 12:34:34 UTC
  • mfrom: (6874.2.9 iter-files-bytes)
  • Revision ID: breezy.the.bot@gmail.com-20180324123434-zogy2xskr96vv5xm
Change Tree.iter_files_bytes() to take a (path, identifier) list rather than a (file_id, identifier) list.

Merged from https://code.launchpad.net/~jelmer/brz/iter-files-bytes/+merge/340578

Show diffs side-by-side

added added

removed removed

Lines of Context:
356
356
            rev = RevisionSpec_revid.from_string("revid:"+revid)
357
357
            tree = rev.as_tree(branch)
358
358
            for path in opts.path_list:
359
 
                path_for_id = osutils.pathjoin(relpath, path)
360
 
                if not tree.is_versioned(path_for_id):
 
359
                tree_path = osutils.pathjoin(relpath, path)
 
360
                if not tree.has_filename(tree_path):
361
361
                    trace.warning("Skipped unknown file '%s'." % path)
362
362
                    continue
363
363
 
365
365
                    path_prefix = path
366
366
                    dir_grep(tree, path, relpath, opts, revno, path_prefix)
367
367
                else:
368
 
                    versioned_file_grep(tree, path_for_id, '.', path, opts, revno)
 
368
                    versioned_file_grep(tree, tree_path, '.', path, opts, revno)
369
369
 
370
370
 
371
371
def workingtree_grep(opts):
407
407
    from_dir = osutils.pathjoin(relpath, path)
408
408
    if opts.from_root:
409
409
        # start searching recursively from root
410
 
        from_dir=None
411
 
        recursive=True
 
410
        from_dir = None
 
411
        recursive = True
412
412
 
413
413
    to_grep = []
414
414
    to_grep_append = to_grep.append
434
434
                    #                but it's what the old code seemed to do
435
435
                    outputter.write_cached_lines(cache_id, revno)
436
436
                else:
437
 
                    to_grep_append((fid, (fp, fid)))
 
437
                    to_grep_append((osutils.pathjoin(from_dir if from_dir else '', fp), (fp, fid)))
438
438
            else:
439
439
                # we are grepping working tree.
440
440
                if from_dir is None:
453
453
    if revno != None: # grep versioned files
454
454
        for (path, fid), chunks in tree.iter_files_bytes(to_grep):
455
455
            path = _make_display_path(relpath, path)
456
 
            _file_grep(chunks[0], path, opts, revno, path_prefix,
 
456
            _file_grep(''.join(chunks), path, opts, revno, path_prefix,
457
457
                tree.get_file_revision(path, fid))
458
458
 
459
459
 
472
472
    return path
473
473
 
474
474
 
475
 
def versioned_file_grep(tree, path_for_id, relpath, path, opts, revno, path_prefix=None):
 
475
def versioned_file_grep(tree, tree_path, relpath, path, opts, revno, path_prefix = None):
476
476
    """Create a file object for the specified id and pass it on to _file_grep.
477
477
    """
478
478
 
479
479
    path = _make_display_path(relpath, path)
480
 
    file_text = tree.get_file_text(path_for_id)
 
480
    file_text = tree.get_file_text(tree_path)
481
481
    _file_grep(file_text, path, opts, revno, path_prefix)
482
482
 
483
483