mercurial/commands.py
changeset 45699 888e633f0c1c
parent 45698 41e0cbccb260
child 45700 c694b1841a5e
equal deleted inserted replaced
45698:41e0cbccb260 45699:888e633f0c1c
  3517     found = False
  3517     found = False
  3518     follow = opts.get(b'follow')
  3518     follow = opts.get(b'follow')
  3519 
  3519 
  3520     getrenamed = searcher._getrenamed
  3520     getrenamed = searcher._getrenamed
  3521 
  3521 
  3522     def readfile(ctx, fn):
       
  3523         rev = ctx.rev()
       
  3524         if rev is None:
       
  3525             fctx = ctx[fn]
       
  3526             try:
       
  3527                 return fctx.data()
       
  3528             except IOError as e:
       
  3529                 if e.errno != errno.ENOENT:
       
  3530                     raise
       
  3531         else:
       
  3532             flog = getfile(fn)
       
  3533             fnode = ctx.filenode(fn)
       
  3534             try:
       
  3535                 return flog.read(fnode)
       
  3536             except error.CensoredNodeError:
       
  3537                 ui.warn(
       
  3538                     _(
       
  3539                         b'cannot search in censored file: %(filename)s:%(revnum)s\n'
       
  3540                     )
       
  3541                     % {b'filename': fn, b'revnum': pycompat.bytestr(rev),}
       
  3542                 )
       
  3543 
       
  3544     def prep(ctx, fmatch):
  3522     def prep(ctx, fmatch):
  3545         rev = ctx.rev()
  3523         rev = ctx.rev()
  3546         pctx = ctx.p1()
  3524         pctx = ctx.p1()
  3547         matches.setdefault(rev, {})
  3525         matches.setdefault(rev, {})
  3548         if diff:
  3526         if diff:
  3579                 if fn in skip:
  3557                 if fn in skip:
  3580                     continue
  3558                     continue
  3581                 files.append(fn)
  3559                 files.append(fn)
  3582 
  3560 
  3583                 if fn not in matches[rev]:
  3561                 if fn not in matches[rev]:
  3584                     searcher._grepbody(fn, rev, readfile(ctx, fn))
  3562                     searcher._grepbody(fn, rev, searcher._readfile(ctx, fn))
  3585 
  3563 
  3586                 if diff:
  3564                 if diff:
  3587                     pfn = copy or fn
  3565                     pfn = copy or fn
  3588                     if pfn not in matches[parent] and pfn in pctx:
  3566                     if pfn not in matches[parent] and pfn in pctx:
  3589                         searcher._grepbody(pfn, parent, readfile(pctx, pfn))
  3567                         searcher._grepbody(
       
  3568                             pfn, parent, searcher._readfile(pctx, pfn)
       
  3569                         )
  3590 
  3570 
  3591     wopts = logcmdutil.walkopts(
  3571     wopts = logcmdutil.walkopts(
  3592         pats=pats,
  3572         pats=pats,
  3593         opts=opts,
  3573         opts=opts,
  3594         revspec=opts[b'rev'],
  3574         revspec=opts[b'rev'],