mirror of
https://github.com/facebook/sapling.git
synced 2024-10-09 00:14:35 +03:00
98d9269874
Summary: Create a fork of the Mercurial code that we can use to build server rpms. The hg servers will continue to exist for a few more months while we move the darkstorm and ediscovery use cases off them. In the mean time, we want to start making breaking changes to the client, so let's create a stable copy of the hg code to produce rpms for the hg servers. The fork is based off c7770c78d, the latest hg release. This copies the files as is, then adds some minor tweaks to get it to build: - Disables some lint checks that appear to be bypassed by path - sed replace eden/scm with eden/hg-server - Removed a dependency on scm/telemetry from the edenfs-client tests since scm/telemetry pulls in the original eden/scm/lib/configparser which conflicts with the hg-server conflict parser. allow-large-files Reviewed By: quark-zju Differential Revision: D27632557 fbshipit-source-id: b2f442f4ec000ea08e4d62de068750832198e1f4
88 lines
2.1 KiB
Python
Executable File
88 lines
2.1 KiB
Python
Executable File
#!/usr/bin/env python
|
|
# This is a terribly anemic fake implementation of the biggrep client
|
|
import argparse
|
|
import re
|
|
import subprocess
|
|
|
|
|
|
# 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"
|
|
|
|
|
|
parser = argparse.ArgumentParser()
|
|
parser.add_argument("--stripdir", action="store_true")
|
|
parser.add_argument("-r", action="store_true")
|
|
parser.add_argument("--color")
|
|
parser.add_argument("--expression")
|
|
parser.add_argument("-f")
|
|
parser.add_argument("tier")
|
|
parser.add_argument("corpus")
|
|
parser.add_argument("engine")
|
|
args = parser.parse_args()
|
|
|
|
|
|
def magenta(what):
|
|
if args.color:
|
|
return MAGENTA + what + OFF
|
|
return what
|
|
|
|
|
|
def blue(what):
|
|
if args.color:
|
|
return BLUE + what + OFF
|
|
return what
|
|
|
|
|
|
def green(what):
|
|
if args.color:
|
|
return GREEN + what + OFF
|
|
return what
|
|
|
|
|
|
def result_line(filename, line, col, context):
|
|
if args.f:
|
|
if not re.match(args.f, filename):
|
|
return
|
|
|
|
if not re.match(args.expression, context):
|
|
return
|
|
|
|
print(
|
|
magenta(filename)
|
|
+ blue(":")
|
|
+ green(str(line))
|
|
+ blue(":")
|
|
+ green(str(col))
|
|
+ blue(":")
|
|
+ context
|
|
# stick _bg on the end so we can tell that the result
|
|
# came from biggrep
|
|
+ "_bg"
|
|
)
|
|
|
|
|
|
# Report the current commit as the corpus revision so that `hg grep` doesn't
|
|
# then need to go and run grep for itself over the files
|
|
p = subprocess.Popen(["hg", "log", "-r", ".", "-T{node}"], stdout=subprocess.PIPE)
|
|
out, err = p.communicate()
|
|
rev = out.rstrip()
|
|
print("#fake=%s:0" % rev.decode("utf-8"))
|
|
|
|
# This list is coupled with the "Set up the repository with some simple files"
|
|
# section of eden/hg-server/tests/test-fb-hgext-tweakdefaults-grep.t
|
|
files = {
|
|
"grepdir/grepfile1": "foobarbaz",
|
|
"grepdir/grepfile2": "foobarboo",
|
|
"grepdir/subdir1/subfile1": "foobar_subdir",
|
|
"grepdir/subdir2/subfile2": "foobar_dirsub",
|
|
}
|
|
|
|
for (filename, context) in files.items():
|
|
result_line(filename, 1, 1, context)
|