~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/plugins/grep/grep.py

  • Committer: Jelmer Vernooij
  • Date: 2012-08-02 10:38:21 UTC
  • mto: This revision was merged to the branch mainline in revision 6555.
  • Revision ID: jelmer@samba.org-20120802103821-pto2dgacjtmpzl1n
Move color feature into bzrlib.tests.features.

Show diffs side-by-side

added added

removed removed

Lines of Context:
24
24
import re
25
25
from cStringIO import StringIO
26
26
 
27
 
from bzrlib.plugins.grep.termcolor import color_string, re_color_string, FG
 
27
from bzrlib.termcolor import color_string, re_color_string, FG
28
28
 
29
 
from bzrlib.workingtree import WorkingTree
30
 
from bzrlib.revision import Revision
31
29
from bzrlib.revisionspec import (
32
30
    RevisionSpec,
33
31
    RevisionSpec_revid,
34
32
    RevisionSpec_revno,
35
 
    RevisionInfo,
36
33
    )
37
34
from bzrlib import (
38
35
    bzrdir,
41
38
    lazy_regex,
42
39
    osutils,
43
40
    revision as _mod_revision,
44
 
    textfile,
45
41
    trace,
46
42
    )
47
43
""")
48
44
 
49
 
_terminal_encoding = osutils.get_terminal_encoding()
50
45
_user_encoding = osutils.get_user_encoding()
51
46
 
52
47
 
141
136
class _GrepDiffOutputter(object):
142
137
    """Precalculate formatting based on options given for diff grep.
143
138
    """
 
139
 
144
140
    def __init__(self, opts):
145
141
        self.opts = opts
146
142
        self.outf = opts.outf
232
228
        if len(opts.revision) == 2:
233
229
            end_rev = opts.revision[1]
234
230
            end_revid = end_rev.as_revision_id(branch)
235
 
            if end_revid == None:
 
231
            if end_revid is None:
236
232
                end_revno, end_revid = branch.last_revision_info()
237
233
            erevno_tuple = branch.revision_id_to_dotted_revno(end_revid)
238
234
 
312
308
    try:
313
309
        start_rev = opts.revision[0]
314
310
        start_revid = start_rev.as_revision_id(branch)
315
 
        if start_revid == None:
 
311
        if start_revid is None:
316
312
            start_rev = RevisionSpec_revno.from_string("revno:1")
317
313
            start_revid = start_rev.as_revision_id(branch)
318
314
        srevno_tuple = branch.revision_id_to_dotted_revno(start_revid)
320
316
        if len(opts.revision) == 2:
321
317
            end_rev = opts.revision[1]
322
318
            end_revid = end_rev.as_revision_id(branch)
323
 
            if end_revid == None:
 
319
            if end_revid is None:
324
320
                end_revno, end_revid = branch.last_revision_info()
325
321
            erevno_tuple = branch.revision_id_to_dotted_revno(end_revid)
326
322
 
447
443
                    to_grep_append((fid, (fp, fid)))
448
444
            else:
449
445
                # we are grepping working tree.
450
 
                if from_dir == None:
 
446
                if from_dir is None:
451
447
                    from_dir = '.'
452
448
 
453
449
                path_for_file = osutils.pathjoin(tree.basedir, from_dir, fp)