/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-04-06 19:28:01 UTC
  • mfrom: (6940 work)
  • mto: This revision was merged to the branch mainline in revision 6960.
  • Revision ID: jelmer@jelmer.uk-20180406192801-0352t3rvkwsy9s51
merge lp:brz

Show diffs side-by-side

added added

removed removed

Lines of Context:
423
423
            continue
424
424
 
425
425
        if fc == 'V' and fkind == 'file':
426
 
            if revno != None:
 
426
            tree_path = osutils.pathjoin(from_dir if from_dir else '', fp)
 
427
            if revno is not None:
427
428
                # If old result is valid, print results immediately.
428
429
                # Otherwise, add file info to to_grep so that the
429
430
                # loop later will get chunks and grep them
430
 
                cache_id = tree.get_file_revision(fp, fid)
 
431
                cache_id = tree.get_file_revision(tree_path, fid)
431
432
                if cache_id in outputter.cache:
432
433
                    # GZ 2010-06-05: Not really sure caching and re-outputting
433
434
                    #                the old path is really the right thing,
434
435
                    #                but it's what the old code seemed to do
435
436
                    outputter.write_cached_lines(cache_id, revno)
436
437
                else:
437
 
                    to_grep_append((osutils.pathjoin(from_dir if from_dir else '', fp), (fp, fid)))
 
438
                    to_grep_append((tree_path, (fp, tree_path)))
438
439
            else:
439
440
                # we are grepping working tree.
440
441
                if from_dir is None:
450
451
                    file_text = open(path_for_file, 'r').read()
451
452
                    _file_grep(file_text, fp, opts, revno, path_prefix)
452
453
 
453
 
    if revno != None: # grep versioned files
454
 
        for (path, fid), chunks in tree.iter_files_bytes(to_grep):
 
454
    if revno is not None: # grep versioned files
 
455
        for (path, tree_path), chunks in tree.iter_files_bytes(to_grep):
455
456
            path = _make_display_path(relpath, path)
456
457
            _file_grep(''.join(chunks), path, opts, revno, path_prefix,
457
 
                tree.get_file_revision(path, fid))
 
458
                tree.get_file_revision(tree_path))
458
459
 
459
460
 
460
461
def _make_display_path(relpath, path):