sapling/tests/fake-biggrep-client.py
Wez Furlong 67f16a7484 hg: fixup biggrep implementation
Summary:
a couple of problems:

* The recent move from tweakdefaults also broke `bin` symbol, rendering
  this feature completely broken for non svn backed repos
* The `bgr` tool knows about fewer corpuses than we do, so go directly
  to the underlying C++ client binary
* Add configuration options for that binary

Reviewed By: phillco, farnz

Differential Revision: D12849852

fbshipit-source-id: 154d4822d097602505349d3f67b45f19c17a7bf8
2018-10-30 19:13:56 -07:00

42 lines
787 B
Python
Executable File

#!/usr/bin/env python
# This is a terribly anemic fake implementation of the biggrep client
# The null commit
NULL = "0" * 40
# Escape sequences used by biggrep_client
MAGENTA = "\x1b[35m\x1b[K"
OFF = "\x1b[m\x1b[K"
BLUE = "\x1b[36m\x1b[K"
GREEN = "\x1b[32m\x1b[K"
def magenta(what):
return MAGENTA + what + OFF
def blue(what):
return BLUE + what + OFF
def green(what):
return GREEN + what + OFF
def result_line(filename, line, col, context):
return (
magenta(filename)
+ blue(":")
+ green(str(line))
+ blue(":")
+ green(str(col))
+ blue(":")
+ context
)
print("#%s:0" % NULL)
print(result_line("notgrepdir/donotseeme", 10, 1, "lalala"))
print(result_line("grepdir/fakefile", 10, 1, "fakeresult"))