/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: Jelmer Vernooij
  • Date: 2018-03-24 17:48:04 UTC
  • mfrom: (6921 work)
  • mto: This revision was merged to the branch mainline in revision 6923.
  • Revision ID: jelmer@jelmer.uk-20180324174804-xf22o05byoj12x1q
Merge trunk.

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