changeset 43735:7eb701e355bd

merge with stable
author Yuya Nishihara <yuya@tcha.org>
date Fri, 22 Nov 2019 21:42:04 +0900
parents 8ca92bcb3083 (diff) 88a306478556 (current diff)
children 640bae94f2f3
files hgext/remotefilelog/basestore.py hgext/zeroconf/Zeroconf.py mercurial/localrepo.py mercurial/match.py mercurial/patch.py mercurial/util.py
diffstat 365 files changed, 15748 insertions(+), 14741 deletions(-) [+]
line wrap: on
line diff
--- a/.hgignore	Wed Nov 20 19:07:02 2019 +0100
+++ b/.hgignore	Fri Nov 22 21:42:04 2019 +0900
@@ -51,6 +51,7 @@
 cscope.*
 .idea/*
 .asv/*
+.pytype/*
 i18n/hg.pot
 locale/*/LC_MESSAGES/hg.mo
 hgext/__index__.py
--- a/Makefile	Wed Nov 20 19:07:02 2019 +0100
+++ b/Makefile	Fri Nov 22 21:42:04 2019 +0900
@@ -189,7 +189,8 @@
   docker-centos6 \
   docker-centos7 \
   docker-centos8 \
-  docker-debian-jessie \
+  docker-debian-bullseye \
+  docker-debian-buster \
   docker-debian-stretch \
   docker-fedora \
   docker-ubuntu-trusty \
--- a/contrib/automation/hgautomation/windows.py	Wed Nov 20 19:07:02 2019 +0100
+++ b/contrib/automation/hgautomation/windows.py	Fri Nov 22 21:42:04 2019 +0900
@@ -71,7 +71,7 @@
 BUILD_INNO = r'''
 Set-Location C:\hgdev\src
 $python = "C:\hgdev\python27-{arch}\python.exe"
-C:\hgdev\python37-x64\python.exe contrib\packaging\inno\build.py --python $python
+C:\hgdev\python37-x64\python.exe contrib\packaging\packaging.py inno --python $python
 if ($LASTEXITCODE -ne 0) {{
     throw "process exited non-0: $LASTEXITCODE"
 }}
@@ -88,7 +88,7 @@
 BUILD_WIX = r'''
 Set-Location C:\hgdev\src
 $python = "C:\hgdev\python27-{arch}\python.exe"
-C:\hgdev\python37-x64\python.exe contrib\packaging\wix\build.py --python $python {extra_args}
+C:\hgdev\python37-x64\python.exe contrib\packaging\packaging.py wix --python $python {extra_args}
 if ($LASTEXITCODE -ne 0) {{
     throw "process exited non-0: $LASTEXITCODE"
 }}
--- a/contrib/check-code.py	Wed Nov 20 19:07:02 2019 +0100
+++ b/contrib/check-code.py	Fri Nov 22 21:42:04 2019 +0900
@@ -281,10 +281,10 @@
     for tp in testpats[i]:
         p = tp[0]
         m = tp[1]
-        if p.startswith(r'^'):
-            p = r"^  [$>] (%s)" % p[1:]
+        if p.startswith('^'):
+            p = "^  [$>] (%s)" % p[1:]
         else:
-            p = r"^  [$>] .*(%s)" % p
+            p = "^  [$>] .*(%s)" % p
         utestpats[i].append((p, m) + tp[2:])
 
 # don't transform the following rules:
--- a/contrib/check-commit	Wed Nov 20 19:07:02 2019 +0100
+++ b/contrib/check-commit	Fri Nov 22 21:42:04 2019 +0900
@@ -27,32 +27,42 @@
 
 errors = [
     (beforepatch + r".*[(]bc[)]", "(BC) needs to be uppercase"),
-    (beforepatch + r".*[(]issue \d\d\d",
-     "no space allowed between issue and number"),
+    (
+        beforepatch + r".*[(]issue \d\d\d",
+        "no space allowed between issue and number",
+    ),
     (beforepatch + r".*[(]bug(\d|\s)", "use (issueDDDD) instead of bug"),
     (commitheader + r"# User [^@\n]+\n", "username is not an email address"),
-    (commitheader + r"(?!merge with )[^#]\S+[^:] ",
-     "summary line doesn't start with 'topic: '"),
+    (
+        commitheader + r"(?!merge with )[^#]\S+[^:] ",
+        "summary line doesn't start with 'topic: '",
+    ),
     (afterheader + r"[A-Z][a-z]\S+", "don't capitalize summary lines"),
     (afterheader + r"^\S+: *[A-Z][a-z]\S+", "don't capitalize summary lines"),
-    (afterheader + r"\S*[^A-Za-z0-9-_]\S*: ",
-     "summary keyword should be most user-relevant one-word command or topic"),
+    (
+        afterheader + r"\S*[^A-Za-z0-9-_]\S*: ",
+        "summary keyword should be most user-relevant one-word command or topic",
+    ),
     (afterheader + r".*\.\s*\n", "don't add trailing period on summary line"),
     (afterheader + r".{79,}", "summary line too long (limit is 78)"),
 ]
 
 word = re.compile(r'\S')
+
+
 def nonempty(first, second):
     if word.search(first):
         return first
     return second
 
+
 def checkcommit(commit, node=None):
     exitcode = 0
     printed = node is None
     hits = []
-    signtag = (afterheader +
-          r'Added (tag [^ ]+|signature) for changeset [a-f0-9]{12}')
+    signtag = (
+        afterheader + r'Added (tag [^ ]+|signature) for changeset [a-f0-9]{12}'
+    )
     if re.search(signtag, commit):
         return 0
     for exp, msg in errors:
@@ -84,9 +94,11 @@
 
     return exitcode
 
+
 def readcommit(node):
     return os.popen("hg export %s" % node).read()
 
+
 if __name__ == "__main__":
     exitcode = 0
     node = os.environ.get("HG_NODE")
--- a/contrib/dumprevlog	Wed Nov 20 19:07:02 2019 +0100
+++ b/contrib/dumprevlog	Fri Nov 22 21:42:04 2019 +0900
@@ -11,23 +11,26 @@
     pycompat,
     revlog,
 )
-from mercurial.utils import (
-    procutil,
-)
+from mercurial.utils import procutil
 
 for fp in (sys.stdin, sys.stdout, sys.stderr):
     procutil.setbinary(fp)
 
+
 def binopen(path, mode=b'rb'):
     if b'b' not in mode:
         mode = mode + b'b'
     return open(path, pycompat.sysstr(mode))
+
+
 binopen.options = {}
 
+
 def printb(data, end=b'\n'):
     sys.stdout.flush()
     pycompat.stdout.write(data + end)
 
+
 for f in sys.argv[1:]:
     r = revlog.revlog(binopen, encoding.strtolocal(f))
     print("file:", f)
--- a/contrib/examples/fix.hgrc	Wed Nov 20 19:07:02 2019 +0100
+++ b/contrib/examples/fix.hgrc	Fri Nov 22 21:42:04 2019 +0900
@@ -2,7 +2,7 @@
 clang-format:command = clang-format --style file -i
 clang-format:pattern = (**.c or **.cc or **.h) and not "listfile:contrib/clang-format-ignorelist"
 
-rustfmt:command = rustfmt {rootpath}
+rustfmt:command = rustfmt
 rustfmt:pattern = set:**.rs
 
 black:command = black --config=black.toml -
--- a/contrib/fuzz/Makefile	Wed Nov 20 19:07:02 2019 +0100
+++ b/contrib/fuzz/Makefile	Fri Nov 22 21:42:04 2019 +0900
@@ -3,15 +3,6 @@
 
 all: bdiff mpatch xdiff
 
-fuzzutil.o: fuzzutil.cc fuzzutil.h
-	$(CXX) $(CXXFLAGS) -g -O1 \
-	  -std=c++17 \
-	  -I../../mercurial -c -o fuzzutil.o fuzzutil.cc
-
-fuzzutil-oss-fuzz.o: fuzzutil.cc fuzzutil.h
-	$(CXX) $(CXXFLAGS) -std=c++17 \
-	  -I../../mercurial -c -o fuzzutil-oss-fuzz.o fuzzutil.cc
-
 pyutil.o: pyutil.cc pyutil.h
 	$(CXX) $(CXXFLAGS) -g -O1 \
 	  `$$OUT/sanpy/bin/python-config --cflags` \
@@ -21,17 +12,17 @@
 	$(CC) $(CFLAGS) -fsanitize=fuzzer-no-link,address -c -o bdiff.o \
 	  ../../mercurial/bdiff.c
 
-bdiff: bdiff.cc bdiff.o fuzzutil.o
+bdiff: bdiff.cc bdiff.o 
 	$(CXX) $(CXXFLAGS) -DHG_FUZZER_INCLUDE_MAIN=1 -g -O1 -fsanitize=fuzzer-no-link,address \
 	  -std=c++17 \
-	  -I../../mercurial bdiff.cc bdiff.o fuzzutil.o -o bdiff
+	  -I../../mercurial bdiff.cc bdiff.o -o bdiff
 
 bdiff-oss-fuzz.o: ../../mercurial/bdiff.c
 	$(CC) $(CFLAGS) -c -o bdiff-oss-fuzz.o ../../mercurial/bdiff.c
 
-bdiff_fuzzer: bdiff.cc bdiff-oss-fuzz.o fuzzutil-oss-fuzz.o
+bdiff_fuzzer: bdiff.cc bdiff-oss-fuzz.o
 	$(CXX) $(CXXFLAGS) -std=c++17 -I../../mercurial bdiff.cc \
-	  bdiff-oss-fuzz.o fuzzutil-oss-fuzz.o -lFuzzingEngine -o \
+	  bdiff-oss-fuzz.o -lFuzzingEngine -o \
 	  $$OUT/bdiff_fuzzer
 
 mpatch.o: ../../mercurial/mpatch.c
@@ -39,16 +30,16 @@
 	  ../../mercurial/mpatch.c
 
 mpatch: CXXFLAGS += -std=c++17
-mpatch: mpatch.cc mpatch.o fuzzutil.o
+mpatch: mpatch.cc mpatch.o
 	$(CXX) $(CXXFLAGS) -DHG_FUZZER_INCLUDE_MAIN=1 -g -O1 -fsanitize=fuzzer-no-link,address \
-	  -I../../mercurial mpatch.cc mpatch.o fuzzutil.o -o mpatch
+	  -I../../mercurial mpatch.cc mpatch.o -o mpatch
 
 mpatch-oss-fuzz.o: ../../mercurial/mpatch.c
 	$(CC) $(CFLAGS) -c -o mpatch-oss-fuzz.o ../../mercurial/mpatch.c
 
-mpatch_fuzzer: mpatch.cc mpatch-oss-fuzz.o fuzzutil-oss-fuzz.o
+mpatch_fuzzer: mpatch.cc mpatch-oss-fuzz.o 
 	$(CXX) $(CXXFLAGS) -std=c++17 -I../../mercurial mpatch.cc \
-	  mpatch-oss-fuzz.o fuzzutil-oss-fuzz.o -lFuzzingEngine -o \
+	  mpatch-oss-fuzz.o -lFuzzingEngine -o \
 	  $$OUT/mpatch_fuzzer
 
 mpatch_corpus.zip:
@@ -60,19 +51,19 @@
 	  $<
 
 xdiff: CXXFLAGS += -std=c++17
-xdiff: xdiff.cc xdiffi.o xprepare.o xutils.o fuzzutil.o
+xdiff: xdiff.cc xdiffi.o xprepare.o xutils.o 
 	$(CXX) $(CXXFLAGS) -DHG_FUZZER_INCLUDE_MAIN=1 -g -O1 -fsanitize=fuzzer-no-link,address \
 	  -I../../mercurial xdiff.cc \
-	  xdiffi.o xprepare.o xutils.o fuzzutil.o -o xdiff
+	  xdiffi.o xprepare.o xutils.o -o xdiff
 
 fuzz-x%.o: ../../mercurial/thirdparty/xdiff/x%.c ../../mercurial/thirdparty/xdiff/*.h
 	$(CC) $(CFLAGS) -c \
 	  -o $@ \
 	  $<
 
-xdiff_fuzzer: xdiff.cc fuzz-xdiffi.o fuzz-xprepare.o fuzz-xutils.o fuzzutil-oss-fuzz.o
+xdiff_fuzzer: xdiff.cc fuzz-xdiffi.o fuzz-xprepare.o fuzz-xutils.o 
 	$(CXX) $(CXXFLAGS) -std=c++17 -I../../mercurial xdiff.cc \
-	  fuzz-xdiffi.o fuzz-xprepare.o fuzz-xutils.o fuzzutil-oss-fuzz.o \
+	  fuzz-xdiffi.o fuzz-xprepare.o fuzz-xutils.o \
 	  -lFuzzingEngine -o $$OUT/xdiff_fuzzer
 
 manifest.o: ../../mercurial/cext/manifest.c
--- a/contrib/fuzz/bdiff.cc	Wed Nov 20 19:07:02 2019 +0100
+++ b/contrib/fuzz/bdiff.cc	Fri Nov 22 21:42:04 2019 +0900
@@ -9,22 +9,20 @@
 #include <memory>
 #include <stdlib.h>
 
-#include "fuzzutil.h"
+#include <fuzzer/FuzzedDataProvider.h>
 
 extern "C" {
 #include "bdiff.h"
 
 int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size)
 {
-	auto maybe_inputs = SplitInputs(Data, Size);
-	if (!maybe_inputs) {
-		return 0;
-	}
-	auto inputs = std::move(maybe_inputs.value());
+	FuzzedDataProvider provider(Data, Size);
+	std::string left = provider.ConsumeRandomLengthString(Size);
+	std::string right = provider.ConsumeRemainingBytesAsString();
 
 	struct bdiff_line *a, *b;
-	int an = bdiff_splitlines(inputs.left.get(), inputs.left_size, &a);
-	int bn = bdiff_splitlines(inputs.right.get(), inputs.right_size, &b);
+	int an = bdiff_splitlines(left.c_str(), left.size(), &a);
+	int bn = bdiff_splitlines(right.c_str(), right.size(), &b);
 	struct bdiff_hunk l;
 	bdiff_diff(a, an, b, bn, &l);
 	free(a);
--- a/contrib/fuzz/fuzzutil.cc	Wed Nov 20 19:07:02 2019 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,27 +0,0 @@
-#include "fuzzutil.h"
-
-#include <cstring>
-#include <utility>
-
-contrib::optional<two_inputs> SplitInputs(const uint8_t *Data, size_t Size)
-{
-	if (!Size) {
-		return contrib::nullopt;
-	}
-	// figure out a random point in [0, Size] to split our input.
-	size_t left_size = (Data[0] / 255.0) * (Size - 1);
-
-	// Copy inputs to new allocations so if bdiff over-reads
-	// AddressSanitizer can detect it.
-	std::unique_ptr<char[]> left(new char[left_size]);
-	std::memcpy(left.get(), Data + 1, left_size);
-	// right starts at the next byte after left ends
-	size_t right_size = Size - (left_size + 1);
-	std::unique_ptr<char[]> right(new char[right_size]);
-	std::memcpy(right.get(), Data + 1 + left_size, right_size);
-	LOG(2) << "inputs are  " << left_size << " and " << right_size
-	       << " bytes" << std::endl;
-	two_inputs result = {std::move(right), right_size, std::move(left),
-	                     left_size};
-	return result;
-}
--- a/contrib/fuzz/fuzzutil.h	Wed Nov 20 19:07:02 2019 +0100
+++ b/contrib/fuzz/fuzzutil.h	Fri Nov 22 21:42:04 2019 +0900
@@ -34,14 +34,4 @@
 	if (level <= DEBUG)                                                    \
 	std::cout
 
-struct two_inputs {
-	std::unique_ptr<char[]> right;
-	size_t right_size;
-	std::unique_ptr<char[]> left;
-	size_t left_size;
-};
-
-/* Split a non-zero-length input into two inputs. */
-contrib::optional<two_inputs> SplitInputs(const uint8_t *Data, size_t Size);
-
 #endif /* CONTRIB_FUZZ_FUZZUTIL_H */
--- a/contrib/fuzz/xdiff.cc	Wed Nov 20 19:07:02 2019 +0100
+++ b/contrib/fuzz/xdiff.cc	Fri Nov 22 21:42:04 2019 +0900
@@ -10,7 +10,7 @@
 #include <inttypes.h>
 #include <stdlib.h>
 
-#include "fuzzutil.h"
+#include <fuzzer/FuzzedDataProvider.h>
 
 extern "C" {
 
@@ -27,17 +27,15 @@
 	if (Size > 100000) {
 		return 0;
 	}
-	auto maybe_inputs = SplitInputs(Data, Size);
-	if (!maybe_inputs) {
-		return 0;
-	}
-	auto inputs = std::move(maybe_inputs.value());
+	FuzzedDataProvider provider(Data, Size);
+	std::string left = provider.ConsumeRandomLengthString(Size);
+	std::string right = provider.ConsumeRemainingBytesAsString();
 	mmfile_t a, b;
 
-	a.ptr = inputs.left.get();
-	a.size = inputs.left_size;
-	b.ptr = inputs.right.get();
-	b.size = inputs.right_size;
+	a.ptr = (char *)left.c_str();
+	a.size = left.size();
+	b.ptr = (char *)right.c_str();
+	b.size = right.size();
 	xpparam_t xpp = {
 	    XDF_INDENT_HEURISTIC, /* flags */
 	};
--- a/contrib/hg-ssh	Wed Nov 20 19:07:02 2019 +0100
+++ b/contrib/hg-ssh	Fri Nov 22 21:42:04 2019 +0900
@@ -35,7 +35,9 @@
 import sys
 
 # enable importing on demand to reduce startup time
-import hgdemandimport ; hgdemandimport.enable()
+import hgdemandimport
+
+hgdemandimport.enable()
 
 from mercurial import (
     dispatch,
@@ -43,6 +45,7 @@
     ui as uimod,
 )
 
+
 def main():
     # Prevent insertion/deletion of CRs
     dispatch.initstdio()
@@ -56,9 +59,10 @@
             args.pop(0)
         else:
             break
-    allowed_paths = [os.path.normpath(os.path.join(cwd,
-                                                   os.path.expanduser(path)))
-                     for path in args]
+    allowed_paths = [
+        os.path.normpath(os.path.join(cwd, os.path.expanduser(path)))
+        for path in args
+    ]
     orig_cmd = os.getenv('SSH_ORIGINAL_COMMAND', '?')
     try:
         cmdargv = shlex.split(orig_cmd)
@@ -75,10 +79,18 @@
             if readonly:
                 if not req.ui:
                     req.ui = uimod.ui.load()
-                req.ui.setconfig(b'hooks', b'pretxnopen.hg-ssh',
-                                 b'python:__main__.rejectpush', b'hg-ssh')
-                req.ui.setconfig(b'hooks', b'prepushkey.hg-ssh',
-                                 b'python:__main__.rejectpush', b'hg-ssh')
+                req.ui.setconfig(
+                    b'hooks',
+                    b'pretxnopen.hg-ssh',
+                    b'python:__main__.rejectpush',
+                    b'hg-ssh',
+                )
+                req.ui.setconfig(
+                    b'hooks',
+                    b'prepushkey.hg-ssh',
+                    b'python:__main__.rejectpush',
+                    b'hg-ssh',
+                )
             dispatch.dispatch(req)
         else:
             sys.stderr.write('Illegal repository "%s"\n' % repo)
@@ -87,11 +99,13 @@
         sys.stderr.write('Illegal command "%s"\n' % orig_cmd)
         sys.exit(255)
 
+
 def rejectpush(ui, **kwargs):
     ui.warn((b"Permission denied\n"))
     # mercurial hooks use unix process conventions for hook return values
     # so a truthy return means failure
     return True
 
+
 if __name__ == '__main__':
     main()
--- a/contrib/hgclient.py	Wed Nov 20 19:07:02 2019 +0100
+++ b/contrib/hgclient.py	Fri Nov 22 21:42:04 2019 +0900
@@ -39,7 +39,7 @@
     cmdline.extend(extraargs)
 
     def tonative(cmdline):
-        if os.name != r'nt':
+        if os.name != 'nt':
             return cmdline
         return [arg.decode("utf-8") for arg in cmdline]
 
--- a/contrib/hgperf	Wed Nov 20 19:07:02 2019 +0100
+++ b/contrib/hgperf	Fri Nov 22 21:42:04 2019 +0900
@@ -37,18 +37,24 @@
 
 if libdir != '@' 'LIBDIR' '@':
     if not os.path.isabs(libdir):
-        libdir = os.path.join(os.path.dirname(os.path.realpath(__file__)),
-                              libdir)
+        libdir = os.path.join(
+            os.path.dirname(os.path.realpath(__file__)), libdir
+        )
         libdir = os.path.abspath(libdir)
     sys.path.insert(0, libdir)
 
 # enable importing on demand to reduce startup time
 try:
-    from mercurial import demandimport; demandimport.enable()
+    from mercurial import demandimport
+
+    demandimport.enable()
 except ImportError:
     import sys
-    sys.stderr.write("abort: couldn't find mercurial libraries in [%s]\n" %
-                     ' '.join(sys.path))
+
+    sys.stderr.write(
+        "abort: couldn't find mercurial libraries in [%s]\n"
+        % ' '.join(sys.path)
+    )
     sys.stderr.write("(check your install and PYTHONPATH)\n")
     sys.exit(-1)
 
@@ -57,6 +63,7 @@
     util,
 )
 
+
 def timer(func, title=None):
     results = []
     begin = util.timer()
@@ -69,7 +76,7 @@
         ostop = os.times()
         count += 1
         a, b = ostart, ostop
-        results.append((cstop - cstart, b[0] - a[0], b[1]-a[1]))
+        results.append((cstop - cstart, b[0] - a[0], b[1] - a[1]))
         if cstop - begin > 3 and count >= 100:
             break
         if cstop - begin > 10 and count >= 3:
@@ -79,19 +86,27 @@
     if r:
         sys.stderr.write("! result: %s\n" % r)
     m = min(results)
-    sys.stderr.write("! wall %f comb %f user %f sys %f (best of %d)\n"
-                     % (m[0], m[1] + m[2], m[1], m[2], count))
+    sys.stderr.write(
+        "! wall %f comb %f user %f sys %f (best of %d)\n"
+        % (m[0], m[1] + m[2], m[1], m[2], count)
+    )
+
 
 orgruncommand = dispatch.runcommand
 
+
 def runcommand(lui, repo, cmd, fullargs, ui, options, d, cmdpats, cmdoptions):
     ui.pushbuffer()
     lui.pushbuffer()
-    timer(lambda : orgruncommand(lui, repo, cmd, fullargs, ui,
-                                 options, d, cmdpats, cmdoptions))
+    timer(
+        lambda: orgruncommand(
+            lui, repo, cmd, fullargs, ui, options, d, cmdpats, cmdoptions
+        )
+    )
     ui.popbuffer()
     lui.popbuffer()
 
+
 dispatch.runcommand = runcommand
 
 dispatch.run()
--- a/contrib/hgweb.fcgi	Wed Nov 20 19:07:02 2019 +0100
+++ b/contrib/hgweb.fcgi	Fri Nov 22 21:42:04 2019 +0900
@@ -7,13 +7,16 @@
 
 # Uncomment and adjust if Mercurial is not installed system-wide
 # (consult "installed modules" path from 'hg debuginstall'):
-#import sys; sys.path.insert(0, "/path/to/python/lib")
+# import sys; sys.path.insert(0, "/path/to/python/lib")
 
 # Uncomment to send python tracebacks to the browser if an error occurs:
-#import cgitb; cgitb.enable()
+# import cgitb; cgitb.enable()
 
-from mercurial import demandimport; demandimport.enable()
+from mercurial import demandimport
+
+demandimport.enable()
 from mercurial.hgweb import hgweb
 from flup.server.fcgi import WSGIServer
+
 application = hgweb(config)
 WSGIServer(application).run()
--- a/contrib/import-checker.py	Wed Nov 20 19:07:02 2019 +0100
+++ b/contrib/import-checker.py	Fri Nov 22 21:42:04 2019 +0900
@@ -535,6 +535,8 @@
             if fullname != '__future__':
                 if not fullname or (
                     fullname in stdlib_modules
+                    # allow standard 'from typing import ...' style
+                    and fullname != 'typing'
                     and fullname not in localmods
                     and fullname + '.__init__' not in localmods
                 ):
--- a/contrib/packaging/hg-docker	Wed Nov 20 19:07:02 2019 +0100
+++ b/contrib/packaging/hg-docker	Fri Nov 22 21:42:04 2019 +0900
@@ -11,6 +11,7 @@
 import subprocess
 import sys
 
+
 def get_docker() -> str:
     docker = shutil.which('docker.io') or shutil.which('docker')
     if not docker:
@@ -21,15 +22,16 @@
         out = subprocess.check_output([docker, '-h'], stderr=subprocess.STDOUT)
 
         if b'Jansens' in out:
-            print('%s is the Docking System Tray; try installing docker.io' %
-                  docker)
+            print(
+                '%s is the Docking System Tray; try installing docker.io'
+                % docker
+            )
             sys.exit(1)
     except subprocess.CalledProcessError as e:
         print('error calling `%s -h`: %s' % (docker, e.output))
         sys.exit(1)
 
-    out = subprocess.check_output([docker, 'version'],
-                                  stderr=subprocess.STDOUT)
+    out = subprocess.check_output([docker, 'version'], stderr=subprocess.STDOUT)
 
     lines = out.splitlines()
     if not any(l.startswith((b'Client:', b'Client version:')) for l in lines):
@@ -42,6 +44,7 @@
 
     return docker
 
+
 def get_dockerfile(path: pathlib.Path, args: list) -> bytes:
     with path.open('rb') as fh:
         df = fh.read()
@@ -51,6 +54,7 @@
 
     return df
 
+
 def build_docker_image(dockerfile: pathlib.Path, params: list, tag: str):
     """Build a Docker image from a templatized Dockerfile."""
     docker = get_docker()
@@ -65,9 +69,12 @@
     args = [
         docker,
         'build',
-        '--build-arg', 'http_proxy',
-        '--build-arg', 'https_proxy',
-        '--tag', tag,
+        '--build-arg',
+        'http_proxy',
+        '--build-arg',
+        'https_proxy',
+        '--tag',
+        tag,
         '-',
     ]
 
@@ -76,8 +83,10 @@
     p.communicate(input=dockerfile)
     if p.returncode:
         raise subprocess.CalledProcessException(
-                p.returncode, 'failed to build docker image: %s %s'
-                % (p.stdout, p.stderr))
+            p.returncode,
+            'failed to build docker image: %s %s' % (p.stdout, p.stderr),
+        )
+
 
 def command_build(args):
     build_args = []
@@ -85,13 +94,13 @@
         k, v = arg.split('=', 1)
         build_args.append((k.encode('utf-8'), v.encode('utf-8')))
 
-    build_docker_image(pathlib.Path(args.dockerfile),
-                       build_args,
-                       args.tag)
+    build_docker_image(pathlib.Path(args.dockerfile), build_args, args.tag)
+
 
 def command_docker(args):
     print(get_docker())
 
+
 def main() -> int:
     parser = argparse.ArgumentParser()
 
@@ -99,9 +108,12 @@
 
     build = subparsers.add_parser('build', help='Build a Docker image')
     build.set_defaults(func=command_build)
-    build.add_argument('--build-arg', action='append', default=[],
-                        help='Substitution to perform in Dockerfile; '
-                             'format: key=value')
+    build.add_argument(
+        '--build-arg',
+        action='append',
+        default=[],
+        help='Substitution to perform in Dockerfile; ' 'format: key=value',
+    )
     build.add_argument('dockerfile', help='path to Dockerfile to use')
     build.add_argument('tag', help='Tag to apply to created image')
 
@@ -112,5 +124,6 @@
 
     return args.func(args)
 
+
 if __name__ == '__main__':
     sys.exit(main())
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/contrib/packaging/hgpackaging/cli.py	Fri Nov 22 21:42:04 2019 +0900
@@ -0,0 +1,153 @@
+# cli.py - Command line interface for automation
+#
+# Copyright 2019 Gregory Szorc <gregory.szorc@gmail.com>
+#
+# This software may be used and distributed according to the terms of the
+# GNU General Public License version 2 or any later version.
+
+# no-check-code because Python 3 native.
+
+import argparse
+import os
+import pathlib
+
+from . import (
+    inno,
+    wix,
+)
+
+HERE = pathlib.Path(os.path.abspath(os.path.dirname(__file__)))
+SOURCE_DIR = HERE.parent.parent.parent
+
+
+def build_inno(python=None, iscc=None, version=None):
+    if not os.path.isabs(python):
+        raise Exception("--python arg must be an absolute path")
+
+    if iscc:
+        iscc = pathlib.Path(iscc)
+    else:
+        iscc = (
+            pathlib.Path(os.environ["ProgramFiles(x86)"])
+            / "Inno Setup 5"
+            / "ISCC.exe"
+        )
+
+    build_dir = SOURCE_DIR / "build"
+
+    inno.build(
+        SOURCE_DIR, build_dir, pathlib.Path(python), iscc, version=version,
+    )
+
+
+def build_wix(
+    name=None,
+    python=None,
+    version=None,
+    sign_sn=None,
+    sign_cert=None,
+    sign_password=None,
+    sign_timestamp_url=None,
+    extra_packages_script=None,
+    extra_wxs=None,
+    extra_features=None,
+):
+    fn = wix.build_installer
+    kwargs = {
+        "source_dir": SOURCE_DIR,
+        "python_exe": pathlib.Path(python),
+        "version": version,
+    }
+
+    if not os.path.isabs(python):
+        raise Exception("--python arg must be an absolute path")
+
+    if extra_packages_script:
+        kwargs["extra_packages_script"] = extra_packages_script
+    if extra_wxs:
+        kwargs["extra_wxs"] = dict(
+            thing.split("=") for thing in extra_wxs.split(",")
+        )
+    if extra_features:
+        kwargs["extra_features"] = extra_features.split(",")
+
+    if sign_sn or sign_cert:
+        fn = wix.build_signed_installer
+        kwargs["name"] = name
+        kwargs["subject_name"] = sign_sn
+        kwargs["cert_path"] = sign_cert
+        kwargs["cert_password"] = sign_password
+        kwargs["timestamp_url"] = sign_timestamp_url
+
+    fn(**kwargs)
+
+
+def get_parser():
+    parser = argparse.ArgumentParser()
+
+    subparsers = parser.add_subparsers()
+
+    sp = subparsers.add_parser("inno", help="Build Inno Setup installer")
+    sp.add_argument("--python", required=True, help="path to python.exe to use")
+    sp.add_argument("--iscc", help="path to iscc.exe to use")
+    sp.add_argument(
+        "--version",
+        help="Mercurial version string to use "
+        "(detected from __version__.py if not defined",
+    )
+    sp.set_defaults(func=build_inno)
+
+    sp = subparsers.add_parser(
+        "wix", help="Build Windows installer with WiX Toolset"
+    )
+    sp.add_argument("--name", help="Application name", default="Mercurial")
+    sp.add_argument(
+        "--python", help="Path to Python executable to use", required=True
+    )
+    sp.add_argument(
+        "--sign-sn",
+        help="Subject name (or fragment thereof) of certificate "
+        "to use for signing",
+    )
+    sp.add_argument(
+        "--sign-cert", help="Path to certificate to use for signing"
+    )
+    sp.add_argument("--sign-password", help="Password for signing certificate")
+    sp.add_argument(
+        "--sign-timestamp-url",
+        help="URL of timestamp server to use for signing",
+    )
+    sp.add_argument("--version", help="Version string to use")
+    sp.add_argument(
+        "--extra-packages-script",
+        help=(
+            "Script to execute to include extra packages in " "py2exe binary."
+        ),
+    )
+    sp.add_argument(
+        "--extra-wxs", help="CSV of path_to_wxs_file=working_dir_for_wxs_file"
+    )
+    sp.add_argument(
+        "--extra-features",
+        help=(
+            "CSV of extra feature names to include "
+            "in the installer from the extra wxs files"
+        ),
+    )
+    sp.set_defaults(func=build_wix)
+
+    return parser
+
+
+def main():
+    parser = get_parser()
+    args = parser.parse_args()
+
+    if not hasattr(args, "func"):
+        parser.print_help()
+        return
+
+    kwargs = dict(vars(args))
+    del kwargs["func"]
+
+    args.func(**kwargs)
--- a/contrib/packaging/hgpackaging/inno.py	Wed Nov 20 19:07:02 2019 +0100
+++ b/contrib/packaging/hgpackaging/inno.py	Fri Nov 22 21:42:04 2019 +0900
@@ -12,9 +12,16 @@
 import shutil
 import subprocess
 
-from .py2exe import build_py2exe
-from .util import find_vc_runtime_files
+import jinja2
 
+from .py2exe import (
+    build_py2exe,
+    stage_install,
+)
+from .util import (
+    find_vc_runtime_files,
+    read_version_py,
+)
 
 EXTRA_PACKAGES = {
     'dulwich',
@@ -23,6 +30,10 @@
     'win32ctypes',
 }
 
+PACKAGE_FILES_METADATA = {
+    'ReadMe.html': 'Flags: isreadme',
+}
+
 
 def build(
     source_dir: pathlib.Path,
@@ -43,11 +54,17 @@
         raise Exception('%s does not exist' % iscc_exe)
 
     vc_x64 = r'\x64' in os.environ.get('LIB', '')
+    arch = 'x64' if vc_x64 else 'x86'
+    inno_source_dir = source_dir / 'contrib' / 'packaging' / 'inno'
+    inno_build_dir = build_dir / ('inno-%s' % arch)
+    staging_dir = inno_build_dir / 'stage'
 
     requirements_txt = (
         source_dir / 'contrib' / 'packaging' / 'inno' / 'requirements.txt'
     )
 
+    inno_build_dir.mkdir(parents=True, exist_ok=True)
+
     build_py2exe(
         source_dir,
         build_dir,
@@ -57,6 +74,15 @@
         extra_packages=EXTRA_PACKAGES,
     )
 
+    # Purge the staging directory for every build so packaging is
+    # pristine.
+    if staging_dir.exists():
+        print('purging %s' % staging_dir)
+        shutil.rmtree(staging_dir)
+
+    # Now assemble all the packaged files into the staging directory.
+    stage_install(source_dir, staging_dir)
+
     # hg.exe depends on VC9 runtime DLLs. Copy those into place.
     for f in find_vc_runtime_files(vc_x64):
         if f.name.endswith('.manifest'):
@@ -64,22 +90,74 @@
         else:
             basename = f.name
 
-        dest_path = source_dir / 'dist' / basename
+        dest_path = staging_dir / basename
 
         print('copying %s to %s' % (f, dest_path))
         shutil.copyfile(f, dest_path)
 
+    # The final package layout is simply a mirror of the staging directory.
+    package_files = []
+    for root, dirs, files in os.walk(staging_dir):
+        dirs.sort()
+
+        root = pathlib.Path(root)
+
+        for f in sorted(files):
+            full = root / f
+            rel = full.relative_to(staging_dir)
+            if str(rel.parent) == '.':
+                dest_dir = '{app}'
+            else:
+                dest_dir = '{app}\\%s' % rel.parent
+
+            package_files.append(
+                {
+                    'source': rel,
+                    'dest_dir': dest_dir,
+                    'metadata': PACKAGE_FILES_METADATA.get(str(rel), None),
+                }
+            )
+
     print('creating installer')
 
+    # Install Inno files by rendering a template.
+    jinja_env = jinja2.Environment(
+        loader=jinja2.FileSystemLoader(str(inno_source_dir)),
+        # Need to change these to prevent conflict with Inno Setup.
+        comment_start_string='{##',
+        comment_end_string='##}',
+    )
+
+    try:
+        template = jinja_env.get_template('mercurial.iss')
+    except jinja2.TemplateSyntaxError as e:
+        raise Exception(
+            'template syntax error at %s:%d: %s'
+            % (e.name, e.lineno, e.message,)
+        )
+
+    content = template.render(package_files=package_files)
+
+    with (inno_build_dir / 'mercurial.iss').open('w', encoding='utf-8') as fh:
+        fh.write(content)
+
+    # Copy additional files used by Inno.
+    for p in ('mercurial.ico', 'postinstall.txt'):
+        shutil.copyfile(
+            source_dir / 'contrib' / 'win32' / p, inno_build_dir / p
+        )
+
     args = [str(iscc_exe)]
 
     if vc_x64:
         args.append('/dARCH=x64')
 
-    if version:
-        args.append('/dVERSION=%s' % version)
+    if not version:
+        version = read_version_py(source_dir)
+
+    args.append('/dVERSION=%s' % version)
 
     args.append('/Odist')
-    args.append('contrib/packaging/inno/mercurial.iss')
+    args.append(str(inno_build_dir / 'mercurial.iss'))
 
     subprocess.run(args, cwd=str(source_dir), check=True)
--- a/contrib/packaging/hgpackaging/py2exe.py	Wed Nov 20 19:07:02 2019 +0100
+++ b/contrib/packaging/hgpackaging/py2exe.py	Fri Nov 22 21:42:04 2019 +0900
@@ -15,10 +15,48 @@
 from .util import (
     extract_tar_to_directory,
     extract_zip_to_directory,
+    process_install_rules,
     python_exe_info,
 )
 
 
+STAGING_RULES = [
+    ('contrib/bash_completion', 'Contrib/'),
+    ('contrib/hgk', 'Contrib/hgk.tcl'),
+    ('contrib/hgweb.fcgi', 'Contrib/'),
+    ('contrib/hgweb.wsgi', 'Contrib/'),
+    ('contrib/logo-droplets.svg', 'Contrib/'),
+    ('contrib/mercurial.el', 'Contrib/'),
+    ('contrib/mq.el', 'Contrib/'),
+    ('contrib/tcsh_completion', 'Contrib/'),
+    ('contrib/tcsh_completion_build.sh', 'Contrib/'),
+    ('contrib/vim/*', 'Contrib/Vim/'),
+    ('contrib/win32/postinstall.txt', 'ReleaseNotes.txt'),
+    ('contrib/win32/ReadMe.html', 'ReadMe.html'),
+    ('contrib/xml.rnc', 'Contrib/'),
+    ('contrib/zsh_completion', 'Contrib/'),
+    ('dist/hg.exe', './'),
+    ('dist/lib/*.dll', 'lib/'),
+    ('dist/lib/*.pyd', 'lib/'),
+    ('dist/lib/library.zip', 'lib/'),
+    ('dist/Microsoft.VC*.CRT.manifest', './'),
+    ('dist/msvc*.dll', './'),
+    ('dist/python*.dll', './'),
+    ('doc/*.html', 'doc/'),
+    ('doc/style.css', 'doc/'),
+    ('mercurial/help/**/*.txt', 'help/'),
+    ('mercurial/default.d/*.rc', 'hgrc.d/'),
+    ('mercurial/locale/**/*', 'locale/'),
+    ('mercurial/templates/**/*', 'Templates/'),
+    ('COPYING', 'Copying.txt'),
+]
+
+# List of paths to exclude from the staging area.
+STAGING_EXCLUDES = [
+    'doc/hg-ssh.8.html',
+]
+
+
 def build_py2exe(
     source_dir: pathlib.Path,
     build_dir: pathlib.Path,
@@ -169,3 +207,39 @@
         env=env,
         check=True,
     )
+
+
+def stage_install(
+    source_dir: pathlib.Path, staging_dir: pathlib.Path, lower_case=False
+):
+    """Copy all files to be installed to a directory.
+
+    This allows packaging to simply walk a directory tree to find source
+    files.
+    """
+    if lower_case:
+        rules = []
+        for source, dest in STAGING_RULES:
+            # Only lower directory names.
+            if '/' in dest:
+                parent, leaf = dest.rsplit('/', 1)
+                dest = '%s/%s' % (parent.lower(), leaf)
+            rules.append((source, dest))
+    else:
+        rules = STAGING_RULES
+
+    process_install_rules(rules, source_dir, staging_dir)
+
+    # Write out a default editor.rc file to configure notepad as the
+    # default editor.
+    with (staging_dir / 'hgrc.d' / 'editor.rc').open(
+        'w', encoding='utf-8'
+    ) as fh:
+        fh.write('[ui]\neditor = notepad\n')
+
+    # Purge any files we don't want to be there.
+    for f in STAGING_EXCLUDES:
+        p = staging_dir / f
+        if p.exists():
+            print('removing %s' % p)
+            p.unlink()
--- a/contrib/packaging/hgpackaging/util.py	Wed Nov 20 19:07:02 2019 +0100
+++ b/contrib/packaging/hgpackaging/util.py	Fri Nov 22 21:42:04 2019 +0900
@@ -9,8 +9,11 @@
 
 import distutils.version
 import getpass
+import glob
 import os
 import pathlib
+import re
+import shutil
 import subprocess
 import tarfile
 import zipfile
@@ -164,3 +167,60 @@
         'version': version,
         'py3': version >= distutils.version.LooseVersion('3'),
     }
+
+
+def process_install_rules(
+    rules: list, source_dir: pathlib.Path, dest_dir: pathlib.Path
+):
+    for source, dest in rules:
+        if '*' in source:
+            if not dest.endswith('/'):
+                raise ValueError('destination must end in / when globbing')
+
+            # We strip off the source path component before the first glob
+            # character to construct the relative install path.
+            prefix_end_index = source[: source.index('*')].rindex('/')
+            relative_prefix = source_dir / source[0:prefix_end_index]
+
+            for res in glob.glob(str(source_dir / source), recursive=True):
+                source_path = pathlib.Path(res)
+
+                if source_path.is_dir():
+                    continue
+
+                rel_path = source_path.relative_to(relative_prefix)
+
+                dest_path = dest_dir / dest[:-1] / rel_path
+
+                dest_path.parent.mkdir(parents=True, exist_ok=True)
+                print('copying %s to %s' % (source_path, dest_path))
+                shutil.copy(source_path, dest_path)
+
+        # Simple file case.
+        else:
+            source_path = pathlib.Path(source)
+
+            if dest.endswith('/'):
+                dest_path = pathlib.Path(dest) / source_path.name
+            else:
+                dest_path = pathlib.Path(dest)
+
+            full_source_path = source_dir / source_path
+            full_dest_path = dest_dir / dest_path
+
+            full_dest_path.parent.mkdir(parents=True, exist_ok=True)
+            shutil.copy(full_source_path, full_dest_path)
+            print('copying %s to %s' % (full_source_path, full_dest_path))
+
+
+def read_version_py(source_dir):
+    """Read the mercurial/__version__.py file to resolve the version string."""
+    p = source_dir / 'mercurial' / '__version__.py'
+
+    with p.open('r', encoding='utf-8') as fh:
+        m = re.search('version = b"([^"]+)"', fh.read(), re.MULTILINE)
+
+        if not m:
+            raise Exception('could not parse %s' % p)
+
+        return m.group(1)
--- a/contrib/packaging/hgpackaging/wix.py	Wed Nov 20 19:07:02 2019 +0100
+++ b/contrib/packaging/hgpackaging/wix.py	Fri Nov 22 21:42:04 2019 +0900
@@ -7,39 +7,60 @@
 
 # no-check-code because Python 3 native.
 
+import collections
 import os
 import pathlib
 import re
+import shutil
 import subprocess
-import tempfile
 import typing
+import uuid
 import xml.dom.minidom
 
 from .downloads import download_entry
-from .py2exe import build_py2exe
+from .py2exe import (
+    build_py2exe,
+    stage_install,
+)
 from .util import (
     extract_zip_to_directory,
+    process_install_rules,
     sign_with_signtool,
 )
 
 
-SUPPORT_WXS = [
-    ('contrib.wxs', r'contrib'),
-    ('dist.wxs', r'dist'),
-    ('doc.wxs', r'doc'),
-    ('help.wxs', r'mercurial\help'),
-    ('i18n.wxs', r'i18n'),
-    ('locale.wxs', r'mercurial\locale'),
-    ('templates.wxs', r'mercurial\templates'),
-]
-
-
 EXTRA_PACKAGES = {
     'distutils',
     'pygments',
 }
 
 
+EXTRA_INSTALL_RULES = [
+    ('contrib/packaging/wix/COPYING.rtf', 'COPYING.rtf'),
+    ('contrib/win32/mercurial.ini', 'hgrc.d/mercurial.rc'),
+]
+
+STAGING_REMOVE_FILES = [
+    # We use the RTF variant.
+    'copying.txt',
+]
+
+SHORTCUTS = {
+    # hg.1.html'
+    'hg.file.5d3e441c_28d9_5542_afd0_cdd4234f12d5': {
+        'Name': 'Mercurial Command Reference',
+    },
+    # hgignore.5.html
+    'hg.file.5757d8e0_f207_5e10_a2ec_3ba0a062f431': {
+        'Name': 'Mercurial Ignore Files',
+    },
+    # hgrc.5.html
+    'hg.file.92e605fd_1d1a_5dc6_9fc0_5d2998eb8f5e': {
+        'Name': 'Mercurial Configuration Files',
+    },
+}
+
+
 def find_version(source_dir: pathlib.Path):
     version_py = source_dir / 'mercurial' / '__version__.py'
 
@@ -148,49 +169,165 @@
     return post_build_sign
 
 
-LIBRARIES_XML = '''
-<?xml version="1.0" encoding="utf-8"?>
-<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
-
-  <?include {wix_dir}/guids.wxi ?>
-  <?include {wix_dir}/defines.wxi ?>
+def make_files_xml(staging_dir: pathlib.Path, is_x64) -> str:
+    """Create XML string listing every file to be installed."""
 
-  <Fragment>
-    <DirectoryRef Id="INSTALLDIR" FileSource="$(var.SourceDir)">
-      <Directory Id="libdir" Name="lib" FileSource="$(var.SourceDir)/lib">
-        <Component Id="libOutput" Guid="$(var.lib.guid)" Win64='$(var.IsX64)'>
-        </Component>
-      </Directory>
-    </DirectoryRef>
-  </Fragment>
-</Wix>
-'''.lstrip()
+    # We derive GUIDs from a deterministic file path identifier.
+    # We shoehorn the name into something that looks like a URL because
+    # the UUID namespaces are supposed to work that way (even though
+    # the input data probably is never validated).
 
-
-def make_libraries_xml(wix_dir: pathlib.Path, dist_dir: pathlib.Path):
-    """Make XML data for library components WXS."""
-    # We can't use ElementTree because it doesn't handle the
-    # <?include ?> directives.
     doc = xml.dom.minidom.parseString(
-        LIBRARIES_XML.format(wix_dir=str(wix_dir))
+        '<?xml version="1.0" encoding="utf-8"?>'
+        '<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">'
+        '</Wix>'
     )
 
-    component = doc.getElementsByTagName('Component')[0]
+    # Assemble the install layout by directory. This makes it easier to
+    # emit XML, since each directory has separate entities.
+    manifest = collections.defaultdict(dict)
+
+    for root, dirs, files in os.walk(staging_dir):
+        dirs.sort()
+
+        root = pathlib.Path(root)
+        rel_dir = root.relative_to(staging_dir)
+
+        for i in range(len(rel_dir.parts)):
+            parent = '/'.join(rel_dir.parts[0 : i + 1])
+            manifest.setdefault(parent, {})
+
+        for f in sorted(files):
+            full = root / f
+            manifest[str(rel_dir).replace('\\', '/')][full.name] = full
+
+    component_groups = collections.defaultdict(list)
+
+    # Now emit a <Fragment> for each directory.
+    # Each directory is composed of a <DirectoryRef> pointing to its parent
+    # and defines child <Directory>'s and a <Component> with all the files.
+    for dir_name, entries in sorted(manifest.items()):
+        # The directory id is derived from the path. But the root directory
+        # is special.
+        if dir_name == '.':
+            parent_directory_id = 'INSTALLDIR'
+        else:
+            parent_directory_id = 'hg.dir.%s' % dir_name.replace('/', '.')
 
-    f = doc.createElement('File')
-    f.setAttribute('Name', 'library.zip')
-    f.setAttribute('KeyPath', 'yes')
-    component.appendChild(f)
+        fragment = doc.createElement('Fragment')
+        directory_ref = doc.createElement('DirectoryRef')
+        directory_ref.setAttribute('Id', parent_directory_id)
+
+        # Add <Directory> entries for immediate children directories.
+        for possible_child in sorted(manifest.keys()):
+            if (
+                dir_name == '.'
+                and '/' not in possible_child
+                and possible_child != '.'
+            ):
+                child_directory_id = 'hg.dir.%s' % possible_child
+                name = possible_child
+            else:
+                if not possible_child.startswith('%s/' % dir_name):
+                    continue
+                name = possible_child[len(dir_name) + 1 :]
+                if '/' in name:
+                    continue
+
+                child_directory_id = 'hg.dir.%s' % possible_child.replace(
+                    '/', '.'
+                )
+
+            directory = doc.createElement('Directory')
+            directory.setAttribute('Id', child_directory_id)
+            directory.setAttribute('Name', name)
+            directory_ref.appendChild(directory)
+
+        # Add <Component>s for files in this directory.
+        for rel, source_path in sorted(entries.items()):
+            if dir_name == '.':
+                full_rel = rel
+            else:
+                full_rel = '%s/%s' % (dir_name, rel)
 
-    lib_dir = dist_dir / 'lib'
+            component_unique_id = (
+                'https://www.mercurial-scm.org/wix-installer/0/component/%s'
+                % full_rel
+            )
+            component_guid = uuid.uuid5(uuid.NAMESPACE_URL, component_unique_id)
+            component_id = 'hg.component.%s' % str(component_guid).replace(
+                '-', '_'
+            )
+
+            component = doc.createElement('Component')
+
+            component.setAttribute('Id', component_id)
+            component.setAttribute('Guid', str(component_guid).upper())
+            component.setAttribute('Win64', 'yes' if is_x64 else 'no')
+
+            # Assign this component to a top-level group.
+            if dir_name == '.':
+                component_groups['ROOT'].append(component_id)
+            elif '/' in dir_name:
+                component_groups[dir_name[0 : dir_name.index('/')]].append(
+                    component_id
+                )
+            else:
+                component_groups[dir_name].append(component_id)
+
+            unique_id = (
+                'https://www.mercurial-scm.org/wix-installer/0/%s' % full_rel
+            )
+            file_guid = uuid.uuid5(uuid.NAMESPACE_URL, unique_id)
+
+            # IDs have length limits. So use GUID to derive them.
+            file_guid_normalized = str(file_guid).replace('-', '_')
+            file_id = 'hg.file.%s' % file_guid_normalized
 
-    for p in sorted(lib_dir.iterdir()):
-        if not p.name.endswith(('.dll', '.pyd')):
-            continue
+            file_element = doc.createElement('File')
+            file_element.setAttribute('Id', file_id)
+            file_element.setAttribute('Source', str(source_path))
+            file_element.setAttribute('KeyPath', 'yes')
+            file_element.setAttribute('ReadOnly', 'yes')
+
+            component.appendChild(file_element)
+            directory_ref.appendChild(component)
+
+        fragment.appendChild(directory_ref)
+        doc.documentElement.appendChild(fragment)
+
+    for group, component_ids in sorted(component_groups.items()):
+        fragment = doc.createElement('Fragment')
+        component_group = doc.createElement('ComponentGroup')
+        component_group.setAttribute('Id', 'hg.group.%s' % group)
+
+        for component_id in component_ids:
+            component_ref = doc.createElement('ComponentRef')
+            component_ref.setAttribute('Id', component_id)
+            component_group.appendChild(component_ref)
 
-        f = doc.createElement('File')
-        f.setAttribute('Name', p.name)
-        component.appendChild(f)
+        fragment.appendChild(component_group)
+        doc.documentElement.appendChild(fragment)
+
+    # Add <Shortcut> to files that have it defined.
+    for file_id, metadata in sorted(SHORTCUTS.items()):
+        els = doc.getElementsByTagName('File')
+        els = [el for el in els if el.getAttribute('Id') == file_id]
+
+        if not els:
+            raise Exception('could not find File[Id=%s]' % file_id)
+
+        for el in els:
+            shortcut = doc.createElement('Shortcut')
+            shortcut.setAttribute('Id', 'hg.shortcut.%s' % file_id)
+            shortcut.setAttribute('Directory', 'ProgramMenuDir')
+            shortcut.setAttribute('Icon', 'hgIcon.ico')
+            shortcut.setAttribute('IconIndex', '0')
+            shortcut.setAttribute('Advertise', 'yes')
+            for k, v in sorted(metadata.items()):
+                shortcut.setAttribute(k, v)
+
+            el.appendChild(shortcut)
 
     return doc.toprettyxml()
 
@@ -249,9 +386,27 @@
         post_build_fn(source_dir, hg_build_dir, dist_dir, version)
 
     build_dir = hg_build_dir / ('wix-%s' % arch)
+    staging_dir = build_dir / 'stage'
 
     build_dir.mkdir(exist_ok=True)
 
+    # Purge the staging directory for every build so packaging is pristine.
+    if staging_dir.exists():
+        print('purging %s' % staging_dir)
+        shutil.rmtree(staging_dir)
+
+    stage_install(source_dir, staging_dir, lower_case=True)
+
+    # We also install some extra files.
+    process_install_rules(EXTRA_INSTALL_RULES, source_dir, staging_dir)
+
+    # And remove some files we don't want.
+    for f in STAGING_REMOVE_FILES:
+        p = staging_dir / f
+        if p.exists():
+            print('removing %s' % p)
+            p.unlink()
+
     wix_pkg, wix_entry = download_entry('wix', hg_build_dir)
     wix_path = hg_build_dir / ('wix-%s' % wix_entry['version'])
 
@@ -264,25 +419,16 @@
 
     defines = {'Platform': arch}
 
-    for wxs, rel_path in SUPPORT_WXS:
-        wxs = wix_dir / wxs
-        wxs_source_dir = source_dir / rel_path
-        run_candle(wix_path, build_dir, wxs, wxs_source_dir, defines=defines)
+    # Derive a .wxs file with the staged files.
+    manifest_wxs = build_dir / 'stage.wxs'
+    with manifest_wxs.open('w', encoding='utf-8') as fh:
+        fh.write(make_files_xml(staging_dir, is_x64=arch == 'x64'))
+
+    run_candle(wix_path, build_dir, manifest_wxs, staging_dir, defines=defines)
 
     for source, rel_path in sorted((extra_wxs or {}).items()):
         run_candle(wix_path, build_dir, source, rel_path, defines=defines)
 
-    # candle.exe doesn't like when we have an open handle on the file.
-    # So use TemporaryDirectory() instead of NamedTemporaryFile().
-    with tempfile.TemporaryDirectory() as td:
-        td = pathlib.Path(td)
-
-        tf = td / 'library.wxs'
-        with tf.open('w') as fh:
-            fh.write(make_libraries_xml(wix_dir, dist_dir))
-
-        run_candle(wix_path, build_dir, tf, dist_dir, defines=defines)
-
     source = wix_dir / 'mercurial.wxs'
     defines['Version'] = version
     defines['Comments'] = 'Installs Mercurial version %s' % version
@@ -308,20 +454,13 @@
         str(msi_path),
     ]
 
-    for source, rel_path in SUPPORT_WXS:
-        assert source.endswith('.wxs')
-        args.append(str(build_dir / ('%s.wixobj' % source[:-4])))
-
     for source, rel_path in sorted((extra_wxs or {}).items()):
         assert source.endswith('.wxs')
         source = os.path.basename(source)
         args.append(str(build_dir / ('%s.wixobj' % source[:-4])))
 
     args.extend(
-        [
-            str(build_dir / 'library.wixobj'),
-            str(build_dir / 'mercurial.wixobj'),
-        ]
+        [str(build_dir / 'stage.wixobj'), str(build_dir / 'mercurial.wixobj'),]
     )
 
     subprocess.run(args, cwd=str(source_dir), check=True)
--- a/contrib/packaging/inno/build.py	Wed Nov 20 19:07:02 2019 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,60 +0,0 @@
-#!/usr/bin/env python3
-# build.py - Inno installer build script.
-#
-# Copyright 2019 Gregory Szorc <gregory.szorc@gmail.com>
-#
-# This software may be used and distributed according to the terms of the
-# GNU General Public License version 2 or any later version.
-
-# This script automates the building of the Inno MSI installer for Mercurial.
-
-# no-check-code because Python 3 native.
-
-import argparse
-import os
-import pathlib
-import sys
-
-
-if __name__ == '__main__':
-    parser = argparse.ArgumentParser()
-
-    parser.add_argument(
-        '--python', required=True, help='path to python.exe to use'
-    )
-    parser.add_argument('--iscc', help='path to iscc.exe to use')
-    parser.add_argument(
-        '--version',
-        help='Mercurial version string to use '
-        '(detected from __version__.py if not defined',
-    )
-
-    args = parser.parse_args()
-
-    if not os.path.isabs(args.python):
-        raise Exception('--python arg must be an absolute path')
-
-    if args.iscc:
-        iscc = pathlib.Path(args.iscc)
-    else:
-        iscc = (
-            pathlib.Path(os.environ['ProgramFiles(x86)'])
-            / 'Inno Setup 5'
-            / 'ISCC.exe'
-        )
-
-    here = pathlib.Path(os.path.abspath(os.path.dirname(__file__)))
-    source_dir = here.parent.parent.parent
-    build_dir = source_dir / 'build'
-
-    sys.path.insert(0, str(source_dir / 'contrib' / 'packaging'))
-
-    from hgpackaging.inno import build
-
-    build(
-        source_dir,
-        build_dir,
-        pathlib.Path(args.python),
-        iscc,
-        version=args.version,
-    )
--- a/contrib/packaging/inno/mercurial.iss	Wed Nov 20 19:07:02 2019 +0100
+++ b/contrib/packaging/inno/mercurial.iss	Fri Nov 22 21:42:04 2019 +0900
@@ -1,21 +1,6 @@
 ; Script generated by the Inno Setup Script Wizard.
 ; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES!
 
-#ifndef VERSION
-#define FileHandle
-#define FileLine
-#define VERSION = "unknown"
-#if FileHandle = FileOpen(SourcePath + "\..\..\..\mercurial\__version__.py")
-  #expr FileLine = FileRead(FileHandle)
-  #expr FileLine = FileRead(FileHandle)
-  #define VERSION = Copy(FileLine, Pos('"', FileLine)+1, Len(FileLine)-Pos('"', FileLine)-1)
-#endif
-#if FileHandle
-  #expr FileClose(FileHandle)
-#endif
-#pragma message "Detected Version: " + VERSION
-#endif
-
 #ifndef ARCH
 #define ARCH = "x86"
 #endif
@@ -33,68 +18,40 @@
 AppVerName=Mercurial {#VERSION}
 OutputBaseFilename=Mercurial-{#VERSION}
 #endif
-InfoAfterFile=contrib/win32/postinstall.txt
-LicenseFile=COPYING
+InfoAfterFile=../postinstall.txt
+LicenseFile=Copying.txt
 ShowLanguageDialog=yes
 AppPublisher=Matt Mackall and others
 AppPublisherURL=https://mercurial-scm.org/
 AppSupportURL=https://mercurial-scm.org/
 AppUpdatesURL=https://mercurial-scm.org/
-AppID={{4B95A5F1-EF59-4B08-BED8-C891C46121B3}
+{{ 'AppID={{4B95A5F1-EF59-4B08-BED8-C891C46121B3}' }}
 AppContact=mercurial@mercurial-scm.org
 DefaultDirName={pf}\Mercurial
-SourceDir=..\..\..
+SourceDir=stage
 VersionInfoDescription=Mercurial distributed SCM (version {#VERSION})
 VersionInfoCopyright=Copyright 2005-2019 Matt Mackall and others
 VersionInfoCompany=Matt Mackall and others
 InternalCompressLevel=max
 SolidCompression=true
-SetupIconFile=contrib\win32\mercurial.ico
+SetupIconFile=../mercurial.ico
 AllowNoIcons=true
 DefaultGroupName=Mercurial
 PrivilegesRequired=none
 ChangesEnvironment=true
 
 [Files]
-Source: contrib\mercurial.el; DestDir: {app}/Contrib
-Source: contrib\vim\*.*; DestDir: {app}/Contrib/Vim
-Source: contrib\zsh_completion; DestDir: {app}/Contrib
-Source: contrib\bash_completion; DestDir: {app}/Contrib
-Source: contrib\tcsh_completion; DestDir: {app}/Contrib
-Source: contrib\tcsh_completion_build.sh; DestDir: {app}/Contrib
-Source: contrib\hgk; DestDir: {app}/Contrib; DestName: hgk.tcl
-Source: contrib\xml.rnc; DestDir: {app}/Contrib
-Source: contrib\mercurial.el; DestDir: {app}/Contrib
-Source: contrib\mq.el; DestDir: {app}/Contrib
-Source: contrib\hgweb.fcgi; DestDir: {app}/Contrib
-Source: contrib\hgweb.wsgi; DestDir: {app}/Contrib
-Source: contrib\win32\ReadMe.html; DestDir: {app}; Flags: isreadme
-Source: contrib\win32\postinstall.txt; DestDir: {app}; DestName: ReleaseNotes.txt
-Source: dist\hg.exe; DestDir: {app}; AfterInstall: Touch('{app}\hg.exe.local')
-Source: dist\lib\*.dll; Destdir: {app}\lib
-Source: dist\lib\*.pyd; Destdir: {app}\lib
-Source: dist\python*.dll; Destdir: {app}; Flags: skipifsourcedoesntexist
-Source: dist\msvc*.dll; DestDir: {app}; Flags: skipifsourcedoesntexist
-Source: dist\Microsoft.VC*.CRT.manifest; DestDir: {app}; Flags: skipifsourcedoesntexist
-Source: dist\lib\library.zip; DestDir: {app}\lib
-Source: doc\*.html; DestDir: {app}\Docs
-Source: doc\style.css; DestDir: {app}\Docs
-Source: mercurial\help\*.txt; DestDir: {app}\help
-Source: mercurial\help\internals\*.txt; DestDir: {app}\help\internals
-Source: mercurial\default.d\*.rc; DestDir: {app}\default.d
-Source: mercurial\locale\*.*; DestDir: {app}\locale; Flags: recursesubdirs createallsubdirs skipifsourcedoesntexist
-Source: mercurial\templates\*.*; DestDir: {app}\Templates; Flags: recursesubdirs createallsubdirs
-Source: CONTRIBUTORS; DestDir: {app}; DestName: Contributors.txt
-Source: COPYING; DestDir: {app}; DestName: Copying.txt
+{% for entry in package_files -%}
+Source: {{ entry.source }}; DestDir: {{ entry.dest_dir }}
+{%- if entry.metadata %}; {{ entry.metadata }}{% endif %}
+{% endfor %}
 
 [INI]
 Filename: {app}\Mercurial.url; Section: InternetShortcut; Key: URL; String: https://mercurial-scm.org/
-Filename: {app}\default.d\editor.rc; Section: ui; Key: editor; String: notepad
 
 [UninstallDelete]
 Type: files; Name: {app}\Mercurial.url
-Type: filesandordirs; Name: {app}\default.d
-Type: files; Name: "{app}\hg.exe.local"
+Type: filesandordirs; Name: {app}\hgrc.d
 
 [Icons]
 Name: {group}\Uninstall Mercurial; Filename: {uninstallexe}
@@ -121,4 +78,5 @@
     setArrayLength(Result, 1)
     Result[0] := ExpandConstant('{app}');
 end;
-#include "modpath.iss"
+
+{% include 'modpath.iss' %}
--- a/contrib/packaging/inno/readme.rst	Wed Nov 20 19:07:02 2019 +0100
+++ b/contrib/packaging/inno/readme.rst	Fri Nov 22 21:42:04 2019 +0900
@@ -11,12 +11,12 @@
 * Inno Setup (http://jrsoftware.org/isdl.php) version 5.4 or newer.
   Be sure to install the optional Inno Setup Preprocessor feature,
   which is required.
-* Python 3.5+ (to run the ``build.py`` script)
+* Python 3.5+ (to run the ``packaging.py`` script)
 
 Building
 ========
 
-The ``build.py`` script automates the process of producing an
+The ``packaging.py`` script automates the process of producing an
 Inno installer. It manages fetching and configuring the
 non-system dependencies (such as py2exe, gettext, and various
 Python packages).
@@ -31,11 +31,11 @@
 From the prompt, change to the Mercurial source directory. e.g.
 ``cd c:\src\hg``.
 
-Next, invoke ``build.py`` to produce an Inno installer. You will
+Next, invoke ``packaging.py`` to produce an Inno installer. You will
 need to supply the path to the Python interpreter to use.::
 
-   $ python3.exe contrib\packaging\inno\build.py \
-       --python c:\python27\python.exe
+   $ python3.exe contrib\packaging\packaging.py \
+       inno --python c:\python27\python.exe
 
 .. note::
 
@@ -49,13 +49,13 @@
 and an installer placed in the ``dist`` sub-directory. The final
 line of output should print the name of the generated installer.
 
-Additional options may be configured. Run ``build.py --help`` to
-see a list of program flags.
+Additional options may be configured. Run
+``packaging.py inno --help`` to see a list of program flags.
 
 MinGW
 =====
 
 It is theoretically possible to generate an installer that uses
-MinGW. This isn't well tested and ``build.py`` and may properly
+MinGW. This isn't well tested and ``packaging.py`` and may properly
 support it. See old versions of this file in version control for
 potentially useful hints as to how to achieve this.
--- a/contrib/packaging/inno/requirements.txt	Wed Nov 20 19:07:02 2019 +0100
+++ b/contrib/packaging/inno/requirements.txt	Fri Nov 22 21:42:04 2019 +0900
@@ -8,65 +8,6 @@
     --hash=sha256:e4f3620cfea4f83eedc95b24abd9cd56f3c4b146dd0177e83a21b4eb49e21e50 \
     --hash=sha256:fd7c7c74727ddcf00e9acd26bba8da604ffec95bf1c2144e67aff7a8b50e6cef \
     # via dulwich
-cffi==1.13.1 \
-    --hash=sha256:00d890313797d9fe4420506613384b43099ad7d2b905c0752dbcc3a6f14d80fa \
-    --hash=sha256:0cf9e550ac6c5e57b713437e2f4ac2d7fd0cd10336525a27224f5fc1ec2ee59a \
-    --hash=sha256:0ea23c9c0cdd6778146a50d867d6405693ac3b80a68829966c98dd5e1bbae400 \
-    --hash=sha256:193697c2918ecdb3865acf6557cddf5076bb39f1f654975e087b67efdff83365 \
-    --hash=sha256:1ae14b542bf3b35e5229439c35653d2ef7d8316c1fffb980f9b7647e544baa98 \
-    --hash=sha256:1e389e069450609c6ffa37f21f40cce36f9be7643bbe5051ab1de99d5a779526 \
-    --hash=sha256:263242b6ace7f9cd4ea401428d2d45066b49a700852334fd55311bde36dcda14 \
-    --hash=sha256:33142ae9807665fa6511cfa9857132b2c3ee6ddffb012b3f0933fc11e1e830d5 \
-    --hash=sha256:364f8404034ae1b232335d8c7f7b57deac566f148f7222cef78cf8ae28ef764e \
-    --hash=sha256:47368f69fe6529f8f49a5d146ddee713fc9057e31d61e8b6dc86a6a5e38cecc1 \
-    --hash=sha256:4895640844f17bec32943995dc8c96989226974dfeb9dd121cc45d36e0d0c434 \
-    --hash=sha256:558b3afef987cf4b17abd849e7bedf64ee12b28175d564d05b628a0f9355599b \
-    --hash=sha256:5ba86e1d80d458b338bda676fd9f9d68cb4e7a03819632969cf6d46b01a26730 \
-    --hash=sha256:63424daa6955e6b4c70dc2755897f5be1d719eabe71b2625948b222775ed5c43 \
-    --hash=sha256:6381a7d8b1ebd0bc27c3bc85bc1bfadbb6e6f756b4d4db0aa1425c3719ba26b4 \
-    --hash=sha256:6381ab708158c4e1639da1f2a7679a9bbe3e5a776fc6d1fd808076f0e3145331 \
-    --hash=sha256:6fd58366747debfa5e6163ada468a90788411f10c92597d3b0a912d07e580c36 \
-    --hash=sha256:728ec653964655d65408949b07f9b2219df78badd601d6c49e28d604efe40599 \
-    --hash=sha256:7cfcfda59ef1f95b9f729c56fe8a4041899f96b72685d36ef16a3440a0f85da8 \
-    --hash=sha256:819f8d5197c2684524637f940445c06e003c4a541f9983fd30d6deaa2a5487d8 \
-    --hash=sha256:825ecffd9574557590e3225560a8a9d751f6ffe4a49e3c40918c9969b93395fa \
-    --hash=sha256:9009e917d8f5ef780c2626e29b6bc126f4cb2a4d43ca67aa2b40f2a5d6385e78 \
-    --hash=sha256:9c77564a51d4d914ed5af096cd9843d90c45b784b511723bd46a8a9d09cf16fc \
-    --hash=sha256:a19089fa74ed19c4fe96502a291cfdb89223a9705b1d73b3005df4256976142e \
-    --hash=sha256:a40ed527bffa2b7ebe07acc5a3f782da072e262ca994b4f2085100b5a444bbb2 \
-    --hash=sha256:bb75ba21d5716abc41af16eac1145ab2e471deedde1f22c6f99bd9f995504df0 \
-    --hash=sha256:e22a00c0c81ffcecaf07c2bfb3672fa372c50e2bd1024ffee0da191c1b27fc71 \
-    --hash=sha256:e55b5a746fb77f10c83e8af081979351722f6ea48facea79d470b3731c7b2891 \
-    --hash=sha256:ec2fa3ee81707a5232bf2dfbd6623fdb278e070d596effc7e2d788f2ada71a05 \
-    --hash=sha256:fd82eb4694be712fcae03c717ca2e0fc720657ac226b80bbb597e971fc6928c2 \
-    # via cryptography
-configparser==4.0.2 \
-    --hash=sha256:254c1d9c79f60c45dfde850850883d5aaa7f19a23f13561243a050d5a7c3fe4c \
-    --hash=sha256:c7d282687a5308319bf3d2e7706e575c635b0a470342641c93bea0ea3b5331df \
-    # via entrypoints
-cryptography==2.8 \
-    --hash=sha256:02079a6addc7b5140ba0825f542c0869ff4df9a69c360e339ecead5baefa843c \
-    --hash=sha256:1df22371fbf2004c6f64e927668734070a8953362cd8370ddd336774d6743595 \
-    --hash=sha256:369d2346db5934345787451504853ad9d342d7f721ae82d098083e1f49a582ad \
-    --hash=sha256:3cda1f0ed8747339bbdf71b9f38ca74c7b592f24f65cdb3ab3765e4b02871651 \
-    --hash=sha256:44ff04138935882fef7c686878e1c8fd80a723161ad6a98da31e14b7553170c2 \
-    --hash=sha256:4b1030728872c59687badcca1e225a9103440e467c17d6d1730ab3d2d64bfeff \
-    --hash=sha256:58363dbd966afb4f89b3b11dfb8ff200058fbc3b947507675c19ceb46104b48d \
-    --hash=sha256:6ec280fb24d27e3d97aa731e16207d58bd8ae94ef6eab97249a2afe4ba643d42 \
-    --hash=sha256:7270a6c29199adc1297776937a05b59720e8a782531f1f122f2eb8467f9aab4d \
-    --hash=sha256:73fd30c57fa2d0a1d7a49c561c40c2f79c7d6c374cc7750e9ac7c99176f6428e \
-    --hash=sha256:7f09806ed4fbea8f51585231ba742b58cbcfbfe823ea197d8c89a5e433c7e912 \
-    --hash=sha256:90df0cc93e1f8d2fba8365fb59a858f51a11a394d64dbf3ef844f783844cc793 \
-    --hash=sha256:971221ed40f058f5662a604bd1ae6e4521d84e6cad0b7b170564cc34169c8f13 \
-    --hash=sha256:a518c153a2b5ed6b8cc03f7ae79d5ffad7315ad4569b2d5333a13c38d64bd8d7 \
-    --hash=sha256:b0de590a8b0979649ebeef8bb9f54394d3a41f66c5584fff4220901739b6b2f0 \
-    --hash=sha256:b43f53f29816ba1db8525f006fa6f49292e9b029554b3eb56a189a70f2a40879 \
-    --hash=sha256:d31402aad60ed889c7e57934a03477b572a03af7794fa8fb1780f21ea8f6551f \
-    --hash=sha256:de96157ec73458a7f14e3d26f17f8128c959084931e8997b9e655a39c8fde9f9 \
-    --hash=sha256:df6b4dca2e11865e6cfbfb708e800efb18370f5a46fd601d3755bc7f85b3a8a2 \
-    --hash=sha256:ecadccc7ba52193963c0475ac9f6fa28ac01e01349a2ca48509667ef41ffd2cf \
-    --hash=sha256:fb81c17e0ebe3358486cd8cc3ad78adbae58af12fc2bf2bc0bb84e8090fa5ce8 \
-    # via secretstorage
 docutils==0.15.2 \
     --hash=sha256:6c4f696463b79f1fb8ba0c594b63840ebd41f059e92b31957c46b74a4599b6d0 \
     --hash=sha256:9e4d7ecfc600058e07ba661411a2b7de2fd0fafa17d1a7f7361cd47b1175c827 \
@@ -85,35 +26,16 @@
     --hash=sha256:589f874b313739ad35be6e0cd7efde2a4e9b6fea91edcc34e58ecbb8dbe56d19 \
     --hash=sha256:c70dd71abe5a8c85e55e12c19bd91ccfeec11a6e99044204511f9ed547d48451 \
     # via keyring
-enum34==1.1.6 \
-    --hash=sha256:2d81cbbe0e73112bdfe6ef8576f2238f2ba27dd0d55752a776c41d38b7da2850 \
-    --hash=sha256:644837f692e5f550741432dd3f223bbb9852018674981b1664e5dc339387588a \
-    --hash=sha256:6bd0f6ad48ec2aa117d3d141940d484deccda84d4fcd884f5c3d93c23ecd8c79 \
-    --hash=sha256:8ad8c4783bf61ded74527bffb48ed9b54166685e4230386a9ed9b1279e2df5b1 \
-    # via cryptography
-ipaddress==1.0.23 \
-    --hash=sha256:6e0f4a39e66cb5bb9a137b00276a2eff74f93b71dcbdad6f10ff7df9d3557fcc \
-    --hash=sha256:b7f8e0369580bb4a24d5ba1d7cc29660a4a6987763faf1d8a8046830e020e7e2 \
-    # via cryptography
 keyring==18.0.1 \
     --hash=sha256:67d6cc0132bd77922725fae9f18366bb314fd8f95ff4d323a4df41890a96a838 \
     --hash=sha256:7b29ebfcf8678c4da531b2478a912eea01e80007e5ddca9ee0c7038cb3489ec6
-pycparser==2.19 \
-    --hash=sha256:a988718abfad80b6b157acce7bf130a30876d27603738ac39f140993246b25b3 \
-    # via cffi
 pygments==2.4.2 \
     --hash=sha256:71e430bc85c88a430f000ac1d9b331d2407f681d6f6aec95e8bcfbc3df5b0127 \
     --hash=sha256:881c4c157e45f30af185c1ffe8d549d48ac9127433f2c380c24b84572ad66297
 pywin32-ctypes==0.2.0 \
     --hash=sha256:24ffc3b341d457d48e8922352130cf2644024a4ff09762a2261fd34c36ee5942 \
-    --hash=sha256:9dc2d991b3479cc2df15930958b674a48a227d5361d413827a4cfd0b5876fc98
-secretstorage==2.3.1 \
-    --hash=sha256:3af65c87765323e6f64c83575b05393f9e003431959c9395d1791d51497f29b6 \
+    --hash=sha256:9dc2d991b3479cc2df15930958b674a48a227d5361d413827a4cfd0b5876fc98 \
     # via keyring
-six==1.12.0 \
-    --hash=sha256:3350809f0555b11f552448330d0b52d5f24c91a322ea4a15ef22629740f3761c \
-    --hash=sha256:d16a0141ec1a18405cd4ce8b4613101da75da0e9a7aec5bdd4fa804d0e0eba73 \
-    # via cryptography
 urllib3==1.25.6 \
     --hash=sha256:3de946ffbed6e6746608990594d08faac602528ac7015ac28d33cee6a45b7398 \
     --hash=sha256:9a107b99a5393caf59c7aa3c1249c16e6879447533d0887f4336dde834c7be86 \
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/contrib/packaging/packaging.py	Fri Nov 22 21:42:04 2019 +0900
@@ -0,0 +1,74 @@
+#!/usr/bin/env python3
+#
+# packaging.py - Mercurial packaging functionality
+#
+# Copyright 2019 Gregory Szorc <gregory.szorc@gmail.com>
+#
+# This software may be used and distributed according to the terms of the
+# GNU General Public License version 2 or any later version.
+
+import os
+import pathlib
+import subprocess
+import sys
+import venv
+
+
+HERE = pathlib.Path(os.path.abspath(__file__)).parent
+REQUIREMENTS_TXT = HERE / "requirements.txt"
+SOURCE_DIR = HERE.parent.parent
+VENV = SOURCE_DIR / "build" / "venv-packaging"
+
+
+def bootstrap():
+    venv_created = not VENV.exists()
+
+    VENV.parent.mkdir(exist_ok=True)
+
+    venv.create(VENV, with_pip=True)
+
+    if os.name == "nt":
+        venv_bin = VENV / "Scripts"
+        pip = venv_bin / "pip.exe"
+        python = venv_bin / "python.exe"
+    else:
+        venv_bin = VENV / "bin"
+        pip = venv_bin / "pip"
+        python = venv_bin / "python"
+
+    args = [
+        str(pip),
+        "install",
+        "-r",
+        str(REQUIREMENTS_TXT),
+        "--disable-pip-version-check",
+    ]
+
+    if not venv_created:
+        args.append("-q")
+
+    subprocess.run(args, check=True)
+
+    os.environ["HGPACKAGING_BOOTSTRAPPED"] = "1"
+    os.environ["PATH"] = "%s%s%s" % (venv_bin, os.pathsep, os.environ["PATH"])
+
+    subprocess.run([str(python), __file__] + sys.argv[1:], check=True)
+
+
+def run():
+    import hgpackaging.cli as cli
+
+    # Need to strip off main Python executable.
+    cli.main()
+
+
+if __name__ == "__main__":
+    try:
+        if "HGPACKAGING_BOOTSTRAPPED" not in os.environ:
+            bootstrap()
+        else:
+            run()
+    except subprocess.CalledProcessError as e:
+        sys.exit(e.returncode)
+    except KeyboardInterrupt:
+        sys.exit(1)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/contrib/packaging/requirements.txt	Fri Nov 22 21:42:04 2019 +0900
@@ -0,0 +1,39 @@
+#
+# This file is autogenerated by pip-compile
+# To update, run:
+#
+#    pip-compile --generate-hashes --output-file=contrib/packaging/requirements.txt contrib/packaging/requirements.txt.in
+#
+jinja2==2.10.3 \
+    --hash=sha256:74320bb91f31270f9551d46522e33af46a80c3d619f4a4bf42b3164d30b5911f \
+    --hash=sha256:9fe95f19286cfefaa917656583d020be14e7859c6b0252588391e47db34527de
+markupsafe==1.1.1 \
+    --hash=sha256:00bc623926325b26bb9605ae9eae8a215691f33cae5df11ca5424f06f2d1f473 \
+    --hash=sha256:09027a7803a62ca78792ad89403b1b7a73a01c8cb65909cd876f7fcebd79b161 \
+    --hash=sha256:09c4b7f37d6c648cb13f9230d847adf22f8171b1ccc4d5682398e77f40309235 \
+    --hash=sha256:1027c282dad077d0bae18be6794e6b6b8c91d58ed8a8d89a89d59693b9131db5 \
+    --hash=sha256:24982cc2533820871eba85ba648cd53d8623687ff11cbb805be4ff7b4c971aff \
+    --hash=sha256:29872e92839765e546828bb7754a68c418d927cd064fd4708fab9fe9c8bb116b \
+    --hash=sha256:43a55c2930bbc139570ac2452adf3d70cdbb3cfe5912c71cdce1c2c6bbd9c5d1 \
+    --hash=sha256:46c99d2de99945ec5cb54f23c8cd5689f6d7177305ebff350a58ce5f8de1669e \
+    --hash=sha256:500d4957e52ddc3351cabf489e79c91c17f6e0899158447047588650b5e69183 \
+    --hash=sha256:535f6fc4d397c1563d08b88e485c3496cf5784e927af890fb3c3aac7f933ec66 \
+    --hash=sha256:62fe6c95e3ec8a7fad637b7f3d372c15ec1caa01ab47926cfdf7a75b40e0eac1 \
+    --hash=sha256:6dd73240d2af64df90aa7c4e7481e23825ea70af4b4922f8ede5b9e35f78a3b1 \
+    --hash=sha256:717ba8fe3ae9cc0006d7c451f0bb265ee07739daf76355d06366154ee68d221e \
+    --hash=sha256:79855e1c5b8da654cf486b830bd42c06e8780cea587384cf6545b7d9ac013a0b \
+    --hash=sha256:7c1699dfe0cf8ff607dbdcc1e9b9af1755371f92a68f706051cc8c37d447c905 \
+    --hash=sha256:88e5fcfb52ee7b911e8bb6d6aa2fd21fbecc674eadd44118a9cc3863f938e735 \
+    --hash=sha256:8defac2f2ccd6805ebf65f5eeb132adcf2ab57aa11fdf4c0dd5169a004710e7d \
+    --hash=sha256:98c7086708b163d425c67c7a91bad6e466bb99d797aa64f965e9d25c12111a5e \
+    --hash=sha256:9add70b36c5666a2ed02b43b335fe19002ee5235efd4b8a89bfcf9005bebac0d \
+    --hash=sha256:9bf40443012702a1d2070043cb6291650a0841ece432556f784f004937f0f32c \
+    --hash=sha256:ade5e387d2ad0d7ebf59146cc00c8044acbd863725f887353a10df825fc8ae21 \
+    --hash=sha256:b00c1de48212e4cc9603895652c5c410df699856a2853135b3967591e4beebc2 \
+    --hash=sha256:b1282f8c00509d99fef04d8ba936b156d419be841854fe901d8ae224c59f0be5 \
+    --hash=sha256:b2051432115498d3562c084a49bba65d97cf251f5a331c64a12ee7e04dacc51b \
+    --hash=sha256:ba59edeaa2fc6114428f1637ffff42da1e311e29382d81b339c1817d37ec93c6 \
+    --hash=sha256:c8716a48d94b06bb3b2524c2b77e055fb313aeb4ea620c8dd03a105574ba704f \
+    --hash=sha256:cd5df75523866410809ca100dc9681e301e3c27567cf498077e8551b6d20e42f \
+    --hash=sha256:e249096428b3ae81b08327a63a485ad0878de3fb939049038579ac0ef61e17e7 \
+    # via jinja2
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/contrib/packaging/requirements.txt.in	Fri Nov 22 21:42:04 2019 +0900
@@ -0,0 +1,1 @@
+jinja2
--- a/contrib/packaging/wix/build.py	Wed Nov 20 19:07:02 2019 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,96 +0,0 @@
-#!/usr/bin/env python3
-# Copyright 2019 Gregory Szorc <gregory.szorc@gmail.com>
-#
-# This software may be used and distributed according to the terms of the
-# GNU General Public License version 2 or any later version.
-
-# no-check-code because Python 3 native.
-
-"""Code to build Mercurial WiX installer."""
-
-import argparse
-import os
-import pathlib
-import sys
-
-
-if __name__ == '__main__':
-    parser = argparse.ArgumentParser()
-
-    parser.add_argument('--name', help='Application name', default='Mercurial')
-    parser.add_argument(
-        '--python', help='Path to Python executable to use', required=True
-    )
-    parser.add_argument(
-        '--sign-sn',
-        help='Subject name (or fragment thereof) of certificate '
-        'to use for signing',
-    )
-    parser.add_argument(
-        '--sign-cert', help='Path to certificate to use for signing'
-    )
-    parser.add_argument(
-        '--sign-password', help='Password for signing certificate'
-    )
-    parser.add_argument(
-        '--sign-timestamp-url',
-        help='URL of timestamp server to use for signing',
-    )
-    parser.add_argument('--version', help='Version string to use')
-    parser.add_argument(
-        '--extra-packages-script',
-        help=(
-            'Script to execute to include extra packages in ' 'py2exe binary.'
-        ),
-    )
-    parser.add_argument(
-        '--extra-wxs', help='CSV of path_to_wxs_file=working_dir_for_wxs_file'
-    )
-    parser.add_argument(
-        '--extra-features',
-        help=(
-            'CSV of extra feature names to include '
-            'in the installer from the extra wxs files'
-        ),
-    )
-
-    args = parser.parse_args()
-
-    here = pathlib.Path(os.path.abspath(os.path.dirname(__file__)))
-    source_dir = here.parent.parent.parent
-
-    sys.path.insert(0, str(source_dir / 'contrib' / 'packaging'))
-
-    from hgpackaging.wix import (
-        build_installer,
-        build_signed_installer,
-    )
-
-    fn = build_installer
-    kwargs = {
-        'source_dir': source_dir,
-        'python_exe': pathlib.Path(args.python),
-        'version': args.version,
-    }
-
-    if not os.path.isabs(args.python):
-        raise Exception('--python arg must be an absolute path')
-
-    if args.extra_packages_script:
-        kwargs['extra_packages_script'] = args.extra_packages_script
-    if args.extra_wxs:
-        kwargs['extra_wxs'] = dict(
-            thing.split("=") for thing in args.extra_wxs.split(',')
-        )
-    if args.extra_features:
-        kwargs['extra_features'] = args.extra_features.split(',')
-
-    if args.sign_sn or args.sign_cert:
-        fn = build_signed_installer
-        kwargs['name'] = args.name
-        kwargs['subject_name'] = args.sign_sn
-        kwargs['cert_path'] = args.sign_cert
-        kwargs['cert_password'] = args.sign_password
-        kwargs['timestamp_url'] = args.sign_timestamp_url
-
-    fn(**kwargs)
--- a/contrib/packaging/wix/contrib.wxs	Wed Nov 20 19:07:02 2019 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,43 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
-
-  <?include guids.wxi ?>
-  <?include defines.wxi ?>
-
-  <Fragment>
-    <ComponentGroup Id="contribFolder">
-      <ComponentRef Id="contrib" />
-      <ComponentRef Id="contrib.vim" />
-    </ComponentGroup>
-  </Fragment>
-
-  <Fragment>
-    <DirectoryRef Id="INSTALLDIR">
-      <Directory Id="contribdir" Name="contrib" FileSource="$(var.SourceDir)">
-        <Component Id="contrib" Guid="$(var.contrib.guid)" Win64='$(var.IsX64)'>
-          <File Name="bash_completion" KeyPath="yes" />
-          <File Name="hgk" />
-          <File Name="hgweb.fcgi" />
-          <File Name="hgweb.wsgi" />
-          <File Name="logo-droplets.svg" />
-          <File Name="mercurial.el" />
-          <File Name="tcsh_completion" />
-          <File Name="tcsh_completion_build.sh" />
-          <File Name="xml.rnc" />
-          <File Name="zsh_completion" />
-        </Component>
-        <Directory Id="vimdir" Name="vim">
-          <Component Id="contrib.vim" Guid="$(var.contrib.vim.guid)" Win64='$(var.IsX64)'>
-            <File Name="hg-menu.vim" KeyPath="yes" />
-            <File Name="HGAnnotate.vim" />
-            <File Name="hgcommand.vim" />
-            <File Name="patchreview.txt" />
-            <File Name="patchreview.vim" />
-            <File Name="hgtest.vim" />
-          </Component>
-        </Directory>
-      </Directory>
-    </DirectoryRef>
-  </Fragment>
-
-</Wix>
--- a/contrib/packaging/wix/dist.wxs	Wed Nov 20 19:07:02 2019 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,15 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
-
-  <?include guids.wxi ?>
-  <?include defines.wxi ?>
-
-  <Fragment>
-    <DirectoryRef Id="INSTALLDIR" FileSource="$(var.SourceDir)">
-      <Component Id="distOutput" Guid="$(var.dist.guid)" Win64='$(var.IsX64)'>
-        <File Name="python27.dll" KeyPath="yes" />
-      </Component>
-    </DirectoryRef>
-  </Fragment>
-
-</Wix>
--- a/contrib/packaging/wix/doc.wxs	Wed Nov 20 19:07:02 2019 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,50 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
-
-  <?include guids.wxi ?>
-  <?include defines.wxi ?>
-
-  <Fragment>
-    <ComponentGroup Id="docFolder">
-      <ComponentRef Id="doc.hg.1.html" />
-      <ComponentRef Id="doc.hgignore.5.html" />
-      <ComponentRef Id="doc.hgrc.5.html" />
-      <ComponentRef Id="doc.style.css" />
-    </ComponentGroup>
-  </Fragment>
-
-  <Fragment>
-    <DirectoryRef Id="INSTALLDIR">
-      <Directory Id="docdir" Name="doc" FileSource="$(var.SourceDir)">
-        <Component Id="doc.hg.1.html" Guid="$(var.doc.hg.1.html.guid)" Win64='$(var.IsX64)'>
-          <File Name="hg.1.html" KeyPath="yes">
-            <Shortcut Id="hg1StartMenu" Directory="ProgramMenuDir"
-                      Name="Mercurial Command Reference"
-                      Icon="hgIcon.ico" IconIndex="0" Advertise="yes"
-            />
-          </File>
-        </Component>
-        <Component Id="doc.hgignore.5.html" Guid="$(var.doc.hgignore.5.html.guid)" Win64='$(var.IsX64)'>
-          <File Name="hgignore.5.html" KeyPath="yes">
-            <Shortcut Id="hgignore5StartMenu" Directory="ProgramMenuDir"
-                      Name="Mercurial Ignore Files"
-                      Icon="hgIcon.ico" IconIndex="0" Advertise="yes"
-            />
-          </File>
-        </Component>
-        <Component Id="doc.hgrc.5.html" Guid="$(var.doc.hgrc.5.html)" Win64='$(var.IsX64)'>
-          <File Name="hgrc.5.html" KeyPath="yes">
-            <Shortcut Id="hgrc5StartMenu" Directory="ProgramMenuDir"
-                      Name="Mercurial Configuration Files"
-                      Icon="hgIcon.ico" IconIndex="0" Advertise="yes"
-            />
-          </File>
-        </Component>
-        <Component Id="doc.style.css" Guid="$(var.doc.style.css)" Win64='$(var.IsX64)'>
-          <File Name="style.css" KeyPath="yes" />
-        </Component>
-      </Directory>
-    </DirectoryRef>
-  </Fragment>
-
-</Wix>
--- a/contrib/packaging/wix/guids.wxi	Wed Nov 20 19:07:02 2019 +0100
+++ b/contrib/packaging/wix/guids.wxi	Fri Nov 22 21:42:04 2019 +0900
@@ -4,49 +4,9 @@
        and replace 'Mercurial' in this notice with the name of
        your project. Component GUIDs have global namespace!      -->
 
-  <!-- contrib.wxs -->
-  <?define contrib.guid = {4E11FFC2-E2F7-482A-8460-9394B5489F02} ?>
-  <?define contrib.vim.guid = {BB04903A-652D-4C4F-9590-2BD07A2304F2} ?>
-
-  <!-- dist.wxs -->
-  <?define dist.guid = {CE405FE6-CD1E-4873-9C9A-7683AE5A3D90} ?>
-  <?define lib.guid = {877633b5-0b7e-4b46-8f1c-224a61733297} ?>
-
-  <!-- doc.wxs -->
-  <?define doc.hg.1.html.guid = {AAAA3FDA-EDC5-4220-B59D-D342722358A2} ?>
-  <?define doc.hgignore.5.html.guid = {AA9118C4-F3A0-4429-A5F4-5A1906B2D67F} ?>
-  <?define doc.hgrc.5.html = {E0CEA1EB-FA01-408c-844B-EE5965165BAE} ?>
-  <?define doc.style.css = {172F8262-98E0-4711-BD39-4DAE0D77EF05} ?>
-
-  <!-- help.wxs -->
-  <?define help.root.guid = {9FA957DB-6DFE-44f2-AD03-293B2791CF17} ?>
-  <?define help.internals.guid = {2DD7669D-0DB8-4C39-9806-78E6475E7ACC} ?>
-
-  <!-- i18n.wxs -->
-  <?define i18nFolder.guid = {1BF8026D-CF7C-4174-AEE6-D6B7BF119248} ?>
-
-  <!-- templates.wxs -->
-  <?define templates.root.guid = {437FD55C-7756-4EA0-87E5-FDBE75DC8595} ?>
-  <?define templates.atom.guid = {D30E14A5-8AF0-4268-8B00-00BEE9E09E39} ?>
-  <?define templates.coal.guid = {B63CCAAB-4EAF-43b4-901E-4BD13F5B78FC} ?>
-  <?define templates.gitweb.guid = {827334AF-1EFD-421B-962C-5660A068F612} ?>
-  <?define templates.json.guid = {F535BE7A-EC34-46E0-B9BE-013F3DBAFB19} ?>
-  <?define templates.monoblue.guid = {8060A1E4-BD4C-453E-92CB-9536DC44A9E3} ?>
-  <?define templates.paper.guid = {61AB1DE9-645F-46ED-8AF8-0CF02267FFBB} ?>
-  <?define templates.raw.guid = {834DF8D7-9784-43A6-851D-A96CE1B3575B} ?>
-  <?define templates.rss.guid = {9338FA09-E128-4B1C-B723-1142DBD09E14} ?>
-  <?define templates.spartan.guid = {80222625-FA8F-44b1-86CE-1781EF375D09} ?>
-  <?define templates.static.guid = {6B3D7C24-98DA-4B67-9F18-35F77357B0B4} ?>
-
   <!-- mercurial.wxs -->
   <?define ProductUpgradeCode = {A1CC6134-E945-4399-BE36-EB0017FDF7CF} ?>
-
   <?define ComponentMainExecutableGUID = {D102B8FA-059B-4ACC-9FA3-8C78C3B58EEF} ?>
-
-  <?define ReadMe.guid = {56A8E372-991D-4DCA-B91D-93D775974CF5} ?>
-  <?define COPYING.guid = {B7801DBA-1C49-4BF4-91AD-33C65F5C7895} ?>
-  <?define mercurial.rc.guid = {1D5FAEEE-7E6E-43B1-9F7F-802714316B15} ?>
-  <?define mergetools.rc.guid = {E8A1DC29-FF40-4B5F-BD12-80B9F7BF0CCD} ?>
   <?define ProgramMenuDir.guid = {D5A63320-1238-489B-B68B-CF053E9577CA} ?>
 
 </Include>
--- a/contrib/packaging/wix/help.wxs	Wed Nov 20 19:07:02 2019 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,65 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
-
-  <?include guids.wxi ?>
-  <?include defines.wxi ?>
-
-  <Fragment>
-    <ComponentGroup Id='helpFolder'>
-      <ComponentRef Id='help.root' />
-      <ComponentRef Id='help.internals' />
-    </ComponentGroup>
-  </Fragment>
-
-  <Fragment>
-    <DirectoryRef Id="INSTALLDIR">
-      <Directory Id="helpdir" Name="help" FileSource="$(var.SourceDir)">
-        <Component Id="help.root" Guid="$(var.help.root.guid)" Win64='$(var.IsX64)'>
-          <File Name="bundlespec.txt" />
-          <File Name="color.txt" />
-          <File Name="config.txt" KeyPath="yes" />
-          <File Name="dates.txt" />
-          <File Name="deprecated.txt" />
-          <File Name="diffs.txt" />
-          <File Name="environment.txt" />
-          <File Name="extensions.txt" />
-          <File Name="filesets.txt" />
-          <File Name="flags.txt" />
-          <File Name="glossary.txt" />
-          <File Name="hgignore.txt" />
-          <File Name="hgweb.txt" />
-          <File Name="merge-tools.txt" />
-          <File Name="pager.txt" />
-          <File Name="patterns.txt" />
-          <File Name="phases.txt" />
-          <File Name="revisions.txt" />
-          <File Name="scripting.txt" />
-          <File Name="subrepos.txt" />
-          <File Name="templates.txt" />
-          <File Name="urls.txt" />
-        </Component>
-
-        <Directory Id="help.internaldir" Name="internals">
-          <Component Id="help.internals" Guid="$(var.help.internals.guid)" Win64='$(var.IsX64)'>
-            <File Id="internals.bundle2.txt"      Name="bundle2.txt" />
-            <File Id="internals.bundles.txt"      Name="bundles.txt" KeyPath="yes" />
-            <File Id="internals.cbor.txt"         Name="cbor.txt" />
-            <File Id="internals.censor.txt"       Name="censor.txt" />
-            <File Id="internals.changegroups.txt" Name="changegroups.txt" />
-            <File Id="internals.config.txt"       Name="config.txt" />
-            <File Id="internals.extensions.txt"   Name="extensions.txt" />
-            <File Id="internals.linelog.txt"      Name="linelog.txt" />
-            <File Id="internals.mergestate.txt"   Name="mergestate.txt" />
-            <File Id="internals.requirements.txt" Name="requirements.txt" />
-            <File Id="internals.revlogs.txt"      Name="revlogs.txt" />
-            <File Id="internals.wireprotocol.txt" Name="wireprotocol.txt" />
-            <File Id="internals.wireprotocolrpc.txt" Name="wireprotocolrpc.txt" />
-            <File Id="internals.wireprotocolv2.txt" Name="wireprotocolv2.txt" />
-          </Component>
-        </Directory>
-
-      </Directory>
-    </DirectoryRef>
-  </Fragment>
-
-</Wix>
--- a/contrib/packaging/wix/i18n.wxs	Wed Nov 20 19:07:02 2019 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,26 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
-
-  <?include guids.wxi ?>
-  <?include defines.wxi ?>
-
-  <?define hg_po_langs =
-    da;de;el;fr;it;ja;pt_BR;ro;ru;sv;zh_CN;zh_TW
-  ?>
-
-  <Fragment>
-    <DirectoryRef Id="INSTALLDIR">
-      <Directory Id="i18ndir" Name="i18n" FileSource="$(var.SourceDir)">
-        <Component Id="i18nFolder" Guid="$(var.i18nFolder.guid)" Win64='$(var.IsX64)'>
-          <File Name="hggettext" KeyPath="yes" />
-          <?foreach LANG in $(var.hg_po_langs) ?>
-            <File Id="hg.$(var.LANG).po"
-                  Name="$(var.LANG).po"
-            />
-          <?endforeach?>
-        </Component>
-      </Directory>
-    </DirectoryRef>
-  </Fragment>
-
-</Wix>
--- a/contrib/packaging/wix/locale.wxs	Wed Nov 20 19:07:02 2019 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,34 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
-
-  <?include defines.wxi ?>
-
-  <?define hglocales =
-    da;de;el;fr;it;ja;pt_BR;ro;ru;sv;zh_CN;zh_TW
-  ?>
-
-  <Fragment>
-    <ComponentGroup Id="localeFolder">
-      <?foreach LOC in $(var.hglocales) ?>
-        <ComponentRef Id="hg.locale.$(var.LOC)"/>
-      <?endforeach?>
-    </ComponentGroup>
-  </Fragment>
-
-  <Fragment>
-    <DirectoryRef Id="INSTALLDIR">
-      <Directory Id="localedir" Name="locale" FileSource="$(var.SourceDir)">
-        <?foreach LOC in $(var.hglocales) ?>
-          <Directory Id="hg.locale.$(var.LOC)" Name="$(var.LOC)">
-            <Directory Id="hg.locale.$(var.LOC).LC_MESSAGES" Name="LC_MESSAGES">
-              <Component Id="hg.locale.$(var.LOC)" Guid="*" Win64='$(var.IsX64)'>
-                <File Id="hg.mo.$(var.LOC)" Name="hg.mo" KeyPath="yes" />
-              </Component>
-            </Directory>
-          </Directory>
-        <?endforeach?>
-      </Directory>
-    </DirectoryRef>
-  </Fragment>
-
-</Wix>
--- a/contrib/packaging/wix/mercurial.wxs	Wed Nov 20 19:07:02 2019 +0100
+++ b/contrib/packaging/wix/mercurial.wxs	Fri Nov 22 21:42:04 2019 +0900
@@ -60,30 +60,10 @@
       <Directory Id='$(var.PFolder)' Name='PFiles'>
         <Directory Id='INSTALLDIR' Name='Mercurial'>
           <Component Id='MainExecutable' Guid='$(var.ComponentMainExecutableGUID)' Win64='$(var.IsX64)'>
-            <File Id='hgEXE' Name='hg.exe' Source='dist\hg.exe' KeyPath='yes' />
+            <CreateFolder />
             <Environment Id="Environment" Name="PATH" Part="last" System="yes"
                          Permanent="no" Value="[INSTALLDIR]" Action="set" />
           </Component>
-          <Component Id='ReadMe' Guid='$(var.ReadMe.guid)' Win64='$(var.IsX64)'>
-              <File Id='ReadMe' Name='ReadMe.html' Source='contrib\win32\ReadMe.html'
-                    KeyPath='yes'/>
-          </Component>
-          <Component Id='COPYING' Guid='$(var.COPYING.guid)' Win64='$(var.IsX64)'>
-            <File Id='COPYING' Name='COPYING.rtf' Source='contrib\packaging\wix\COPYING.rtf'
-                  KeyPath='yes'/>
-          </Component>
-
-          <Directory Id='HGRCD' Name='hgrc.d'>
-            <Component Id='mercurial.rc' Guid='$(var.mercurial.rc.guid)' Win64='$(var.IsX64)'>
-              <File Id='mercurial.rc' Name='Mercurial.rc' Source='contrib\win32\mercurial.ini'
-                    ReadOnly='yes' KeyPath='yes'/>
-            </Component>
-            <Component Id='mergetools.rc' Guid='$(var.mergetools.rc.guid)' Win64='$(var.IsX64)'>
-              <File Id='mergetools.rc' Name='MergeTools.rc' Source='mercurial\default.d\mergetools.rc'
-                    ReadOnly='yes' KeyPath='yes'/>
-            </Component>
-          </Directory>
-
         </Directory>
       </Directory>
 
@@ -117,15 +97,12 @@
       <Feature Id='MainProgram' Title='Program' Description='Mercurial command line app'
              Level='1' Absent='disallow' >
         <ComponentRef Id='MainExecutable' />
-        <ComponentRef Id='distOutput' />
-        <ComponentRef Id='libOutput' />
         <ComponentRef Id='ProgramMenuDir' />
-        <ComponentRef Id='ReadMe' />
-        <ComponentRef Id='COPYING' />
-        <ComponentRef Id='mercurial.rc' />
-        <ComponentRef Id='mergetools.rc' />
-        <ComponentGroupRef Id='helpFolder' />
-        <ComponentGroupRef Id='templatesFolder' />
+        <ComponentGroupRef Id="hg.group.ROOT" />
+        <ComponentGroupRef Id="hg.group.hgrc.d" />
+        <ComponentGroupRef Id="hg.group.help" />
+        <ComponentGroupRef Id="hg.group.lib" />
+        <ComponentGroupRef Id="hg.group.templates" />
         <MergeRef Id='VCRuntime' />
         <MergeRef Id='VCRuntimePolicy' />
       </Feature>
@@ -135,14 +112,13 @@
         <?endforeach?>
       <?endif?>
       <Feature Id='Locales' Title='Translations' Description='Translations' Level='1'>
-        <ComponentGroupRef Id='localeFolder' />
-        <ComponentRef Id='i18nFolder' />
+        <ComponentGroupRef Id="hg.group.locale" />
       </Feature>
       <Feature Id='Documentation' Title='Documentation' Description='HTML man pages' Level='1'>
-        <ComponentGroupRef Id='docFolder' />
+        <ComponentGroupRef Id="hg.group.doc" />
       </Feature>
       <Feature Id='Misc' Title='Miscellaneous' Description='Contributed scripts' Level='1'>
-        <ComponentGroupRef Id='contribFolder' />
+        <ComponentGroupRef Id="hg.group.contrib" />
       </Feature>
     </Feature>
 
--- a/contrib/packaging/wix/readme.rst	Wed Nov 20 19:07:02 2019 +0100
+++ b/contrib/packaging/wix/readme.rst	Fri Nov 22 21:42:04 2019 +0900
@@ -18,12 +18,12 @@
 * Python 2.7 (download from https://www.python.org/downloads/)
 * Microsoft Visual C++ Compiler for Python 2.7
   (https://www.microsoft.com/en-us/download/details.aspx?id=44266)
-* Python 3.5+ (to run the ``build.py`` script)
+* Python 3.5+ (to run the ``packaging.py`` script)
 
 Building
 ========
 
-The ``build.py`` script automates the process of producing an MSI
+The ``packaging.py`` script automates the process of producing an MSI
 installer. It manages fetching and configuring non-system dependencies
 (such as py2exe, gettext, and various Python packages).
 
@@ -37,11 +37,11 @@
 From the prompt, change to the Mercurial source directory. e.g.
 ``cd c:\src\hg``.
 
-Next, invoke ``build.py`` to produce an MSI installer. You will need
+Next, invoke ``packaging.py`` to produce an MSI installer. You will need
 to supply the path to the Python interpreter to use.::
 
-   $ python3 contrib\packaging\wix\build.py \
-      --python c:\python27\python.exe
+   $ python3 contrib\packaging\packaging.py \
+      wix --python c:\python27\python.exe
 
 .. note::
 
@@ -54,8 +54,8 @@
 and an installer placed in the ``dist`` sub-directory. The final line
 of output should print the name of the generated installer.
 
-Additional options may be configured. Run ``build.py --help`` to see
-a list of program flags.
+Additional options may be configured. Run ``packaging.py wix --help`` to
+see a list of program flags.
 
 Relationship to TortoiseHG
 ==========================
--- a/contrib/packaging/wix/requirements.txt	Wed Nov 20 19:07:02 2019 +0100
+++ b/contrib/packaging/wix/requirements.txt	Fri Nov 22 21:42:04 2019 +0900
@@ -1,13 +1,13 @@
-#
-# This file is autogenerated by pip-compile
-# To update, run:
-#
-#    pip-compile --generate-hashes --output-file=contrib/packaging/wix/requirements.txt contrib/packaging/wix/requirements.txt.in
-#
-docutils==0.15.2 \
-    --hash=sha256:6c4f696463b79f1fb8ba0c594b63840ebd41f059e92b31957c46b74a4599b6d0 \
-    --hash=sha256:9e4d7ecfc600058e07ba661411a2b7de2fd0fafa17d1a7f7361cd47b1175c827 \
-    --hash=sha256:a2aeea129088da402665e92e0b25b04b073c04b2dce4ab65caaa38b7ce2e1a99
-pygments==2.4.2 \
-    --hash=sha256:71e430bc85c88a430f000ac1d9b331d2407f681d6f6aec95e8bcfbc3df5b0127 \
-    --hash=sha256:881c4c157e45f30af185c1ffe8d549d48ac9127433f2c380c24b84572ad66297
+#
+# This file is autogenerated by pip-compile
+# To update, run:
+#
+#    pip-compile --generate-hashes --output-file=contrib/packaging/wix/requirements.txt contrib/packaging/wix/requirements.txt.in
+#
+docutils==0.15.2 \
+    --hash=sha256:6c4f696463b79f1fb8ba0c594b63840ebd41f059e92b31957c46b74a4599b6d0 \
+    --hash=sha256:9e4d7ecfc600058e07ba661411a2b7de2fd0fafa17d1a7f7361cd47b1175c827 \
+    --hash=sha256:a2aeea129088da402665e92e0b25b04b073c04b2dce4ab65caaa38b7ce2e1a99
+pygments==2.4.2 \
+    --hash=sha256:71e430bc85c88a430f000ac1d9b331d2407f681d6f6aec95e8bcfbc3df5b0127 \
+    --hash=sha256:881c4c157e45f30af185c1ffe8d549d48ac9127433f2c380c24b84572ad66297
--- a/contrib/packaging/wix/requirements.txt.in	Wed Nov 20 19:07:02 2019 +0100
+++ b/contrib/packaging/wix/requirements.txt.in	Fri Nov 22 21:42:04 2019 +0900
@@ -1,2 +1,2 @@
-docutils
-pygments
+docutils
+pygments
--- a/contrib/packaging/wix/templates.wxs	Wed Nov 20 19:07:02 2019 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,251 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
-
-  <?include guids.wxi ?>
-  <?include defines.wxi ?>
-
-  <Fragment>
-    <ComponentGroup Id="templatesFolder">
-
-      <ComponentRef Id="templates.root" />
-
-      <ComponentRef Id="templates.atom" />
-      <ComponentRef Id="templates.coal" />
-      <ComponentRef Id="templates.gitweb" />
-      <ComponentRef Id="templates.json" />
-      <ComponentRef Id="templates.monoblue" />
-      <ComponentRef Id="templates.paper" />
-      <ComponentRef Id="templates.raw" />
-      <ComponentRef Id="templates.rss" />
-      <ComponentRef Id="templates.spartan" />
-      <ComponentRef Id="templates.static" />
-
-    </ComponentGroup>
-  </Fragment>
-
-  <Fragment>
-    <DirectoryRef Id="INSTALLDIR">
-
-      <Directory Id="templatesdir" Name="templates" FileSource="$(var.SourceDir)">
-
-        <Component Id="templates.root" Guid="$(var.templates.root.guid)" Win64='$(var.IsX64)'>
-          <File Name="map-cmdline.changelog" KeyPath="yes" />
-          <File Name="map-cmdline.compact" />
-          <File Name="map-cmdline.default" />
-          <File Name="map-cmdline.show" />
-          <File Name="map-cmdline.bisect" />
-          <File Name="map-cmdline.xml" />
-          <File Name="map-cmdline.status" />
-          <File Name="map-cmdline.phases" />
-        </Component>
-
-        <Directory Id="templates.jsondir" Name="json">
-          <Component Id="templates.json" Guid="$(var.templates.json.guid)" Win64='$(var.IsX64)'>
-            <File Id="json.changelist.tmpl" Name="changelist.tmpl" KeyPath="yes" />
-            <File Id="json.graph.tmpl"      Name="graph.tmpl" />
-            <File Id="json.map"             Name="map" />
-          </Component>
-        </Directory>
-
-        <Directory Id="templates.atomdir" Name="atom">
-          <Component Id="templates.atom" Guid="$(var.templates.atom.guid)" Win64='$(var.IsX64)'>
-            <File Id="atom.changelog.tmpl"      Name="changelog.tmpl" KeyPath="yes" />
-            <File Id="atom.changelogentry.tmpl" Name="changelogentry.tmpl" />
-            <File Id="atom.error.tmpl"          Name="error.tmpl" />
-            <File Id="atom.filelog.tmpl"        Name="filelog.tmpl" />
-            <File Id="atom.header.tmpl"         Name="header.tmpl" />
-            <File Id="atom.map"                 Name="map" />
-            <File Id="atom.tagentry.tmpl"       Name="tagentry.tmpl" />
-            <File Id="atom.tags.tmpl"           Name="tags.tmpl" />
-            <File Id="atom.branchentry.tmpl"    Name="branchentry.tmpl" />
-            <File Id="atom.branches.tmpl"       Name="branches.tmpl" />
-            <File Id="atom.bookmarks.tmpl"      Name="bookmarks.tmpl" />
-            <File Id="atom.bookmarkentry.tmpl"  Name="bookmarkentry.tmpl" />
-          </Component>
-        </Directory>
-
-        <Directory Id="templates.coaldir" Name="coal">
-          <Component Id="templates.coal" Guid="$(var.templates.coal.guid)" Win64='$(var.IsX64)'>
-            <File Id="coal.header.tmpl" Name="header.tmpl" KeyPath="yes" />
-            <File Id="coal.map"         Name="map" />
-          </Component>
-        </Directory>
-
-        <Directory Id="templates.gitwebdir" Name="gitweb">
-          <Component Id="templates.gitweb" Guid="$(var.templates.gitweb.guid)" Win64='$(var.IsX64)'>
-            <File Id="gitweb.branches.tmpl"       Name="branches.tmpl" KeyPath="yes" />
-            <File Id="gitweb.bookmarks.tmpl"      Name="bookmarks.tmpl" />
-            <File Id="gitweb.changelog.tmpl"      Name="changelog.tmpl" />
-            <File Id="gitweb.changelogentry.tmpl" Name="changelogentry.tmpl" />
-            <File Id="gitweb.changeset.tmpl"      Name="changeset.tmpl" />
-            <File Id="gitweb.error.tmpl"          Name="error.tmpl" />
-            <File Id="gitweb.fileannotate.tmpl"   Name="fileannotate.tmpl" />
-            <File Id="gitweb.filecomparison.tmpl" Name="filecomparison.tmpl" />
-            <File Id="gitweb.filediff.tmpl"       Name="filediff.tmpl" />
-            <File Id="gitweb.filelog.tmpl"        Name="filelog.tmpl" />
-            <File Id="gitweb.filerevision.tmpl"   Name="filerevision.tmpl" />
-            <File Id="gitweb.footer.tmpl"         Name="footer.tmpl" />
-            <File Id="gitweb.graph.tmpl"          Name="graph.tmpl" />
-            <File Id="gitweb.graphentry.tmpl"     Name="graphentry.tmpl" />
-            <File Id="gitweb.header.tmpl"         Name="header.tmpl" />
-            <File Id="gitweb.index.tmpl"          Name="index.tmpl" />
-            <File Id="gitweb.manifest.tmpl"       Name="manifest.tmpl" />
-            <File Id="gitweb.map"                 Name="map" />
-            <File Id="gitweb.notfound.tmpl"       Name="notfound.tmpl" />
-            <File Id="gitweb.search.tmpl"         Name="search.tmpl" />
-            <File Id="gitweb.shortlog.tmpl"       Name="shortlog.tmpl" />
-            <File Id="gitweb.summary.tmpl"        Name="summary.tmpl" />
-            <File Id="gitweb.tags.tmpl"           Name="tags.tmpl" />
-            <File Id="gitweb.help.tmpl"           Name="help.tmpl" />
-            <File Id="gitweb.helptopics.tmpl"     Name="helptopics.tmpl" />
-          </Component>
-        </Directory>
-
-        <Directory Id="templates.monobluedir" Name="monoblue">
-          <Component Id="templates.monoblue" Guid="$(var.templates.monoblue.guid)" Win64='$(var.IsX64)'>
-            <File Id="monoblue.branches.tmpl"       Name="branches.tmpl" KeyPath="yes" />
-            <File Id="monoblue.bookmarks.tmpl"      Name="bookmarks.tmpl" />
-            <File Id="monoblue.changelog.tmpl"      Name="changelog.tmpl" />
-            <File Id="monoblue.changelogentry.tmpl" Name="changelogentry.tmpl" />
-            <File Id="monoblue.changeset.tmpl"      Name="changeset.tmpl" />
-            <File Id="monoblue.error.tmpl"          Name="error.tmpl" />
-            <File Id="monoblue.fileannotate.tmpl"   Name="fileannotate.tmpl" />
-            <File Id="monoblue.filecomparison.tmpl" Name="filecomparison.tmpl" />
-            <File Id="monoblue.filediff.tmpl"       Name="filediff.tmpl" />
-            <File Id="monoblue.filelog.tmpl"        Name="filelog.tmpl" />
-            <File Id="monoblue.filerevision.tmpl"   Name="filerevision.tmpl" />
-            <File Id="monoblue.footer.tmpl"         Name="footer.tmpl" />
-            <File Id="monoblue.graph.tmpl"          Name="graph.tmpl" />
-            <File Id="monoblue.graphentry.tmpl"     Name="graphentry.tmpl" />
-            <File Id="monoblue.header.tmpl"         Name="header.tmpl" />
-            <File Id="monoblue.index.tmpl"          Name="index.tmpl" />
-            <File Id="monoblue.manifest.tmpl"       Name="manifest.tmpl" />
-            <File Id="monoblue.map"                 Name="map" />
-            <File Id="monoblue.notfound.tmpl"       Name="notfound.tmpl" />
-            <File Id="monoblue.search.tmpl"         Name="search.tmpl" />
-            <File Id="monoblue.shortlog.tmpl"       Name="shortlog.tmpl" />
-            <File Id="monoblue.summary.tmpl"        Name="summary.tmpl" />
-            <File Id="monoblue.tags.tmpl"           Name="tags.tmpl" />
-            <File Id="monoblue.help.tmpl"           Name="help.tmpl" />
-            <File Id="monoblue.helptopics.tmpl"     Name="helptopics.tmpl" />
-          </Component>
-        </Directory>
-
-        <Directory Id="templates.paperdir" Name="paper">
-          <Component Id="templates.paper" Guid="$(var.templates.paper.guid)" Win64='$(var.IsX64)'>
-            <File Id="paper.branches.tmpl"      Name="branches.tmpl" KeyPath="yes" />
-            <File Id="paper.bookmarks.tmpl"     Name="bookmarks.tmpl" />
-            <File Id="paper.changeset.tmpl"     Name="changeset.tmpl" />
-            <File Id="paper.diffstat.tmpl"      Name="diffstat.tmpl" />
-            <File Id="paper.error.tmpl"         Name="error.tmpl" />
-            <File Id="paper.fileannotate.tmpl"  Name="fileannotate.tmpl" />
-            <File Id="paper.filecomparison.tmpl" Name="filecomparison.tmpl" />
-            <File Id="paper.filediff.tmpl"      Name="filediff.tmpl" />
-            <File Id="paper.filelog.tmpl"       Name="filelog.tmpl" />
-            <File Id="paper.filelogentry.tmpl"  Name="filelogentry.tmpl" />
-            <File Id="paper.filerevision.tmpl"  Name="filerevision.tmpl" />
-            <File Id="paper.footer.tmpl"        Name="footer.tmpl" />
-            <File Id="paper.graph.tmpl"         Name="graph.tmpl" />
-            <File Id="paper.graphentry.tmpl"    Name="graphentry.tmpl" />
-            <File Id="paper.header.tmpl"        Name="header.tmpl" />
-            <File Id="paper.index.tmpl"         Name="index.tmpl" />
-            <File Id="paper.manifest.tmpl"      Name="manifest.tmpl" />
-            <File Id="paper.map"                Name="map" />
-            <File Id="paper.notfound.tmpl"      Name="notfound.tmpl" />
-            <File Id="paper.search.tmpl"        Name="search.tmpl" />
-            <File Id="paper.shortlog.tmpl"      Name="shortlog.tmpl" />
-            <File Id="paper.shortlogentry.tmpl" Name="shortlogentry.tmpl" />
-            <File Id="paper.tags.tmpl"          Name="tags.tmpl" />
-            <File Id="paper.help.tmpl"          Name="help.tmpl" />
-            <File Id="paper.helptopics.tmpl"    Name="helptopics.tmpl" />
-          </Component>
-        </Directory>
-
-        <Directory Id="templates.rawdir" Name="raw">
-          <Component Id="templates.raw" Guid="$(var.templates.raw.guid)" Win64='$(var.IsX64)'>
-            <File Id="raw.changeset.tmpl"    Name="changeset.tmpl" KeyPath="yes" />
-            <File Id="raw.error.tmpl"        Name="error.tmpl" />
-            <File Id="raw.fileannotate.tmpl" Name="fileannotate.tmpl" />
-            <File Id="raw.filediff.tmpl"     Name="filediff.tmpl" />
-            <File Id="raw.graph.tmpl"        Name="graph.tmpl" />
-            <File Id="raw.graphedge.tmpl"    Name="graphedge.tmpl" />
-            <File Id="raw.graphnode.tmpl"    Name="graphnode.tmpl" />
-            <File Id="raw.index.tmpl"        Name="index.tmpl" />
-            <File Id="raw.manifest.tmpl"     Name="manifest.tmpl" />
-            <File Id="raw.map"               Name="map" />
-            <File Id="raw.notfound.tmpl"     Name="notfound.tmpl" />
-            <File Id="raw.search.tmpl"       Name="search.tmpl" />
-            <File Id="raw.logentry.tmpl"     Name="logentry.tmpl" />
-            <File Id="raw.changelog.tmpl"    Name="changelog.tmpl" />
-          </Component>
-        </Directory>
-
-        <Directory Id="templates.rssdir" Name="rss">
-          <Component Id="templates.rss" Guid="$(var.templates.rss.guid)" Win64='$(var.IsX64)'>
-            <File Id="rss.changelog.tmpl"      Name="changelog.tmpl" KeyPath="yes" />
-            <File Id="rss.changelogentry.tmpl" Name="changelogentry.tmpl" />
-            <File Id="rss.error.tmpl"          Name="error.tmpl" />
-            <File Id="rss.filelog.tmpl"        Name="filelog.tmpl" />
-            <File Id="rss.filelogentry.tmpl"   Name="filelogentry.tmpl" />
-            <File Id="rss.header.tmpl"         Name="header.tmpl" />
-            <File Id="rss.map"                 Name="map" />
-            <File Id="rss.tagentry.tmpl"       Name="tagentry.tmpl" />
-            <File Id="rss.tags.tmpl"           Name="tags.tmpl" />
-            <File Id="rss.bookmarks.tmpl"      Name="bookmarks.tmpl" />
-            <File Id="rss.bookmarkentry.tmpl"  Name="bookmarkentry.tmpl" />
-            <File Id="rss.branchentry.tmpl"    Name="branchentry.tmpl" />
-            <File Id="rss.branches.tmpl"       Name="branches.tmpl" />
-          </Component>
-        </Directory>
-
-        <Directory Id="templates.spartandir" Name="spartan">
-          <Component Id="templates.spartan" Guid="$(var.templates.spartan.guid)" Win64='$(var.IsX64)'>
-            <File Id="spartan.branches.tmpl"       Name="branches.tmpl" KeyPath="yes" />
-            <File Id="spartan.changelog.tmpl"      Name="changelog.tmpl" />
-            <File Id="spartan.changelogentry.tmpl" Name="changelogentry.tmpl" />
-            <File Id="spartan.changeset.tmpl"      Name="changeset.tmpl" />
-            <File Id="spartan.error.tmpl"          Name="error.tmpl" />
-            <File Id="spartan.fileannotate.tmpl"   Name="fileannotate.tmpl" />
-            <File Id="spartan.filediff.tmpl"       Name="filediff.tmpl" />
-            <File Id="spartan.filelog.tmpl"        Name="filelog.tmpl" />
-            <File Id="spartan.filelogentry.tmpl"   Name="filelogentry.tmpl" />
-            <File Id="spartan.filerevision.tmpl"   Name="filerevision.tmpl" />
-            <File Id="spartan.footer.tmpl"         Name="footer.tmpl" />
-            <File Id="spartan.graph.tmpl"          Name="graph.tmpl" />
-            <File Id="spartan.graphentry.tmpl"     Name="graphentry.tmpl" />
-            <File Id="spartan.header.tmpl"         Name="header.tmpl" />
-            <File Id="spartan.index.tmpl"          Name="index.tmpl" />
-            <File Id="spartan.manifest.tmpl"       Name="manifest.tmpl" />
-            <File Id="spartan.map"                 Name="map" />
-            <File Id="spartan.notfound.tmpl"       Name="notfound.tmpl" />
-            <File Id="spartan.search.tmpl"         Name="search.tmpl" />
-            <File Id="spartan.shortlog.tmpl"       Name="shortlog.tmpl" />
-            <File Id="spartan.shortlogentry.tmpl"  Name="shortlogentry.tmpl" />
-            <File Id="spartan.tags.tmpl"           Name="tags.tmpl" />
-          </Component>
-        </Directory>
-
-        <Directory Id="templates.staticdir" Name="static">
-          <Component Id="templates.static" Guid="$(var.templates.static.guid)" Win64='$(var.IsX64)'>
-            <File Id="static.background.png"     Name="background.png" KeyPath="yes" />
-            <File Id="static.coal.file.png"      Name="coal-file.png" />
-            <File Id="static.coal.folder.png"    Name="coal-folder.png" />
-            <File Id="static.followlines.js"     Name="followlines.js" />
-            <File Id="static.mercurial.js"       Name="mercurial.js" />
-            <File Id="static.hgicon.png"         Name="hgicon.png" />
-            <File Id="static.hglogo.png"         Name="hglogo.png" />
-            <File Id="static.style.coal.css"     Name="style-extra-coal.css" />
-            <File Id="static.style.gitweb.css"   Name="style-gitweb.css" />
-            <File Id="static.style.monoblue.css" Name="style-monoblue.css" />
-            <File Id="static.style.paper.css"    Name="style-paper.css" />
-            <File Id="static.style.css"          Name="style.css" />
-            <File Id="static.feed.icon"          Name="feed-icon-14x14.png" />
-          </Component>
-        </Directory>
-
-      </Directory>
-
-    </DirectoryRef>
-  </Fragment>
-
- </Wix>
--- a/contrib/perf.py	Wed Nov 20 19:07:02 2019 +0100
+++ b/contrib/perf.py	Fri Nov 22 21:42:04 2019 +0900
@@ -726,8 +726,8 @@
 
 def clearchangelog(repo):
     if repo is not repo.unfiltered():
-        object.__setattr__(repo, r'_clcachekey', None)
-        object.__setattr__(repo, r'_clcache', None)
+        object.__setattr__(repo, '_clcachekey', None)
+        object.__setattr__(repo, '_clcache', None)
     clearfilecache(repo.unfiltered(), 'changelog')
 
 
@@ -760,7 +760,10 @@
 
 @command(
     b'perfstatus',
-    [(b'u', b'unknown', False, b'ask status to look for unknown files')]
+    [
+        (b'u', b'unknown', False, b'ask status to look for unknown files'),
+        (b'', b'dirstate', False, b'benchmark the internal dirstate call'),
+    ]
     + formatteropts,
 )
 def perfstatus(ui, repo, **opts):
@@ -776,7 +779,20 @@
     # timer(lambda: sum(map(len, repo.dirstate.status(m, [], False, False,
     #                                                False))))
     timer, fm = gettimer(ui, opts)
-    timer(lambda: sum(map(len, repo.status(unknown=opts[b'unknown']))))
+    if opts[b'dirstate']:
+        dirstate = repo.dirstate
+        m = scmutil.matchall(repo)
+        unknown = opts[b'unknown']
+
+        def status_dirstate():
+            s = dirstate.status(
+                m, subrepos=[], ignored=False, clean=False, unknown=unknown
+            )
+            sum(map(bool, s))
+
+        timer(status_dirstate)
+    else:
+        timer(lambda: sum(map(len, repo.status(unknown=opts[b'unknown']))))
     fm.end()
 
 
@@ -804,6 +820,7 @@
     if util.safehasattr(cl, b'clearcaches'):
         cl.clearcaches()
     elif util.safehasattr(cl, b'_nodecache'):
+        # <= hg-5.2
         from mercurial.node import nullid, nullrev
 
         cl._nodecache = {nullid: nullrev}
@@ -1404,13 +1421,15 @@
     else:
         ui.statusnoi18n(b'publishing: no\n')
 
-    nodemap = repo.changelog.nodemap
+    has_node = getattr(repo.changelog.index, 'has_node', None)
+    if has_node is None:
+        has_node = repo.changelog.nodemap.__contains__
     nonpublishroots = 0
     for nhex, phase in remotephases.iteritems():
         if nhex == b'publishing':  # ignore data related to publish option
             continue
         node = bin(nhex)
-        if node in nodemap and int(phase):
+        if has_node(node) and int(phase):
             nonpublishroots += 1
     ui.statusnoi18n(b'number of roots: %d\n' % len(remotephases))
     ui.statusnoi18n(b'number of known non public roots: %d\n' % nonpublishroots)
@@ -1610,7 +1629,11 @@
     def setnodeget():
         # probably not necessary, but for good measure
         clearchangelog(unfi)
-        nodeget[0] = makecl(unfi).nodemap.get
+        cl = makecl(unfi)
+        if util.safehasattr(cl.index, 'get_rev'):
+            nodeget[0] = cl.index.get_rev
+        else:
+            nodeget[0] = cl.nodemap.get
 
     def d():
         get = nodeget[0]
@@ -1636,13 +1659,13 @@
     timer, fm = gettimer(ui, opts)
 
     def d():
-        if os.name != r'nt':
+        if os.name != 'nt':
             os.system(
                 b"HGRCPATH= %s version -q > /dev/null" % fsencode(sys.argv[0])
             )
         else:
-            os.environ[r'HGRCPATH'] = r' '
-            os.system(r"%s version -q > NUL" % sys.argv[0])
+            os.environ['HGRCPATH'] = r' '
+            os.system("%s version -q > NUL" % sys.argv[0])
 
     timer(d)
     fm.end()
@@ -1828,7 +1851,7 @@
     opts = _byteskwargs(opts)
 
     nullui = ui.copy()
-    nullui.fout = open(os.devnull, r'wb')
+    nullui.fout = open(os.devnull, 'wb')
     nullui.disablepager()
     revs = opts.get(b'rev')
     if not revs:
@@ -2576,25 +2599,38 @@
                 index[rev]
 
     def resolvenode(node):
-        nodemap = revlogio.parseindex(data, inline)[1]
-        # This only works for the C code.
-        if nodemap is None:
-            return
+        index = revlogio.parseindex(data, inline)[0]
+        rev = getattr(index, 'rev', None)
+        if rev is None:
+            nodemap = getattr(
+                revlogio.parseindex(data, inline)[0], 'nodemap', None
+            )
+            # This only works for the C code.
+            if nodemap is None:
+                return
+            rev = nodemap.__getitem__
 
         try:
-            nodemap[node]
+            rev(node)
         except error.RevlogError:
             pass
 
     def resolvenodes(nodes, count=1):
-        nodemap = revlogio.parseindex(data, inline)[1]
-        if nodemap is None:
-            return
+        index = revlogio.parseindex(data, inline)[0]
+        rev = getattr(index, 'rev', None)
+        if rev is None:
+            nodemap = getattr(
+                revlogio.parseindex(data, inline)[0], 'nodemap', None
+            )
+            # This only works for the C code.
+            if nodemap is None:
+                return
+            rev = nodemap.__getitem__
 
         for i in range(count):
             for node in nodes:
                 try:
-                    nodemap[node]
+                    rev(node)
                 except error.RevlogError:
                     pass
 
--- a/contrib/python3-ratchet.py	Wed Nov 20 19:07:02 2019 +0100
+++ b/contrib/python3-ratchet.py	Fri Nov 22 21:42:04 2019 +0900
@@ -60,7 +60,7 @@
     )
     p.add_argument(
         '-j',
-        default=os.sysconf(r'SC_NPROCESSORS_ONLN'),
+        default=os.sysconf('SC_NPROCESSORS_ONLN'),
         type=int,
         help='Number of parallel tests to run.',
     )
--- a/contrib/relnotes	Wed Nov 20 19:07:02 2019 +0100
+++ b/contrib/relnotes	Fri Nov 22 21:42:04 2019 +0900
@@ -98,6 +98,7 @@
     (r"shelve|unshelve", "extensions"),
 ]
 
+
 def wikify(desc):
     desc = desc.replace("(issue", "(Bts:issue")
     desc = re.sub(r"\b([0-9a-f]{12})\b", r"Cset:\1", desc)
@@ -107,6 +108,7 @@
     desc = re.sub(r"\b(\S*__\S*)\b", r"`\1`", desc)
     return desc
 
+
 def main():
     desc = "example: %(prog)s 4.7.2 --stoprev 4.8rc0"
     ap = argparse.ArgumentParser(description=desc)
@@ -200,5 +202,6 @@
     for d in sorted(apis):
         print(" * %s" % d)
 
+
 if __name__ == "__main__":
     main()
--- a/contrib/simplemerge	Wed Nov 20 19:07:02 2019 +0100
+++ b/contrib/simplemerge	Fri Nov 22 21:42:04 2019 +0900
@@ -5,6 +5,7 @@
 import sys
 
 import hgdemandimport
+
 hgdemandimport.enable()
 
 from mercurial.i18n import _
@@ -16,44 +17,54 @@
     simplemerge,
     ui as uimod,
 )
-from mercurial.utils import (
-    procutil,
-    stringutil
-)
+from mercurial.utils import procutil, stringutil
 
-options = [(b'L', b'label', [], _(b'labels to use on conflict markers')),
-           (b'a', b'text', None, _(b'treat all files as text')),
-           (b'p', b'print', None,
-            _(b'print results instead of overwriting LOCAL')),
-           (b'', b'no-minimal', None, _(b'no effect (DEPRECATED)')),
-           (b'h', b'help', None, _(b'display help and exit')),
-           (b'q', b'quiet', None, _(b'suppress output'))]
+options = [
+    (b'L', b'label', [], _(b'labels to use on conflict markers')),
+    (b'a', b'text', None, _(b'treat all files as text')),
+    (b'p', b'print', None, _(b'print results instead of overwriting LOCAL')),
+    (b'', b'no-minimal', None, _(b'no effect (DEPRECATED)')),
+    (b'h', b'help', None, _(b'display help and exit')),
+    (b'q', b'quiet', None, _(b'suppress output')),
+]
 
-usage = _(b'''simplemerge [OPTS] LOCAL BASE OTHER
+usage = _(
+    b'''simplemerge [OPTS] LOCAL BASE OTHER
 
     Simple three-way file merge utility with a minimal feature set.
 
     Apply to LOCAL the changes necessary to go from BASE to OTHER.
 
     By default, LOCAL is overwritten with the results of this operation.
-''')
+'''
+)
+
 
 class ParseError(Exception):
     """Exception raised on errors in parsing the command line."""
 
+
 def showhelp():
     pycompat.stdout.write(usage)
     pycompat.stdout.write(b'\noptions:\n')
 
     out_opts = []
     for shortopt, longopt, default, desc in options:
-        out_opts.append((b'%2s%s' % (shortopt and b'-%s' % shortopt,
-                                     longopt and b' --%s' % longopt),
-                         b'%s' % desc))
+        out_opts.append(
+            (
+                b'%2s%s'
+                % (
+                    shortopt and b'-%s' % shortopt,
+                    longopt and b' --%s' % longopt,
+                ),
+                b'%s' % desc,
+            )
+        )
     opts_len = max([len(opt[0]) for opt in out_opts])
     for first, second in out_opts:
         pycompat.stdout.write(b' %-*s  %s\n' % (opts_len, first, second))
 
+
 try:
     for fp in (sys.stdin, pycompat.stdout, sys.stderr):
         procutil.setbinary(fp)
@@ -68,13 +79,17 @@
         showhelp()
         sys.exit(0)
     if len(args) != 3:
-            raise ParseError(_(b'wrong number of arguments').decode('utf8'))
+        raise ParseError(_(b'wrong number of arguments').decode('utf8'))
     local, base, other = args
-    sys.exit(simplemerge.simplemerge(uimod.ui.load(),
-                                     context.arbitraryfilectx(local),
-                                     context.arbitraryfilectx(base),
-                                     context.arbitraryfilectx(other),
-                                     **pycompat.strkwargs(opts)))
+    sys.exit(
+        simplemerge.simplemerge(
+            uimod.ui.load(),
+            context.arbitraryfilectx(local),
+            context.arbitraryfilectx(base),
+            context.arbitraryfilectx(other),
+            **pycompat.strkwargs(opts)
+        )
+    )
 except ParseError as e:
     e = stringutil.forcebytestr(e)
     pycompat.stdout.write(b"%s: %s\n" % (sys.argv[0].encode('utf8'), e))
--- a/contrib/testparseutil.py	Wed Nov 20 19:07:02 2019 +0100
+++ b/contrib/testparseutil.py	Fri Nov 22 21:42:04 2019 +0900
@@ -80,7 +80,7 @@
 ####################
 
 
-class embeddedmatcher(object):
+class embeddedmatcher(object):  # pytype: disable=ignored-metaclass
     """Base class to detect embedded code fragments in *.t test script
     """
 
--- a/contrib/undumprevlog	Wed Nov 20 19:07:02 2019 +0100
+++ b/contrib/undumprevlog	Fri Nov 22 21:42:04 2019 +0900
@@ -14,16 +14,15 @@
     transaction,
     vfs as vfsmod,
 )
-from mercurial.utils import (
-    procutil,
-)
+from mercurial.utils import procutil
 
 for fp in (sys.stdin, sys.stdout, sys.stderr):
     procutil.setbinary(fp)
 
 opener = vfsmod.vfs(b'.', False)
-tr = transaction.transaction(sys.stderr.write, opener, {b'store': opener},
-                             b"undump.journal")
+tr = transaction.transaction(
+    sys.stderr.write, opener, {b'store': opener}, b"undump.journal"
+)
 while True:
     l = sys.stdin.readline()
     if not l:
@@ -42,9 +41,9 @@
         p2 = node.bin(p[1])
     elif l.startswith("length:"):
         length = int(l[8:-1])
-        sys.stdin.readline() # start marker
+        sys.stdin.readline()  # start marker
         d = encoding.strtolocal(sys.stdin.read(length))
-        sys.stdin.readline() # end marker
+        sys.stdin.readline()  # end marker
         r.addrevision(d, tr, lr, p1, p2)
 
 tr.close()
--- a/contrib/vagrant/Vagrantfile	Wed Nov 20 19:07:02 2019 +0100
+++ b/contrib/vagrant/Vagrantfile	Fri Nov 22 21:42:04 2019 +0900
@@ -1,8 +1,8 @@
 # -*- mode: ruby -*-
 
 Vagrant.configure('2') do |config|
-  # Debian 8.1 x86_64 without configuration management software
-  config.vm.box = "debian/jessie64"
+  # Debian 10.1 x86_64 without configuration management software
+  config.vm.box = "debian/buster64"
   config.vm.hostname = "tests"
 
   config.vm.define "tests" do |conf|
--- a/contrib/win32/ReadMe.html	Wed Nov 20 19:07:02 2019 +0100
+++ b/contrib/win32/ReadMe.html	Fri Nov 22 21:42:04 2019 +0900
@@ -140,8 +140,7 @@
     </p>
 
     <p>
-      Mercurial is Copyright 2005-2019 Matt Mackall and others. See
-      the <tt>Contributors.txt</tt> file for a list of contributors.
+      Mercurial is Copyright 2005-2019 Matt Mackall and others.
     </p>
 
     <p>
--- a/contrib/win32/mercurial.ini	Wed Nov 20 19:07:02 2019 +0100
+++ b/contrib/win32/mercurial.ini	Fri Nov 22 21:42:04 2019 +0900
@@ -16,7 +16,7 @@
 
 [ui]
 ; editor used to enter commit logs, etc.  Most text editors will work.
-editor = notepad
+; editor = notepad
 ; show changed files and be a bit more verbose if True
 ; verbose = True
 ; colorize commands output
--- a/doc/docchecker	Wed Nov 20 19:07:02 2019 +0100
+++ b/doc/docchecker	Fri Nov 22 21:42:04 2019 +0900
@@ -15,6 +15,7 @@
 
 try:
     import msvcrt
+
     msvcrt.setmode(sys.stdout.fileno(), os.O_BINARY)
     msvcrt.setmode(sys.stderr.fileno(), os.O_BINARY)
 except ImportError:
@@ -25,14 +26,18 @@
 leadingline = re.compile(br'(^\s*)(\S.*)$')
 
 checks = [
-  (br""":hg:`[^`]*'[^`]*`""",
-   b"""warning: please avoid nesting ' in :hg:`...`"""),
-  (br'\w:hg:`',
-   b'warning: please have a space before :hg:'),
-  (br"""(?:[^a-z][^'.])hg ([^,;"`]*'(?!hg)){2}""",
-   b'''warning: please use " instead of ' for hg ... "..."'''),
+    (
+        br""":hg:`[^`]*'[^`]*`""",
+        b"""warning: please avoid nesting ' in :hg:`...`""",
+    ),
+    (br'\w:hg:`', b'warning: please have a space before :hg:'),
+    (
+        br"""(?:[^a-z][^'.])hg ([^,;"`]*'(?!hg)){2}""",
+        b'''warning: please use " instead of ' for hg ... "..."''',
+    ),
 ]
 
+
 def check(line):
     messages = []
     for match, msg in checks:
@@ -43,6 +48,7 @@
         for msg in messages:
             stdout.write(b'%s\n' % msg)
 
+
 def work(file):
     (llead, lline) = (b'', b'')
 
@@ -55,8 +61,8 @@
             continue
 
         lead, line = match.group(1), match.group(2)
-        if (lead == llead):
-            if (lline != b''):
+        if lead == llead:
+            if lline != b'':
                 lline += b' ' + line
             else:
                 lline = line
@@ -65,6 +71,7 @@
             (llead, lline) = (lead, line)
     check(lline)
 
+
 def main():
     for f in sys.argv[1:]:
         try:
@@ -73,4 +80,5 @@
         except BaseException as e:
             sys.stdout.write(r"failed to process %s: %s\n" % (f, e))
 
+
 main()
--- a/doc/gendoc.py	Wed Nov 20 19:07:02 2019 +0100
+++ b/doc/gendoc.py	Fri Nov 22 21:42:04 2019 +0900
@@ -20,17 +20,13 @@
 
 # This script is executed during installs and may not have C extensions
 # available. Relax C module requirements.
-os.environ[r'HGMODULEPOLICY'] = r'allow'
+os.environ['HGMODULEPOLICY'] = 'allow'
 # import from the live mercurial repo
-sys.path.insert(0, r"..")
+sys.path.insert(0, "..")
 from mercurial import demandimport
 
 demandimport.enable()
-# Load util so that the locale path is set by i18n.setdatapath() before
-# calling _().
-from mercurial import util
 
-util.datapath
 from mercurial import (
     commands,
     encoding,
--- a/doc/runrst	Wed Nov 20 19:07:02 2019 +0100
+++ b/doc/runrst	Fri Nov 22 21:42:04 2019 +0900
@@ -15,20 +15,25 @@
 from __future__ import absolute_import
 
 import sys
+
 try:
     import docutils.core as core
     import docutils.nodes as nodes
     import docutils.utils as utils
     import docutils.parsers.rst.roles as roles
 except ImportError:
-    sys.stderr.write("abort: couldn't generate documentation: docutils "
-                     "module is missing\n")
-    sys.stderr.write("please install python-docutils or see "
-                     "http://docutils.sourceforge.net/\n")
+    sys.stderr.write(
+        "abort: couldn't generate documentation: docutils "
+        "module is missing\n"
+    )
+    sys.stderr.write(
+        "please install python-docutils or see "
+        "http://docutils.sourceforge.net/\n"
+    )
     sys.exit(-1)
 
-def role_hg(name, rawtext, text, lineno, inliner,
-            options={}, content=[]):
+
+def role_hg(name, rawtext, text, lineno, inliner, options=None, content=None):
     text = "hg " + utils.unescape(text)
     linktext = nodes.literal(rawtext, text)
     parts = text.split()
@@ -47,10 +52,10 @@
             refuri = "hg.1.html#%s" % args[1]
         else:
             refuri = "hg.1.html#%s" % args[0]
-    node = nodes.reference(rawtext, '', linktext,
-                           refuri=refuri)
+    node = nodes.reference(rawtext, '', linktext, refuri=refuri)
     return [node], []
 
+
 roles.register_local_role("hg", role_hg)
 
 if __name__ == "__main__":
--- a/hg	Wed Nov 20 19:07:02 2019 +0100
+++ b/hg	Fri Nov 22 21:42:04 2019 +0900
@@ -15,22 +15,29 @@
 
 if libdir != '@' 'LIBDIR' '@':
     if not os.path.isabs(libdir):
-        libdir = os.path.join(os.path.dirname(os.path.realpath(__file__)),
-                              libdir)
+        libdir = os.path.join(
+            os.path.dirname(os.path.realpath(__file__)), libdir
+        )
         libdir = os.path.abspath(libdir)
     sys.path.insert(0, libdir)
 
 from hgdemandimport import tracing
+
 with tracing.log('hg script'):
     # enable importing on demand to reduce startup time
     try:
         if sys.version_info[0] < 3 or sys.version_info >= (3, 6):
-            import hgdemandimport; hgdemandimport.enable()
+            import hgdemandimport
+
+            hgdemandimport.enable()
     except ImportError:
-        sys.stderr.write("abort: couldn't find mercurial libraries in [%s]\n" %
-                         ' '.join(sys.path))
+        sys.stderr.write(
+            "abort: couldn't find mercurial libraries in [%s]\n"
+            % ' '.join(sys.path)
+        )
         sys.stderr.write("(check your install and PYTHONPATH)\n")
         sys.exit(-1)
 
     from mercurial import dispatch
+
     dispatch.run()
--- a/hgdemandimport/demandimportpy2.py	Wed Nov 20 19:07:02 2019 +0100
+++ b/hgdemandimport/demandimportpy2.py	Fri Nov 22 21:42:04 2019 +0900
@@ -70,9 +70,9 @@
             head = name
             after = []
         object.__setattr__(
-            self, r"_data", (head, globals, locals, after, level, set())
+            self, "_data", (head, globals, locals, after, level, set())
         )
-        object.__setattr__(self, r"_module", None)
+        object.__setattr__(self, "_module", None)
 
     def _extend(self, name):
         """add to the list of submodules to load"""
@@ -135,15 +135,15 @@
                 if locals:
                     if locals.get(head) is self:
                         locals[head] = mod
-                    elif locals.get(head + r'mod') is self:
-                        locals[head + r'mod'] = mod
+                    elif locals.get(head + 'mod') is self:
+                        locals[head + 'mod'] = mod
 
                 for modname in modrefs:
                     modref = sys.modules.get(modname, None)
                     if modref and getattr(modref, head, None) is self:
                         setattr(modref, head, mod)
 
-                object.__setattr__(self, r"_module", mod)
+                object.__setattr__(self, "_module", mod)
 
     def __repr__(self):
         if self._module:
--- a/hgext/acl.py	Wed Nov 20 19:07:02 2019 +0100
+++ b/hgext/acl.py	Fri Nov 22 21:42:04 2019 +0900
@@ -369,8 +369,8 @@
         return
 
     user = None
-    if source == b'serve' and r'url' in kwargs:
-        url = kwargs[r'url'].split(b':')
+    if source == b'serve' and 'url' in kwargs:
+        url = kwargs['url'].split(b':')
         if url[0] == b'remote' and url[1].startswith(b'http'):
             user = urlreq.unquote(url[3])
 
@@ -386,9 +386,9 @@
 
 
 def _pkhook(ui, repo, hooktype, node, source, user, **kwargs):
-    if kwargs[r'namespace'] == b'bookmarks':
-        bookmark = kwargs[r'key']
-        ctx = kwargs[r'new']
+    if kwargs['namespace'] == b'bookmarks':
+        bookmark = kwargs['key']
+        ctx = kwargs['new']
         allowbookmarks = buildmatch(ui, None, user, b'acl.allow.bookmarks')
         denybookmarks = buildmatch(ui, None, user, b'acl.deny.bookmarks')
 
--- a/hgext/beautifygraph.py	Wed Nov 20 19:07:02 2019 +0100
+++ b/hgext/beautifygraph.py	Fri Nov 22 21:42:04 2019 +0900
@@ -94,7 +94,7 @@
         ui.warn(_(b'beautifygraph: unsupported encoding, UTF-8 required\n'))
         return
 
-    if r'A' in encoding._wide:
+    if 'A' in encoding._wide:
         ui.warn(
             _(
                 b'beautifygraph: unsupported terminal settings, '
--- a/hgext/blackbox.py	Wed Nov 20 19:07:02 2019 +0100
+++ b/hgext/blackbox.py	Fri Nov 22 21:42:04 2019 +0900
@@ -201,7 +201,7 @@
     if not repo.vfs.exists(b'blackbox.log'):
         return
 
-    limit = opts.get(r'limit')
+    limit = opts.get('limit')
     fp = repo.vfs(b'blackbox.log', b'r')
     lines = fp.read().split(b'\n')
 
--- a/hgext/bookflow.py	Wed Nov 20 19:07:02 2019 +0100
+++ b/hgext/bookflow.py	Fri Nov 22 21:42:04 2019 +0900
@@ -101,7 +101,7 @@
 
 
 def commands_branch(orig, ui, repo, label=None, **opts):
-    if label and not opts.get(r'clean') and not opts.get(r'rev'):
+    if label and not opts.get('clean') and not opts.get('rev'):
         raise error.Abort(
             _(
                 b"creating named branches is disabled and you should use bookmarks"
--- a/hgext/bugzilla.py	Wed Nov 20 19:07:02 2019 +0100
+++ b/hgext/bugzilla.py	Fri Nov 22 21:42:04 2019 +0900
@@ -612,7 +612,7 @@
             self.ui.warn(_(b"Bugzilla/MySQL cannot update bug state\n"))
 
         (user, userid) = self.get_bugzilla_user(committer)
-        now = time.strftime(r'%Y-%m-%d %H:%M:%S')
+        now = time.strftime('%Y-%m-%d %H:%M:%S')
         self.run(
             '''insert into longdescs
                     (bug_id, who, bug_when, thetext)
--- a/hgext/censor.py	Wed Nov 20 19:07:02 2019 +0100
+++ b/hgext/censor.py	Fri Nov 22 21:42:04 2019 +0900
@@ -23,6 +23,9 @@
 ``hg update``, must be capable of tolerating censored data to continue to
 function in a meaningful way. Such commands only tolerate censored file
 revisions if they are allowed by the "censor.policy=ignore" config option.
+
+A few informative commands such as ``hg grep`` will unconditionally
+ignore censored data and merely report that it was encountered.
 """
 
 from __future__ import absolute_import
--- a/hgext/churn.py	Wed Nov 20 19:07:02 2019 +0100
+++ b/hgext/churn.py	Fri Nov 22 21:42:04 2019 +0900
@@ -197,7 +197,7 @@
         return s + b" " * (l - encoding.colwidth(s))
 
     amap = {}
-    aliases = opts.get(r'aliases')
+    aliases = opts.get('aliases')
     if not aliases and os.path.exists(repo.wjoin(b'.hgchurn')):
         aliases = repo.wjoin(b'.hgchurn')
     if aliases:
@@ -215,7 +215,7 @@
     if not rate:
         return
 
-    if opts.get(r'sort'):
+    if opts.get('sort'):
         rate.sort()
     else:
         rate.sort(key=lambda x: (-sum(x[1]), x))
@@ -228,7 +228,7 @@
     ui.debug(b"assuming %i character terminal\n" % ttywidth)
     width = ttywidth - maxname - 2 - 2 - 2
 
-    if opts.get(r'diffstat'):
+    if opts.get('diffstat'):
         width -= 15
 
         def format(name, diffstat):
--- a/hgext/commitextras.py	Wed Nov 20 19:07:02 2019 +0100
+++ b/hgext/commitextras.py	Fri Nov 22 21:42:04 2019 +0900
@@ -58,7 +58,7 @@
 
     class repoextra(repo.__class__):
         def commit(self, *innerpats, **inneropts):
-            extras = opts.get(r'extra')
+            extras = opts.get('extra')
             for raw in extras:
                 if b'=' not in raw:
                     msg = _(
@@ -82,7 +82,7 @@
                         b"manually"
                     )
                     raise error.Abort(msg % k)
-                inneropts[r'extra'][k] = v
+                inneropts['extra'][k] = v
             return super(repoextra, self).commit(*innerpats, **inneropts)
 
     repo.__class__ = repoextra
--- a/hgext/convert/common.py	Wed Nov 20 19:07:02 2019 +0100
+++ b/hgext/convert/common.py	Fri Nov 22 21:42:04 2019 +0900
@@ -57,7 +57,7 @@
 def shlexer(data=None, filepath=None, wordchars=None, whitespace=None):
     if data is None:
         if pycompat.ispy3:
-            data = open(filepath, b'r', encoding=r'latin1')
+            data = open(filepath, b'r', encoding='latin1')
         else:
             data = open(filepath, b'r')
     else:
@@ -493,7 +493,7 @@
         # POSIX requires at least 4096 bytes for ARG_MAX
         argmax = 4096
         try:
-            argmax = os.sysconf(r"SC_ARG_MAX")
+            argmax = os.sysconf("SC_ARG_MAX")
         except (AttributeError, ValueError):
             pass
 
--- a/hgext/convert/cvsps.py	Wed Nov 20 19:07:02 2019 +0100
+++ b/hgext/convert/cvsps.py	Fri Nov 22 21:42:04 2019 +0900
@@ -54,10 +54,8 @@
         self.__dict__.update(entries)
 
     def __repr__(self):
-        items = (
-            r"%s=%r" % (k, self.__dict__[k]) for k in sorted(self.__dict__)
-        )
-        return r"%s(%s)" % (type(self).__name__, r", ".join(items))
+        items = ("%s=%r" % (k, self.__dict__[k]) for k in sorted(self.__dict__))
+        return "%s(%s)" % (type(self).__name__, ", ".join(items))
 
 
 class logerror(Exception):
--- a/hgext/convert/gnuarch.py	Wed Nov 20 19:07:02 2019 +0100
+++ b/hgext/convert/gnuarch.py	Fri Nov 22 21:42:04 2019 +0900
@@ -302,25 +302,25 @@
 
             # Commit date
             self.changes[rev].date = dateutil.datestr(
-                dateutil.strdate(catlog[r'Standard-date'], b'%Y-%m-%d %H:%M:%S')
+                dateutil.strdate(catlog['Standard-date'], b'%Y-%m-%d %H:%M:%S')
             )
 
             # Commit author
-            self.changes[rev].author = self.recode(catlog[r'Creator'])
+            self.changes[rev].author = self.recode(catlog['Creator'])
 
             # Commit description
             self.changes[rev].summary = b'\n\n'.join(
                 (
-                    self.recode(catlog[r'Summary']),
+                    self.recode(catlog['Summary']),
                     self.recode(catlog.get_payload()),
                 )
             )
             self.changes[rev].summary = self.recode(self.changes[rev].summary)
 
             # Commit revision origin when dealing with a branch or tag
-            if r'Continuation-of' in catlog:
+            if 'Continuation-of' in catlog:
                 self.changes[rev].continuationof = self.recode(
-                    catlog[r'Continuation-of']
+                    catlog['Continuation-of']
                 )
         except Exception:
             raise error.Abort(_(b'could not parse cat-log of %s') % rev)
--- a/hgext/convert/monotone.py	Wed Nov 20 19:07:02 2019 +0100
+++ b/hgext/convert/monotone.py	Fri Nov 22 21:42:04 2019 +0900
@@ -96,7 +96,7 @@
             return self.mtnrunsingle(*args, **kwargs)
 
     def mtnrunsingle(self, *args, **kwargs):
-        kwargs[r'd'] = self.path
+        kwargs['d'] = self.path
         return self.run0(b'automate', *args, **kwargs)
 
     def mtnrunstdio(self, *args, **kwargs):
--- a/hgext/convert/subversion.py	Wed Nov 20 19:07:02 2019 +0100
+++ b/hgext/convert/subversion.py	Fri Nov 22 21:42:04 2019 +0900
@@ -1359,11 +1359,11 @@
         m = set()
         output = self.run0(b'ls', recursive=True, xml=True)
         doc = xml.dom.minidom.parseString(output)
-        for e in doc.getElementsByTagName(r'entry'):
+        for e in doc.getElementsByTagName('entry'):
             for n in e.childNodes:
-                if n.nodeType != n.ELEMENT_NODE or n.tagName != r'name':
+                if n.nodeType != n.ELEMENT_NODE or n.tagName != 'name':
                     continue
-                name = r''.join(
+                name = ''.join(
                     c.data for c in n.childNodes if c.nodeType == c.TEXT_NODE
                 )
                 # Entries are compared with names coming from
@@ -1502,7 +1502,7 @@
             self.setexec = []
 
         fd, messagefile = pycompat.mkstemp(prefix=b'hg-convert-')
-        fp = os.fdopen(fd, r'wb')
+        fp = os.fdopen(fd, 'wb')
         fp.write(util.tonativeeol(commit.desc))
         fp.close()
         try:
--- a/hgext/extdiff.py	Wed Nov 20 19:07:02 2019 +0100
+++ b/hgext/extdiff.py	Fri Nov 22 21:42:04 2019 +0900
@@ -401,13 +401,14 @@
         if node2 is None:
             raise error.Abort(_(b'--patch requires two revisions'))
     else:
-        mod_a, add_a, rem_a = map(
-            set, repo.status(node1a, node2, matcher, listsubrepos=subrepos)[:3]
-        )
+        st = repo.status(node1a, node2, matcher, listsubrepos=subrepos)
+        mod_a, add_a, rem_a = set(st.modified), set(st.added), set(st.removed)
         if do3way:
-            mod_b, add_b, rem_b = map(
-                set,
-                repo.status(node1b, node2, matcher, listsubrepos=subrepos)[:3],
+            stb = repo.status(node1b, node2, matcher, listsubrepos=subrepos)
+            mod_b, add_b, rem_b = (
+                set(stb.modified),
+                set(stb.added),
+                set(stb.removed),
             )
         else:
             mod_b, add_b, rem_b = set(), set(), set()
@@ -655,7 +656,7 @@
         # in an unknown encoding anyway), but avoid double separators on
         # Windows
         docpath = stringutil.escapestr(path).replace(b'\\\\', b'\\')
-        self.__doc__ %= {r'path': pycompat.sysstr(stringutil.uirepr(docpath))}
+        self.__doc__ %= {'path': pycompat.sysstr(stringutil.uirepr(docpath))}
         self._cmdline = cmdline
         self._isgui = isgui
 
--- a/hgext/fastannotate/commands.py	Wed Nov 20 19:07:02 2019 +0100
+++ b/hgext/fastannotate/commands.py	Fri Nov 22 21:42:04 2019 +0900
@@ -82,7 +82,7 @@
 
 
 fastannotatecommandargs = {
-    r'options': [
+    'options': [
         (b'r', b'rev', b'.', _(b'annotate the specified revision'), _(b'REV')),
         (b'u', b'user', None, _(b'list the author (long with -v)')),
         (b'f', b'file', None, _(b'list the filename')),
@@ -133,8 +133,8 @@
     + commands.diffwsopts
     + commands.walkopts
     + commands.formatteropts,
-    r'synopsis': _(b'[-r REV] [-f] [-a] [-u] [-d] [-n] [-c] [-l] FILE...'),
-    r'inferrepo': True,
+    'synopsis': _(b'[-r REV] [-f] [-a] [-u] [-d] [-n] [-c] [-l] FILE...'),
+    'inferrepo': True,
 }
 
 
@@ -257,7 +257,7 @@
 _newopts = set()
 _knownopts = {
     opt[1].replace(b'-', b'_')
-    for opt in (fastannotatecommandargs[r'options'] + commands.globalopts)
+    for opt in (fastannotatecommandargs['options'] + commands.globalopts)
 }
 
 
@@ -269,10 +269,10 @@
 
     # treat the file as text (skip the isbinary check)
     if ui.configbool(b'fastannotate', b'forcetext'):
-        opts[r'text'] = True
+        opts['text'] = True
 
     # check if we need to do prefetch (client-side)
-    rev = opts.get(r'rev')
+    rev = opts.get('rev')
     if util.safehasattr(repo, 'prefetchfastannotate') and rev is not None:
         paths = list(_matchpaths(repo, rev, pats, pycompat.byteskwargs(opts)))
         repo.prefetchfastannotate(paths)
--- a/hgext/fix.py	Wed Nov 20 19:07:02 2019 +0100
+++ b/hgext/fix.py	Fri Nov 22 21:42:04 2019 +0900
@@ -681,7 +681,7 @@
             if rev is None:
                 ui.warn(_(b'wdir'), label=b'evolve.rev')
             else:
-                ui.warn((str(rev)), label=b'evolve.rev')
+                ui.warn(b'%d' % rev, label=b'evolve.rev')
             ui.warn(b'] %s: %s\n' % (fixername, line))
 
 
--- a/hgext/githelp.py	Wed Nov 20 19:07:02 2019 +0100
+++ b/hgext/githelp.py	Fri Nov 22 21:42:04 2019 +0900
@@ -90,11 +90,11 @@
             args = fancyopts.fancyopts(list(args), cmdoptions, opts, True)
             break
         except getopt.GetoptError as ex:
-            if r"requires argument" in ex.msg:
+            if "requires argument" in ex.msg:
                 raise
-            if (r'--' + ex.opt) in ex.msg:
+            if ('--' + ex.opt) in ex.msg:
                 flag = b'--' + pycompat.bytestr(ex.opt)
-            elif (r'-' + ex.opt) in ex.msg:
+            elif ('-' + ex.opt) in ex.msg:
                 flag = b'-' + pycompat.bytestr(ex.opt)
             else:
                 raise error.Abort(
--- a/hgext/gpg.py	Wed Nov 20 19:07:02 2019 +0100
+++ b/hgext/gpg.py	Fri Nov 22 21:42:04 2019 +0900
@@ -69,11 +69,11 @@
         try:
             # create temporary files
             fd, sigfile = pycompat.mkstemp(prefix=b"hg-gpg-", suffix=b".sig")
-            fp = os.fdopen(fd, r'wb')
+            fp = os.fdopen(fd, 'wb')
             fp.write(sig)
             fp.close()
             fd, datafile = pycompat.mkstemp(prefix=b"hg-gpg-", suffix=b".txt")
-            fp = os.fdopen(fd, r'wb')
+            fp = os.fdopen(fd, 'wb')
             fp.write(data)
             fp.close()
             gpgcmd = (
@@ -121,7 +121,7 @@
 def newgpg(ui, **opts):
     """create a new gpg instance"""
     gpgpath = ui.config(b"gpg", b"cmd")
-    gpgkey = opts.get(r'key')
+    gpgkey = opts.get('key')
     if not gpgkey:
         gpgkey = ui.config(b"gpg", b"key")
     return gpg(gpgpath, gpgkey)
--- a/hgext/graphlog.py	Wed Nov 20 19:07:02 2019 +0100
+++ b/hgext/graphlog.py	Fri Nov 22 21:42:04 2019 +0900
@@ -121,5 +121,5 @@
 
     This is an alias to :hg:`log -G`.
     """
-    opts[r'graph'] = True
+    opts['graph'] = True
     return commands.log(ui, repo, *pats, **opts)
--- a/hgext/hgk.py	Wed Nov 20 19:07:02 2019 +0100
+++ b/hgext/hgk.py	Fri Nov 22 21:42:04 2019 +0900
@@ -92,21 +92,21 @@
         mmap = repo[node1].manifest()
         mmap2 = repo[node2].manifest()
         m = scmutil.match(repo[node1], files)
-        modified, added, removed = repo.status(node1, node2, m)[:3]
+        st = repo.status(node1, node2, m)
         empty = short(nullid)
 
-        for f in modified:
+        for f in st.modified:
             # TODO get file permissions
             ui.writenoi18n(
                 b":100664 100664 %s %s M\t%s\t%s\n"
                 % (short(mmap[f]), short(mmap2[f]), f, f)
             )
-        for f in added:
+        for f in st.added:
             ui.writenoi18n(
                 b":000000 100664 %s %s N\t%s\t%s\n"
                 % (empty, short(mmap2[f]), f, f)
             )
-        for f in removed:
+        for f in st.removed:
             ui.writenoi18n(
                 b":100664 000000 %s %s D\t%s\t%s\n"
                 % (short(mmap[f]), empty, f, f)
@@ -115,7 +115,7 @@
     ##
 
     while True:
-        if opts[r'stdin']:
+        if opts['stdin']:
             line = ui.fin.readline()
             if not line:
                 break
@@ -131,8 +131,8 @@
         else:
             node2 = node1
             node1 = repo.changelog.parents(node1)[0]
-        if opts[r'patch']:
-            if opts[r'pretty']:
+        if opts['patch']:
+            if opts['pretty']:
                 catcommit(ui, repo, node2, b"")
             m = scmutil.match(repo[node1], files)
             diffopts = patch.difffeatureopts(ui)
@@ -142,7 +142,7 @@
                 ui.write(chunk)
         else:
             __difftree(repo, node1, node2, files=files)
-        if not opts[r'stdin']:
+        if not opts['stdin']:
             break
 
 
@@ -201,7 +201,7 @@
     # strings
     #
     prefix = b""
-    if opts[r'stdin']:
+    if opts['stdin']:
         line = ui.fin.readline()
         if not line:
             return
@@ -218,7 +218,7 @@
             return 1
         n = repo.lookup(r)
         catcommit(ui, repo, n, prefix)
-        if opts[r'stdin']:
+        if opts['stdin']:
             line = ui.fin.readline()
             if not line:
                 break
@@ -363,7 +363,7 @@
     else:
         full = None
     copy = [x for x in revs]
-    revtree(ui, copy, repo, full, opts[r'max_count'], opts[r'parents'])
+    revtree(ui, copy, repo, full, opts['max_count'], opts[r'parents'])
 
 
 @command(
--- a/hgext/histedit.py	Wed Nov 20 19:07:02 2019 +0100
+++ b/hgext/histedit.py	Fri Nov 22 21:42:04 2019 +0900
@@ -624,9 +624,9 @@
     def commitfunc(**kwargs):
         overrides = {(b'phases', b'new-commit'): phasemin}
         with repo.ui.configoverride(overrides, b'histedit'):
-            extra = kwargs.get(r'extra', {}).copy()
+            extra = kwargs.get('extra', {}).copy()
             extra[b'histedit_source'] = src.hex()
-            kwargs[r'extra'] = extra
+            kwargs['extra'] = extra
             return repo.commit(**kwargs)
 
     return commitfunc
@@ -1056,6 +1056,7 @@
 
 COLOR_HELP, COLOR_SELECTED, COLOR_OK, COLOR_WARN, COLOR_CURRENT = 1, 2, 3, 4, 5
 COLOR_DIFF_ADD_LINE, COLOR_DIFF_DEL_LINE, COLOR_DIFF_OFFSET = 6, 7, 8
+COLOR_ROLL, COLOR_ROLL_CURRENT, COLOR_ROLL_SELECTED = 9, 10, 11
 
 E_QUIT, E_HISTEDIT = 1, 2
 E_PAGEDOWN, E_PAGEUP, E_LINEUP, E_LINEDOWN, E_RESIZE = 3, 4, 5, 6, 7
@@ -1119,32 +1120,42 @@
         self.conflicts = []
 
     def __bytes__(self):
-        # Some actions ('fold' and 'roll') combine a patch with a previous one.
-        # Add a marker showing which patch they apply to, and also omit the
-        # description for 'roll' (since it will get discarded). Example display:
+        # Example display of several histeditrules:
         #
         #  #10 pick   316392:06a16c25c053   add option to skip tests
-        #  #11 ^roll  316393:71313c964cc5
+        #  #11 ^roll  316393:71313c964cc5   <RED>oops a fixup commit</RED>
         #  #12 pick   316394:ab31f3973b0d   include mfbt for mozilla-config.h
         #  #13 ^fold  316395:14ce5803f4c3   fix warnings
         #
         # The carets point to the changeset being folded into ("roll this
         # changeset into the changeset above").
+        return b'%s%s' % (self.prefix, self.desc)
+
+    __str__ = encoding.strmethod(__bytes__)
+
+    @property
+    def prefix(self):
+        # Some actions ('fold' and 'roll') combine a patch with a
+        # previous one. Add a marker showing which patch they apply
+        # to.
         action = ACTION_LABELS.get(self.action, self.action)
+
         h = self.ctx.hex()[0:12]
         r = self.ctx.rev()
-        desc = self.ctx.description().splitlines()[0].strip()
-        if self.action == b'roll':
-            desc = b''
-        return b"#%s %s %d:%s   %s" % (
+
+        return b"#%s %s %d:%s   " % (
             (b'%d' % self.origpos).ljust(2),
             action.ljust(6),
             r,
             h,
-            desc,
         )
 
-    __str__ = encoding.strmethod(__bytes__)
+    @property
+    def desc(self):
+        # This is split off from the prefix property so that we can
+        # separately make the description for 'roll' red (since it
+        # will get discarded).
+        return self.ctx.description().splitlines()[0].strip()
 
     def checkconflicts(self, other):
         if other.pos > self.pos and other.origpos <= self.origpos:
@@ -1382,6 +1393,11 @@
     curses.init_pair(COLOR_DIFF_ADD_LINE, curses.COLOR_GREEN, -1)
     curses.init_pair(COLOR_DIFF_DEL_LINE, curses.COLOR_RED, -1)
     curses.init_pair(COLOR_DIFF_OFFSET, curses.COLOR_MAGENTA, -1)
+    curses.init_pair(COLOR_ROLL, curses.COLOR_RED, -1)
+    curses.init_pair(
+        COLOR_ROLL_CURRENT, curses.COLOR_BLACK, curses.COLOR_MAGENTA
+    )
+    curses.init_pair(COLOR_ROLL_SELECTED, curses.COLOR_RED, curses.COLOR_WHITE)
 
     # don't display the cursor
     try:
@@ -1483,9 +1499,12 @@
                 rulesscr.addstr(y, 0, b" ", curses.color_pair(COLOR_WARN))
             else:
                 rulesscr.addstr(y, 0, b" ", curses.COLOR_BLACK)
+
             if y + start == selected:
+                rollcolor = COLOR_ROLL_SELECTED
                 addln(rulesscr, y, 2, rule, curses.color_pair(COLOR_SELECTED))
             elif y + start == pos:
+                rollcolor = COLOR_ROLL_CURRENT
                 addln(
                     rulesscr,
                     y,
@@ -1494,7 +1513,17 @@
                     curses.color_pair(COLOR_CURRENT) | curses.A_BOLD,
                 )
             else:
+                rollcolor = COLOR_ROLL
                 addln(rulesscr, y, 2, rule)
+
+            if rule.action == b'roll':
+                rulesscr.addstr(
+                    y,
+                    2 + len(rule.prefix),
+                    rule.desc,
+                    curses.color_pair(rollcolor),
+                )
+
         rulesscr.noutrefresh()
 
     def renderstring(win, state, output, diffcolors=False):
@@ -1674,7 +1703,7 @@
         # Curses requires setting the locale or it will default to the C
         # locale. This sets the locale to the user's default system
         # locale.
-        locale.setlocale(locale.LC_ALL, r'')
+        locale.setlocale(locale.LC_ALL, '')
         rc = curses.wrapper(functools.partial(_chisteditmain, repo, ctxs))
         curses.echo()
         curses.endwin()
@@ -2046,11 +2075,11 @@
             mapping[n] = ()
 
     # remove entries about unknown nodes
-    nodemap = repo.unfiltered().changelog.nodemap
+    has_node = repo.unfiltered().changelog.index.has_node
     mapping = {
         k: v
         for k, v in mapping.items()
-        if k in nodemap and all(n in nodemap for n in v)
+        if has_node(k) and all(has_node(n) for n in v)
     }
     scmutil.cleanupnodes(repo, mapping, b'histedit')
     hf = fm.hexfunc
@@ -2447,7 +2476,7 @@
         return oldreplacements
 
     unfi = repo.unfiltered()
-    nm = unfi.changelog.nodemap
+    get_rev = unfi.changelog.index.get_rev
     obsstore = repo.obsstore
     newreplacements = list(oldreplacements)
     oldsuccs = [r[1] for r in oldreplacements]
@@ -2458,7 +2487,7 @@
     succstocheck = list(seensuccs)
     while succstocheck:
         n = succstocheck.pop()
-        missing = nm.get(n) is None
+        missing = get_rev(n) is None
         markers = obsstore.successors.get(n, ())
         if missing and not markers:
             # dead end, mark it as such
@@ -2517,9 +2546,9 @@
         del final[n]
     # we expect all changes involved in final to exist in the repo
     # turn `final` into list (topologically sorted)
-    nm = state.repo.changelog.nodemap
+    get_rev = state.repo.changelog.index.get_rev
     for prec, succs in final.items():
-        final[prec] = sorted(succs, key=nm.get)
+        final[prec] = sorted(succs, key=get_rev)
 
     # computed topmost element (necessary for bookmark)
     if new:
@@ -2565,8 +2594,8 @@
         repo = repo.unfiltered()
         # Find all nodes that need to be stripped
         # (we use %lr instead of %ln to silently ignore unknown items)
-        nm = repo.changelog.nodemap
-        nodes = sorted(n for n in nodes if n in nm)
+        has_node = repo.changelog.index.has_node
+        nodes = sorted(n for n in nodes if has_node(n))
         roots = [c.node() for c in repo.set(b"roots(%ln)", nodes)]
         if roots:
             backup = not nobackup
--- a/hgext/infinitepush/__init__.py	Wed Nov 20 19:07:02 2019 +0100
+++ b/hgext/infinitepush/__init__.py	Fri Nov 22 21:42:04 2019 +0900
@@ -195,7 +195,7 @@
 revsetpredicate = registrar.revsetpredicate()
 templatekeyword = registrar.templatekeyword()
 _scratchbranchmatcher = lambda x: False
-_maybehash = re.compile(r'^[a-f0-9]+$').search
+_maybehash = re.compile('^[a-f0-9]+$').search
 
 
 def _buildexternalbundlestore(ui):
@@ -548,7 +548,7 @@
     allbundlestocleanup = []
     try:
         for head in heads:
-            if head not in repo.changelog.nodemap:
+            if not repo.changelog.index.has_node(head):
                 if head not in nodestobundle:
                     newbundlefile = common.downloadbundle(repo, head)
                     bundlepath = b"bundle:%s+%s" % (repo.root, newbundlefile)
@@ -1031,7 +1031,7 @@
     fd, bundlefile = pycompat.mkstemp()
     try:
         try:
-            fp = os.fdopen(fd, r'wb')
+            fp = os.fdopen(fd, 'wb')
             fp.write(buf.read())
         finally:
             fp.close()
@@ -1122,7 +1122,7 @@
         fd, bundlefile = pycompat.mkstemp()
         try:
             try:
-                fp = os.fdopen(fd, r'wb')
+                fp = os.fdopen(fd, 'wb')
                 fp.write(buf.read())
             finally:
                 fp.close()
@@ -1254,7 +1254,7 @@
     fd, bundlefile = pycompat.mkstemp()
     try:
         try:
-            fp = os.fdopen(fd, r'wb')
+            fp = os.fdopen(fd, 'wb')
             fp.write(buf.read())
         finally:
             fp.close()
--- a/hgext/infinitepush/common.py	Wed Nov 20 19:07:02 2019 +0100
+++ b/hgext/infinitepush/common.py	Fri Nov 22 21:42:04 2019 +0900
@@ -37,7 +37,7 @@
     fd, bundlefile = pycompat.mkstemp()
     try:  # guards bundlefile
         try:  # guards fp
-            fp = os.fdopen(fd, r'wb')
+            fp = os.fdopen(fd, 'wb')
             fp.write(data)
         finally:
             fp.close()
--- a/hgext/infinitepush/store.py	Wed Nov 20 19:07:02 2019 +0100
+++ b/hgext/infinitepush/store.py	Fri Nov 22 21:42:04 2019 +0900
@@ -29,7 +29,7 @@
     pass
 
 
-class abstractbundlestore(object):
+class abstractbundlestore(object):  # pytype: disable=ignored-metaclass
     """Defines the interface for bundle stores.
 
     A bundle store is an entity that stores raw bundle data. It is a simple
--- a/hgext/journal.py	Wed Nov 20 19:07:02 2019 +0100
+++ b/hgext/journal.py	Fri Nov 22 21:42:04 2019 +0900
@@ -149,7 +149,7 @@
 
     Note that by default entries go from most recent to oldest.
     """
-    order = kwargs.pop(r'order', max)
+    order = kwargs.pop('order', max)
     iterables = [iter(it) for it in iterables]
     # this tracks still active iterables; iterables are deleted as they are
     # exhausted, which is why this is a dictionary and why each entry also
@@ -214,8 +214,8 @@
 
 class journalentry(
     collections.namedtuple(
-        r'journalentry',
-        r'timestamp user command namespace name oldhashes newhashes',
+        'journalentry',
+        'timestamp user command namespace name oldhashes newhashes',
     )
 ):
     """Individual journal entry
--- a/hgext/keyword.py	Wed Nov 20 19:07:02 2019 +0100
+++ b/hgext/keyword.py	Fri Nov 22 21:42:04 2019 +0900
@@ -482,16 +482,16 @@
     ui.setconfig(b'keywordset', b'svn', svn, b'keyword')
 
     uikwmaps = ui.configitems(b'keywordmaps')
-    if args or opts.get(r'rcfile'):
+    if args or opts.get('rcfile'):
         ui.status(_(b'\n\tconfiguration using custom keyword template maps\n'))
         if uikwmaps:
             ui.status(_(b'\textending current template maps\n'))
-        if opts.get(r'default') or not uikwmaps:
+        if opts.get('default') or not uikwmaps:
             if svn:
                 ui.status(_(b'\toverriding default svn keywordset\n'))
             else:
                 ui.status(_(b'\toverriding default cvs keywordset\n'))
-        if opts.get(r'rcfile'):
+        if opts.get('rcfile'):
             ui.readconfig(opts.get(b'rcfile'))
         if args:
             # simulate hgrc parsing
@@ -499,7 +499,7 @@
             repo.vfs.write(b'hgrc', rcmaps)
             ui.readconfig(repo.vfs.join(b'hgrc'))
         kwmaps = dict(ui.configitems(b'keywordmaps'))
-    elif opts.get(r'default'):
+    elif opts.get('default'):
         if svn:
             ui.status(_(b'\n\tconfiguration using default svn keywordset\n'))
         else:
--- a/hgext/largefiles/lfcommands.py	Wed Nov 20 19:07:02 2019 +0100
+++ b/hgext/largefiles/lfcommands.py	Fri Nov 22 21:42:04 2019 +0900
@@ -648,7 +648,7 @@
     """
     repo.lfpullsource = source
 
-    revs = opts.get(r'rev', [])
+    revs = opts.get('rev', [])
     if not revs:
         raise error.Abort(_(b'no revisions specified'))
     revs = scmutil.revrange(repo, revs)
--- a/hgext/largefiles/lfutil.py	Wed Nov 20 19:07:02 2019 +0100
+++ b/hgext/largefiles/lfutil.py	Fri Nov 22 21:42:04 2019 +0900
@@ -9,6 +9,7 @@
 '''largefiles utility code: must not import other modules in this package.'''
 from __future__ import absolute_import
 
+import contextlib
 import copy
 import hashlib
 import os
@@ -39,6 +40,16 @@
 # -- Private worker functions ------------------------------------------
 
 
+@contextlib.contextmanager
+def lfstatus(repo, value=True):
+    oldvalue = getattr(repo, 'lfstatus', False)
+    repo.lfstatus = value
+    try:
+        yield
+    finally:
+        repo.lfstatus = oldvalue
+
+
 def getminsize(ui, assumelfiles, opt, default=10):
     lfsize = opt
     if not lfsize and assumelfiles:
@@ -580,12 +591,8 @@
             progress.update(i)
             parents = [p for p in repo[n].parents() if p != node.nullid]
 
-            oldlfstatus = repo.lfstatus
-            repo.lfstatus = False
-            try:
+            with lfstatus(repo, value=False):
                 ctx = repo[n]
-            finally:
-                repo.lfstatus = oldlfstatus
 
             files = set(ctx.files())
             if len(parents) == 2:
--- a/hgext/largefiles/overrides.py	Wed Nov 20 19:07:02 2019 +0100
+++ b/hgext/largefiles/overrides.py	Fri Nov 22 21:42:04 2019 +0900
@@ -9,7 +9,6 @@
 '''Overridden Mercurial commands and functions for the largefiles extension'''
 from __future__ import absolute_import
 
-import contextlib
 import copy
 import os
 
@@ -50,6 +49,8 @@
 
 eh = exthelper.exthelper()
 
+lfstatus = lfutil.lfstatus
+
 # -- Utility functions: commonly/repeatedly needed functionality ---------------
 
 
@@ -84,9 +85,9 @@
 
 
 def addlargefiles(ui, repo, isaddremove, matcher, uipathfn, **opts):
-    large = opts.get(r'large')
+    large = opts.get('large')
     lfsize = lfutil.getminsize(
-        ui, lfutil.islfilesrepo(repo), opts.get(r'lfsize')
+        ui, lfutil.islfilesrepo(repo), opts.get('lfsize')
     )
 
     lfmatcher = None
@@ -131,7 +132,7 @@
     # Need to lock, otherwise there could be a race condition between
     # when standins are created and added to the repo.
     with repo.wlock():
-        if not opts.get(r'dry_run'):
+        if not opts.get('dry_run'):
             standins = []
             lfdirstate = lfutil.openlfdirstate(ui, repo)
             for f in lfnames:
@@ -158,18 +159,8 @@
     return added, bad
 
 
-@contextlib.contextmanager
-def lfstatus(repo):
-    oldvalue = getattr(repo, 'lfstatus', False)
-    repo.lfstatus = True
-    try:
-        yield
-    finally:
-        repo.lfstatus = oldvalue
-
-
 def removelargefiles(ui, repo, isaddremove, matcher, uipathfn, dryrun, **opts):
-    after = opts.get(r'after')
+    after = opts.get('after')
     m = composelargefilematcher(matcher, repo[None].manifest())
     with lfstatus(repo):
         s = repo.status(match=m, clean=not isaddremove)
@@ -269,7 +260,7 @@
     ],
 )
 def overrideadd(orig, ui, repo, *pats, **opts):
-    if opts.get(r'normal') and opts.get(r'large'):
+    if opts.get('normal') and opts.get('large'):
         raise error.Abort(_(b'--normal cannot be used with --large'))
     return orig(ui, repo, *pats, **opts)
 
@@ -277,7 +268,7 @@
 @eh.wrapfunction(cmdutil, b'add')
 def cmdutiladd(orig, ui, repo, matcher, prefix, uipathfn, explicitonly, **opts):
     # The --normal flag short circuits this override
-    if opts.get(r'normal'):
+    if opts.get('normal'):
         return orig(ui, repo, matcher, prefix, uipathfn, explicitonly, **opts)
 
     ladded, lbad = addlargefiles(ui, repo, False, matcher, uipathfn, **opts)
@@ -477,9 +468,9 @@
     ],
 )
 def overrideverify(orig, ui, repo, *pats, **opts):
-    large = opts.pop(r'large', False)
-    all = opts.pop(r'lfa', False)
-    contents = opts.pop(r'lfc', False)
+    large = opts.pop('large', False)
+    all = opts.pop('lfa', False)
+    contents = opts.pop('lfc', False)
 
     result = orig(ui, repo, *pats, **opts)
     if large or all or contents:
@@ -492,7 +483,7 @@
     opts=[(b'', b'large', None, _(b'display largefiles dirstate'))],
 )
 def overridedebugstate(orig, ui, repo, *pats, **opts):
-    large = opts.pop(r'large', False)
+    large = opts.pop('large', False)
     if large:
 
         class fakerepo(object):
@@ -975,8 +966,8 @@
     repo.lfpullsource = source
     result = orig(ui, repo, source, **opts)
     revspostpull = len(repo)
-    lfrevs = opts.get(r'lfrev', [])
-    if opts.get(r'all_largefiles'):
+    lfrevs = opts.get('lfrev', [])
+    if opts.get('all_largefiles'):
         lfrevs.append(b'pulled()')
     if lfrevs and revspostpull > revsprepull:
         numcached = 0
@@ -1006,9 +997,9 @@
 )
 def overridepush(orig, ui, repo, *args, **kwargs):
     """Override push command and store --lfrev parameters in opargs"""
-    lfrevs = kwargs.pop(r'lfrev', None)
+    lfrevs = kwargs.pop('lfrev', None)
     if lfrevs:
-        opargs = kwargs.setdefault(r'opargs', {})
+        opargs = kwargs.setdefault('opargs', {})
         opargs[b'lfrevs'] = scmutil.revrange(repo, lfrevs)
     return orig(ui, repo, *args, **kwargs)
 
@@ -1016,7 +1007,7 @@
 @eh.wrapfunction(exchange, b'pushoperation')
 def exchangepushoperation(orig, *args, **kwargs):
     """Override pushoperation constructor and store lfrevs parameter"""
-    lfrevs = kwargs.pop(r'lfrevs', None)
+    lfrevs = kwargs.pop('lfrevs', None)
     pushop = orig(*args, **kwargs)
     pushop.lfrevs = lfrevs
     return pushop
@@ -1064,7 +1055,7 @@
     d = dest
     if d is None:
         d = hg.defaultdest(source)
-    if opts.get(r'all_largefiles') and not hg.islocal(d):
+    if opts.get('all_largefiles') and not hg.islocal(d):
         raise error.Abort(
             _(b'--all-largefiles is incompatible with non-local destination %s')
             % d
@@ -1104,7 +1095,7 @@
     if not util.safehasattr(repo, b'_largefilesenabled'):
         return orig(ui, repo, **opts)
 
-    resuming = opts.get(r'continue')
+    resuming = opts.get('continue')
     repo._lfcommithooks.append(lfutil.automatedcommithook(resuming))
     repo._lfstatuswriters.append(lambda *msg, **opts: None)
     try:
@@ -1596,7 +1587,7 @@
 
 @eh.wrapcommand(b'transplant', extension=b'transplant')
 def overridetransplant(orig, ui, repo, *revs, **opts):
-    resuming = opts.get(r'continue')
+    resuming = opts.get('continue')
     repo._lfcommithooks.append(lfutil.automatedcommithook(resuming))
     repo._lfstatuswriters.append(lambda *msg, **opts: None)
     try:
@@ -1681,7 +1672,7 @@
 
 @eh.wrapfunction(merge, b'update')
 def mergeupdate(orig, repo, node, branchmerge, force, *args, **kwargs):
-    matcher = kwargs.get(r'matcher', None)
+    matcher = kwargs.get('matcher', None)
     # note if this is a partial update
     partial = matcher and not matcher.always()
     with repo.wlock():
@@ -1741,7 +1732,7 @@
         # Make sure the merge runs on disk, not in-memory. largefiles is not a
         # good candidate for in-memory merge (large files, custom dirstate,
         # matcher usage).
-        kwargs[r'wc'] = repo[None]
+        kwargs['wc'] = repo[None]
         result = orig(repo, node, branchmerge, force, *args, **kwargs)
 
         newstandins = lfutil.getstandinsstate(repo)
--- a/hgext/largefiles/proto.py	Wed Nov 20 19:07:02 2019 +0100
+++ b/hgext/largefiles/proto.py	Fri Nov 22 21:42:04 2019 +0900
@@ -116,7 +116,7 @@
                     b'putlfile',
                     data=fd,
                     sha=sha,
-                    headers={r'content-type': r'application/mercurial-0.1'},
+                    headers={'content-type': 'application/mercurial-0.1'},
                 )
                 try:
                     d, output = res.split(b'\n', 1)
@@ -206,7 +206,7 @@
     if cmd == b'heads' and self.capable(b'largefiles'):
         cmd = b'lheads'
     if cmd == b'batch' and self.capable(b'largefiles'):
-        args[r'cmds'] = args[r'cmds'].replace(b'heads ', b'lheads ')
+        args['cmds'] = args[r'cmds'].replace(b'heads ', b'lheads ')
     return ssholdcallstream(self, cmd, **args)
 
 
@@ -217,5 +217,5 @@
     if cmd == b'heads' and self.capable(b'largefiles'):
         cmd = b'lheads'
     if cmd == b'batch' and self.capable(b'largefiles'):
-        args[r'cmds'] = headsre.sub(b'lheads', args[r'cmds'])
+        args['cmds'] = headsre.sub(b'lheads', args['cmds'])
     return httpoldcallstream(self, cmd, **args)
--- a/hgext/largefiles/reposetup.py	Wed Nov 20 19:07:02 2019 +0100
+++ b/hgext/largefiles/reposetup.py	Fri Nov 22 21:42:04 2019 +0900
@@ -15,9 +15,11 @@
 
 from mercurial import (
     error,
+    extensions,
     localrepo,
     match as matchmod,
     scmutil,
+    util,
 )
 
 from . import (
@@ -38,9 +40,6 @@
 
         lfstatus = False
 
-        def status_nolfiles(self, *args, **kwargs):
-            return super(lfilesrepo, self).status(*args, **kwargs)
-
         # When lfstatus is set, return a context that gives the names
         # of largefiles instead of their corresponding standins and
         # identifies the largefiles as always binary, regardless of
@@ -49,45 +48,46 @@
             ctx = super(lfilesrepo, self).__getitem__(changeid)
             if self.lfstatus:
 
-                class lfilesctx(ctx.__class__):
-                    def files(self):
-                        filenames = super(lfilesctx, self).files()
-                        return [lfutil.splitstandin(f) or f for f in filenames]
+                def files(orig):
+                    filenames = orig()
+                    return [lfutil.splitstandin(f) or f for f in filenames]
 
-                    def manifest(self):
-                        man1 = super(lfilesctx, self).manifest()
+                extensions.wrapfunction(ctx, 'files', files)
+
+                def manifest(orig):
+                    man1 = orig()
 
-                        class lfilesmanifest(man1.__class__):
-                            def __contains__(self, filename):
-                                orig = super(lfilesmanifest, self).__contains__
-                                return orig(filename) or orig(
-                                    lfutil.standin(filename)
-                                )
+                    class lfilesmanifest(man1.__class__):
+                        def __contains__(self, filename):
+                            orig = super(lfilesmanifest, self).__contains__
+                            return orig(filename) or orig(
+                                lfutil.standin(filename)
+                            )
 
-                        man1.__class__ = lfilesmanifest
-                        return man1
+                    man1.__class__ = lfilesmanifest
+                    return man1
 
-                    def filectx(self, path, fileid=None, filelog=None):
-                        orig = super(lfilesctx, self).filectx
-                        try:
-                            if filelog is not None:
-                                result = orig(path, fileid, filelog)
-                            else:
-                                result = orig(path, fileid)
-                        except error.LookupError:
-                            # Adding a null character will cause Mercurial to
-                            # identify this as a binary file.
-                            if filelog is not None:
-                                result = orig(
-                                    lfutil.standin(path), fileid, filelog
-                                )
-                            else:
-                                result = orig(lfutil.standin(path), fileid)
-                            olddata = result.data
-                            result.data = lambda: olddata() + b'\0'
-                        return result
+                extensions.wrapfunction(ctx, 'manifest', manifest)
 
-                ctx.__class__ = lfilesctx
+                def filectx(orig, path, fileid=None, filelog=None):
+                    try:
+                        if filelog is not None:
+                            result = orig(path, fileid, filelog)
+                        else:
+                            result = orig(path, fileid)
+                    except error.LookupError:
+                        # Adding a null character will cause Mercurial to
+                        # identify this as a binary file.
+                        if filelog is not None:
+                            result = orig(lfutil.standin(path), fileid, filelog)
+                        else:
+                            result = orig(lfutil.standin(path), fileid)
+                        olddata = result.data
+                        result.data = lambda: olddata() + b'\0'
+                    return result
+
+                extensions.wrapfunction(ctx, 'filectx', filectx)
+
             return ctx
 
         # Figure out the status of big files and insert them into the
@@ -130,14 +130,15 @@
             if match is None:
                 match = matchmod.always()
 
-            wlock = None
             try:
-                try:
-                    # updating the dirstate is optional
-                    # so we don't wait on the lock
-                    wlock = self.wlock(False)
-                except error.LockError:
-                    pass
+                # updating the dirstate is optional
+                # so we don't wait on the lock
+                wlock = self.wlock(False)
+                gotlock = True
+            except error.LockError:
+                wlock = util.nullcontextmanager()
+                gotlock = False
+            with wlock:
 
                 # First check if paths or patterns were specified on the
                 # command line.  If there were, and they don't match any
@@ -308,13 +309,9 @@
                         for items in result
                     ]
 
-                if wlock:
+                if gotlock:
                     lfdirstate.write()
 
-            finally:
-                if wlock:
-                    wlock.release()
-
             self.lfstatus = True
             return scmutil.status(*result)
 
@@ -360,20 +357,6 @@
                 )
                 return result
 
-        def push(self, remote, force=False, revs=None, newbranch=False):
-            if remote.local():
-                missing = set(self.requirements) - remote.local().supported
-                if missing:
-                    msg = _(
-                        b"required features are not"
-                        b" supported in the destination:"
-                        b" %s"
-                    ) % (b', '.join(sorted(missing)))
-                    raise error.Abort(msg)
-            return super(lfilesrepo, self).push(
-                remote, force=force, revs=revs, newbranch=newbranch
-            )
-
         # TODO: _subdirlfs should be moved into "lfutil.py", because
         # it is referred only from "lfutil.updatestandinsbymatch"
         def _subdirlfs(self, files, lfiles):
--- a/hgext/lfs/__init__.py	Wed Nov 20 19:07:02 2019 +0100
+++ b/hgext/lfs/__init__.py	Fri Nov 22 21:42:04 2019 +0900
@@ -241,12 +241,12 @@
             if b'lfs' in repo.requirements:
                 return 0
 
-            last = kwargs.get(r'node_last')
+            last = kwargs.get('node_last')
             _bin = node.bin
             if last:
-                s = repo.set(b'%n:%n', _bin(kwargs[r'node']), _bin(last))
+                s = repo.set(b'%n:%n', _bin(kwargs['node']), _bin(last))
             else:
-                s = repo.set(b'%n', _bin(kwargs[r'node']))
+                s = repo.set(b'%n', _bin(kwargs['node']))
             match = repo._storenarrowmatch
             for ctx in s:
                 # TODO: is there a way to just walk the files in the commit?
@@ -399,6 +399,6 @@
 )
 def debuglfsupload(ui, repo, **opts):
     """upload lfs blobs added by the working copy parent or given revisions"""
-    revs = opts.get(r'rev', [])
+    revs = opts.get('rev', [])
     pointers = wrapper.extractpointers(repo, scmutil.revrange(repo, revs))
     wrapper.uploadblobs(repo, pointers)
--- a/hgext/lfs/blobstore.py	Wed Nov 20 19:07:02 2019 +0100
+++ b/hgext/lfs/blobstore.py	Fri Nov 22 21:42:04 2019 +0900
@@ -280,11 +280,11 @@
         """Enforces that any authentication performed is HTTP Basic
         Authentication.  No authentication is also acceptable.
         """
-        authreq = headers.get(r'www-authenticate', None)
+        authreq = headers.get('www-authenticate', None)
         if authreq:
             scheme = authreq.split()[0]
 
-            if scheme.lower() != r'basic':
+            if scheme.lower() != 'basic':
                 msg = _(b'the server must support Basic Authentication')
                 raise util.urlerr.httperror(
                     req.get_full_url(),
@@ -324,18 +324,18 @@
         See https://github.com/git-lfs/git-lfs/blob/master/docs/api/batch.md
         """
         objects = [
-            {r'oid': pycompat.strurl(p.oid()), r'size': p.size()}
+            {'oid': pycompat.strurl(p.oid()), 'size': p.size()}
             for p in pointers
         ]
         requestdata = pycompat.bytesurl(
             json.dumps(
-                {r'objects': objects, r'operation': pycompat.strurl(action),}
+                {'objects': objects, 'operation': pycompat.strurl(action),}
             )
         )
         url = b'%s/objects/batch' % self.baseurl
         batchreq = util.urlreq.request(pycompat.strurl(url), data=requestdata)
-        batchreq.add_header(r'Accept', r'application/vnd.git-lfs+json')
-        batchreq.add_header(r'Content-Type', r'application/vnd.git-lfs+json')
+        batchreq.add_header('Accept', 'application/vnd.git-lfs+json')
+        batchreq.add_header('Content-Type', 'application/vnd.git-lfs+json')
         try:
             with contextlib.closing(self.urlopener.open(batchreq)) as rsp:
                 rawjson = rsp.read()
@@ -376,9 +376,9 @@
             headers = pycompat.bytestr(rsp.info()).strip()
             self.ui.debug(b'%s\n' % b'\n'.join(sorted(headers.splitlines())))
 
-            if r'objects' in response:
-                response[r'objects'] = sorted(
-                    response[r'objects'], key=lambda p: p[r'oid']
+            if 'objects' in response:
+                response['objects'] = sorted(
+                    response['objects'], key=lambda p: p['oid']
                 )
             self.ui.debug(
                 b'%s\n'
@@ -386,7 +386,7 @@
                     json.dumps(
                         response,
                         indent=2,
-                        separators=(r'', r': '),
+                        separators=('', ': '),
                         sort_keys=True,
                     )
                 )
@@ -483,8 +483,8 @@
                 )
             request.data = filewithprogress(localstore.open(oid), None)
             request.get_method = lambda: r'PUT'
-            request.add_header(r'Content-Type', r'application/octet-stream')
-            request.add_header(r'Content-Length', len(request.data))
+            request.add_header('Content-Type', 'application/octet-stream')
+            request.add_header('Content-Length', len(request.data))
 
         for k, v in headers:
             request.add_header(pycompat.strurl(k), pycompat.strurl(v))
--- a/hgext/lfs/wireprotolfsserver.py	Wed Nov 20 19:07:02 2019 +0100
+++ b/hgext/lfs/wireprotolfsserver.py	Fri Nov 22 21:42:04 2019 +0900
@@ -136,7 +136,7 @@
     lfsreq = pycompat.json_loads(req.bodyfh.read())
 
     # If no transfer handlers are explicitly requested, 'basic' is assumed.
-    if r'basic' not in lfsreq.get(r'transfers', [r'basic']):
+    if 'basic' not in lfsreq.get('transfers', ['basic']):
         _sethttperror(
             res,
             HTTP_BAD_REQUEST,
@@ -144,7 +144,7 @@
         )
         return True
 
-    operation = lfsreq.get(r'operation')
+    operation = lfsreq.get('operation')
     operation = pycompat.bytestr(operation)
 
     if operation not in (b'upload', b'download'):
@@ -160,13 +160,13 @@
     objects = [
         p
         for p in _batchresponseobjects(
-            req, lfsreq.get(r'objects', []), operation, localstore
+            req, lfsreq.get('objects', []), operation, localstore
         )
     ]
 
     rsp = {
-        r'transfer': r'basic',
-        r'objects': objects,
+        'transfer': 'basic',
+        'objects': objects,
     }
 
     res.status = hgwebcommon.statusmessage(HTTP_OK)
@@ -206,12 +206,12 @@
 
     for obj in objects:
         # Convert unicode to ASCII to create a filesystem path
-        soid = obj.get(r'oid')
-        oid = soid.encode(r'ascii')
+        soid = obj.get('oid')
+        oid = soid.encode('ascii')
         rsp = {
-            r'oid': soid,
-            r'size': obj.get(r'size'),  # XXX: should this check the local size?
-            # r'authenticated': True,
+            'oid': soid,
+            'size': obj.get('size'),  # XXX: should this check the local size?
+            # 'authenticated': True,
         }
 
         exists = True
@@ -234,9 +234,9 @@
             if inst.errno != errno.ENOENT:
                 _logexception(req)
 
-                rsp[r'error'] = {
-                    r'code': 500,
-                    r'message': inst.strerror or r'Internal Server Server',
+                rsp['error'] = {
+                    'code': 500,
+                    'message': inst.strerror or 'Internal Server Server',
                 }
                 yield rsp
                 continue
@@ -247,17 +247,17 @@
         # IFF they already exist locally.
         if action == b'download':
             if not exists:
-                rsp[r'error'] = {
-                    r'code': 404,
-                    r'message': r"The object does not exist",
+                rsp['error'] = {
+                    'code': 404,
+                    'message': "The object does not exist",
                 }
                 yield rsp
                 continue
 
             elif not verifies:
-                rsp[r'error'] = {
-                    r'code': 422,  # XXX: is this the right code?
-                    r'message': r"The object is corrupt",
+                rsp['error'] = {
+                    'code': 422,  # XXX: is this the right code?
+                    'message': "The object is corrupt",
                 }
                 yield rsp
                 continue
@@ -272,23 +272,23 @@
             # The spec doesn't mention the Accept header here, but avoid
             # a gratuitous deviation from lfs-test-server in the test
             # output.
-            hdr = {r'Accept': r'application/vnd.git-lfs'}
+            hdr = {'Accept': 'application/vnd.git-lfs'}
 
             auth = req.headers.get(b'Authorization', b'')
             if auth.startswith(b'Basic '):
-                hdr[r'Authorization'] = pycompat.strurl(auth)
+                hdr['Authorization'] = pycompat.strurl(auth)
 
             return hdr
 
-        rsp[r'actions'] = {
-            r'%s'
+        rsp['actions'] = {
+            '%s'
             % pycompat.strurl(action): {
-                r'href': pycompat.strurl(
+                'href': pycompat.strurl(
                     b'%s%s/.hg/lfs/objects/%s' % (req.baseurl, req.apppath, oid)
                 ),
                 # datetime.isoformat() doesn't include the 'Z' suffix
-                r"expires_at": expiresat.strftime(r'%Y-%m-%dT%H:%M:%SZ'),
-                r'header': _buildheader(),
+                "expires_at": expiresat.strftime('%Y-%m-%dT%H:%M:%SZ'),
+                'header': _buildheader(),
             }
         }
 
--- a/hgext/mq.py	Wed Nov 20 19:07:02 2019 +0100
+++ b/hgext/mq.py	Fri Nov 22 21:42:04 2019 +0900
@@ -490,7 +490,7 @@
     def __init__(self, ui, baseui, path, patchdir=None):
         self.basepath = path
         try:
-            with open(os.path.join(path, b'patches.queue'), r'rb') as fh:
+            with open(os.path.join(path, b'patches.queue'), 'rb') as fh:
                 cur = fh.read().rstrip()
 
             if not cur:
@@ -1251,16 +1251,19 @@
         return None, None
 
     def putsubstate2changes(self, substatestate, changes):
-        for files in changes[:3]:
-            if b'.hgsubstate' in files:
-                return  # already listed up
+        if isinstance(changes, list):
+            mar = changes[:3]
+        else:
+            mar = (changes.modified, changes.added, changes.removed)
+        if any((b'.hgsubstate' in files for files in mar)):
+            return  # already listed up
         # not yet listed up
         if substatestate in b'a?':
-            changes[1].append(b'.hgsubstate')
+            mar[1].append(b'.hgsubstate')
         elif substatestate in b'r':
-            changes[2].append(b'.hgsubstate')
+            mar[2].append(b'.hgsubstate')
         else:  # modified
-            changes[0].append(b'.hgsubstate')
+            mar[0].append(b'.hgsubstate')
 
     def checklocalchanges(self, repo, force=False, refresh=True):
         excsuffix = b''
@@ -1377,8 +1380,9 @@
         else:
             changes = self.checklocalchanges(repo, force=True)
         commitfiles = list(inclsubs)
-        for files in changes[:3]:
-            commitfiles.extend(files)
+        commitfiles.extend(changes.modified)
+        commitfiles.extend(changes.added)
+        commitfiles.extend(changes.removed)
         match = scmutil.matchfiles(repo, commitfiles)
         if len(repo[None].parents()) > 1:
             raise error.Abort(_(b'cannot manage merge changesets'))
@@ -1818,7 +1822,8 @@
             if update:
                 qp = self.qparents(repo, rev)
                 ctx = repo[qp]
-                m, a, r, d = repo.status(qp, b'.')[:4]
+                st = repo.status(qp, b'.')
+                m, a, r, d = st.modified, st.added, st.removed, st.deleted
                 if d:
                     raise error.Abort(_(b"deletions found between repo revs"))
 
@@ -1910,10 +1915,11 @@
             # and then commit.
             #
             # this should really read:
-            #   mm, dd, aa = repo.status(top, patchparent)[:3]
+            #   st = repo.status(top, patchparent)
             # but we do it backwards to take advantage of manifest/changelog
             # caching against the next repo.status call
-            mm, aa, dd = repo.status(patchparent, top)[:3]
+            st = repo.status(patchparent, top)
+            mm, aa, dd = st.modified, st.added, st.removed
             ctx = repo[top]
             aaa = aa[:]
             match1 = scmutil.match(repo[None], pats, opts)
@@ -1927,7 +1933,8 @@
                 match1 = scmutil.match(repo[None], opts=opts)
             else:
                 match = scmutil.matchall(repo)
-            m, a, r, d = repo.status(match=match)[:4]
+            stb = repo.status(match=match)
+            m, a, r, d = stb.modified, stb.added, stb.removed, stb.deleted
             mm = set(mm)
             aa = set(aa)
             dd = set(dd)
@@ -1966,7 +1973,8 @@
 
             # create 'match' that includes the files to be recommitted.
             # apply match1 via repo.status to ensure correct case handling.
-            cm, ca, cr, cd = repo.status(patchparent, match=match1)[:4]
+            st = repo.status(patchparent, match=match1)
+            cm, ca, cr, cd = st.modified, st.added, st.removed, st.deleted
             allmatches = set(cm + ca + cr + cd)
             refreshchanges = [x.intersection(allmatches) for x in (mm, aa, dd)]
 
@@ -2777,7 +2785,7 @@
 
     This command is deprecated. Without -c, it's implied by other relevant
     commands. With -c, use :hg:`init --mq` instead."""
-    return qinit(ui, repo, create=opts.get(r'create_repo'))
+    return qinit(ui, repo, create=opts.get('create_repo'))
 
 
 @command(
@@ -2933,7 +2941,7 @@
 
     Returns 0 on success."""
     repo.mq.qseries(
-        repo, missing=opts.get(r'missing'), summary=opts.get(r'summary')
+        repo, missing=opts.get('missing'), summary=opts.get('summary')
     )
     return 0
 
@@ -2960,7 +2968,7 @@
             start=t - 1,
             length=1,
             status=b'A',
-            summary=opts.get(r'summary'),
+            summary=opts.get('summary'),
         )
     else:
         ui.write(_(b"no patches applied\n"))
@@ -2982,7 +2990,7 @@
     if end == len(q.series):
         ui.write(_(b"all patches applied\n"))
         return 1
-    q.qseries(repo, start=end, length=1, summary=opts.get(r'summary'))
+    q.qseries(repo, start=end, length=1, summary=opts.get('summary'))
 
 
 @command(
@@ -3005,7 +3013,7 @@
         return 1
     idx = q.series.index(q.applied[-2].name)
     q.qseries(
-        repo, start=idx, length=1, status=b'A', summary=opts.get(r'summary')
+        repo, start=idx, length=1, status=b'A', summary=opts.get('summary')
     )
 
 
@@ -3356,8 +3364,8 @@
     applied = set(p.name for p in q.applied)
     patch = None
     args = list(args)
-    if opts.get(r'list'):
-        if args or opts.get(r'none'):
+    if opts.get('list'):
+        if args or opts.get('none'):
             raise error.Abort(
                 _(b'cannot mix -l/--list with options or arguments')
             )
@@ -3372,7 +3380,7 @@
         patch = args.pop(0)
     if patch is None:
         raise error.Abort(_(b'no patch to work with'))
-    if args or opts.get(r'none'):
+    if args or opts.get('none'):
         idx = q.findseries(patch)
         if idx is None:
             raise error.Abort(_(b'no patch named %s') % patch)
@@ -3634,9 +3642,7 @@
     This command is deprecated, use :hg:`rebase` instead."""
     rev = repo.lookup(rev)
     q = repo.mq
-    q.restore(
-        repo, rev, delete=opts.get(r'delete'), qupdate=opts.get(r'update')
-    )
+    q.restore(repo, rev, delete=opts.get('delete'), qupdate=opts.get('update'))
     q.savedirty()
     return 0
 
@@ -3841,9 +3847,9 @@
 
     Returns 0 on success.
     """
-    if not opts.get(r'applied') and not revrange:
+    if not opts.get('applied') and not revrange:
         raise error.Abort(_(b'no revisions specified'))
-    elif opts.get(r'applied'):
+    elif opts.get('applied'):
         revrange = (b'qbase::qtip',) + revrange
 
     q = repo.mq
@@ -4072,9 +4078,9 @@
 
         def invalidateall(self):
             super(mqrepo, self).invalidateall()
-            if localrepo.hasunfilteredcache(self, r'mq'):
+            if localrepo.hasunfilteredcache(self, 'mq'):
                 # recreate mq in case queue path was changed
-                delattr(self.unfiltered(), r'mq')
+                delattr(self.unfiltered(), 'mq')
 
         def abortifwdirpatched(self, errmsg, force=False):
             if self.mq.applied and self.mq.checkapplied and not force:
@@ -4172,16 +4178,16 @@
 
 def mqimport(orig, ui, repo, *args, **kwargs):
     if util.safehasattr(repo, b'abortifwdirpatched') and not kwargs.get(
-        r'no_commit', False
+        'no_commit', False
     ):
         repo.abortifwdirpatched(
-            _(b'cannot import over an applied patch'), kwargs.get(r'force')
+            _(b'cannot import over an applied patch'), kwargs.get('force')
         )
     return orig(ui, repo, *args, **kwargs)
 
 
 def mqinit(orig, ui, *args, **kwargs):
-    mq = kwargs.pop(r'mq', None)
+    mq = kwargs.pop('mq', None)
 
     if not mq:
         return orig(ui, *args, **kwargs)
@@ -4206,7 +4212,7 @@
     """Add --mq option to operate on patch repository instead of main"""
 
     # some commands do not like getting unknown options
-    mq = kwargs.pop(r'mq', None)
+    mq = kwargs.pop('mq', None)
 
     if not mq:
         return orig(ui, repo, *args, **kwargs)
--- a/hgext/narrow/narrowbundle2.py	Wed Nov 20 19:07:02 2019 +0100
+++ b/hgext/narrow/narrowbundle2.py	Fri Nov 22 21:42:04 2019 +0900
@@ -62,8 +62,8 @@
         raise ValueError(_(b'no common changegroup version'))
     version = max(cgversions)
 
-    include = sorted(filter(bool, kwargs.get(r'includepats', [])))
-    exclude = sorted(filter(bool, kwargs.get(r'excludepats', [])))
+    include = sorted(filter(bool, kwargs.get('includepats', [])))
+    exclude = sorted(filter(bool, kwargs.get('excludepats', [])))
     generateellipsesbundle2(
         bundler,
         repo,
@@ -72,7 +72,7 @@
         version,
         common,
         heads,
-        kwargs.get(r'depth', None),
+        kwargs.get('depth', None),
     )
 
 
@@ -316,7 +316,7 @@
         if repo.ui.has_section(_NARROWACL_SECTION):
             kwargs = exchange.applynarrowacl(repo, kwargs)
 
-        if kwargs.get(r'narrow', False) and repo.ui.configbool(
+        if kwargs.get('narrow', False) and repo.ui.configbool(
             b'experimental', b'narrowservebrokenellipses'
         ):
             getbundlechangegrouppart_narrow(*args, **kwargs)
--- a/hgext/narrow/narrowcommands.py	Wed Nov 20 19:07:02 2019 +0100
+++ b/hgext/narrow/narrowcommands.py	Fri Nov 22 21:42:04 2019 +0900
@@ -22,6 +22,7 @@
     hg,
     narrowspec,
     node,
+    pathutil,
     pycompat,
     registrar,
     repair,
@@ -136,8 +137,8 @@
 
         def pullbundle2extraprepare_widen(orig, pullop, kwargs):
             orig(pullop, kwargs)
-            if opts.get(r'depth'):
-                kwargs[b'depth'] = opts[r'depth']
+            if opts.get('depth'):
+                kwargs[b'depth'] = opts['depth']
 
         wrappedextraprepare = extensions.wrappedfunction(
             exchange, b'_pullbundle2extraprepare', pullbundle2extraprepare_widen
@@ -151,15 +152,15 @@
     """Wraps archive command to narrow the default includes."""
     if repository.NARROW_REQUIREMENT in repo.requirements:
         repo_includes, repo_excludes = repo.narrowpats
-        includes = set(opts.get(r'include', []))
-        excludes = set(opts.get(r'exclude', []))
+        includes = set(opts.get('include', []))
+        excludes = set(opts.get('exclude', []))
         includes, excludes, unused_invalid = narrowspec.restrictpatterns(
             includes, excludes, repo_includes, repo_excludes
         )
         if includes:
-            opts[r'include'] = includes
+            opts['include'] = includes
         if excludes:
-            opts[r'exclude'] = excludes
+            opts['exclude'] = excludes
     return orig(ui, repo, *args, **opts)
 
 
@@ -277,7 +278,7 @@
                     todelete.append(f)
             elif f.startswith(b'meta/'):
                 dir = f[5:-13]
-                dirs = sorted(util.dirs({dir})) + [dir]
+                dirs = sorted(pathutil.dirs({dir})) + [dir]
                 include = True
                 for d in dirs:
                     visit = newmatch.visitdir(d)
--- a/hgext/narrow/narrowwirepeer.py	Wed Nov 20 19:07:02 2019 +0100
+++ b/hgext/narrow/narrowwirepeer.py	Fri Nov 22 21:42:04 2019 +0900
@@ -33,8 +33,8 @@
                 # TODO: don't blindly add include/exclude wireproto
                 # arguments to unbundle.
                 include, exclude = repo.narrowpats
-                kwargs[r"includepats"] = b','.join(include)
-                kwargs[r"excludepats"] = b','.join(exclude)
+                kwargs["includepats"] = b','.join(include)
+                kwargs["excludepats"] = b','.join(exclude)
             return orig(cmd, *args, **kwargs)
 
         extensions.wrapfunction(peer, b'_calltwowaystream', wrapped)
@@ -139,12 +139,12 @@
 
 
 def peernarrowwiden(remote, **kwargs):
-    for ch in (r'commonheads', r'known'):
+    for ch in ('commonheads', 'known'):
         kwargs[ch] = wireprototypes.encodelist(kwargs[ch])
 
-    for ch in (r'oldincludes', r'newincludes', r'oldexcludes', r'newexcludes'):
+    for ch in ('oldincludes', 'newincludes', 'oldexcludes', 'newexcludes'):
         kwargs[ch] = b','.join(kwargs[ch])
 
-    kwargs[r'ellipses'] = b'%i' % bool(kwargs[r'ellipses'])
+    kwargs['ellipses'] = b'%i' % bool(kwargs['ellipses'])
     f = remote._callcompressable(b'narrow_widen', **kwargs)
     return bundle2.getunbundler(remote.ui, f)
--- a/hgext/notify.py	Wed Nov 20 19:07:02 2019 +0100
+++ b/hgext/notify.py	Fri Nov 22 21:42:04 2019 +0900
@@ -388,13 +388,13 @@
             raise error.Abort(inst)
 
         # store sender and subject
-        sender = msg[r'From']
-        subject = msg[r'Subject']
+        sender = msg['From']
+        subject = msg['Subject']
         if sender is not None:
             sender = mail.headdecode(sender)
         if subject is not None:
             subject = mail.headdecode(subject)
-        del msg[r'From'], msg[r'Subject']
+        del msg['From'], msg['Subject']
 
         if not msg.is_multipart():
             # create fresh mime message from scratch
@@ -407,7 +407,7 @@
             for k, v in headers:
                 msg[k] = v
 
-        msg[r'Date'] = encoding.strfromlocal(
+        msg['Date'] = encoding.strfromlocal(
             dateutil.datestr(format=b"%a, %d %b %Y %H:%M:%S %1%2")
         )
 
@@ -421,8 +421,8 @@
         maxsubject = int(self.ui.config(b'notify', b'maxsubject'))
         if maxsubject:
             subject = stringutil.ellipsis(subject, maxsubject)
-        msg[r'Subject'] = encoding.strfromlocal(
-            mail.headencode(self.ui, subject, self.charsets, self.test)
+        msg['Subject'] = mail.headencode(
+            self.ui, subject, self.charsets, self.test
         )
 
         # try to make message have proper sender
@@ -430,14 +430,14 @@
             sender = self.ui.config(b'email', b'from') or self.ui.username()
         if b'@' not in sender or b'@localhost' in sender:
             sender = self.fixmail(sender)
-        msg[r'From'] = encoding.strfromlocal(
-            mail.addressencode(self.ui, sender, self.charsets, self.test)
+        msg['From'] = mail.addressencode(
+            self.ui, sender, self.charsets, self.test
         )
 
-        msg[r'X-Hg-Notification'] = r'changeset %s' % ctx
-        if not msg[r'Message-Id']:
-            msg[r'Message-Id'] = messageid(ctx, self.domain, self.messageidseed)
-        msg[r'To'] = encoding.strfromlocal(b', '.join(sorted(subs)))
+        msg['X-Hg-Notification'] = 'changeset %s' % ctx
+        if not msg['Message-Id']:
+            msg['Message-Id'] = messageid(ctx, self.domain, self.messageidseed)
+        msg['To'] = ', '.join(sorted(subs))
 
         msgtext = msg.as_bytes() if pycompat.ispy3 else msg.as_string()
         if self.test:
@@ -451,7 +451,7 @@
             )
             mail.sendmail(
                 self.ui,
-                emailutils.parseaddr(msg[r'From'])[1],
+                emailutils.parseaddr(msg['From'])[1],
                 subs,
                 msgtext,
                 mbox=self.mbox,
--- a/hgext/patchbomb.py	Wed Nov 20 19:07:02 2019 +0100
+++ b/hgext/patchbomb.py	Fri Nov 22 21:42:04 2019 +0900
@@ -285,7 +285,7 @@
         if body:
             msg.attach(mail.mimeencode(ui, body, _charsets, opts.get(b'test')))
         p = mail.mimetextpatch(
-            b'\n'.join(patchlines), b'x-patch', opts.get(b'test')
+            b'\n'.join(patchlines), 'x-patch', opts.get(b'test')
         )
         binnode = nodemod.bin(node)
         # if node is mq patch, it will have the patch file's name as a tag
@@ -306,8 +306,8 @@
         disposition = r'inline'
         if opts.get(b'attach'):
             disposition = r'attachment'
-        p[r'Content-Disposition'] = (
-            disposition + r'; filename=' + encoding.strfromlocal(patchname)
+        p['Content-Disposition'] = (
+            disposition + '; filename=' + encoding.strfromlocal(patchname)
         )
         msg.attach(p)
     else:
@@ -321,10 +321,10 @@
         subj = b' '.join([prefix, opts.get(b'subject') or subj])
     else:
         subj = b' '.join([prefix, subj])
-    msg[b'Subject'] = mail.headencode(ui, subj, _charsets, opts.get(b'test'))
-    msg[b'X-Mercurial-Node'] = node
-    msg[b'X-Mercurial-Series-Index'] = b'%i' % idx
-    msg[b'X-Mercurial-Series-Total'] = b'%i' % total
+    msg['Subject'] = mail.headencode(ui, subj, _charsets, opts.get(b'test'))
+    msg['X-Mercurial-Node'] = pycompat.sysstr(node)
+    msg['X-Mercurial-Series-Index'] = '%i' % idx
+    msg['X-Mercurial-Series-Total'] = '%i' % total
     return msg, subj, ds
 
 
@@ -358,7 +358,7 @@
     tmpfn = os.path.join(tmpdir, b'bundle')
     btype = ui.config(b'patchbomb', b'bundletype')
     if btype:
-        opts[r'type'] = btype
+        opts['type'] = btype
     try:
         commands.bundle(ui, repo, tmpfn, dest, **opts)
         return util.readfile(tmpfn)
@@ -379,8 +379,8 @@
     the user through the editor.
     """
     ui = repo.ui
-    if opts.get(r'desc'):
-        body = open(opts.get(r'desc')).read()
+    if opts.get('desc'):
+        body = open(opts.get('desc')).read()
     else:
         ui.write(
             _(b'\nWrite the introductory message for the patch series.\n\n')
@@ -403,25 +403,25 @@
     """
     ui = repo.ui
     _charsets = mail._charsets(ui)
-    subj = opts.get(r'subject') or prompt(
+    subj = opts.get('subject') or prompt(
         ui, b'Subject:', b'A bundle for your repository'
     )
 
     body = _getdescription(repo, b'', sender, **opts)
     msg = emimemultipart.MIMEMultipart()
     if body:
-        msg.attach(mail.mimeencode(ui, body, _charsets, opts.get(r'test')))
-    datapart = emimebase.MIMEBase(r'application', r'x-mercurial-bundle')
+        msg.attach(mail.mimeencode(ui, body, _charsets, opts.get('test')))
+    datapart = emimebase.MIMEBase('application', 'x-mercurial-bundle')
     datapart.set_payload(bundle)
-    bundlename = b'%s.hg' % opts.get(r'bundlename', b'bundle')
+    bundlename = b'%s.hg' % opts.get('bundlename', b'bundle')
     datapart.add_header(
-        r'Content-Disposition',
-        r'attachment',
+        'Content-Disposition',
+        'attachment',
         filename=encoding.strfromlocal(bundlename),
     )
     emailencoders.encode_base64(datapart)
     msg.attach(datapart)
-    msg[b'Subject'] = mail.headencode(ui, subj, _charsets, opts.get(r'test'))
+    msg['Subject'] = mail.headencode(ui, subj, _charsets, opts.get('test'))
     return [(msg, subj, None)]
 
 
@@ -434,9 +434,9 @@
 
     # use the last revision which is likely to be a bookmarked head
     prefix = _formatprefix(
-        ui, repo, revs.last(), opts.get(r'flag'), 0, len(patches), numbered=True
+        ui, repo, revs.last(), opts.get('flag'), 0, len(patches), numbered=True
     )
-    subj = opts.get(r'subject') or prompt(
+    subj = opts.get('subject') or prompt(
         ui, b'(optional) Subject: ', rest=prefix, default=b''
     )
     if not subj:
@@ -445,7 +445,7 @@
     subj = prefix + b' ' + subj
 
     body = b''
-    if opts.get(r'diffstat'):
+    if opts.get('diffstat'):
         # generate a cumulative diffstat of the whole patch series
         diffstat = patch.diffstat(sum(patches, []))
         body = b'\n' + diffstat
@@ -453,8 +453,8 @@
         diffstat = None
 
     body = _getdescription(repo, body, sender, **opts)
-    msg = mail.mimeencode(ui, body, _charsets, opts.get(r'test'))
-    msg[b'Subject'] = mail.headencode(ui, subj, _charsets, opts.get(r'test'))
+    msg = mail.mimeencode(ui, body, _charsets, opts.get('test'))
+    msg['Subject'] = mail.headencode(ui, subj, _charsets, opts.get('test'))
     return (msg, subj, diffstat)
 
 
@@ -522,9 +522,11 @@
 
 
 def _msgid(node, timestamp):
-    hostname = encoding.strtolocal(socket.getfqdn())
-    hostname = encoding.environ.get(b'HGHOSTNAME', hostname)
-    return b'<%s.%d@%s>' % (node, timestamp, hostname)
+    try:
+        hostname = encoding.strfromlocal(encoding.environ[b'HGHOSTNAME'])
+    except KeyError:
+        hostname = socket.getfqdn()
+    return '<%s.%d@%s>' % (node, timestamp, hostname)
 
 
 emailopts = [
@@ -847,7 +849,7 @@
         stropts = pycompat.strkwargs(opts)
         bundledata = _getbundle(repo, dest, **stropts)
         bundleopts = stropts.copy()
-        bundleopts.pop(r'bundle', None)  # already processed
+        bundleopts.pop('bundle', None)  # already processed
         msgs = _getbundlemsgs(repo, sender, bundledata, **bundleopts)
     else:
         msgs = _getpatchmsgs(repo, sender, revs, **pycompat.strkwargs(opts))
@@ -912,10 +914,11 @@
     parent = opts.get(b'in_reply_to') or None
     # angle brackets may be omitted, they're not semantically part of the msg-id
     if parent is not None:
-        if not parent.startswith(b'<'):
-            parent = b'<' + parent
-        if not parent.endswith(b'>'):
-            parent += b'>'
+        parent = encoding.strfromlocal(parent)
+        if not parent.startswith('<'):
+            parent = '<' + parent
+        if not parent.endswith('>'):
+            parent += '>'
 
     sender_addr = eutil.parseaddr(encoding.strfromlocal(sender))[1]
     sender = mail.addressencode(ui, sender, _charsets, opts.get(b'test'))
@@ -926,56 +929,36 @@
     )
     for i, (m, subj, ds) in enumerate(msgs):
         try:
-            m[b'Message-Id'] = genmsgid(m[b'X-Mercurial-Node'])
+            m['Message-Id'] = genmsgid(m['X-Mercurial-Node'])
             if not firstpatch:
-                firstpatch = m[b'Message-Id']
-            m[b'X-Mercurial-Series-Id'] = firstpatch
+                firstpatch = m['Message-Id']
+            m['X-Mercurial-Series-Id'] = firstpatch
         except TypeError:
-            m[b'Message-Id'] = genmsgid(b'patchbomb')
+            m['Message-Id'] = genmsgid('patchbomb')
         if parent:
-            m[b'In-Reply-To'] = parent
-            m[b'References'] = parent
-        if not parent or b'X-Mercurial-Node' not in m:
-            parent = m[b'Message-Id']
+            m['In-Reply-To'] = parent
+            m['References'] = parent
+        if not parent or 'X-Mercurial-Node' not in m:
+            parent = m['Message-Id']
 
-        m[b'User-Agent'] = b'Mercurial-patchbomb/%s' % util.version()
-        m[b'Date'] = eutil.formatdate(start_time[0], localtime=True)
+        m['User-Agent'] = 'Mercurial-patchbomb/%s' % util.version().decode()
+        m['Date'] = eutil.formatdate(start_time[0], localtime=True)
 
         start_time = (start_time[0] + 1, start_time[1])
-        m[b'From'] = sender
-        m[b'To'] = b', '.join(to)
+        m['From'] = sender
+        m['To'] = ', '.join(to)
         if cc:
-            m[b'Cc'] = b', '.join(cc)
+            m['Cc'] = ', '.join(cc)
         if bcc:
-            m[b'Bcc'] = b', '.join(bcc)
+            m['Bcc'] = ', '.join(bcc)
         if replyto:
-            m[b'Reply-To'] = b', '.join(replyto)
-        # Fix up all headers to be native strings.
-        # TODO(durin42): this should probably be cleaned up above in the future.
-        if pycompat.ispy3:
-            for hdr, val in list(m.items()):
-                change = False
-                if isinstance(hdr, bytes):
-                    del m[hdr]
-                    hdr = pycompat.strurl(hdr)
-                    change = True
-                if isinstance(val, bytes):
-                    # header value should be ASCII since it's encoded by
-                    # mail.headencode(), but -n/--test disables it and raw
-                    # value of platform encoding is stored.
-                    val = encoding.strfromlocal(val)
-                    if not change:
-                        # prevent duplicate headers
-                        del m[hdr]
-                    change = True
-                if change:
-                    m[hdr] = val
+            m['Reply-To'] = ', '.join(replyto)
         if opts.get(b'test'):
             ui.status(_(b'displaying '), subj, b' ...\n')
             ui.pager(b'email')
             generator = mail.Generator(ui, mangle_from_=False)
             try:
-                generator.flatten(m, 0)
+                generator.flatten(m, False)
                 ui.write(b'\n')
             except IOError as inst:
                 if inst.errno != errno.EPIPE:
@@ -987,12 +970,11 @@
             progress.update(i, item=subj)
             if not mbox:
                 # Exim does not remove the Bcc field
-                del m[b'Bcc']
+                del m['Bcc']
             fp = stringio()
             generator = mail.Generator(fp, mangle_from_=False)
-            generator.flatten(m, 0)
+            generator.flatten(m, False)
             alldests = to + bcc + cc
-            alldests = [encoding.strfromlocal(d) for d in alldests]
             sendmail(sender_addr, alldests, fp.getvalue())
 
     progress.complete()
--- a/hgext/phabricator.py	Wed Nov 20 19:07:02 2019 +0100
+++ b/hgext/phabricator.py	Fri Nov 22 21:42:04 2019 +0900
@@ -167,13 +167,13 @@
         return request
 
     def sanitiseresponse(response):
-        if r'set-cookie' in response[r'headers']:
-            del response[r'headers'][r'set-cookie']
+        if 'set-cookie' in response['headers']:
+            del response['headers']['set-cookie']
         return response
 
     def decorate(fn):
         def inner(*args, **kwargs):
-            cassette = pycompat.fsdecode(kwargs.pop(r'test_vcr', None))
+            cassette = pycompat.fsdecode(kwargs.pop('test_vcr', None))
             if cassette:
                 import hgdemandimport
 
@@ -182,24 +182,24 @@
                     import vcr.stubs as stubs
 
                     vcr = vcrmod.VCR(
-                        serializer=r'json',
+                        serializer='json',
                         before_record_request=sanitiserequest,
                         before_record_response=sanitiseresponse,
                         custom_patches=[
                             (
                                 urlmod,
-                                r'httpconnection',
+                                'httpconnection',
                                 stubs.VCRHTTPConnection,
                             ),
                             (
                                 urlmod,
-                                r'httpsconnection',
+                                'httpsconnection',
                                 stubs.VCRHTTPSConnection,
                             ),
                         ],
                     )
-                    vcr.register_matcher(r'hgmatcher', hgmatcher)
-                    with vcr.use_cassette(cassette, match_on=[r'hgmatcher']):
+                    vcr.register_matcher('hgmatcher', hgmatcher)
+                    with vcr.use_cassette(cassette, match_on=['hgmatcher']):
                         return fn(*args, **kwargs)
             return fn(*args, **kwargs)
 
@@ -389,7 +389,7 @@
     corresponding Differential Revision, and exist in the repo.
     """
     unfi = repo.unfiltered()
-    nodemap = unfi.changelog.nodemap
+    has_node = unfi.changelog.index.has_node
 
     result = {}  # {node: (oldnode?, lastdiff?, drev)}
     toconfirm = {}  # {node: (force, {precnode}, drev)}
@@ -398,7 +398,7 @@
         # For tags like "D123", put them into "toconfirm" to verify later
         precnodes = list(obsutil.allpredecessors(unfi.obsstore, [node]))
         for n in precnodes:
-            if n in nodemap:
+            if has_node(n):
                 for tag in unfi.nodetags(n):
                     m = _differentialrevisiontagre.match(tag)
                     if m:
@@ -408,7 +408,7 @@
         # Check commit message
         m = _differentialrevisiondescre.search(ctx.description())
         if m:
-            toconfirm[node] = (1, set(precnodes), int(m.group(r'id')))
+            toconfirm[node] = (1, set(precnodes), int(m.group('id')))
 
     # Double check if tags are genuine by collecting all old nodes from
     # Phabricator, and expect precursors overlap with it.
@@ -454,7 +454,7 @@
             if diffs:
                 lastdiff = max(diffs, key=lambda d: int(d[b'id']))
                 oldnode = getnode(lastdiff)
-                if oldnode and oldnode not in nodemap:
+                if oldnode and not has_node(oldnode):
                     oldnode = None
 
             result[newnode] = (oldnode, lastdiff, drev)
@@ -609,26 +609,25 @@
     """
     ui = fctx.repo().ui
     chunks = callconduit(ui, b'file.querychunks', {b'filePHID': fphid})
-    progress = ui.makeprogress(
+    with ui.makeprogress(
         _(b'uploading file chunks'), unit=_(b'chunks'), total=len(chunks)
-    )
-    for chunk in chunks:
-        progress.increment()
-        if chunk[b'complete']:
-            continue
-        bstart = int(chunk[b'byteStart'])
-        bend = int(chunk[b'byteEnd'])
-        callconduit(
-            ui,
-            b'file.uploadchunk',
-            {
-                b'filePHID': fphid,
-                b'byteStart': bstart,
-                b'data': base64.b64encode(fctx.data()[bstart:bend]),
-                b'dataEncoding': b'base64',
-            },
-        )
-    progress.complete()
+    ) as progress:
+        for chunk in chunks:
+            progress.increment()
+            if chunk[b'complete']:
+                continue
+            bstart = int(chunk[b'byteStart'])
+            bend = int(chunk[b'byteEnd'])
+            callconduit(
+                ui,
+                b'file.uploadchunk',
+                {
+                    b'filePHID': fphid,
+                    b'byteStart': bstart,
+                    b'data': base64.b64encode(fctx.data()[bstart:bend]),
+                    b'dataEncoding': b'base64',
+                },
+            )
 
 
 def uploadfile(fctx):
@@ -1089,7 +1088,7 @@
             # Create a local tag to note the association, if commit message
             # does not have it already
             m = _differentialrevisiondescre.search(ctx.description())
-            if not m or int(m.group(r'id')) != newrevid:
+            if not m or int(m.group('id')) != newrevid:
                 tagname = b'D%d' % newrevid
                 tags.tag(
                     repo,
@@ -1636,7 +1635,7 @@
     m = _differentialrevisiondescre.search(ctx.description())
     if m:
         return templateutil.hybriddict(
-            {b'url': m.group(r'url'), b'id': b"D%s" % m.group(r'id'),}
+            {b'url': m.group('url'), b'id': b"D%s" % m.group('id'),}
         )
     else:
         tags = ctx.repo().nodetags(ctx.node())
--- a/hgext/rebase.py	Wed Nov 20 19:07:02 2019 +0100
+++ b/hgext/rebase.py	Fri Nov 22 21:42:04 2019 +0900
@@ -1274,8 +1274,8 @@
     if revf and srcf:
         raise error.Abort(_(b'cannot specify both a revision and a source'))
 
+    cmdutil.checkunfinished(repo)
     if not inmemory:
-        cmdutil.checkunfinished(repo)
         cmdutil.bailifchanged(repo)
 
     if ui.configbool(b'commands', b'rebase.requiredest') and not destf:
@@ -1643,10 +1643,11 @@
 def successorrevs(unfi, rev):
     """yield revision numbers for successors of rev"""
     assert unfi.filtername is None
-    nodemap = unfi.changelog.nodemap
+    get_rev = unfi.changelog.index.get_rev
     for s in obsutil.allsuccessors(unfi.obsstore, [unfi[rev].node()]):
-        if s in nodemap:
-            yield nodemap[s]
+        r = get_rev(s)
+        if r is not None:
+            yield r
 
 
 def defineparents(repo, rev, destmap, state, skipped, obsskipped):
@@ -2127,15 +2128,15 @@
 
 def pullrebase(orig, ui, repo, *args, **opts):
     b'Call rebase after pull if the latter has been invoked with --rebase'
-    if opts.get(r'rebase'):
+    if opts.get('rebase'):
         if ui.configbool(b'commands', b'rebase.requiredest'):
             msg = _(b'rebase destination required by configuration')
             hint = _(b'use hg pull followed by hg rebase -d DEST')
             raise error.Abort(msg, hint=hint)
 
         with repo.wlock(), repo.lock():
-            if opts.get(r'update'):
-                del opts[r'update']
+            if opts.get('update'):
+                del opts['update']
                 ui.debug(
                     b'--update and --rebase are not compatible, ignoring '
                     b'the update flag\n'
@@ -2165,15 +2166,15 @@
             if revspostpull > revsprepull:
                 # --rev option from pull conflict with rebase own --rev
                 # dropping it
-                if r'rev' in opts:
-                    del opts[r'rev']
+                if 'rev' in opts:
+                    del opts['rev']
                 # positional argument from pull conflicts with rebase's own
                 # --source.
-                if r'source' in opts:
-                    del opts[r'source']
+                if 'source' in opts:
+                    del opts['source']
                 # revsprepull is the len of the repo, not revnum of tip.
                 destspace = list(repo.changelog.revs(start=revsprepull))
-                opts[r'_destspace'] = destspace
+                opts['_destspace'] = destspace
                 try:
                     rebase(ui, repo, **opts)
                 except error.NoMergeDestAbort:
@@ -2187,7 +2188,7 @@
                         # with warning and trumpets
                         commands.update(ui, repo)
     else:
-        if opts.get(r'tool'):
+        if opts.get('tool'):
             raise error.Abort(_(b'--tool can only be used with --rebase'))
         ret = orig(ui, repo, *args, **opts)
 
@@ -2217,7 +2218,7 @@
 
     assert repo.filtername is None
     cl = repo.changelog
-    nodemap = cl.nodemap
+    get_rev = cl.index.get_rev
     extinctrevs = set(repo.revs(b'extinct()'))
     for srcrev in rebaseobsrevs:
         srcnode = cl.node(srcrev)
@@ -2225,7 +2226,8 @@
         successors = set(obsutil.allsuccessors(repo.obsstore, [srcnode]))
         # obsutil.allsuccessors includes node itself
         successors.remove(srcnode)
-        succrevs = {nodemap[s] for s in successors if s in nodemap}
+        succrevs = {get_rev(s) for s in successors}
+        succrevs.discard(None)
         if succrevs.issubset(extinctrevs):
             # all successors are extinct
             obsoleteextinctsuccessors.add(srcrev)
--- a/hgext/record.py	Wed Nov 20 19:07:02 2019 +0100
+++ b/hgext/record.py	Fri Nov 22 21:42:04 2019 +0900
@@ -72,14 +72,14 @@
             _(b'running non-interactively, use %s instead') % b'commit'
         )
 
-    opts[r"interactive"] = True
+    opts["interactive"] = True
     overrides = {(b'experimental', b'crecord'): False}
     with ui.configoverride(overrides, b'record'):
         return commands.commit(ui, repo, *pats, **opts)
 
 
 def qrefresh(origfn, ui, repo, *pats, **opts):
-    if not opts[r'interactive']:
+    if not opts['interactive']:
         return origfn(ui, repo, *pats, **opts)
 
     mq = extensions.find(b'mq')
@@ -123,7 +123,7 @@
     repo.mq.checkpatchname(patch)
 
     def committomq(ui, repo, *pats, **opts):
-        opts[r'checkname'] = False
+        opts['checkname'] = False
         mq.new(ui, repo, patch, *pats, **opts)
 
     overrides = {(b'experimental', b'crecord'): False}
@@ -142,7 +142,7 @@
 
 
 def qnew(origfn, ui, repo, patch, *args, **opts):
-    if opts[r'interactive']:
+    if opts['interactive']:
         return _qrecord(None, ui, repo, patch, *args, **opts)
     return origfn(ui, repo, patch, *args, **opts)
 
--- a/hgext/remotefilelog/__init__.py	Wed Nov 20 19:07:02 2019 +0100
+++ b/hgext/remotefilelog/__init__.py	Fri Nov 22 21:42:04 2019 +0900
@@ -288,7 +288,7 @@
 
     # Prevent 'hg manifest --all'
     def _manifest(orig, ui, repo, *args, **opts):
-        if isenabled(repo) and opts.get(r'all'):
+        if isenabled(repo) and opts.get('all'):
             raise error.Abort(_(b"--all is not supported in a shallow repo"))
 
         return orig(ui, repo, *args, **opts)
@@ -344,7 +344,7 @@
 
 
 def cloneshallow(orig, ui, repo, *args, **opts):
-    if opts.get(r'shallow'):
+    if opts.get('shallow'):
         repos = []
 
         def pull_shallow(orig, self, *args, **kwargs):
@@ -381,13 +381,9 @@
                 if constants.NETWORK_CAP_LEGACY_SSH_GETFILES in caps:
                     opts = {}
                     if repo.includepattern:
-                        opts[r'includepattern'] = b'\0'.join(
-                            repo.includepattern
-                        )
+                        opts['includepattern'] = b'\0'.join(repo.includepattern)
                     if repo.excludepattern:
-                        opts[r'excludepattern'] = b'\0'.join(
-                            repo.excludepattern
-                        )
+                        opts['excludepattern'] = b'\0'.join(repo.excludepattern)
                     return remote._callstream(b'stream_out_shallow', **opts)
                 else:
                     return orig()
@@ -424,7 +420,7 @@
     try:
         orig(ui, repo, *args, **opts)
     finally:
-        if opts.get(r'shallow'):
+        if opts.get('shallow'):
             for r in repos:
                 if util.safehasattr(r, b'fileservice'):
                     r.fileservice.close()
@@ -723,9 +719,9 @@
         remotefilelog.remotefilelog, b'addrawrevision', addrawrevision
     )
 
-    def changelogadd(orig, self, *args):
+    def changelogadd(orig, self, *args, **kwargs):
         oldlen = len(self)
-        node = orig(self, *args)
+        node = orig(self, *args, **kwargs)
         newlen = len(self)
         if oldlen != newlen:
             for oldargs in pendingfilecommits:
@@ -991,14 +987,14 @@
     if not isenabled(repo):
         return orig(ui, repo, *pats, **opts)
 
-    follow = opts.get(r'follow')
-    revs = opts.get(r'rev')
+    follow = opts.get('follow')
+    revs = opts.get('rev')
     if pats:
         # Force slowpath for non-follow patterns and follows that start from
         # non-working-copy-parent revs.
         if not follow or revs:
             # This forces the slowpath
-            opts[r'removed'] = True
+            opts['removed'] = True
 
         # If this is a non-follow log without any revs specified, recommend that
         # the user add -f to speed it up.
@@ -1279,20 +1275,20 @@
     _(b'hg repack [OPTIONS]'),
 )
 def repack_(ui, repo, *pats, **opts):
-    if opts.get(r'background'):
+    if opts.get('background'):
         ensurestart = repo.ui.configbool(b'devel', b'remotefilelog.ensurestart')
         repackmod.backgroundrepack(
             repo,
-            incremental=opts.get(r'incremental'),
-            packsonly=opts.get(r'packsonly', False),
+            incremental=opts.get('incremental'),
+            packsonly=opts.get('packsonly', False),
             ensurestart=ensurestart,
         )
         return
 
-    options = {b'packsonly': opts.get(r'packsonly')}
+    options = {b'packsonly': opts.get('packsonly')}
 
     try:
-        if opts.get(r'incremental'):
+        if opts.get('incremental'):
             repackmod.incrementalrepack(repo, options=options)
         else:
             repackmod.fullrepack(repo, options=options)
--- a/hgext/remotefilelog/basepack.py	Wed Nov 20 19:07:02 2019 +0100
+++ b/hgext/remotefilelog/basepack.py	Fri Nov 22 21:42:04 2019 +0900
@@ -22,7 +22,7 @@
 )
 from . import shallowutil
 
-osutil = policy.importmod(r'osutil')
+osutil = policy.importmod('osutil')
 
 # The pack version supported by this implementation. This will need to be
 # rev'd whenever the byte format changes. Ex: changing the fanout prefix,
@@ -390,8 +390,8 @@
         self.idxfp, self.idxpath = opener.mkstemp(
             suffix=self.INDEXSUFFIX + b'-tmp'
         )
-        self.packfp = os.fdopen(self.packfp, r'wb+')
-        self.idxfp = os.fdopen(self.idxfp, r'wb+')
+        self.packfp = os.fdopen(self.packfp, 'wb+')
+        self.idxfp = os.fdopen(self.idxfp, 'wb+')
         self.sha = hashlib.sha1()
         self._closed = False
 
@@ -530,11 +530,11 @@
 
 class indexparams(object):
     __slots__ = (
-        r'fanoutprefix',
-        r'fanoutstruct',
-        r'fanoutcount',
-        r'fanoutsize',
-        r'indexstart',
+        'fanoutprefix',
+        'fanoutstruct',
+        'fanoutcount',
+        'fanoutsize',
+        'indexstart',
     )
 
     def __init__(self, prefixsize, version):
--- a/hgext/remotefilelog/basestore.py	Wed Nov 20 19:07:02 2019 +0100
+++ b/hgext/remotefilelog/basestore.py	Fri Nov 22 21:42:04 2019 +0900
@@ -420,10 +420,10 @@
         # throw a KeyError, try this many times with a full refresh between
         # attempts. A repack operation may have moved data from one store to
         # another while we were running.
-        self.numattempts = kwargs.get(r'numretries', 0) + 1
+        self.numattempts = kwargs.get('numretries', 0) + 1
         # If not-None, call this function on every retry and if the attempts are
         # exhausted.
-        self.retrylog = kwargs.get(r'retrylog', None)
+        self.retrylog = kwargs.get('retrylog', None)
 
     def markforrefresh(self):
         for store in self.stores:
--- a/hgext/remotefilelog/contentstore.py	Wed Nov 20 19:07:02 2019 +0100
+++ b/hgext/remotefilelog/contentstore.py	Fri Nov 22 21:42:04 2019 +0900
@@ -40,12 +40,12 @@
         super(unioncontentstore, self).__init__(*args, **kwargs)
 
         self.stores = args
-        self.writestore = kwargs.get(r'writestore')
+        self.writestore = kwargs.get('writestore')
 
         # If allowincomplete==True then the union store can return partial
         # delta chains, otherwise it will throw a KeyError if a full
         # deltachain can't be found.
-        self.allowincomplete = kwargs.get(r'allowincomplete', False)
+        self.allowincomplete = kwargs.get('allowincomplete', False)
 
     def get(self, name, node):
         """Fetches the full text revision contents of the given name+node pair.
--- a/hgext/remotefilelog/debugcommands.py	Wed Nov 20 19:07:02 2019 +0100
+++ b/hgext/remotefilelog/debugcommands.py	Fri Nov 22 21:42:04 2019 +0900
@@ -32,7 +32,7 @@
 
 
 def debugremotefilelog(ui, path, **opts):
-    decompress = opts.get(r'decompress')
+    decompress = opts.get('decompress')
 
     size, firstnode, mapping = parsefileblob(path, decompress)
 
@@ -101,9 +101,9 @@
 def debugindex(orig, ui, repo, file_=None, **opts):
     """dump the contents of an index file"""
     if (
-        opts.get(r'changelog')
-        or opts.get(r'manifest')
-        or opts.get(r'dir')
+        opts.get('changelog')
+        or opts.get('manifest')
+        or opts.get('dir')
         or not shallowutil.isenabled(repo)
         or not repo.shallowmatch(file_)
     ):
@@ -199,7 +199,7 @@
 
 
 def verifyremotefilelog(ui, path, **opts):
-    decompress = opts.get(r'decompress')
+    decompress = opts.get('decompress')
 
     for root, dirs, files in os.walk(path):
         for file in files:
@@ -262,13 +262,13 @@
             path = path[: path.index(b'.data')]
         ui.write(b"%s:\n" % path)
         dpack = datapack.datapack(path)
-        node = opts.get(r'node')
+        node = opts.get('node')
         if node:
             deltachain = dpack.getdeltachain(b'', bin(node))
             dumpdeltachain(ui, deltachain, **opts)
             return
 
-        if opts.get(r'long'):
+        if opts.get('long'):
             hashformatter = hex
             hashlen = 42
         else:
--- a/hgext/remotefilelog/metadatastore.py	Wed Nov 20 19:07:02 2019 +0100
+++ b/hgext/remotefilelog/metadatastore.py	Fri Nov 22 21:42:04 2019 +0900
@@ -12,12 +12,12 @@
         super(unionmetadatastore, self).__init__(*args, **kwargs)
 
         self.stores = args
-        self.writestore = kwargs.get(r'writestore')
+        self.writestore = kwargs.get('writestore')
 
         # If allowincomplete==True then the union store can return partial
         # ancestor lists, otherwise it will throw a KeyError if a full
         # history can't be found.
-        self.allowincomplete = kwargs.get(r'allowincomplete', False)
+        self.allowincomplete = kwargs.get('allowincomplete', False)
 
     def getancestors(self, name, node, known=None):
         """Returns as many ancestors as we're aware of.
--- a/hgext/remotefilelog/remotefilectx.py	Wed Nov 20 19:07:02 2019 +0100
+++ b/hgext/remotefilelog/remotefilectx.py	Fri Nov 22 21:42:04 2019 +0900
@@ -48,11 +48,11 @@
 
     @propertycache
     def _changeid(self):
-        if r'_changeid' in self.__dict__:
+        if '_changeid' in self.__dict__:
             return self._changeid
-        elif r'_changectx' in self.__dict__:
+        elif '_changectx' in self.__dict__:
             return self._changectx.rev()
-        elif r'_descendantrev' in self.__dict__:
+        elif '_descendantrev' in self.__dict__:
             # this file context was created from a revision with a known
             # descendant, we can (lazily) correct for linkrev aliases
             linknode = self._adjustlinknode(
@@ -83,7 +83,7 @@
 
         ancestormap = self.ancestormap()
         p1, p2, linknode, copyfrom = ancestormap[self._filenode]
-        rev = self._repo.changelog.nodemap.get(linknode)
+        rev = self._repo.changelog.index.get_rev(linknode)
         if rev is not None:
             return rev
 
@@ -119,7 +119,7 @@
         """
         lkr = self.linkrev()
         attrs = vars(self)
-        noctx = not (r'_changeid' in attrs or r'_changectx' in attrs)
+        noctx = not ('_changeid' in attrs or r'_changectx' in attrs)
         if noctx or self.rev() == lkr:
             return lkr
         linknode = self._adjustlinknode(
@@ -246,11 +246,11 @@
             return linknode
 
         commonlogkwargs = {
-            r'revs': b' '.join([hex(cl.node(rev)) for rev in revs]),
-            r'fnode': hex(fnode),
-            r'filepath': path,
-            r'user': shallowutil.getusername(repo.ui),
-            r'reponame': shallowutil.getreponame(repo.ui),
+            'revs': b' '.join([hex(cl.node(rev)) for rev in revs]),
+            'fnode': hex(fnode),
+            'filepath': path,
+            'user': shallowutil.getusername(repo.ui),
+            'reponame': shallowutil.getreponame(repo.ui),
         }
 
         repo.ui.log(b'linkrevfixup', b'adjusting linknode\n', **commonlogkwargs)
@@ -439,7 +439,7 @@
 
     def annotate(self, *args, **kwargs):
         introctx = self
-        prefetchskip = kwargs.pop(r'prefetchskip', None)
+        prefetchskip = kwargs.pop('prefetchskip', None)
         if prefetchskip:
             # use introrev so prefetchskip can be accurately tested
             introrev = self.introrev()
--- a/hgext/remotefilelog/repack.py	Wed Nov 20 19:07:02 2019 +0100
+++ b/hgext/remotefilelog/repack.py	Fri Nov 22 21:42:04 2019 +0900
@@ -29,7 +29,7 @@
     shallowutil,
 )
 
-osutil = policy.importmod(r'osutil')
+osutil = policy.importmod('osutil')
 
 
 class RepackAlreadyRunning(error.Abort):
@@ -876,13 +876,13 @@
     """
 
     __slots__ = (
-        r'filename',
-        r'node',
-        r'datasource',
-        r'historysource',
-        r'datarepacked',
-        r'historyrepacked',
-        r'gced',
+        'filename',
+        'node',
+        'datasource',
+        'historysource',
+        'datarepacked',
+        'historyrepacked',
+        'gced',
     )
 
     def __init__(self, filename, node):
--- a/hgext/remotefilelog/shallowbundle.py	Wed Nov 20 19:07:02 2019 +0100
+++ b/hgext/remotefilelog/shallowbundle.py	Fri Nov 22 21:42:04 2019 +0900
@@ -153,7 +153,7 @@
     try:
         # if serving, only send files the clients has patterns for
         if source == b'serve':
-            bundlecaps = kwargs.get(r'bundlecaps')
+            bundlecaps = kwargs.get('bundlecaps')
             includepattern = None
             excludepattern = None
             for cap in bundlecaps or []:
--- a/hgext/remotefilelog/shallowutil.py	Wed Nov 20 19:07:02 2019 +0100
+++ b/hgext/remotefilelog/shallowutil.py	Fri Nov 22 21:42:04 2019 +0900
@@ -260,9 +260,9 @@
             # v0, str(int(size)) is the header
             size = int(header)
     except ValueError:
-        raise RuntimeError(r"unexpected remotefilelog header: illegal format")
+        raise RuntimeError("unexpected remotefilelog header: illegal format")
     if size is None:
-        raise RuntimeError(r"unexpected remotefilelog header: no size found")
+        raise RuntimeError("unexpected remotefilelog header: no size found")
     return index + 1, size, flags
 
 
--- a/hgext/share.py	Wed Nov 20 19:07:02 2019 +0100
+++ b/hgext/share.py	Fri Nov 22 21:42:04 2019 +0900
@@ -122,7 +122,7 @@
     if pool:
         pool = util.expandpath(pool)
 
-    opts[r'shareopts'] = {
+    opts['shareopts'] = {
         b'pool': pool,
         b'mode': ui.config(b'share', b'poolnaming'),
     }
--- a/hgext/sparse.py	Wed Nov 20 19:07:02 2019 +0100
+++ b/hgext/sparse.py	Fri Nov 22 21:42:04 2019 +0900
@@ -153,10 +153,10 @@
 
 
 def _clonesparsecmd(orig, ui, repo, *args, **opts):
-    include_pat = opts.get(r'include')
-    exclude_pat = opts.get(r'exclude')
-    enableprofile_pat = opts.get(r'enable_profile')
-    narrow_pat = opts.get(r'narrow')
+    include_pat = opts.get('include')
+    exclude_pat = opts.get('exclude')
+    enableprofile_pat = opts.get('enable_profile')
+    narrow_pat = opts.get('narrow')
     include = exclude = enableprofile = False
     if include_pat:
         pat = include_pat
@@ -209,7 +209,7 @@
     )
 
     def _add(orig, ui, repo, *pats, **opts):
-        if opts.get(r'sparse'):
+        if opts.get('sparse'):
             dirs = set()
             for pat in pats:
                 dirname, basename = util.split(pat)
--- a/hgext/split.py	Wed Nov 20 19:07:02 2019 +0100
+++ b/hgext/split.py	Fri Nov 22 21:42:04 2019 +0900
@@ -152,7 +152,9 @@
         scmutil.movedirstate(repo, ctx.p1())
 
     # Any modified, added, removed, deleted result means split is incomplete
-    incomplete = lambda repo: any(repo.status()[:4])
+    def incomplete(repo):
+        st = repo.status()
+        return any((st.modified, st.added, st.removed, st.deleted))
 
     # Main split loop
     while incomplete(repo):
--- a/hgext/sqlitestore.py	Wed Nov 20 19:07:02 2019 +0100
+++ b/hgext/sqlitestore.py	Fri Nov 22 21:42:04 2019 +0900
@@ -121,19 +121,19 @@
     # Deltas are stored as content-indexed blobs.
     # compression column holds COMPRESSION_* constant for how the
     # delta is encoded.
-    r'CREATE TABLE delta ('
-    r'    id INTEGER PRIMARY KEY, '
-    r'    compression INTEGER NOT NULL, '
-    r'    hash BLOB UNIQUE ON CONFLICT ABORT, '
-    r'    delta BLOB NOT NULL '
-    r')',
+    'CREATE TABLE delta ('
+    '    id INTEGER PRIMARY KEY, '
+    '    compression INTEGER NOT NULL, '
+    '    hash BLOB UNIQUE ON CONFLICT ABORT, '
+    '    delta BLOB NOT NULL '
+    ')',
     # Tracked paths are denormalized to integers to avoid redundant
     # storage of the path name.
-    r'CREATE TABLE filepath ('
-    r'    id INTEGER PRIMARY KEY, '
-    r'    path BLOB NOT NULL '
-    r')',
-    r'CREATE UNIQUE INDEX filepath_path ' r'    ON filepath (path)',
+    'CREATE TABLE filepath ('
+    '    id INTEGER PRIMARY KEY, '
+    '    path BLOB NOT NULL '
+    ')',
+    'CREATE UNIQUE INDEX filepath_path ON filepath (path)',
     # We have a single table for all file revision data.
     # Each file revision is uniquely described by a (path, rev) and
     # (path, node).
@@ -145,39 +145,38 @@
     #
     # flags column holds bitwise integer flags controlling storage options.
     # These flags are defined by the FLAG_* constants.
-    r'CREATE TABLE fileindex ('
-    r'    id INTEGER PRIMARY KEY, '
-    r'    pathid INTEGER REFERENCES filepath(id), '
-    r'    revnum INTEGER NOT NULL, '
-    r'    p1rev INTEGER NOT NULL, '
-    r'    p2rev INTEGER NOT NULL, '
-    r'    linkrev INTEGER NOT NULL, '
-    r'    flags INTEGER NOT NULL, '
-    r'    deltaid INTEGER REFERENCES delta(id), '
-    r'    deltabaseid INTEGER REFERENCES fileindex(id), '
-    r'    node BLOB NOT NULL '
-    r')',
-    r'CREATE UNIQUE INDEX fileindex_pathrevnum '
-    r'    ON fileindex (pathid, revnum)',
-    r'CREATE UNIQUE INDEX fileindex_pathnode '
-    r'    ON fileindex (pathid, node)',
+    'CREATE TABLE fileindex ('
+    '    id INTEGER PRIMARY KEY, '
+    '    pathid INTEGER REFERENCES filepath(id), '
+    '    revnum INTEGER NOT NULL, '
+    '    p1rev INTEGER NOT NULL, '
+    '    p2rev INTEGER NOT NULL, '
+    '    linkrev INTEGER NOT NULL, '
+    '    flags INTEGER NOT NULL, '
+    '    deltaid INTEGER REFERENCES delta(id), '
+    '    deltabaseid INTEGER REFERENCES fileindex(id), '
+    '    node BLOB NOT NULL '
+    ')',
+    'CREATE UNIQUE INDEX fileindex_pathrevnum '
+    '    ON fileindex (pathid, revnum)',
+    'CREATE UNIQUE INDEX fileindex_pathnode ON fileindex (pathid, node)',
     # Provide a view over all file data for convenience.
-    r'CREATE VIEW filedata AS '
-    r'SELECT '
-    r'    fileindex.id AS id, '
-    r'    filepath.id AS pathid, '
-    r'    filepath.path AS path, '
-    r'    fileindex.revnum AS revnum, '
-    r'    fileindex.node AS node, '
-    r'    fileindex.p1rev AS p1rev, '
-    r'    fileindex.p2rev AS p2rev, '
-    r'    fileindex.linkrev AS linkrev, '
-    r'    fileindex.flags AS flags, '
-    r'    fileindex.deltaid AS deltaid, '
-    r'    fileindex.deltabaseid AS deltabaseid '
-    r'FROM filepath, fileindex '
-    r'WHERE fileindex.pathid=filepath.id',
-    r'PRAGMA user_version=%d' % CURRENT_SCHEMA_VERSION,
+    'CREATE VIEW filedata AS '
+    'SELECT '
+    '    fileindex.id AS id, '
+    '    filepath.id AS pathid, '
+    '    filepath.path AS path, '
+    '    fileindex.revnum AS revnum, '
+    '    fileindex.node AS node, '
+    '    fileindex.p1rev AS p1rev, '
+    '    fileindex.p2rev AS p2rev, '
+    '    fileindex.linkrev AS linkrev, '
+    '    fileindex.flags AS flags, '
+    '    fileindex.deltaid AS deltaid, '
+    '    fileindex.deltabaseid AS deltabaseid '
+    'FROM filepath, fileindex '
+    'WHERE fileindex.pathid=filepath.id',
+    'PRAGMA user_version=%d' % CURRENT_SCHEMA_VERSION,
 ]
 
 
@@ -190,22 +189,22 @@
     # baseid "poisoned" to null and limited the recursive filter to
     # "is not null".
     res = db.execute(
-        r'WITH RECURSIVE '
-        r'    deltachain(deltaid, baseid) AS ('
-        r'        SELECT deltaid, deltabaseid FROM fileindex '
-        r'            WHERE pathid=? AND node=? '
-        r'        UNION ALL '
-        r'        SELECT fileindex.deltaid, deltabaseid '
-        r'            FROM fileindex, deltachain '
-        r'            WHERE '
-        r'                fileindex.id=deltachain.baseid '
-        r'                AND deltachain.baseid IS NOT NULL '
-        r'                AND fileindex.id NOT IN ({stops}) '
-        r'    ) '
-        r'SELECT deltachain.baseid, compression, delta '
-        r'FROM deltachain, delta '
-        r'WHERE delta.id=deltachain.deltaid'.format(
-            stops=r','.join([r'?'] * len(stoprids))
+        'WITH RECURSIVE '
+        '    deltachain(deltaid, baseid) AS ('
+        '        SELECT deltaid, deltabaseid FROM fileindex '
+        '            WHERE pathid=? AND node=? '
+        '        UNION ALL '
+        '        SELECT fileindex.deltaid, deltabaseid '
+        '            FROM fileindex, deltachain '
+        '            WHERE '
+        '                fileindex.id=deltachain.baseid '
+        '                AND deltachain.baseid IS NOT NULL '
+        '                AND fileindex.id NOT IN ({stops}) '
+        '    ) '
+        'SELECT deltachain.baseid, compression, delta '
+        'FROM deltachain, delta '
+        'WHERE delta.id=deltachain.deltaid'.format(
+            stops=','.join(['?'] * len(stoprids))
         ),
         tuple([pathid, node] + list(stoprids.keys())),
     )
@@ -249,13 +248,12 @@
 def insertdelta(db, compression, hash, delta):
     try:
         return db.execute(
-            r'INSERT INTO delta (compression, hash, delta) '
-            r'VALUES (?, ?, ?)',
+            'INSERT INTO delta (compression, hash, delta) VALUES (?, ?, ?)',
             (compression, hash, delta),
         ).lastrowid
     except sqlite3.IntegrityError:
         return db.execute(
-            r'SELECT id FROM delta WHERE hash=?', (hash,)
+            'SELECT id FROM delta WHERE hash=?', (hash,)
         ).fetchone()[0]
 
 
@@ -335,7 +333,7 @@
 
         res = list(
             self._db.execute(
-                r'SELECT id FROM filepath WHERE path=?', (self._path,)
+                'SELECT id FROM filepath WHERE path=?', (self._path,)
             )
         )
 
@@ -346,10 +344,10 @@
         self._pathid = res[0][0]
 
         res = self._db.execute(
-            r'SELECT id, revnum, node, p1rev, p2rev, linkrev, flags '
-            r'FROM fileindex '
-            r'WHERE pathid=? '
-            r'ORDER BY revnum ASC',
+            'SELECT id, revnum, node, p1rev, p2rev, linkrev, flags '
+            'FROM fileindex '
+            'WHERE pathid=? '
+            'ORDER BY revnum ASC',
             (self._pathid,),
         )
 
@@ -496,11 +494,11 @@
         rev = self.rev(node)
 
         res = self._db.execute(
-            r'SELECT'
-            r'  node '
-            r'  FROM filedata '
-            r'  WHERE path=? AND (p1rev=? OR p2rev=?) '
-            r'  ORDER BY revnum ASC',
+            'SELECT'
+            '  node '
+            '  FROM filedata '
+            '  WHERE path=? AND (p1rev=? OR p2rev=?) '
+            '  ORDER BY revnum ASC',
             (self._path, rev, rev),
         )
 
@@ -598,9 +596,9 @@
 
         # TODO perform in a single query.
         res = self._db.execute(
-            r'SELECT revnum, deltaid FROM fileindex '
-            r'WHERE pathid=? '
-            r'    AND node in (%s)' % (r','.join([r'?'] * len(nodes))),
+            'SELECT revnum, deltaid FROM fileindex '
+            'WHERE pathid=? '
+            '    AND node in (%s)' % (','.join(['?'] * len(nodes))),
             tuple([self._pathid] + nodes),
         )
 
@@ -608,7 +606,7 @@
 
         for rev, deltaid in res:
             res = self._db.execute(
-                r'SELECT revnum from fileindex WHERE pathid=? AND deltaid=?',
+                'SELECT revnum from fileindex WHERE pathid=? AND deltaid=?',
                 (self._pathid, deltaid),
             )
             deltabases[rev] = res.fetchone()[0]
@@ -726,7 +724,7 @@
                     entry.flags &= ~FLAG_MISSING_P1
 
                     self._db.execute(
-                        r'UPDATE fileindex SET p1rev=?, flags=? ' r'WHERE id=?',
+                        'UPDATE fileindex SET p1rev=?, flags=? WHERE id=?',
                         (self._nodetorev[p1], entry.flags, entry.rid),
                     )
 
@@ -736,7 +734,7 @@
                     entry.flags &= ~FLAG_MISSING_P2
 
                     self._db.execute(
-                        r'UPDATE fileindex SET p2rev=?, flags=? ' r'WHERE id=?',
+                        'UPDATE fileindex SET p2rev=?, flags=? WHERE id=?',
                         (self._nodetorev[p1], entry.flags, entry.rid),
                     )
 
@@ -787,7 +785,7 @@
 
         # Find the delta to be censored.
         censoreddeltaid = self._db.execute(
-            r'SELECT deltaid FROM fileindex WHERE id=?',
+            'SELECT deltaid FROM fileindex WHERE id=?',
             (self._revisions[censornode].rid,),
         ).fetchone()[0]
 
@@ -796,8 +794,8 @@
         # for those delta chains too.
         rows = list(
             self._db.execute(
-                r'SELECT id, pathid, node FROM fileindex '
-                r'WHERE deltabaseid=? OR deltaid=?',
+                'SELECT id, pathid, node FROM fileindex '
+                'WHERE deltabaseid=? OR deltaid=?',
                 (censoreddeltaid, censoreddeltaid),
             )
         )
@@ -832,8 +830,8 @@
             deltaid = insertdelta(self._db, compression, deltahash, deltablob)
 
             self._db.execute(
-                r'UPDATE fileindex SET deltaid=?, deltabaseid=NULL '
-                r'WHERE id=?',
+                'UPDATE fileindex SET deltaid=?, deltabaseid=NULL '
+                'WHERE id=?',
                 (deltaid, rid),
             )
 
@@ -848,12 +846,12 @@
         flags |= FLAG_CENSORED
 
         self._db.execute(
-            r'UPDATE fileindex SET flags=?, deltaid=?, deltabaseid=NULL '
-            r'WHERE pathid=? AND node=?',
+            'UPDATE fileindex SET flags=?, deltaid=?, deltabaseid=NULL '
+            'WHERE pathid=? AND node=?',
             (flags, tombstonedeltaid, self._pathid, censornode),
         )
 
-        self._db.execute(r'DELETE FROM delta WHERE id=?', (censoreddeltaid,))
+        self._db.execute('DELETE FROM delta WHERE id=?', (censoreddeltaid,))
 
         self._refreshindex()
         self._revisioncache.clear()
@@ -878,7 +876,7 @@
 
         for rev in self.revs(rev):
             self._db.execute(
-                r'DELETE FROM fileindex WHERE pathid=? AND node=?',
+                'DELETE FROM fileindex WHERE pathid=? AND node=?',
                 (self._pathid, self.node(rev)),
             )
 
@@ -971,7 +969,7 @@
     ):
         if self._pathid is None:
             res = self._db.execute(
-                r'INSERT INTO filepath (path) VALUES (?)', (self._path,)
+                'INSERT INTO filepath (path) VALUES (?)', (self._path,)
             )
             self._pathid = res.lastrowid
 
@@ -1042,10 +1040,10 @@
             p2rev = self._nodetorev[p2]
 
         rid = self._db.execute(
-            r'INSERT INTO fileindex ('
-            r'    pathid, revnum, node, p1rev, p2rev, linkrev, flags, '
-            r'    deltaid, deltabaseid) '
-            r'    VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)',
+            'INSERT INTO fileindex ('
+            '    pathid, revnum, node, p1rev, p2rev, linkrev, flags, '
+            '    deltaid, deltabaseid) '
+            '    VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)',
             (
                 self._pathid,
                 rev,
@@ -1090,7 +1088,7 @@
         if current:
             return tr
 
-        self._dbconn.execute(r'BEGIN TRANSACTION')
+        self._dbconn.execute('BEGIN TRANSACTION')
 
         def committransaction(_):
             self._dbconn.commit()
@@ -1122,7 +1120,7 @@
     db = sqlite3.connect(encoding.strfromlocal(path))
     db.text_factory = bytes
 
-    res = db.execute(r'PRAGMA user_version').fetchone()[0]
+    res = db.execute('PRAGMA user_version').fetchone()[0]
 
     # New database.
     if res == 0:
@@ -1137,7 +1135,7 @@
     else:
         raise error.Abort(_(b'sqlite database has unrecognized version'))
 
-    db.execute(r'PRAGMA journal_mode=WAL')
+    db.execute('PRAGMA journal_mode=WAL')
 
     return db
 
--- a/hgext/transplant.py	Wed Nov 20 19:07:02 2019 +0100
+++ b/hgext/transplant.py	Fri Nov 22 21:42:04 2019 +0900
@@ -235,7 +235,7 @@
                     patchfile = None
                 else:
                     fd, patchfile = pycompat.mkstemp(prefix=b'hg-transplant-')
-                    fp = os.fdopen(fd, r'wb')
+                    fp = os.fdopen(fd, 'wb')
                     gen = patch.diff(source, parent, node, opts=diffopts)
                     for chunk in gen:
                         fp.write(chunk)
@@ -290,7 +290,7 @@
         self.ui.status(_(b'filtering %s\n') % patchfile)
         user, date, msg = (changelog[1], changelog[2], changelog[4])
         fd, headerfile = pycompat.mkstemp(prefix=b'hg-transplant-')
-        fp = os.fdopen(fd, r'wb')
+        fp = os.fdopen(fd, 'wb')
         fp.write(b"# HG changeset patch\n")
         fp.write(b"# User %s\n" % user)
         fp.write(b"# Date %d %d\n" % date)
@@ -443,7 +443,13 @@
                 )
             if merge:
                 repo.setparents(p1, parents[1])
-            modified, added, removed, deleted = repo.status()[:4]
+            st = repo.status()
+            modified, added, removed, deleted = (
+                st.modified,
+                st.added,
+                st.removed,
+                st.deleted,
+            )
             if merge or modified or added or removed or deleted:
                 n = repo.commit(
                     message,
--- a/hgext/uncommit.py	Wed Nov 20 19:07:02 2019 +0100
+++ b/hgext/uncommit.py	Fri Nov 22 21:42:04 2019 +0900
@@ -29,11 +29,11 @@
     error,
     node,
     obsutil,
+    pathutil,
     pycompat,
     registrar,
     rewriteutil,
     scmutil,
-    util,
 )
 
 cmdtable = {}
@@ -157,7 +157,8 @@
 
     with repo.wlock(), repo.lock():
 
-        m, a, r, d = repo.status()[:4]
+        st = repo.status()
+        m, a, r, d = st.modified, st.added, st.removed, st.deleted
         isdirtypath = any(set(m + a + r + d) & set(pats))
         allowdirtywcopy = opts[
             b'allow_dirty_working_copy'
@@ -185,7 +186,7 @@
             # if not everything tracked in that directory can be
             # uncommitted.
             if badfiles:
-                badfiles -= {f for f in util.dirs(eligible)}
+                badfiles -= {f for f in pathutil.dirs(eligible)}
 
             for f in sorted(badfiles):
                 if f in s.clean:
--- a/hgext/zeroconf/Zeroconf.py	Wed Nov 20 19:07:02 2019 +0100
+++ b/hgext/zeroconf/Zeroconf.py	Fri Nov 22 21:42:04 2019 +0900
@@ -684,7 +684,7 @@
                 break
             t = len & 0xC0
             if t == 0x00:
-                result = r''.join((result, self.readUTF(off, len) + r'.'))
+                result = ''.join((result, self.readUTF(off, len) + '.'))
                 off += len
             elif t == 0xC0:
                 if next < 0:
@@ -1429,7 +1429,7 @@
         self.socket.setsockopt(
             socket.SOL_IP,
             socket.IP_ADD_MEMBERSHIP,
-            socket.inet_aton(_MDNS_ADDR) + socket.inet_aton(r'0.0.0.0'),
+            socket.inet_aton(_MDNS_ADDR) + socket.inet_aton('0.0.0.0'),
         )
 
         self.listeners = []
@@ -1845,7 +1845,7 @@
             self.socket.setsockopt(
                 socket.SOL_IP,
                 socket.IP_DROP_MEMBERSHIP,
-                socket.inet_aton(_MDNS_ADDR) + socket.inet_aton(r'0.0.0.0'),
+                socket.inet_aton(_MDNS_ADDR) + socket.inet_aton('0.0.0.0'),
             )
             self.socket.close()
 
--- a/hgext/zeroconf/__init__.py	Wed Nov 20 19:07:02 2019 +0100
+++ b/hgext/zeroconf/__init__.py	Fri Nov 22 21:42:04 2019 +0900
@@ -6,9 +6,9 @@
 # GNU General Public License version 2 or any later version.
 '''discover and advertise repositories on the local network
 
-Zeroconf-enabled repositories will be announced in a network without
-the need to configure a server or a service. They can be discovered
-without knowing their actual IP address.
+The zeroconf extension will advertise :hg:`serve` instances over
+DNS-SD so that they can be discovered using the :hg:`paths` command
+without knowing the server's IP address.
 
 To allow other people to discover your repository using run
 :hg:`serve` in your repository::
@@ -55,7 +55,7 @@
     # finds external-facing interface without sending any packets (Linux)
     try:
         s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
-        s.connect((r'1.0.0.1', 0))
+        s.connect(('1.0.0.1', 0))
         ip = s.getsockname()[0]
         return ip
     except socket.error:
@@ -64,17 +64,17 @@
     # Generic method, sometimes gives useless results
     try:
         dumbip = socket.gethostbyaddr(socket.gethostname())[2][0]
-        if r':' in dumbip:
-            dumbip = r'127.0.0.1'
-        if not dumbip.startswith(r'127.'):
+        if ':' in dumbip:
+            dumbip = '127.0.0.1'
+        if not dumbip.startswith('127.'):
             return dumbip
     except (socket.gaierror, socket.herror):
-        dumbip = r'127.0.0.1'
+        dumbip = '127.0.0.1'
 
     # works elsewhere, but actually sends a packet
     try:
         s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
-        s.connect((r'1.0.0.1', 1))
+        s.connect(('1.0.0.1', 1))
         ip = s.getsockname()[0]
         return ip
     except socket.error:
@@ -87,20 +87,20 @@
     global server, localip
     if not server:
         ip = getip()
-        if ip.startswith(r'127.'):
+        if ip.startswith('127.'):
             # if we have no internet connection, this can happen.
             return
         localip = socket.inet_aton(ip)
         server = Zeroconf.Zeroconf(ip)
 
-    hostname = socket.gethostname().split(r'.')[0]
-    host = hostname + r".local"
-    name = r"%s-%s" % (hostname, name)
+    hostname = socket.gethostname().split('.')[0]
+    host = hostname + ".local"
+    name = "%s-%s" % (hostname, name)
 
     # advertise to browsers
     svc = Zeroconf.ServiceInfo(
         b'_http._tcp.local.',
-        pycompat.bytestr(name + r'._http._tcp.local.'),
+        pycompat.bytestr(name + '._http._tcp.local.'),
         server=host,
         port=port,
         properties={b'description': desc, b'path': b"/" + path},
@@ -113,7 +113,7 @@
     # advertise to Mercurial clients
     svc = Zeroconf.ServiceInfo(
         b'_hg._tcp.local.',
-        pycompat.bytestr(name + r'._hg._tcp.local.'),
+        pycompat.bytestr(name + '._hg._tcp.local.'),
         server=host,
         port=port,
         properties={b'description': desc, b'path': b"/" + path},
@@ -171,7 +171,7 @@
 
 def getzcpaths():
     ip = getip()
-    if ip.startswith(r'127.'):
+    if ip.startswith('127.'):
         return
     server = Zeroconf.Zeroconf(ip)
     l = listener()
@@ -180,10 +180,10 @@
     server.close()
     for value in l.found.values():
         name = value.name[: value.name.index(b'.')]
-        url = r"http://%s:%s%s" % (
+        url = "http://%s:%s%s" % (
             socket.inet_ntoa(value.address),
             value.port,
-            value.properties.get(r"path", r"/"),
+            value.properties.get("path", "/"),
         )
         yield b"zc-" + name, pycompat.bytestr(url)
 
--- a/hgweb.cgi	Wed Nov 20 19:07:02 2019 +0100
+++ b/hgweb.cgi	Fri Nov 22 21:42:04 2019 +0900
@@ -8,12 +8,15 @@
 
 # Uncomment and adjust if Mercurial is not installed system-wide
 # (consult "installed modules" path from 'hg debuginstall'):
-#import sys; sys.path.insert(0, "/path/to/python/lib")
+# import sys; sys.path.insert(0, "/path/to/python/lib")
 
 # Uncomment to send python tracebacks to the browser if an error occurs:
-#import cgitb; cgitb.enable()
+# import cgitb; cgitb.enable()
+
+from mercurial import demandimport
 
-from mercurial import demandimport; demandimport.enable()
+demandimport.enable()
 from mercurial.hgweb import hgweb, wsgicgi
+
 application = hgweb(config)
 wsgicgi.launch(application)
--- a/i18n/hggettext	Wed Nov 20 19:07:02 2019 +0100
+++ b/i18n/hggettext	Fri Nov 22 21:42:04 2019 +0900
@@ -57,18 +57,22 @@
 
 
 def poentry(path, lineno, s):
-    return ('#: %s:%d\n' % (path, lineno) +
-            'msgid %s\n' % normalize(s) +
-            'msgstr ""\n')
+    return (
+        '#: %s:%d\n' % (path, lineno)
+        + 'msgid %s\n' % normalize(s)
+        + 'msgstr ""\n'
+    )
+
 
 doctestre = re.compile(r'^ +>>> ', re.MULTILINE)
 
+
 def offset(src, doc, name, lineno, default):
     """Compute offset or issue a warning on stdout."""
     # remove doctest part, in order to avoid backslash mismatching
     m = doctestre.search(doc)
     if m:
-        doc = doc[:m.start()]
+        doc = doc[: m.start()]
 
     # Backslashes in doc appear doubled in src.
     end = src.find(doc.replace('\\', '\\\\'))
@@ -76,9 +80,11 @@
         # This can happen if the docstring contains unnecessary escape
         # sequences such as \" in a triple-quoted string. The problem
         # is that \" is turned into " and so doc wont appear in src.
-        sys.stderr.write("%s:%d:warning:"
-                         " unknown docstr offset, assuming %d lines\n"
-                         % (name, lineno, default))
+        sys.stderr.write(
+            "%s:%d:warning:"
+            " unknown docstr offset, assuming %d lines\n"
+            % (name, lineno, default)
+        )
         return default
     else:
         return src.count('\n', 0, end)
@@ -121,7 +127,7 @@
 
     for func, rstrip in functions:
         if func.__doc__:
-            docobj = func # this might be a proxy to provide formatted doc
+            docobj = func  # this might be a proxy to provide formatted doc
             func = getattr(func, '_origfunc', func)
             funcmod = inspect.getmodule(func)
             extra = ''
@@ -155,7 +161,9 @@
     # accidentally import and extract strings from a Mercurial
     # installation mentioned in PYTHONPATH.
     sys.path.insert(0, os.getcwd())
-    from mercurial import demandimport; demandimport.enable()
+    from mercurial import demandimport
+
+    demandimport.enable()
     for path in sys.argv[1:]:
         if path.endswith('.txt'):
             rawtext(path)
--- a/i18n/posplit	Wed Nov 20 19:07:02 2019 +0100
+++ b/i18n/posplit	Fri Nov 22 21:42:04 2019 +0900
@@ -11,6 +11,7 @@
 import re
 import sys
 
+
 def addentry(po, entry, cache):
     e = cache.get(entry.msgid)
     if e:
@@ -27,6 +28,7 @@
         po.append(entry)
         cache[entry.msgid] = entry
 
+
 def mkentry(orig, delta, msgid, msgstr):
     entry = polib.POEntry()
     entry.merge(orig)
@@ -35,13 +37,14 @@
     entry.occurrences = [(p, int(l) + delta) for (p, l) in orig.occurrences]
     return entry
 
+
 if __name__ == "__main__":
     po = polib.pofile(sys.argv[1])
 
     cache = {}
     entries = po[:]
     po[:] = []
-    findd = re.compile(r' *\.\. (\w+)::') # for finding directives
+    findd = re.compile(r' *\.\. (\w+)::')  # for finding directives
     for entry in entries:
         msgids = entry.msgid.split(u'\n\n')
         if entry.msgstr:
@@ -65,7 +68,7 @@
                 newentry = mkentry(entry, delta, msgid, msgstr)
                 mdirective = findd.match(msgid)
                 if mdirective:
-                    if not msgid[mdirective.end():].rstrip():
+                    if not msgid[mdirective.end() :].rstrip():
                         # only directive, nothing to translate here
                         delta += 2
                         continue
@@ -77,8 +80,10 @@
                             continue
                         else:
                             # lines following directly, unexpected
-                            print('Warning: text follows line with directive'
-                                  ' %s' % directive)
+                            print(
+                                'Warning: text follows line with directive'
+                                ' %s' % directive
+                            )
                     comment = 'do not translate: .. %s::' % directive
                     if not newentry.comment:
                         newentry.comment = comment
--- a/mercurial/ancestor.py	Wed Nov 20 19:07:02 2019 +0100
+++ b/mercurial/ancestor.py	Fri Nov 22 21:42:04 2019 +0900
@@ -16,7 +16,7 @@
     pycompat,
 )
 
-parsers = policy.importmod(r'parsers')
+parsers = policy.importmod('parsers')
 
 
 def commonancestorsheads(pfunc, *nodes):
--- a/mercurial/archival.py	Wed Nov 20 19:07:02 2019 +0100
+++ b/mercurial/archival.py	Fri Nov 22 21:42:04 2019 +0900
@@ -138,8 +138,8 @@
     class GzipFileWithTime(gzip.GzipFile):
         def __init__(self, *args, **kw):
             timestamp = None
-            if r'timestamp' in kw:
-                timestamp = kw.pop(r'timestamp')
+            if 'timestamp' in kw:
+                timestamp = kw.pop('timestamp')
             if timestamp is None:
                 self.timestamp = time.time()
             else:
@@ -154,9 +154,11 @@
                 fname = fname[:-3]
             flags = 0
             if fname:
-                flags = gzip.FNAME
+                flags = gzip.FNAME  # pytype: disable=module-attr
             self.fileobj.write(pycompat.bytechr(flags))
-            gzip.write32u(self.fileobj, int(self.timestamp))
+            gzip.write32u(  # pytype: disable=module-attr
+                self.fileobj, int(self.timestamp)
+            )
             self.fileobj.write(b'\002')
             self.fileobj.write(b'\377')
             if fname:
@@ -179,7 +181,7 @@
                     timestamp=mtime,
                 )
                 self.fileobj = gzfileobj
-                return tarfile.TarFile.taropen(
+                return tarfile.TarFile.taropen(  # pytype: disable=attribute-error
                     name, pycompat.sysstr(mode), gzfileobj
                 )
             else:
@@ -220,7 +222,7 @@
         if isinstance(dest, bytes):
             dest = pycompat.fsdecode(dest)
         self.z = zipfile.ZipFile(
-            dest, r'w', compress and zipfile.ZIP_DEFLATED or zipfile.ZIP_STORED
+            dest, 'w', compress and zipfile.ZIP_DEFLATED or zipfile.ZIP_STORED
         )
 
         # Python's zipfile module emits deprecation warnings if we try
@@ -234,7 +236,7 @@
 
     def addfile(self, name, mode, islink, data):
         i = zipfile.ZipInfo(pycompat.fsdecode(name), self.date_time)
-        i.compress_type = self.z.compression
+        i.compress_type = self.z.compression  # pytype: disable=attribute-error
         # unzip will not honor unix file modes unless file creator is
         # set to unix (id 3).
         i.create_system = 3
--- a/mercurial/bookmarks.py	Wed Nov 20 19:07:02 2019 +0100
+++ b/mercurial/bookmarks.py	Fri Nov 22 21:42:04 2019 +0900
@@ -78,7 +78,7 @@
         self._nodemap = nodemap = {}  # node: sorted([refspec, ...])
         self._clean = True
         self._aclean = True
-        nm = repo.changelog.nodemap
+        has_node = repo.changelog.index.has_node
         tonode = bin  # force local lookup
         try:
             with _getbkfile(repo) as bkfile:
@@ -89,7 +89,7 @@
                     try:
                         sha, refspec = line.split(b' ', 1)
                         node = tonode(sha)
-                        if node in nm:
+                        if has_node(node):
                             refspec = encoding.tolocal(refspec)
                             refmap[refspec] = node
                             nrefs = nodemap.get(node)
@@ -953,38 +953,43 @@
     cur = repo[b'.'].node()
     newact = None
     changes = []
-    hiddenrev = None
 
     # unhide revs if any
     if rev:
         repo = scmutil.unhidehashlikerevs(repo, [rev], b'nowarn')
 
+    ctx = scmutil.revsingle(repo, rev, None)
+    # bookmarking wdir means creating a bookmark on p1 and activating it
+    activatenew = not inactive and ctx.rev() is None
+    if ctx.node() is None:
+        ctx = ctx.p1()
+    tgt = ctx.node()
+    assert tgt
+
     for mark in names:
         mark = checkformat(repo, mark)
         if newact is None:
             newact = mark
         if inactive and mark == repo._activebookmark:
             deactivate(repo)
-            return
-        tgt = cur
-        if rev:
-            ctx = scmutil.revsingle(repo, rev)
-            if ctx.hidden():
-                hiddenrev = ctx.hex()[:12]
-            tgt = ctx.node()
+            continue
         for bm in marks.checkconflict(mark, force, tgt):
             changes.append((bm, None))
         changes.append((mark, tgt))
 
-    if hiddenrev:
-        repo.ui.warn(_(b"bookmarking hidden changeset %s\n") % hiddenrev)
+    # nothing changed but for the one deactivated above
+    if not changes:
+        return
+
+    if ctx.hidden():
+        repo.ui.warn(_(b"bookmarking hidden changeset %s\n") % ctx.hex()[:12])
 
         if ctx.obsolete():
-            msg = obsutil._getfilteredreason(repo, b"%s" % hiddenrev, ctx)
+            msg = obsutil._getfilteredreason(repo, ctx.hex()[:12], ctx)
             repo.ui.warn(b"(%s)\n" % msg)
 
     marks.applychanges(repo, tr, changes)
-    if not inactive and cur == marks[newact] and not rev:
+    if activatenew and cur == marks[newact]:
         activate(repo, newact)
     elif cur != tgt and newact == repo._activebookmark:
         deactivate(repo)
--- a/mercurial/branchmap.py	Wed Nov 20 19:07:02 2019 +0100
+++ b/mercurial/branchmap.py	Fri Nov 22 21:42:04 2019 +0900
@@ -27,6 +27,23 @@
     stringutil,
 )
 
+if not globals():
+    from typing import (
+        Any,
+        Callable,
+        Dict,
+        Iterable,
+        List,
+        Optional,
+        Set,
+        Tuple,
+        Union,
+    )
+
+    assert any(
+        (Any, Callable, Dict, Iterable, List, Optional, Set, Tuple, Union,)
+    )
+
 subsettable = repoviewutil.subsettable
 
 calcsize = struct.calcsize
@@ -90,14 +107,14 @@
         clrev = cl.rev
         clbranchinfo = cl.branchinfo
         rbheads = []
-        closed = []
+        closed = set()
         for bheads in pycompat.itervalues(remotebranchmap):
             rbheads += bheads
             for h in bheads:
                 r = clrev(h)
                 b, c = clbranchinfo(r)
                 if c:
-                    closed.append(h)
+                    closed.add(h)
 
         if rbheads:
             rtiprev = max((int(clrev(node)) for node in rbheads))
@@ -124,7 +141,7 @@
 def _unknownnode(node):
     """ raises ValueError when branchcache found a node which does not exists
     """
-    raise ValueError(r'node %s does not exist' % pycompat.sysstr(hex(node)))
+    raise ValueError('node %s does not exist' % pycompat.sysstr(hex(node)))
 
 
 def _branchcachedesc(repo):
@@ -165,6 +182,7 @@
         closednodes=None,
         hasnode=None,
     ):
+        # type: (Union[Dict[bytes, List[bytes]], Iterable[Tuple[bytes, List[bytes]]]], bytes,  int, Optional[bytes], Optional[Set[bytes]], Optional[Callable[[bytes], bool]]) -> None
         """ hasnode is a function which can be used to verify whether changelog
         has a given node or not. If it's not provided, we assume that every node
         we have exists in changelog """
@@ -260,7 +278,7 @@
             )
             if not bcache.validfor(repo):
                 # invalidate the cache
-                raise ValueError(r'tip differs')
+                raise ValueError('tip differs')
             bcache.load(repo, lineiter)
         except (IOError, OSError):
             return None
@@ -269,7 +287,13 @@
             if repo.ui.debugflag:
                 msg = b'invalid %s: %s\n'
                 repo.ui.debug(
-                    msg % (_branchcachedesc(repo), pycompat.bytestr(inst))
+                    msg
+                    % (
+                        _branchcachedesc(repo),
+                        pycompat.bytestr(
+                            inst  # pytype: disable=wrong-arg-types
+                        ),
+                    )
                 )
             bcache = None
 
@@ -288,7 +312,7 @@
                 continue
             node, state, label = line.split(b" ", 2)
             if state not in b'oc':
-                raise ValueError(r'invalid branch state')
+                raise ValueError('invalid branch state')
             label = encoding.tolocal(label.strip())
             node = bin(node)
             self._entries.setdefault(label, []).append(node)
@@ -640,7 +664,7 @@
         #   self.branchinfo = self._branchinfo
         #
         # Since we now have data in the cache, we need to drop this bypassing.
-        if r'branchinfo' in vars(self):
+        if 'branchinfo' in vars(self):
             del self.branchinfo
 
     def _setcachedata(self, rev, node, branchidx):
--- a/mercurial/bundle2.py	Wed Nov 20 19:07:02 2019 +0100
+++ b/mercurial/bundle2.py	Fri Nov 22 21:42:04 2019 +0900
@@ -653,7 +653,9 @@
         """add a stream level parameter"""
         if not name:
             raise error.ProgrammingError(b'empty parameter name')
-        if name[0:1] not in pycompat.bytestr(string.ascii_letters):
+        if name[0:1] not in pycompat.bytestr(
+            string.ascii_letters  # pytype: disable=wrong-arg-types
+        ):
             raise error.ProgrammingError(
                 b'non letter first character: %s' % name
             )
@@ -835,9 +837,11 @@
               ignored or failing.
         """
         if not name:
-            raise ValueError(r'empty parameter name')
-        if name[0:1] not in pycompat.bytestr(string.ascii_letters):
-            raise ValueError(r'non letter first character: %s' % name)
+            raise ValueError('empty parameter name')
+        if name[0:1] not in pycompat.bytestr(
+            string.ascii_letters  # pytype: disable=wrong-arg-types
+        ):
+            raise ValueError('non letter first character: %s' % name)
         try:
             handler = b2streamparamsmap[name.lower()]
         except KeyError:
@@ -1141,8 +1145,8 @@
             headerchunk = b''.join(header)
         except TypeError:
             raise TypeError(
-                r'Found a non-bytes trying to '
-                r'build bundle part header: %r' % header
+                'Found a non-bytes trying to '
+                'build bundle part header: %r' % header
             )
         outdebug(ui, b'header chunk size: %i' % len(headerchunk))
         yield _pack(_fpartheadersize, len(headerchunk))
@@ -1793,7 +1797,7 @@
 
 
 def addpartbundlestream2(bundler, repo, **kwargs):
-    if not kwargs.get(r'stream', False):
+    if not kwargs.get('stream', False):
         return
 
     if not streamclone.allowservergeneration(repo):
@@ -1815,8 +1819,8 @@
     bundler.prefercompressed = False
 
     # get the includes and excludes
-    includepats = kwargs.get(r'includepats')
-    excludepats = kwargs.get(r'excludepats')
+    includepats = kwargs.get('includepats')
+    excludepats = kwargs.get('excludepats')
 
     narrowstream = repo.ui.configbool(
         b'experimental', b'server.stream-narrow-clones'
@@ -1985,7 +1989,7 @@
     extrakwargs = {}
     targetphase = inpart.params.get(b'targetphase')
     if targetphase is not None:
-        extrakwargs[r'targetphase'] = int(targetphase)
+        extrakwargs['targetphase'] = int(targetphase)
     ret = _processchangegroup(
         op,
         cg,
--- a/mercurial/bundlerepo.py	Wed Nov 20 19:07:02 2019 +0100
+++ b/mercurial/bundlerepo.py	Fri Nov 22 21:42:04 2019 +0900
@@ -64,18 +64,18 @@
             start = cgunpacker.tell() - size
 
             link = linkmapper(cs)
-            if node in self.nodemap:
+            if self.index.has_node(node):
                 # this can happen if two branches make the same change
-                self.bundlerevs.add(self.nodemap[node])
+                self.bundlerevs.add(self.index.rev(node))
                 continue
 
             for p in (p1, p2):
-                if p not in self.nodemap:
+                if not self.index.has_node(p):
                     raise error.LookupError(
                         p, self.indexfile, _(b"unknown parent")
                     )
 
-            if deltabase not in self.nodemap:
+            if not self.index.has_node(deltabase):
                 raise LookupError(
                     deltabase, self.indexfile, _(b'unknown delta base')
                 )
@@ -93,7 +93,6 @@
                 node,
             )
             self.index.append(e)
-            self.nodemap[node] = n
             self.bundlerevs.add(n)
             n += 1
 
@@ -331,7 +330,7 @@
         fdtemp, temp = self.vfs.mkstemp(prefix=b"hg-bundle-", suffix=suffix)
         self.tempfile = temp
 
-        with os.fdopen(fdtemp, r'wb') as fptemp:
+        with os.fdopen(fdtemp, 'wb') as fptemp:
             fptemp.write(header)
             while True:
                 chunk = readfn(2 ** 18)
@@ -393,7 +392,7 @@
         # manifestlog implementation did not consume the manifests from the
         # changegroup (ex: it might be consuming trees from a separate bundle2
         # part instead). So we need to manually consume it.
-        if r'filestart' not in self.__dict__:
+        if 'filestart' not in self.__dict__:
             self._consumemanifest()
 
         return self.filestart
--- a/mercurial/cext/dirs.c	Wed Nov 20 19:07:02 2019 +0100
+++ b/mercurial/cext/dirs.c	Fri Nov 22 21:42:04 2019 +0900
@@ -9,6 +9,7 @@
 
 #define PY_SSIZE_T_CLEAN
 #include <Python.h>
+#include <string.h>
 
 #include "util.h"
 
@@ -48,12 +49,19 @@
 	return pos;
 }
 
+/* Mercurial will fail to run on directory hierarchies deeper than
+ * this constant, so we should try and keep this constant as big as
+ * possible.
+ */
+#define MAX_DIRS_DEPTH 2048
+
 static int _addpath(PyObject *dirs, PyObject *path)
 {
 	const char *cpath = PyBytes_AS_STRING(path);
 	Py_ssize_t pos = PyBytes_GET_SIZE(path);
 	PyObject *key = NULL;
 	int ret = -1;
+	size_t num_slashes = 0;
 
 	/* This loop is super critical for performance. That's why we inline
 	 * access to Python structs instead of going through a supported API.
@@ -65,6 +73,20 @@
 	 * unnoticed. */
 	while ((pos = _finddir(cpath, pos - 1)) != -1) {
 		PyObject *val;
+		++num_slashes;
+		if (num_slashes > MAX_DIRS_DEPTH) {
+			PyErr_SetString(PyExc_ValueError,
+			                "Directory hierarchy too deep.");
+			goto bail;
+		}
+
+		/* Sniff for trailing slashes, a marker of an invalid input. */
+		if (pos > 0 && cpath[pos - 1] == '/') {
+			PyErr_SetString(
+			    PyExc_ValueError,
+			    "found invalid consecutive slashes in path");
+			goto bail;
+		}
 
 		key = PyBytes_FromStringAndSize(cpath, pos);
 		if (key == NULL)
--- a/mercurial/cext/parsers.c	Wed Nov 20 19:07:02 2019 +0100
+++ b/mercurial/cext/parsers.c	Fri Nov 22 21:42:04 2019 +0900
@@ -667,7 +667,7 @@
 void manifest_module_init(PyObject *mod);
 void revlog_module_init(PyObject *mod);
 
-static const int version = 13;
+static const int version = 16;
 
 static void module_init(PyObject *mod)
 {
--- a/mercurial/cext/revlog.c	Wed Nov 20 19:07:02 2019 +0100
+++ b/mercurial/cext/revlog.c	Fri Nov 22 21:42:04 2019 +0900
@@ -62,10 +62,9 @@
  * This class has two behaviors.
  *
  * When used in a list-like way (with integer keys), we decode an
- * entry in a RevlogNG index file on demand. Our last entry is a
- * sentinel, always a nullid.  We have limited support for
+ * entry in a RevlogNG index file on demand. We have limited support for
  * integer-keyed insert and delete, only at elements right before the
- * sentinel.
+ * end.
  *
  * With string keys, we lazily perform a reverse mapping from node to
  * rev, using a base-16 trie.
@@ -2065,6 +2064,29 @@
 	}
 }
 
+static PyObject *index_m_has_node(indexObject *self, PyObject *args)
+{
+	int ret = index_contains(self, args);
+	if (ret < 0)
+		return NULL;
+	return PyBool_FromLong((long)ret);
+}
+
+static PyObject *index_m_rev(indexObject *self, PyObject *val)
+{
+	char *node;
+	int rev;
+
+	if (node_check(val, &node) == -1)
+		return NULL;
+	rev = index_find_node(self, node, 20);
+	if (rev >= -1)
+		return PyInt_FromLong(rev);
+	if (rev == -2)
+		raise_revlog_error();
+	return NULL;
+}
+
 typedef uint64_t bitmask;
 
 /*
@@ -2443,7 +2465,7 @@
 
 /*
  * Delete a numeric range of revs, which must be at the end of the
- * range, but exclude the sentinel nullid entry.
+ * range.
  */
 static int index_slice_del(indexObject *self, PyObject *item)
 {
@@ -2489,7 +2511,7 @@
 		if (self->ntinitialized) {
 			Py_ssize_t i;
 
-			for (i = start + 1; i < self->length; i++) {
+			for (i = start; i < self->length; i++) {
 				const char *node = index_node_existing(self, i);
 				if (node == NULL)
 					return -1;
@@ -2723,6 +2745,12 @@
     {"clearcaches", (PyCFunction)index_clearcaches, METH_NOARGS,
      "clear the index caches"},
     {"get", (PyCFunction)index_m_get, METH_VARARGS, "get an index entry"},
+    {"get_rev", (PyCFunction)index_m_get, METH_VARARGS,
+     "return `rev` associated with a node or None"},
+    {"has_node", (PyCFunction)index_m_has_node, METH_O,
+     "return True if the node exist in the index"},
+    {"rev", (PyCFunction)index_m_rev, METH_O,
+     "return `rev` associated with a node or raise RevlogError"},
     {"computephasesmapsets", (PyCFunction)compute_phases_map_sets, METH_VARARGS,
      "compute phases"},
     {"reachableroots2", (PyCFunction)reachableroots2, METH_VARARGS,
--- a/mercurial/changegroup.py	Wed Nov 20 19:07:02 2019 +0100
+++ b/mercurial/changegroup.py	Fri Nov 22 21:42:04 2019 +0900
@@ -85,7 +85,7 @@
                 fh = open(filename, b"wb", 131072)
         else:
             fd, filename = pycompat.mkstemp(prefix=b"hg-bundle-", suffix=b".hg")
-            fh = os.fdopen(fd, r"wb")
+            fh = os.fdopen(fd, "wb")
         cleanup = filename
         for c in chunks:
             fh.write(c)
@@ -315,15 +315,15 @@
             )
             self.callback = progress.increment
 
-            efiles = set()
+            efilesset = set()
 
             def onchangelog(cl, node):
-                efiles.update(cl.readfiles(node))
+                efilesset.update(cl.readfiles(node))
 
             self.changelogheader()
             deltas = self.deltaiter()
             cgnodes = cl.addgroup(deltas, csmap, trp, addrevisioncb=onchangelog)
-            efiles = len(efiles)
+            efiles = len(efilesset)
 
             if not cgnodes:
                 repo.ui.develwarn(
@@ -1150,7 +1150,9 @@
         def makelookupmflinknode(tree, nodes):
             if fastpathlinkrev:
                 assert not tree
-                return manifests.__getitem__
+                return (
+                    manifests.__getitem__  # pytype: disable=unsupported-operands
+                )
 
             def lookupmflinknode(x):
                 """Callback for looking up the linknode for manifests.
--- a/mercurial/changelog.py	Wed Nov 20 19:07:02 2019 +0100
+++ b/mercurial/changelog.py	Fri Nov 22 21:42:04 2019 +0900
@@ -21,7 +21,6 @@
     error,
     pycompat,
     revlog,
-    util,
 )
 from .utils import (
     dateutil,
@@ -212,10 +211,10 @@
     """
 
     __slots__ = (
-        r'_offsets',
-        r'_text',
-        r'_sidedata',
-        r'_cpsd',
+        '_offsets',
+        '_text',
+        '_sidedata',
+        '_cpsd',
     )
 
     def __new__(cls, text, sidedata, cpsd):
@@ -405,110 +404,6 @@
         self.filteredrevs = frozenset()
         self._copiesstorage = opener.options.get(b'copies-storage')
 
-    def tiprev(self):
-        for i in pycompat.xrange(len(self) - 1, -2, -1):
-            if i not in self.filteredrevs:
-                return i
-
-    def tip(self):
-        """filtered version of revlog.tip"""
-        return self.node(self.tiprev())
-
-    def __contains__(self, rev):
-        """filtered version of revlog.__contains__"""
-        return 0 <= rev < len(self) and rev not in self.filteredrevs
-
-    def __iter__(self):
-        """filtered version of revlog.__iter__"""
-        if len(self.filteredrevs) == 0:
-            return revlog.revlog.__iter__(self)
-
-        def filterediter():
-            for i in pycompat.xrange(len(self)):
-                if i not in self.filteredrevs:
-                    yield i
-
-        return filterediter()
-
-    def revs(self, start=0, stop=None):
-        """filtered version of revlog.revs"""
-        for i in super(changelog, self).revs(start, stop):
-            if i not in self.filteredrevs:
-                yield i
-
-    def _checknofilteredinrevs(self, revs):
-        """raise the appropriate error if 'revs' contains a filtered revision
-
-        This returns a version of 'revs' to be used thereafter by the caller.
-        In particular, if revs is an iterator, it is converted into a set.
-        """
-        safehasattr = util.safehasattr
-        if safehasattr(revs, '__next__'):
-            # Note that inspect.isgenerator() is not true for iterators,
-            revs = set(revs)
-
-        filteredrevs = self.filteredrevs
-        if safehasattr(revs, 'first'):  # smartset
-            offenders = revs & filteredrevs
-        else:
-            offenders = filteredrevs.intersection(revs)
-
-        for rev in offenders:
-            raise error.FilteredIndexError(rev)
-        return revs
-
-    def headrevs(self, revs=None):
-        if revs is None and self.filteredrevs:
-            try:
-                return self.index.headrevsfiltered(self.filteredrevs)
-            # AttributeError covers non-c-extension environments and
-            # old c extensions without filter handling.
-            except AttributeError:
-                return self._headrevs()
-
-        if self.filteredrevs:
-            revs = self._checknofilteredinrevs(revs)
-        return super(changelog, self).headrevs(revs)
-
-    def strip(self, *args, **kwargs):
-        # XXX make something better than assert
-        # We can't expect proper strip behavior if we are filtered.
-        assert not self.filteredrevs
-        super(changelog, self).strip(*args, **kwargs)
-
-    def rev(self, node):
-        """filtered version of revlog.rev"""
-        r = super(changelog, self).rev(node)
-        if r in self.filteredrevs:
-            raise error.FilteredLookupError(
-                hex(node), self.indexfile, _(b'filtered node')
-            )
-        return r
-
-    def node(self, rev):
-        """filtered version of revlog.node"""
-        if rev in self.filteredrevs:
-            raise error.FilteredIndexError(rev)
-        return super(changelog, self).node(rev)
-
-    def linkrev(self, rev):
-        """filtered version of revlog.linkrev"""
-        if rev in self.filteredrevs:
-            raise error.FilteredIndexError(rev)
-        return super(changelog, self).linkrev(rev)
-
-    def parentrevs(self, rev):
-        """filtered version of revlog.parentrevs"""
-        if rev in self.filteredrevs:
-            raise error.FilteredIndexError(rev)
-        return super(changelog, self).parentrevs(rev)
-
-    def flags(self, rev):
-        """filtered version of revlog.flags"""
-        if rev in self.filteredrevs:
-            raise error.FilteredIndexError(rev)
-        return super(changelog, self).flags(rev)
-
     def delayupdate(self, tr):
         b"delay visibility of index updates to other readers"
 
--- a/mercurial/chgserver.py	Wed Nov 20 19:07:02 2019 +0100
+++ b/mercurial/chgserver.py	Fri Nov 22 21:42:04 2019 +0900
@@ -345,9 +345,9 @@
 
 _iochannels = [
     # server.ch, ui.fp, mode
-    (b'cin', b'fin', r'rb'),
-    (b'cout', b'fout', r'wb'),
-    (b'cerr', b'ferr', r'wb'),
+    (b'cin', b'fin', 'rb'),
+    (b'cout', b'fout', 'wb'),
+    (b'cerr', b'ferr', 'wb'),
 ]
 
 
@@ -505,7 +505,7 @@
         path = self._readstr()
         if not path:
             return
-        self.ui.log(b'chgserver', b'chdir to %r\n', path)
+        self.ui.log(b'chgserver', b"chdir to '%s'\n", path)
         os.chdir(path)
 
     def setumask(self):
--- a/mercurial/cmdutil.py	Wed Nov 20 19:07:02 2019 +0100
+++ b/mercurial/cmdutil.py	Fri Nov 22 21:42:04 2019 +0900
@@ -61,6 +61,15 @@
     stringutil,
 )
 
+if not globals():
+    from typing import (
+        Any,
+        Dict,
+    )
+
+    for t in (Any, Dict):
+        assert t
+
 stringio = util.stringio
 
 # templates of common command options
@@ -320,7 +329,7 @@
 def setupwrapcolorwrite(ui):
     # wrap ui.write so diff output can be labeled/colorized
     def wrapwrite(orig, *args, **kw):
-        label = kw.pop(r'label', b'')
+        label = kw.pop('label', b'')
         for chunk, l in patch.difflabel(lambda: args):
             orig(chunk, label=label + l)
 
@@ -347,7 +356,7 @@
                 ui, originalhunks, recordfn, operation
             )
     except crecordmod.fallbackerror as e:
-        ui.warn(b'%s\n' % e.message)
+        ui.warn(b'%s\n' % e.message)  # pytype: disable=attribute-error
         ui.warn(_(b'falling back to text mode\n'))
 
     return patch.filterpatch(ui, originalhunks, match, operation)
@@ -418,9 +427,7 @@
 
         force = opts.get(b'force')
         if not force:
-            vdirs = []
             match = matchmod.badmatch(match, fail)
-            match.explicitdir = vdirs.append
 
         status = repo.status(match=match)
 
@@ -429,13 +436,13 @@
         with repo.ui.configoverride(overrides, b'record'):
             # subrepoutil.precommit() modifies the status
             tmpstatus = scmutil.status(
-                copymod.copy(status[0]),
-                copymod.copy(status[1]),
-                copymod.copy(status[2]),
-                copymod.copy(status[3]),
-                copymod.copy(status[4]),
-                copymod.copy(status[5]),
-                copymod.copy(status[6]),
+                copymod.copy(status.modified),
+                copymod.copy(status.added),
+                copymod.copy(status.removed),
+                copymod.copy(status.deleted),
+                copymod.copy(status.unknown),
+                copymod.copy(status.ignored),
+                copymod.copy(status.clean),  # pytype: disable=wrong-arg-count
             )
 
             # Force allows -X subrepo to skip the subrepo.
@@ -448,7 +455,7 @@
                     raise error.Abort(dirtyreason)
 
         if not force:
-            repo.checkcommitpatterns(wctx, vdirs, match, status, fail)
+            repo.checkcommitpatterns(wctx, match, status, fail)
         diffopts = patch.difffeatureopts(
             ui,
             opts=opts,
@@ -761,7 +768,7 @@
         tersedict[st].sort()
         tersedlist.append(tersedict[st])
 
-    return tersedlist
+    return scmutil.status(*tersedlist)
 
 
 def _commentlines(raw):
@@ -991,8 +998,8 @@
 
     if merge and repo.dirstate.p2() != nullid:
         raise error.Abort(_(b'outstanding uncommitted merge'), hint=hint)
-    modified, added, removed, deleted = repo.status()[:4]
-    if modified or added or removed or deleted:
+    st = repo.status()
+    if st.modified or st.added or st.removed or st.deleted:
         raise error.Abort(_(b'uncommitted changes'), hint=hint)
     ctx = repo[None]
     for s in sorted(ctx.substate):
@@ -1289,7 +1296,7 @@
             if isinstance(r, revlog.revlog):
                 pass
             elif util.safehasattr(r, b'_revlog'):
-                r = r._revlog
+                r = r._revlog  # pytype: disable=attribute-error
             elif r is not None:
                 raise error.Abort(_(b'%r does not appear to be a revlog') % r)
 
@@ -1764,6 +1771,8 @@
             overrides = {}
             if partial:
                 overrides[(b'ui', b'allowemptycommit')] = True
+            if opts.get(b'secret'):
+                overrides[(b'phases', b'new-commit')] = b'secret'
             with repo.ui.configoverride(overrides, b'import'):
                 n = repo.commit(
                     message, user, date, match=m, editor=editor, extra=extra
@@ -2022,7 +2031,7 @@
         rev = ctx.rev()
         if rev in results:
             ui.status(
-                _(b"found revision %s from %s\n")
+                _(b"found revision %d from %s\n")
                 % (rev, dateutil.datestr(results[rev]))
             )
             return b'%d' % rev
@@ -2397,7 +2406,7 @@
             submatch = matchmod.subdirmatcher(subpath, match)
             subprefix = repo.wvfs.reljoin(prefix, subpath)
             subuipathfn = scmutil.subdiruipathfn(subpath, uipathfn)
-            if opts.get(r'subrepos'):
+            if opts.get('subrepos'):
                 bad.extend(
                     sub.add(ui, submatch, subprefix, subuipathfn, False, **opts)
                 )
@@ -2410,7 +2419,7 @@
                 _(b"skipping missing subrepository: %s\n") % uipathfn(subpath)
             )
 
-    if not opts.get(r'dry_run'):
+    if not opts.get('dry_run'):
         rejected = wctx.add(names, prefix)
         bad.extend(f for f in rejected if f in match.files())
     return bad
@@ -2565,7 +2574,7 @@
 ):
     ret = 0
     s = repo.status(match=m, clean=True)
-    modified, added, deleted, clean = s[0], s[1], s[3], s[6]
+    modified, added, deleted, clean = s.modified, s.added, s.deleted, s.clean
 
     wctx = repo[None]
 
@@ -2606,7 +2615,7 @@
     progress.complete()
 
     # warn about failure to delete explicit files/dirs
-    deleteddirs = util.dirs(deleted)
+    deleteddirs = pathutil.dirs(deleted)
     files = m.files()
     progress = ui.makeprogress(
         _(b'deleting'), total=len(files), unit=_(b'files')
@@ -2876,7 +2885,8 @@
         if len(old.parents()) > 1:
             # ctx.files() isn't reliable for merges, so fall back to the
             # slower repo.status() method
-            files = {fn for st in base.status(old)[:3] for fn in st}
+            st = base.status(old)
+            files = set(st.modified) | set(st.added) | set(st.removed)
         else:
             files = set(old.files())
 
@@ -3958,6 +3968,7 @@
 
 
 def readgraftstate(repo, graftstate):
+    # type: (Any, statemod.cmdstate) -> Dict[bytes, Any]
     """read the graft state file and return a dict of the data stored in it"""
     try:
         return graftstate.read()
--- a/mercurial/color.py	Wed Nov 20 19:07:02 2019 +0100
+++ b/mercurial/color.py	Fri Nov 22 21:42:04 2019 +0900
@@ -184,7 +184,7 @@
             # noisy and use ui.debug().
             ui.debug(b"no terminfo entry for %s\n" % e)
             del ui._terminfoparams[key]
-    if not curses.tigetstr(r'setaf') or not curses.tigetstr(r'setab'):
+    if not curses.tigetstr('setaf') or not curses.tigetstr('setab'):
         # Only warn about missing terminfo entries if we explicitly asked for
         # terminfo mode and we're in a formatted terminal.
         if mode == b"terminfo" and formatted:
@@ -353,9 +353,9 @@
         else:
             return curses.tigetstr(pycompat.sysstr(val))
     elif bg:
-        return curses.tparm(curses.tigetstr(r'setab'), val)
+        return curses.tparm(curses.tigetstr('setab'), val)
     else:
-        return curses.tparm(curses.tigetstr(r'setaf'), val)
+        return curses.tparm(curses.tigetstr('setaf'), val)
 
 
 def _mergeeffects(text, start, stop):
@@ -435,30 +435,30 @@
 if pycompat.iswindows:
     import ctypes
 
-    _kernel32 = ctypes.windll.kernel32
+    _kernel32 = ctypes.windll.kernel32  # pytype: disable=module-attr
 
     _WORD = ctypes.c_ushort
 
     _INVALID_HANDLE_VALUE = -1
 
     class _COORD(ctypes.Structure):
-        _fields_ = [(r'X', ctypes.c_short), (r'Y', ctypes.c_short)]
+        _fields_ = [('X', ctypes.c_short), ('Y', ctypes.c_short)]
 
     class _SMALL_RECT(ctypes.Structure):
         _fields_ = [
-            (r'Left', ctypes.c_short),
-            (r'Top', ctypes.c_short),
-            (r'Right', ctypes.c_short),
-            (r'Bottom', ctypes.c_short),
+            ('Left', ctypes.c_short),
+            ('Top', ctypes.c_short),
+            ('Right', ctypes.c_short),
+            ('Bottom', ctypes.c_short),
         ]
 
     class _CONSOLE_SCREEN_BUFFER_INFO(ctypes.Structure):
         _fields_ = [
-            (r'dwSize', _COORD),
-            (r'dwCursorPosition', _COORD),
-            (r'wAttributes', _WORD),
-            (r'srWindow', _SMALL_RECT),
-            (r'dwMaximumWindowSize', _COORD),
+            ('dwSize', _COORD),
+            ('dwCursorPosition', _COORD),
+            ('wAttributes', _WORD),
+            ('srWindow', _SMALL_RECT),
+            ('dwMaximumWindowSize', _COORD),
         ]
 
     _STD_OUTPUT_HANDLE = 0xFFFFFFF5  # (DWORD)-11
@@ -529,7 +529,7 @@
             )
 
     def win32print(ui, writefunc, text, **opts):
-        label = opts.get(r'label', b'')
+        label = opts.get('label', b'')
         attr = origattr
 
         def mapcolor(val, attr):
--- a/mercurial/commands.py	Wed Nov 20 19:07:02 2019 +0100
+++ b/mercurial/commands.py	Fri Nov 22 21:42:04 2019 +0900
@@ -180,7 +180,7 @@
 
     use --dry-run/-n to dry run the command.
     """
-    dryrun = opts.get(r'dry_run')
+    dryrun = opts.get('dry_run')
     abortstate = cmdutil.getunfinishedstate(repo)
     if not abortstate:
         raise error.Abort(_(b'no operation in progress'))
@@ -1073,7 +1073,7 @@
                 raise error.Abort(_(b'current bisect revision is a merge'))
         if rev:
             node = repo[scmutil.revsingle(repo, rev, node)].node()
-        try:
+        with hbisect.restore_state(repo, state, node):
             while changesets:
                 # update state
                 state[b'current'] = [node]
@@ -1105,9 +1105,6 @@
                 # update to next check
                 node = nodes[0]
                 mayupdate(repo, node, show_stats=False)
-        finally:
-            state[b'current'] = [node]
-            hbisect.save_state(repo, state)
         hbisect.printresult(ui, repo, state, displayer, nodes, bgood)
         return
 
@@ -2019,8 +2016,8 @@
 
 
 def _docommit(ui, repo, *pats, **opts):
-    if opts.get(r'interactive'):
-        opts.pop(r'interactive')
+    if opts.get('interactive'):
+        opts.pop('interactive')
         ret = cmdutil.dorecord(
             ui, repo, commit, None, False, cmdutil.recordfilter, *pats, **opts
         )
@@ -2116,13 +2113,13 @@
 
         if not node:
             stat = cmdutil.postcommitstatus(repo, pats, opts)
-            if stat[3]:
+            if stat.deleted:
                 ui.status(
                     _(
                         b"nothing changed (%d missing files, see "
                         b"'hg status')\n"
                     )
-                    % len(stat[3])
+                    % len(stat.deleted)
                 )
             else:
                 ui.status(_(b"nothing changed\n"))
@@ -2295,7 +2292,7 @@
 
     use --dry-run/-n to dry run the command.
     """
-    dryrun = opts.get(r'dry_run')
+    dryrun = opts.get('dry_run')
     contstate = cmdutil.getunfinishedstate(repo)
     if not contstate:
         raise error.Abort(_(b'no operation in progress'))
@@ -2375,7 +2372,7 @@
 def debugcomplete(ui, cmd=b'', **opts):
     """returns the completion list associated with the given command"""
 
-    if opts.get(r'options'):
+    if opts.get('options'):
         options = []
         otables = [globalopts]
         if cmd:
@@ -3446,6 +3443,9 @@
     def grepbody(fn, rev, body):
         matches[rev].setdefault(fn, [])
         m = matches[rev][fn]
+        if body is None:
+            return
+
         for lnum, cstart, cend, line in matchlines(body):
             s = linestate(line, lnum, cstart, cend)
             m.append(s)
@@ -3453,13 +3453,13 @@
     def difflinestates(a, b):
         sm = difflib.SequenceMatcher(None, a, b)
         for tag, alo, ahi, blo, bhi in sm.get_opcodes():
-            if tag == r'insert':
+            if tag == 'insert':
                 for i in pycompat.xrange(blo, bhi):
                     yield (b'+', b[i])
-            elif tag == r'delete':
+            elif tag == 'delete':
                 for i in pycompat.xrange(alo, ahi):
                     yield (b'-', a[i])
-            elif tag == r'replace':
+            elif tag == 'replace':
                 for i in pycompat.xrange(alo, ahi):
                     yield (b'-', a[i])
                 for i in pycompat.xrange(blo, bhi):
@@ -3581,6 +3581,19 @@
 
     getrenamed = scmutil.getrenamedfn(repo)
 
+    def get_file_content(filename, filelog, filenode, context, revision):
+        try:
+            content = filelog.read(filenode)
+        except error.WdirUnsupported:
+            content = context[filename].data()
+        except error.CensoredNodeError:
+            content = None
+            ui.warn(
+                _(b'cannot search in censored file: %(filename)s:%(revnum)s\n')
+                % {b'filename': filename, b'revnum': pycompat.bytestr(revision)}
+            )
+        return content
+
     def prep(ctx, fns):
         rev = ctx.rev()
         pctx = ctx.p1()
@@ -3607,17 +3620,15 @@
             files.append(fn)
 
             if fn not in matches[rev]:
-                try:
-                    content = flog.read(fnode)
-                except error.WdirUnsupported:
-                    content = ctx[fn].data()
+                content = get_file_content(fn, flog, fnode, ctx, rev)
                 grepbody(fn, rev, content)
 
             pfn = copy or fn
             if pfn not in matches[parent]:
                 try:
-                    fnode = pctx.filenode(pfn)
-                    grepbody(pfn, parent, flog.read(fnode))
+                    pfnode = pctx.filenode(pfn)
+                    pcontent = get_file_content(pfn, flog, pfnode, pctx, parent)
+                    grepbody(pfn, parent, pcontent)
                 except error.LookupError:
                     pass
 
@@ -3775,7 +3786,7 @@
     Returns 0 if successful.
     """
 
-    keep = opts.get(r'system') or []
+    keep = opts.get('system') or []
     if len(keep) == 0:
         if pycompat.sysplatform.startswith(b'win'):
             keep.append(b'windows')
@@ -4022,6 +4033,7 @@
             _(b'NUM'),
         ),
         (b'b', b'base', b'', _(b'base path (DEPRECATED)'), _(b'PATH')),
+        (b'', b'secret', None, _(b'use the secret phase for committing')),
         (b'e', b'edit', False, _(b'invoke editor on commit messages')),
         (
             b'f',
@@ -4170,6 +4182,8 @@
     update = not opts.get(b'bypass')
     if not update and opts.get(b'no_commit'):
         raise error.Abort(_(b'cannot use --no-commit with --bypass'))
+    if opts.get(b'secret') and opts.get(b'no_commit'):
+        raise error.Abort(_(b'cannot use --no-commit with --secret'))
     try:
         sim = float(opts.get(b'similarity') or 0)
     except ValueError:
@@ -5685,7 +5699,7 @@
     """
     ret = repo.recover()
     if ret:
-        if opts[r'verify']:
+        if opts['verify']:
             return hg.verify(repo)
         else:
             msg = _(
@@ -6330,7 +6344,7 @@
             _(b'rollback is disabled because it is unsafe'),
             hint=b'see `hg help -v rollback` for information',
         )
-    return repo.rollback(dryrun=opts.get(r'dry_run'), force=opts.get(r'force'))
+    return repo.rollback(dryrun=opts.get('dry_run'), force=opts.get('force'))
 
 
 @command(
@@ -6803,7 +6817,6 @@
         end = b'\0'
     else:
         end = b'\n'
-    copy = {}
     states = b'modified added removed deleted unknown ignored clean'.split()
     show = [k for k in states if opts.get(k)]
     if opts.get(b'all'):
@@ -6840,8 +6853,13 @@
             opts.get(b'subrepos'),
         )
 
-    changestates = zip(states, pycompat.iterbytestr(b'MAR!?IC'), stat)
-
+    changestates = zip(
+        states,
+        pycompat.iterbytestr(b'MAR!?IC'),
+        [getattr(stat, s.decode('utf8')) for s in states],
+    )
+
+    copy = {}
     if (
         opts.get(b'all')
         or opts.get(b'copies')
@@ -7480,7 +7498,7 @@
                 )
             modheads = bundle2.combinechangegroupresults(op)
 
-    return postincoming(ui, repo, modheads, opts.get(r'update'), None, None)
+    return postincoming(ui, repo, modheads, opts.get('update'), None, None)
 
 
 @command(
@@ -7511,7 +7529,7 @@
             _(b'DATE'),
         ),
     ],
-    _(b'hg unshelve [OPTION]... [FILE]... [-n SHELVED]'),
+    _(b'hg unshelve [OPTION]... [[-n] SHELVED]'),
     helpcategory=command.CATEGORY_WORKING_DIRECTORY,
 )
 def unshelve(ui, repo, *shelved, **opts):
@@ -7535,9 +7553,9 @@
     that causes a conflict. This reverts the unshelved changes, and
     leaves the bundle in place.)
 
-    If bare shelved change (when no files are specified, without interactive,
-    include and exclude option) was done on newly created branch it would
-    restore branch information to the working directory.
+    If bare shelved change (without interactive, include and exclude
+    option) was done on newly created branch it would restore branch
+    information to the working directory.
 
     After a successful unshelve, the shelved changes are stored in a
     backup directory. Only the N most recent backups are kept. N
@@ -7641,11 +7659,11 @@
 
     Returns 0 on success, 1 if there are unresolved files.
     """
-    rev = opts.get(r'rev')
-    date = opts.get(r'date')
-    clean = opts.get(r'clean')
-    check = opts.get(r'check')
-    merge = opts.get(r'merge')
+    rev = opts.get('rev')
+    date = opts.get('date')
+    clean = opts.get('clean')
+    check = opts.get('check')
+    merge = opts.get('merge')
     if rev and node:
         raise error.Abort(_(b"please specify just one revision"))
 
@@ -7688,7 +7706,7 @@
         ctx = scmutil.revsingle(repo, rev, default=None)
         rev = ctx.rev()
         hidden = ctx.hidden()
-        overrides = {(b'ui', b'forcemerge'): opts.get(r'tool', b'')}
+        overrides = {(b'ui', b'forcemerge'): opts.get('tool', b'')}
         with ui.configoverride(overrides, b'update'):
             ret = hg.updatetotally(
                 ui, repo, rev, brev, clean=clean, updatecheck=updatecheck
--- a/mercurial/commandserver.py	Wed Nov 20 19:07:02 2019 +0100
+++ b/mercurial/commandserver.py	Fri Nov 22 21:42:04 2019 +0900
@@ -64,7 +64,7 @@
         self.out.flush()
 
     def __getattr__(self, attr):
-        if attr in (r'isatty', r'fileno', r'tell', r'seek'):
+        if attr in ('isatty', 'fileno', 'tell', 'seek'):
             raise AttributeError(attr)
         return getattr(self.out, attr)
 
@@ -180,7 +180,7 @@
     __next__ = next
 
     def __getattr__(self, attr):
-        if attr in (r'isatty', r'fileno', r'tell', r'seek'):
+        if attr in ('isatty', 'fileno', 'tell', 'seek'):
             raise AttributeError(attr)
         return getattr(self.in_, attr)
 
@@ -450,8 +450,8 @@
 
 
 def _serverequest(ui, repo, conn, createcmdserver, prereposetups):
-    fin = conn.makefile(r'rb')
-    fout = conn.makefile(r'wb')
+    fin = conn.makefile('rb')
+    fout = conn.makefile('wb')
     sv = None
     try:
         sv = createcmdserver(repo, conn, fin, fout, prereposetups)
--- a/mercurial/config.py	Wed Nov 20 19:07:02 2019 +0100
+++ b/mercurial/config.py	Fri Nov 22 21:42:04 2019 +0900
@@ -212,7 +212,7 @@
     def read(self, path, fp=None, sections=None, remap=None):
         if not fp:
             fp = util.posixfile(path, b'rb')
-        assert getattr(fp, 'mode', r'rb') == r'rb', (
+        assert getattr(fp, 'mode', 'rb') == 'rb', (
             b'config files must be opened in binary mode, got fp=%r mode=%r'
             % (fp, fp.mode,)
         )
--- a/mercurial/context.py	Wed Nov 20 19:07:02 2019 +0100
+++ b/mercurial/context.py	Fri Nov 22 21:42:04 2019 +0900
@@ -71,7 +71,7 @@
     __str__ = encoding.strmethod(__bytes__)
 
     def __repr__(self):
-        return r"<%s %s>" % (type(self).__name__, str(self))
+        return "<%s %s>" % (type(self).__name__, str(self))
 
     def __eq__(self, other):
         try:
@@ -265,14 +265,14 @@
         return self._repo[nullrev]
 
     def _fileinfo(self, path):
-        if r'_manifest' in self.__dict__:
+        if '_manifest' in self.__dict__:
             try:
                 return self._manifest[path], self._manifest.flags(path)
             except KeyError:
                 raise error.ManifestLookupError(
                     self._node, path, _(b'not found in manifest')
                 )
-        if r'_manifestdelta' in self.__dict__ or path in self.files():
+        if '_manifestdelta' in self.__dict__ or path in self.files():
             if path in self._manifestdelta:
                 return (
                     self._manifestdelta[path],
@@ -449,11 +449,25 @@
                     unknown=listunknown,
                     listsubrepos=True,
                 )
-                for rfiles, sfiles in zip(r, s):
+                for k in (
+                    'modified',
+                    'added',
+                    'removed',
+                    'deleted',
+                    'unknown',
+                    'ignored',
+                    'clean',
+                ):
+                    rfiles, sfiles = getattr(r, k), getattr(s, k)
                     rfiles.extend(b"%s/%s" % (subpath, f) for f in sfiles)
 
-        for l in r:
-            l.sort()
+        r.modified.sort()
+        r.added.sort()
+        r.removed.sort()
+        r.deleted.sort()
+        r.unknown.sort()
+        r.ignored.sort()
+        r.clean.sort()
 
         return r
 
@@ -746,9 +760,9 @@
 
     @propertycache
     def _changeid(self):
-        if r'_changectx' in self.__dict__:
+        if '_changectx' in self.__dict__:
             return self._changectx.rev()
-        elif r'_descendantrev' in self.__dict__:
+        elif '_descendantrev' in self.__dict__:
             # this file context was created from a revision with a known
             # descendant, we can (lazily) correct for linkrev aliases
             return self._adjustlinkrev(self._descendantrev)
@@ -757,7 +771,7 @@
 
     @propertycache
     def _filenode(self):
-        if r'_fileid' in self.__dict__:
+        if '_fileid' in self.__dict__:
             return self._filelog.lookup(self._fileid)
         else:
             return self._changectx.filenode(self._path)
@@ -789,7 +803,7 @@
     __str__ = encoding.strmethod(__bytes__)
 
     def __repr__(self):
-        return r"<%s %s>" % (type(self).__name__, str(self))
+        return "<%s %s>" % (type(self).__name__, str(self))
 
     def __hash__(self):
         try:
@@ -1024,16 +1038,16 @@
         """
         toprev = None
         attrs = vars(self)
-        if r'_changeid' in attrs:
+        if '_changeid' in attrs:
             # We have a cached value already
             toprev = self._changeid
-        elif r'_changectx' in attrs:
+        elif '_changectx' in attrs:
             # We know which changelog entry we are coming from
             toprev = self._changectx.rev()
 
         if toprev is not None:
             return self._adjustlinkrev(toprev, inclusive=True, stoprev=stoprev)
-        elif r'_descendantrev' in attrs:
+        elif '_descendantrev' in attrs:
             introrev = self._adjustlinkrev(self._descendantrev, stoprev=stoprev)
             # be nice and cache the result of the computation
             if introrev is not None:
@@ -1053,14 +1067,14 @@
     def _parentfilectx(self, path, fileid, filelog):
         """create parent filectx keeping ancestry info for _adjustlinkrev()"""
         fctx = filectx(self._repo, path, fileid=fileid, filelog=filelog)
-        if r'_changeid' in vars(self) or r'_changectx' in vars(self):
+        if '_changeid' in vars(self) or '_changectx' in vars(self):
             # If self is associated with a changeset (probably explicitly
             # fed), ensure the created filectx is associated with a
             # changeset that is an ancestor of self.changectx.
             # This lets us later use _adjustlinkrev to get a correct link.
             fctx._descendantrev = self.rev()
             fctx._ancestrycontext = getattr(self, '_ancestrycontext', None)
-        elif r'_descendantrev' in vars(self):
+        elif '_descendantrev' in vars(self):
             # Otherwise propagate _descendantrev if we have one associated.
             fctx._descendantrev = self._descendantrev
             fctx._ancestrycontext = getattr(self, '_ancestrycontext', None)
@@ -1120,7 +1134,7 @@
             # renamed filectx won't have a filelog yet, so set it
             # from the cache to save time
             for p in pl:
-                if not r'_filelog' in p.__dict__:
+                if not '_filelog' in p.__dict__:
                     p._filelog = getlog(p.path())
 
             return pl
@@ -1534,7 +1548,7 @@
         return self._repo.dirstate.flagfunc(self._buildflagfunc)
 
     def flags(self, path):
-        if r'_manifest' in self.__dict__:
+        if '_manifest' in self.__dict__:
             try:
                 return self._manifest.flags(path)
             except KeyError:
@@ -2080,7 +2094,7 @@
             # warned and backed up
             if wvfs.isdir(f) and not wvfs.islink(f):
                 wvfs.rmtree(f, forcibly=True)
-            for p in reversed(list(util.finddirs(f))):
+            for p in reversed(list(pathutil.finddirs(f))):
                 if wvfs.isfileorlink(p):
                     wvfs.unlink(p)
                     break
--- a/mercurial/crecord.py	Wed Nov 20 19:07:02 2019 +0100
+++ b/mercurial/crecord.py	Fri Nov 22 21:42:04 2019 +0900
@@ -522,7 +522,7 @@
         return getattr(self._hunk, name)
 
     def __repr__(self):
-        return r'<hunk %r@%d>' % (self.filename(), self.fromline)
+        return '<hunk %r@%d>' % (self.filename(), self.fromline)
 
 
 def filterpatch(ui, chunks, chunkselector, operation=None):
@@ -569,7 +569,7 @@
     chunkselector = curseschunkselector(headerlist, ui, operation)
     # This is required for ncurses to display non-ASCII characters in
     # default user locale encoding correctly.  --immerrr
-    locale.setlocale(locale.LC_ALL, r'')
+    locale.setlocale(locale.LC_ALL, '')
     origsigtstp = sentinel = object()
     if util.safehasattr(signal, b'SIGTSTP'):
         origsigtstp = signal.getsignal(signal.SIGTSTP)
--- a/mercurial/dagparser.py	Wed Nov 20 19:07:02 2019 +0100
+++ b/mercurial/dagparser.py	Fri Nov 22 21:42:04 2019 +0900
@@ -168,7 +168,9 @@
     if not desc:
         return
 
-    wordchars = pycompat.bytestr(string.ascii_letters + string.digits)
+    wordchars = pycompat.bytestr(
+        string.ascii_letters + string.digits
+    )  # pytype: disable=wrong-arg-types
 
     labels = {}
     p1 = -1
@@ -177,7 +179,9 @@
     def resolve(ref):
         if not ref:
             return p1
-        elif ref[0] in pycompat.bytestr(string.digits):
+        elif ref[0] in pycompat.bytestr(
+            string.digits
+        ):  # pytype: disable=wrong-arg-types
             return r - int(ref)
         else:
             return labels[ref]
@@ -211,7 +215,9 @@
 
     c = nextch()
     while c != b'\0':
-        while c in pycompat.bytestr(string.whitespace):
+        while c in pycompat.bytestr(
+            string.whitespace
+        ):  # pytype: disable=wrong-arg-types
             c = nextch()
         if c == b'.':
             yield b'n', (r, [p1])
@@ -219,7 +225,9 @@
             r += 1
             c = nextch()
         elif c == b'+':
-            c, digs = nextrun(nextch(), pycompat.bytestr(string.digits))
+            c, digs = nextrun(
+                nextch(), pycompat.bytestr(string.digits)
+            )  # pytype: disable=wrong-arg-types
             n = int(digs)
             for i in pycompat.xrange(0, n):
                 yield b'n', (r, [p1])
--- a/mercurial/debugcommands.py	Wed Nov 20 19:07:02 2019 +0100
+++ b/mercurial/debugcommands.py	Fri Nov 22 21:42:04 2019 +0900
@@ -59,6 +59,7 @@
     merge as mergemod,
     obsolete,
     obsutil,
+    pathutil,
     phases,
     policy,
     pvec,
@@ -393,7 +394,7 @@
     if not isinstance(gen, bundle2.unbundle20):
         raise error.Abort(_(b'not a bundle2 file'))
     ui.write((b'Stream params: %s\n' % _quasirepr(gen.params)))
-    parttypes = opts.get(r'part_type', [])
+    parttypes = opts.get('part_type', [])
     for part in gen.iterparts():
         if parttypes and part.type not in parttypes:
             continue
@@ -480,8 +481,8 @@
             ui.warn(_(b"%s in manifest1, but listed as state %s") % (f, state))
             errors += 1
     if errors:
-        error = _(b".hg/dirstate inconsistent with current parent's manifest")
-        raise error.Abort(error)
+        errstr = _(b".hg/dirstate inconsistent with current parent's manifest")
+        raise error.Abort(errstr)
 
 
 @command(
@@ -492,7 +493,7 @@
 def debugcolor(ui, repo, **opts):
     """show available color, effects or style"""
     ui.writenoi18n(b'color mode: %s\n' % stringutil.pprint(ui._colormode))
-    if opts.get(r'style'):
+    if opts.get('style'):
         return _debugdisplaystyle(ui)
     else:
         return _debugdisplaycolor(ui)
@@ -573,8 +574,8 @@
 
     Otherwise, the changelog DAG of the current repo is emitted.
     """
-    spaces = opts.get(r'spaces')
-    dots = opts.get(r'dots')
+    spaces = opts.get('spaces')
+    dots = opts.get('dots')
     if file_:
         rlog = revlog.revlog(vfsmod.vfs(encoding.getcwd(), audit=False), file_)
         revs = set((int(r) for r in revs))
@@ -587,8 +588,8 @@
 
     elif repo:
         cl = repo.changelog
-        tags = opts.get(r'tags')
-        branches = opts.get(r'branches')
+        tags = opts.get('tags')
+        branches = opts.get('branches')
         if tags:
             labels = {}
             for l, n in repo.tags().items():
@@ -651,7 +652,7 @@
 )
 def debugdate(ui, date, range=None, **opts):
     """parse and display a date"""
-    if opts[r"extended"]:
+    if opts["extended"]:
         d = dateutil.parsedate(date, util.extendeddateformats)
     else:
         d = dateutil.parsedate(date)
@@ -861,10 +862,10 @@
 def debugstate(ui, repo, **opts):
     """show the contents of the current dirstate"""
 
-    nodates = not opts[r'dates']
-    if opts.get(r'nodates') is not None:
+    nodates = not opts['dates']
+    if opts.get('nodates') is not None:
         nodates = True
-    datesort = opts.get(r'datesort')
+    datesort = opts.get('datesort')
 
     if datesort:
         keyfunc = lambda x: (x[1][3], x[0])  # sort by mtime, then by filename
@@ -877,7 +878,7 @@
             timestr = b'set                 '
         else:
             timestr = time.strftime(
-                r"%Y-%m-%d %H:%M:%S ", time.localtime(ent[3])
+                "%Y-%m-%d %H:%M:%S ", time.localtime(ent[3])
             )
             timestr = encoding.strtolocal(timestr)
         if ent[1] & 0o20000:
@@ -1028,7 +1029,12 @@
     fm = ui.formatter(b'debugextensions', opts)
     for extname, extmod in sorted(exts, key=operator.itemgetter(0)):
         isinternal = extensions.ismoduleinternal(extmod)
-        extsource = pycompat.fsencode(extmod.__file__)
+        extsource = None
+
+        if util.safehasattr(extmod, '__file__'):
+            extsource = pycompat.fsencode(extmod.__file__)
+        elif getattr(sys, 'oxidized', False):
+            extsource = pycompat.sysexecutable
         if isinternal:
             exttestedwith = []  # never expose magic string to users
         else:
@@ -1298,11 +1304,11 @@
         raise error.Abort(b"getbundle() not supported by target repository")
     args = {}
     if common:
-        args[r'common'] = [bin(s) for s in common]
+        args['common'] = [bin(s) for s in common]
     if head:
-        args[r'heads'] = [bin(s) for s in head]
+        args['heads'] = [bin(s) for s in head]
     # TODO: get desired bundlecaps from command line.
-    args[r'bundlecaps'] = None
+    args['bundlecaps'] = None
     bundle = repo.getbundle(b'debug', **args)
 
     bundletype = opts.get(b'type', b'bzip2').lower()
@@ -1343,7 +1349,7 @@
                     ignored = nf
                     ignoredata = repo.dirstate._ignorefileandline(nf)
                 else:
-                    for p in util.finddirs(nf):
+                    for p in pathutil.finddirs(nf):
                         if ignore(p):
                             ignored = p
                             ignoredata = repo.dirstate._ignorefileandline(p)
@@ -1469,6 +1475,12 @@
     )
 
     # Python
+    pythonlib = None
+    if util.safehasattr(os, '__file__'):
+        pythonlib = os.path.dirname(pycompat.fsencode(os.__file__))
+    elif getattr(sys, 'oxidized', False):
+        pythonlib = pycompat.sysexecutable
+
     fm.write(
         b'pythonexe',
         _(b"checking Python executable (%s)\n"),
@@ -1482,7 +1494,7 @@
     fm.write(
         b'pythonlib',
         _(b"checking Python lib (%s)...\n"),
-        os.path.dirname(pycompat.fsencode(os.__file__)),
+        pythonlib or _(b"unknown"),
     )
 
     security = set(sslutil.supportedprotocols)
@@ -1526,13 +1538,19 @@
     )
 
     # compiled modules
+    hgmodules = None
+    if util.safehasattr(sys.modules[__name__], '__file__'):
+        hgmodules = os.path.dirname(pycompat.fsencode(__file__))
+    elif getattr(sys, 'oxidized', False):
+        hgmodules = pycompat.sysexecutable
+
     fm.write(
         b'hgmodulepolicy', _(b"checking module policy (%s)\n"), policy.policy
     )
     fm.write(
         b'hgmodules',
         _(b"checking installed modules (%s)...\n"),
-        os.path.dirname(pycompat.fsencode(__file__)),
+        hgmodules or _(b"unknown"),
     )
 
     rustandc = policy.policy in (b'rust+c', b'rust+c-allow')
@@ -1543,7 +1561,7 @@
         err = None
         try:
             if cext:
-                from .cext import (
+                from .cext import (  # pytype: disable=import-error
                     base85,
                     bdiff,
                     mpatch,
@@ -1553,7 +1571,7 @@
                 # quiet pyflakes
                 dir(bdiff), dir(mpatch), dir(base85), dir(osutil)
             if rustext:
-                from .rustext import (
+                from .rustext import (  # pytype: disable=import-error
                     ancestor,
                     dirstate,
                 )
@@ -1775,21 +1793,21 @@
 
     """
 
-    if opts.get(r'force_lock'):
+    if opts.get('force_lock'):
         repo.svfs.unlink(b'lock')
-    if opts.get(r'force_wlock'):
+    if opts.get('force_wlock'):
         repo.vfs.unlink(b'wlock')
-    if opts.get(r'force_lock') or opts.get(r'force_wlock'):
+    if opts.get('force_lock') or opts.get('force_wlock'):
         return 0
 
     locks = []
     try:
-        if opts.get(r'set_wlock'):
+        if opts.get('set_wlock'):
             try:
                 locks.append(repo.wlock(False))
             except error.LockHeld:
                 raise error.Abort(_(b'wlock is already held'))
-        if opts.get(r'set_lock'):
+        if opts.get('set_lock'):
             try:
                 locks.append(repo.lock(False))
             except error.LockHeld:
@@ -1871,7 +1889,7 @@
             )
             raise error.Abort(msg)
 
-    if opts.get(r'clear'):
+    if opts.get('clear'):
         with repo.wlock():
             cache = getcache()
             cache.clear(clear_persisted_data=True)
@@ -2265,7 +2283,7 @@
         if fixpaths:
             spec = spec.replace(pycompat.ossep, b'/')
         speclen = len(spec)
-        fullpaths = opts[r'full']
+        fullpaths = opts['full']
         files, dirs = set(), set()
         adddir, addfile = dirs.add, files.add
         for f, st in pycompat.iteritems(dirstate):
@@ -2283,11 +2301,11 @@
         return files, dirs
 
     acceptable = b''
-    if opts[r'normal']:
+    if opts['normal']:
         acceptable += b'nm'
-    if opts[r'added']:
+    if opts['added']:
         acceptable += b'a'
-    if opts[r'removed']:
+    if opts['removed']:
         acceptable += b'r'
     cwd = repo.getcwd()
     if not specs:
@@ -2526,7 +2544,7 @@
         dirstate = repo.dirstate
         changedfiles = None
         # See command doc for what minimal does.
-        if opts.get(r'minimal'):
+        if opts.get('minimal'):
             manifestfiles = set(ctx.manifest().keys())
             dirstatefiles = set(dirstate)
             manifestonly = manifestfiles - dirstatefiles
@@ -3147,13 +3165,13 @@
         ui.writenoi18n(b'+++ optimized\n', label=b'diff.file_b')
         sm = difflib.SequenceMatcher(None, arevs, brevs)
         for tag, alo, ahi, blo, bhi in sm.get_opcodes():
-            if tag in (r'delete', r'replace'):
+            if tag in ('delete', 'replace'):
                 for c in arevs[alo:ahi]:
                     ui.write(b'-%d\n' % c, label=b'diff.deleted')
-            if tag in (r'insert', r'replace'):
+            if tag in ('insert', 'replace'):
                 for c in brevs[blo:bhi]:
                     ui.write(b'+%d\n' % c, label=b'diff.inserted')
-            if tag == r'equal':
+            if tag == 'equal':
                 for c in arevs[alo:ahi]:
                     ui.write(b' %d\n' % c)
         return 1
@@ -3202,12 +3220,12 @@
     if opts[b'logiofd']:
         # Line buffered because output is line based.
         try:
-            logfh = os.fdopen(int(opts[b'logiofd']), r'ab', 1)
+            logfh = os.fdopen(int(opts[b'logiofd']), 'ab', 1)
         except OSError as e:
             if e.errno != errno.ESPIPE:
                 raise
             # can't seek a pipe, so `ab` mode fails on py3
-            logfh = os.fdopen(int(opts[b'logiofd']), r'wb', 1)
+            logfh = os.fdopen(int(opts[b'logiofd']), 'wb', 1)
     elif opts[b'logiofile']:
         logfh = open(opts[b'logiofile'], b'ab', 1)
 
@@ -3391,7 +3409,7 @@
         ctx = repo[rev]
         ui.write(b'%s\n' % ctx2str(ctx))
         for succsset in obsutil.successorssets(
-            repo, ctx.node(), closest=opts[r'closest'], cache=cache
+            repo, ctx.node(), closest=opts['closest'], cache=cache
         ):
             if succsset:
                 ui.write(b'    ')
@@ -3421,15 +3439,15 @@
     Use --verbose to print the parsed tree.
     """
     revs = None
-    if opts[r'rev']:
+    if opts['rev']:
         if repo is None:
             raise error.RepoError(
                 _(b'there is no Mercurial repository here (.hg not found)')
             )
-        revs = scmutil.revrange(repo, opts[r'rev'])
+        revs = scmutil.revrange(repo, opts['rev'])
 
     props = {}
-    for d in opts[r'define']:
+    for d in opts['define']:
         try:
             k, v = (e.strip() for e in d.split(b'=', 1))
             if not k or k == b'ui':
@@ -3985,27 +4003,27 @@
 
         url, authinfo = u.authinfo()
         openerargs = {
-            r'useragent': b'Mercurial debugwireproto',
+            'useragent': b'Mercurial debugwireproto',
         }
 
         # Turn pipes/sockets into observers so we can log I/O.
         if ui.verbose:
             openerargs.update(
                 {
-                    r'loggingfh': ui,
-                    r'loggingname': b's',
-                    r'loggingopts': {r'logdata': True, r'logdataapis': False,},
+                    'loggingfh': ui,
+                    'loggingname': b's',
+                    'loggingopts': {'logdata': True, 'logdataapis': False,},
                 }
             )
 
         if ui.debugflag:
-            openerargs[r'loggingopts'][r'logdataapis'] = True
+            openerargs['loggingopts']['logdataapis'] = True
 
         # Don't send default headers when in raw mode. This allows us to
         # bypass most of the behavior of our URL handling code so we can
         # have near complete control over what's sent on the wire.
         if opts[b'peer'] == b'raw':
-            openerargs[r'sendaccept'] = False
+            openerargs['sendaccept'] = False
 
         opener = urlmod.opener(ui, authinfo, **openerargs)
 
@@ -4105,7 +4123,7 @@
             ui.status(_(b'sending %s command\n') % command)
 
             if b'PUSHFILE' in args:
-                with open(args[b'PUSHFILE'], r'rb') as fh:
+                with open(args[b'PUSHFILE'], 'rb') as fh:
                     del args[b'PUSHFILE']
                     res, output = peer._callpush(
                         command, fh, **pycompat.strkwargs(args)
@@ -4143,6 +4161,7 @@
                 _(b'sending batch with %d sub-commands\n')
                 % len(batchedcommands)
             )
+            assert peer is not None
             for i, chunk in enumerate(peer._submitbatch(batchedcommands)):
                 ui.status(
                     _(b'response #%d: %s\n') % (i, stringutil.escapestr(chunk))
@@ -4213,8 +4232,8 @@
                 getattr(e, 'read', lambda: None)()
                 continue
 
-            ct = res.headers.get(r'Content-Type')
-            if ct == r'application/mercurial-cbor':
+            ct = res.headers.get('Content-Type')
+            if ct == 'application/mercurial-cbor':
                 ui.write(
                     _(b'cbor> %s\n')
                     % stringutil.pprint(
@@ -4223,6 +4242,7 @@
                 )
 
         elif action == b'close':
+            assert peer is not None
             peer.close()
         elif action == b'readavailable':
             if not stdout or not stderr:
--- a/mercurial/default.d/mergetools.rc	Wed Nov 20 19:07:02 2019 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,146 +0,0 @@
-# Some default global settings for common merge tools
-
-[merge-tools]
-kdiff3.args=--auto --L1 $labelbase --L2 $labellocal --L3 $labelother $base $local $other -o $output
-kdiff3.regkey=Software\KDiff3
-kdiff3.regkeyalt=Software\Wow6432Node\KDiff3
-kdiff3.regappend=\kdiff3.exe
-kdiff3.fixeol=True
-kdiff3.gui=True
-kdiff3.diffargs=--L1 $plabel1 --L2 $clabel $parent $child
-
-gvimdiff.args=--nofork -d -g -O $local $other $base
-gvimdiff.regkey=Software\Vim\GVim
-gvimdiff.regkeyalt=Software\Wow6432Node\Vim\GVim
-gvimdiff.regname=path
-gvimdiff.priority=-9
-gvimdiff.diffargs=--nofork -d -g -O $parent $child
-
-vimdiff.args=$local $other $base -c 'redraw | echomsg "hg merge conflict, type \":cq\" to abort vimdiff"'
-vimdiff.check=changed
-vimdiff.priority=-10
-
-merge.check=conflicts
-merge.priority=-100
-
-gpyfm.gui=True
-
-meld.gui=True
-meld.args=--label=$labellocal $local --label='merged' $base --label=$labelother $other -o $output --auto-merge
-meld.check=changed
-meld.diffargs=-a --label=$plabel1 $parent --label=$clabel $child
-
-tkdiff.args=$local $other -a $base -o $output
-tkdiff.gui=True
-tkdiff.priority=-8
-tkdiff.diffargs=-L $plabel1 $parent -L $clabel $child
-
-xxdiff.args=--show-merged-pane --exit-with-merge-status --title1 $labellocal --title2 $labelbase --title3 $labelother --merged-filename $output --merge $local $base $other
-xxdiff.gui=True
-xxdiff.priority=-8
-xxdiff.diffargs=--title1 $plabel1 $parent --title2 $clabel $child
-
-diffmerge.regkey=Software\SourceGear\SourceGear DiffMerge\
-diffmerge.regkeyalt=Software\Wow6432Node\SourceGear\SourceGear DiffMerge\
-diffmerge.regname=Location
-diffmerge.priority=-7
-diffmerge.args=-nosplash -merge -title1=$labellocal -title2=merged -title3=$labelother $local $base $other -result=$output
-diffmerge.check=changed
-diffmerge.gui=True
-diffmerge.diffargs=--nosplash --title1=$plabel1 --title2=$clabel $parent $child
-
-p4merge.args=$base $local $other $output
-p4merge.regkey=Software\Perforce\Environment
-p4merge.regkeyalt=Software\Wow6432Node\Perforce\Environment
-p4merge.regname=P4INSTROOT
-p4merge.regappend=\p4merge.exe
-p4merge.gui=True
-p4merge.priority=-8
-p4merge.diffargs=$parent $child
-
-p4mergeosx.executable = /Applications/p4merge.app/Contents/MacOS/p4merge
-p4mergeosx.args = $base $local $other $output
-p4mergeosx.gui = True
-p4mergeosx.priority=-8
-p4mergeosx.diffargs=$parent $child
-
-tortoisemerge.args=/base:$base /mine:$local /theirs:$other /merged:$output
-tortoisemerge.regkey=Software\TortoiseSVN
-tortoisemerge.regkeyalt=Software\Wow6432Node\TortoiseSVN
-tortoisemerge.check=changed
-tortoisemerge.gui=True
-tortoisemerge.priority=-8
-tortoisemerge.diffargs=/base:$parent /mine:$child /basename:$plabel1 /minename:$clabel
-
-ecmerge.args=$base $local $other --mode=merge3 --title0=$labelbase --title1=$labellocal --title2=$labelother --to=$output
-ecmerge.regkey=Software\Elli\xc3\xa9 Computing\Merge
-ecmerge.regkeyalt=Software\Wow6432Node\Elli\xc3\xa9 Computing\Merge
-ecmerge.gui=True
-ecmerge.diffargs=$parent $child --mode=diff2 --title1=$plabel1 --title2=$clabel
-
-# editmerge is a small script shipped in contrib.
-# It needs this config otherwise it behaves the same as internal:local
-editmerge.args=$output
-editmerge.check=changed
-editmerge.premerge=keep
-
-filemerge.executable=/Developer/Applications/Utilities/FileMerge.app/Contents/MacOS/FileMerge
-filemerge.args=-left $other -right $local -ancestor $base -merge $output
-filemerge.gui=True
-
-filemergexcode.executable=/Applications/Xcode.app/Contents/Applications/FileMerge.app/Contents/MacOS/FileMerge
-filemergexcode.args=-left $other -right $local -ancestor $base -merge $output
-filemergexcode.gui=True
-
-; Windows version of Beyond Compare
-beyondcompare3.args=$local $other $base $output /ro /lefttitle=$labellocal /centertitle=$labelbase /righttitle=$labelother /automerge /reviewconflicts /solo
-beyondcompare3.regkey=Software\Scooter Software\Beyond Compare 3
-beyondcompare3.regname=ExePath
-beyondcompare3.gui=True
-beyondcompare3.priority=-2
-beyondcompare3.diffargs=/lro /lefttitle=$plabel1 /righttitle=$clabel /solo /expandall $parent $child
-
-; Linux version of Beyond Compare
-bcompare.args=$local $other $base -mergeoutput=$output -ro -lefttitle=$labellocal -centertitle=$labelbase -righttitle=$labelother -outputtitle=merged -automerge -reviewconflicts -solo
-bcompare.gui=True
-bcompare.priority=-1
-bcompare.diffargs=-lro -lefttitle=$plabel1 -righttitle=$clabel -solo -expandall $parent $child
-
-; OS X version of Beyond Compare
-bcomposx.executable = /Applications/Beyond Compare.app/Contents/MacOS/bcomp
-bcomposx.args=$local $other $base -mergeoutput=$output -ro -lefttitle=$labellocal -centertitle=$labelbase -righttitle=$labelother -outputtitle=merged -automerge -reviewconflicts -solo
-bcomposx.gui=True
-bcomposx.priority=-1
-bcomposx.diffargs=-lro -lefttitle=$plabel1 -righttitle=$clabel -solo -expandall $parent $child
-
-winmerge.args=/e /x /wl /ub /dl $labelother /dr $labellocal $other $local $output
-winmerge.regkey=Software\Thingamahoochie\WinMerge
-winmerge.regkeyalt=Software\Wow6432Node\Thingamahoochie\WinMerge\
-winmerge.regname=Executable
-winmerge.check=changed
-winmerge.gui=True
-winmerge.priority=-10
-winmerge.diffargs=/r /e /x /ub /wl /dl $plabel1 /dr $clabel $parent $child
-
-araxis.regkey=SOFTWARE\Classes\TypeLib\{46799e0a-7bd1-4330-911c-9660bb964ea2}\7.0\HELPDIR
-araxis.regappend=\ConsoleCompare.exe
-araxis.priority=-2
-araxis.args=/3 /a2 /wait /merge /title1:"Other" /title2:"Base" /title3:"Local :"$local $other $base $local $output
-araxis.checkconflict=True
-araxis.binary=True
-araxis.gui=True
-araxis.diffargs=/2 /wait /title1:$plabel1 /title2:$clabel $parent $child
-
-diffuse.priority=-3
-diffuse.args=$local $base $other
-diffuse.gui=True
-diffuse.diffargs=$parent $child
-
-UltraCompare.regkey=Software\Microsoft\Windows\CurrentVersion\App Paths\UC.exe
-UltraCompare.regkeyalt=Software\Wow6432Node\Microsoft\Windows\CurrentVersion\App Paths\UC.exe
-UltraCompare.args = $base $local $other -title1 base -title3 other
-UltraCompare.priority = -2
-UltraCompare.gui = True
-UltraCompare.binary = True
-UltraCompare.check = conflicts,changed
-UltraCompare.diffargs=$child $parent -title1 $clabel -title2 $plabel1
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mercurial/defaultrc/mergetools.rc	Fri Nov 22 21:42:04 2019 +0900
@@ -0,0 +1,146 @@
+# Some default global settings for common merge tools
+
+[merge-tools]
+kdiff3.args=--auto --L1 $labelbase --L2 $labellocal --L3 $labelother $base $local $other -o $output
+kdiff3.regkey=Software\KDiff3
+kdiff3.regkeyalt=Software\Wow6432Node\KDiff3
+kdiff3.regappend=\kdiff3.exe
+kdiff3.fixeol=True
+kdiff3.gui=True
+kdiff3.diffargs=--L1 $plabel1 --L2 $clabel $parent $child
+
+gvimdiff.args=--nofork -d -g -O $local $other $base
+gvimdiff.regkey=Software\Vim\GVim
+gvimdiff.regkeyalt=Software\Wow6432Node\Vim\GVim
+gvimdiff.regname=path
+gvimdiff.priority=-9
+gvimdiff.diffargs=--nofork -d -g -O $parent $child
+
+vimdiff.args=$local $other $base -c 'redraw | echomsg "hg merge conflict, type \":cq\" to abort vimdiff"'
+vimdiff.check=changed
+vimdiff.priority=-10
+
+merge.check=conflicts
+merge.priority=-100
+
+gpyfm.gui=True
+
+meld.gui=True
+meld.args=--label=$labellocal $local --label='merged' $base --label=$labelother $other -o $output --auto-merge
+meld.check=changed
+meld.diffargs=-a --label=$plabel1 $parent --label=$clabel $child
+
+tkdiff.args=$local $other -a $base -o $output
+tkdiff.gui=True
+tkdiff.priority=-8
+tkdiff.diffargs=-L $plabel1 $parent -L $clabel $child
+
+xxdiff.args=--show-merged-pane --exit-with-merge-status --title1 $labellocal --title2 $labelbase --title3 $labelother --merged-filename $output --merge $local $base $other
+xxdiff.gui=True
+xxdiff.priority=-8
+xxdiff.diffargs=--title1 $plabel1 $parent --title2 $clabel $child
+
+diffmerge.regkey=Software\SourceGear\SourceGear DiffMerge\
+diffmerge.regkeyalt=Software\Wow6432Node\SourceGear\SourceGear DiffMerge\
+diffmerge.regname=Location
+diffmerge.priority=-7
+diffmerge.args=-nosplash -merge -title1=$labellocal -title2=merged -title3=$labelother $local $base $other -result=$output
+diffmerge.check=changed
+diffmerge.gui=True
+diffmerge.diffargs=--nosplash --title1=$plabel1 --title2=$clabel $parent $child
+
+p4merge.args=$base $local $other $output
+p4merge.regkey=Software\Perforce\Environment
+p4merge.regkeyalt=Software\Wow6432Node\Perforce\Environment
+p4merge.regname=P4INSTROOT
+p4merge.regappend=\p4merge.exe
+p4merge.gui=True
+p4merge.priority=-8
+p4merge.diffargs=$parent $child
+
+p4mergeosx.executable = /Applications/p4merge.app/Contents/MacOS/p4merge
+p4mergeosx.args = $base $local $other $output
+p4mergeosx.gui = True
+p4mergeosx.priority=-8
+p4mergeosx.diffargs=$parent $child
+
+tortoisemerge.args=/base:$base /mine:$local /theirs:$other /merged:$output
+tortoisemerge.regkey=Software\TortoiseSVN
+tortoisemerge.regkeyalt=Software\Wow6432Node\TortoiseSVN
+tortoisemerge.check=changed
+tortoisemerge.gui=True
+tortoisemerge.priority=-8
+tortoisemerge.diffargs=/base:$parent /mine:$child /basename:$plabel1 /minename:$clabel
+
+ecmerge.args=$base $local $other --mode=merge3 --title0=$labelbase --title1=$labellocal --title2=$labelother --to=$output
+ecmerge.regkey=Software\Elli\xc3\xa9 Computing\Merge
+ecmerge.regkeyalt=Software\Wow6432Node\Elli\xc3\xa9 Computing\Merge
+ecmerge.gui=True
+ecmerge.diffargs=$parent $child --mode=diff2 --title1=$plabel1 --title2=$clabel
+
+# editmerge is a small script shipped in contrib.
+# It needs this config otherwise it behaves the same as internal:local
+editmerge.args=$output
+editmerge.check=changed
+editmerge.premerge=keep
+
+filemerge.executable=/Developer/Applications/Utilities/FileMerge.app/Contents/MacOS/FileMerge
+filemerge.args=-left $other -right $local -ancestor $base -merge $output
+filemerge.gui=True
+
+filemergexcode.executable=/Applications/Xcode.app/Contents/Applications/FileMerge.app/Contents/MacOS/FileMerge
+filemergexcode.args=-left $other -right $local -ancestor $base -merge $output
+filemergexcode.gui=True
+
+; Windows version of Beyond Compare
+beyondcompare3.args=$local $other $base $output /ro /lefttitle=$labellocal /centertitle=$labelbase /righttitle=$labelother /automerge /reviewconflicts /solo
+beyondcompare3.regkey=Software\Scooter Software\Beyond Compare 3
+beyondcompare3.regname=ExePath
+beyondcompare3.gui=True
+beyondcompare3.priority=-2
+beyondcompare3.diffargs=/lro /lefttitle=$plabel1 /righttitle=$clabel /solo /expandall $parent $child
+
+; Linux version of Beyond Compare
+bcompare.args=$local $other $base -mergeoutput=$output -ro -lefttitle=$labellocal -centertitle=$labelbase -righttitle=$labelother -outputtitle=merged -automerge -reviewconflicts -solo
+bcompare.gui=True
+bcompare.priority=-1
+bcompare.diffargs=-lro -lefttitle=$plabel1 -righttitle=$clabel -solo -expandall $parent $child
+
+; OS X version of Beyond Compare
+bcomposx.executable = /Applications/Beyond Compare.app/Contents/MacOS/bcomp
+bcomposx.args=$local $other $base -mergeoutput=$output -ro -lefttitle=$labellocal -centertitle=$labelbase -righttitle=$labelother -outputtitle=merged -automerge -reviewconflicts -solo
+bcomposx.gui=True
+bcomposx.priority=-1
+bcomposx.diffargs=-lro -lefttitle=$plabel1 -righttitle=$clabel -solo -expandall $parent $child
+
+winmerge.args=/e /x /wl /ub /dl $labelother /dr $labellocal $other $local $output
+winmerge.regkey=Software\Thingamahoochie\WinMerge
+winmerge.regkeyalt=Software\Wow6432Node\Thingamahoochie\WinMerge\
+winmerge.regname=Executable
+winmerge.check=changed
+winmerge.gui=True
+winmerge.priority=-10
+winmerge.diffargs=/r /e /x /ub /wl /dl $plabel1 /dr $clabel $parent $child
+
+araxis.regkey=SOFTWARE\Classes\TypeLib\{46799e0a-7bd1-4330-911c-9660bb964ea2}\7.0\HELPDIR
+araxis.regappend=\ConsoleCompare.exe
+araxis.priority=-2
+araxis.args=/3 /a2 /wait /merge /title1:"Other" /title2:"Base" /title3:"Local :"$local $other $base $local $output
+araxis.checkconflict=True
+araxis.binary=True
+araxis.gui=True
+araxis.diffargs=/2 /wait /title1:$plabel1 /title2:$clabel $parent $child
+
+diffuse.priority=-3
+diffuse.args=$local $base $other
+diffuse.gui=True
+diffuse.diffargs=$parent $child
+
+UltraCompare.regkey=Software\Microsoft\Windows\CurrentVersion\App Paths\UC.exe
+UltraCompare.regkeyalt=Software\Wow6432Node\Microsoft\Windows\CurrentVersion\App Paths\UC.exe
+UltraCompare.args = $base $local $other -title1 base -title3 other
+UltraCompare.priority = -2
+UltraCompare.gui = True
+UltraCompare.binary = True
+UltraCompare.check = conflicts,changed
+UltraCompare.diffargs=$child $parent -title1 $clabel -title2 $plabel1
--- a/mercurial/dirstate.py	Wed Nov 20 19:07:02 2019 +0100
+++ b/mercurial/dirstate.py	Fri Nov 22 21:42:04 2019 +0900
@@ -36,8 +36,8 @@
     util as interfaceutil,
 )
 
-parsers = policy.importmod(r'parsers')
-rustmod = policy.importrust(r'dirstate')
+parsers = policy.importmod('parsers')
+rustmod = policy.importrust('dirstate')
 
 propertycache = util.propertycache
 filecache = scmutil.filecache
@@ -368,7 +368,7 @@
         rereads the dirstate. Use localrepo.invalidatedirstate() if you want to
         check whether the dirstate has changed before rereading it.'''
 
-        for a in (r"_map", r"_branch", r"_ignore"):
+        for a in ("_map", "_branch", "_ignore"):
             if a in self.__dict__:
                 delattr(self, a)
         self._lastnormaltime = 0
@@ -404,7 +404,7 @@
                     _(b'directory %r already in dirstate') % pycompat.bytestr(f)
                 )
             # shadows
-            for d in util.finddirs(f):
+            for d in pathutil.finddirs(f):
                 if self._map.hastrackeddir(d):
                     break
                 entry = self._map.get(d)
@@ -687,8 +687,7 @@
         delaywrite = self._ui.configint(b'debug', b'dirstate.delaywrite')
         if delaywrite > 0:
             # do we have any files to delay for?
-            items = pycompat.iteritems(self._map)
-            for f, e in items:
+            for f, e in pycompat.iteritems(self._map):
                 if e[0] == b'n' and e[3] == now:
                     import time  # to avoid useless import
 
@@ -700,12 +699,6 @@
                     time.sleep(end - clock)
                     now = end  # trust our estimate that the end is near now
                     break
-            # since the iterator is potentially not deleted,
-            # delete the iterator to release the reference for the Rust
-            # implementation.
-            # TODO make the Rust implementation behave like Python
-            # since this would not work with a non ref-counting GC.
-            del items
 
         self._map.write(st, now)
         self._lastnormaltime = 0
@@ -714,7 +707,7 @@
     def _dirignore(self, f):
         if self._ignore(f):
             return True
-        for p in util.finddirs(f):
+        for p in pathutil.finddirs(f):
             if self._ignore(p):
                 return True
         return False
@@ -776,7 +769,6 @@
                 kind = _(b'directory')
             return _(b'unsupported file type (type is %s)') % kind
 
-        matchedir = match.explicitdir
         badfn = match.bad
         dmap = self._map
         lstat = os.lstat
@@ -830,8 +822,6 @@
                     if nf in dmap:
                         # file replaced by dir on disk but still in dirstate
                         results[nf] = None
-                    if matchedir:
-                        matchedir(nf)
                     foundadd((nf, ff))
                 elif kind == regkind or kind == lnkkind:
                     results[nf] = st
@@ -844,8 +834,6 @@
                     results[nf] = None
                 else:  # does it match a missing directory?
                     if self._map.hasdir(nf):
-                        if matchedir:
-                            matchedir(nf)
                         notfoundadd(nf)
                     else:
                         badfn(ff, encoding.strtolocal(inst.strerror))
@@ -946,6 +934,11 @@
 
         # step 1: find all explicit files
         results, work, dirsnotfound = self._walkexplicit(match, subrepos)
+        if matchtdir:
+            for d in work:
+                matchtdir(d[0])
+            for d in dirsnotfound:
+                matchtdir(d)
 
         skipstep3 = skipstep3 and not (work or dirsnotfound)
         work = [d for d in work if not dirignore(d[0])]
@@ -1116,6 +1109,19 @@
             use_rust = False
 
         if use_rust:
+            # Force Rayon (Rust parallelism library) to respect the number of
+            # workers. This is a temporary workaround until Rust code knows
+            # how to read the config file.
+            numcpus = self._ui.configint(b"worker", b"numcpus")
+            if numcpus is not None:
+                encoding.environ.setdefault(
+                    b'RAYON_NUM_THREADS', b'%d' % numcpus
+                )
+
+            workers_enabled = self._ui.configbool(b"worker", b"enabled", True)
+            if not workers_enabled:
+                encoding.environ[b"RAYON_NUM_THREADS"] = b"1"
+
             (
                 lookup,
                 modified,
@@ -1127,7 +1133,6 @@
             ) = rustmod.status(
                 dmap._rustmap,
                 self._rootdir,
-                match.files(),
                 bool(listclean),
                 self._lastnormaltime,
                 self._checkexec,
@@ -1144,16 +1149,19 @@
             )
             return (lookup, status)
 
+        def noop(f):
+            pass
+
         dcontains = dmap.__contains__
         dget = dmap.__getitem__
         ladd = lookup.append  # aka "unsure"
         madd = modified.append
         aadd = added.append
-        uadd = unknown.append
-        iadd = ignored.append
+        uadd = unknown.append if listunknown else noop
+        iadd = ignored.append if listignored else noop
         radd = removed.append
         dadd = deleted.append
-        cadd = clean.append
+        cadd = clean.append if listclean else noop
         mexact = match.exact
         dirignore = self._dirignore
         checkexec = self._checkexec
@@ -1407,9 +1415,9 @@
 
     def addfile(self, f, oldstate, state, mode, size, mtime):
         """Add a tracked file to the dirstate."""
-        if oldstate in b"?r" and r"_dirs" in self.__dict__:
+        if oldstate in b"?r" and "_dirs" in self.__dict__:
             self._dirs.addpath(f)
-        if oldstate == b"?" and r"_alldirs" in self.__dict__:
+        if oldstate == b"?" and "_alldirs" in self.__dict__:
             self._alldirs.addpath(f)
         self._map[f] = dirstatetuple(state, mode, size, mtime)
         if state != b'n' or mtime == -1:
@@ -1425,11 +1433,11 @@
         the file's previous state.  In the future, we should refactor this
         to be more explicit about what that state is.
         """
-        if oldstate not in b"?r" and r"_dirs" in self.__dict__:
+        if oldstate not in b"?r" and "_dirs" in self.__dict__:
             self._dirs.delpath(f)
-        if oldstate == b"?" and r"_alldirs" in self.__dict__:
+        if oldstate == b"?" and "_alldirs" in self.__dict__:
             self._alldirs.addpath(f)
-        if r"filefoldmap" in self.__dict__:
+        if "filefoldmap" in self.__dict__:
             normed = util.normcase(f)
             self.filefoldmap.pop(normed, None)
         self._map[f] = dirstatetuple(b'r', 0, size, 0)
@@ -1442,11 +1450,11 @@
         """
         exists = self._map.pop(f, None) is not None
         if exists:
-            if oldstate != b"r" and r"_dirs" in self.__dict__:
+            if oldstate != b"r" and "_dirs" in self.__dict__:
                 self._dirs.delpath(f)
-            if r"_alldirs" in self.__dict__:
+            if "_alldirs" in self.__dict__:
                 self._alldirs.delpath(f)
-        if r"filefoldmap" in self.__dict__:
+        if "filefoldmap" in self.__dict__:
             normed = util.normcase(f)
             self.filefoldmap.pop(normed, None)
         self.nonnormalset.discard(f)
@@ -1511,11 +1519,11 @@
 
     @propertycache
     def _dirs(self):
-        return util.dirs(self._map, b'r')
+        return pathutil.dirs(self._map, b'r')
 
     @propertycache
     def _alldirs(self):
-        return util.dirs(self._map)
+        return pathutil.dirs(self._map)
 
     def _opendirstatefile(self):
         fp, mode = txnutil.trypending(self._root, self._opener, self._filename)
--- a/mercurial/discovery.py	Wed Nov 20 19:07:02 2019 +0100
+++ b/mercurial/discovery.py	Fri Nov 22 21:42:04 2019 +0900
@@ -499,7 +499,7 @@
     repo = pushop.repo
     unfi = repo.unfiltered()
     tonode = unfi.changelog.node
-    torev = unfi.changelog.nodemap.get
+    torev = unfi.changelog.index.get_rev
     public = phases.public
     getphase = unfi._phasecache.phase
     ispublic = lambda r: getphase(unfi, r) == public
--- a/mercurial/dispatch.py	Wed Nov 20 19:07:02 2019 +0100
+++ b/mercurial/dispatch.py	Fri Nov 22 21:42:04 2019 +0900
@@ -115,6 +115,8 @@
 
     # In all cases we try to flush stdio streams.
     if util.safehasattr(req.ui, b'fout'):
+        assert req.ui is not None  # help pytype
+        assert req.ui.fout is not None  # help pytype
         try:
             req.ui.fout.flush()
         except IOError as e:
@@ -122,6 +124,8 @@
             status = -1
 
     if util.safehasattr(req.ui, b'ferr'):
+        assert req.ui is not None  # help pytype
+        assert req.ui.ferr is not None  # help pytype
         try:
             if err is not None and err.errno != errno.EPIPE:
                 req.ui.ferr.write(
@@ -658,10 +662,10 @@
 
     def __getattr__(self, name):
         adefaults = {
-            r'norepo': True,
-            r'intents': set(),
-            r'optionalrepo': False,
-            r'inferrepo': False,
+            'norepo': True,
+            'intents': set(),
+            'optionalrepo': False,
+            'inferrepo': False,
         }
         if name not in adefaults:
             raise AttributeError(name)
@@ -1108,6 +1112,7 @@
 
         repo = None
         cmdpats = args[:]
+        assert func is not None  # help out pytype
         if not func.norepo:
             # use the repo from the request only if we don't have -R
             if not rpath and not cwd:
--- a/mercurial/encoding.py	Wed Nov 20 19:07:02 2019 +0100
+++ b/mercurial/encoding.py	Fri Nov 22 21:42:04 2019 +0900
@@ -20,7 +20,27 @@
 
 from .pure import charencode as charencodepure
 
-charencode = policy.importmod(r'charencode')
+_TYPE_CHECKING = False
+
+if not globals():  # hide this from non-pytype users
+    from typing import (
+        Any,
+        Callable,
+        List,
+        TYPE_CHECKING as _TYPE_CHECKING,
+        Text,
+        Type,
+        TypeVar,
+        Union,
+    )
+
+    # keep pyflakes happy
+    for t in (Any, Callable, List, Text, Type, Union):
+        assert t
+
+    _Tlocalstr = TypeVar('_Tlocalstr', bound='localstr')
+
+charencode = policy.importmod('charencode')
 
 isasciistr = charencode.isasciistr
 asciilower = charencode.asciilower
@@ -45,6 +65,7 @@
 
 
 def hfsignoreclean(s):
+    # type: (bytes) -> bytes
     """Remove codepoints ignored by HFS+ from s.
 
     >>> hfsignoreclean(u'.h\u200cg'.encode('utf-8'))
@@ -69,7 +90,7 @@
     # preferred encoding isn't known yet; use utf-8 to avoid unicode error
     # and recreate it once encoding is settled
     environ = dict(
-        (k.encode(r'utf-8'), v.encode(r'utf-8'))
+        (k.encode('utf-8'), v.encode('utf-8'))
         for k, v in os.environ.items()  # re-exports
     )
 
@@ -103,6 +124,13 @@
         s._utf8 = u
         return s
 
+    if _TYPE_CHECKING:
+        # pseudo implementation to help pytype see localstr() constructor
+        def __init__(self, u, l):
+            # type: (bytes, bytes) -> None
+            super(localstr, self).__init__(l)
+            self._utf8 = u
+
     def __hash__(self):
         return hash(self._utf8)  # avoid collisions in local string space
 
@@ -119,6 +147,7 @@
 
 
 def tolocal(s):
+    # type: (bytes) -> bytes
     """
     Convert a string from internal UTF-8 to local encoding
 
@@ -162,7 +191,7 @@
             if encoding == b'UTF-8':
                 # fast path
                 return s
-            r = u.encode(_sysstr(encoding), r"replace")
+            r = u.encode(_sysstr(encoding), "replace")
             if u == r.decode(_sysstr(encoding)):
                 # r is a safe, non-lossy encoding of s
                 return safelocalstr(r)
@@ -171,7 +200,7 @@
             # we should only get here if we're looking at an ancient changeset
             try:
                 u = s.decode(_sysstr(fallbackencoding))
-                r = u.encode(_sysstr(encoding), r"replace")
+                r = u.encode(_sysstr(encoding), "replace")
                 if u == r.decode(_sysstr(encoding)):
                     # r is a safe, non-lossy encoding of s
                     return safelocalstr(r)
@@ -179,12 +208,13 @@
             except UnicodeDecodeError:
                 u = s.decode("utf-8", "replace")  # last ditch
                 # can't round-trip
-                return u.encode(_sysstr(encoding), r"replace")
+                return u.encode(_sysstr(encoding), "replace")
     except LookupError as k:
         raise error.Abort(k, hint=b"please check your locale settings")
 
 
 def fromlocal(s):
+    # type: (bytes) -> bytes
     """
     Convert a string from the local character encoding to UTF-8
 
@@ -214,16 +244,19 @@
 
 
 def unitolocal(u):
+    # type: (Text) -> bytes
     """Convert a unicode string to a byte string of local encoding"""
     return tolocal(u.encode('utf-8'))
 
 
 def unifromlocal(s):
+    # type: (bytes) -> Text
     """Convert a byte string of local encoding to a unicode string"""
     return fromlocal(s).decode('utf-8')
 
 
 def unimethod(bytesfunc):
+    # type: (Callable[[Any], bytes]) -> Callable[[Any], Text]
     """Create a proxy method that forwards __unicode__() and __str__() of
     Python 3 to __bytes__()"""
 
@@ -241,15 +274,22 @@
     strfromlocal = unifromlocal
     strmethod = unimethod
 else:
-    strtolocal = pycompat.identity
-    strfromlocal = pycompat.identity
+
+    def strtolocal(s):
+        # type: (str) -> bytes
+        return s  # pytype: disable=bad-return-type
+
+    def strfromlocal(s):
+        # type: (bytes) -> str
+        return s  # pytype: disable=bad-return-type
+
     strmethod = pycompat.identity
 
 if not _nativeenviron:
     # now encoding and helper functions are available, recreate the environ
     # dict to be exported to other modules
     environ = dict(
-        (tolocal(k.encode(r'utf-8')), tolocal(v.encode(r'utf-8')))
+        (tolocal(k.encode('utf-8')), tolocal(v.encode('utf-8')))
         for k, v in os.environ.items()  # re-exports
     )
 
@@ -274,11 +314,13 @@
 
 
 def colwidth(s):
+    # type: (bytes) -> int
     b"Find the column width of a string for display in the local encoding"
-    return ucolwidth(s.decode(_sysstr(encoding), r'replace'))
+    return ucolwidth(s.decode(_sysstr(encoding), 'replace'))
 
 
 def ucolwidth(d):
+    # type: (Text) -> int
     b"Find the column width of a Unicode string for display"
     eaw = getattr(unicodedata, 'east_asian_width', None)
     if eaw is not None:
@@ -287,15 +329,18 @@
 
 
 def getcols(s, start, c):
+    # type: (bytes, int, int) -> bytes
     '''Use colwidth to find a c-column substring of s starting at byte
     index start'''
     for x in pycompat.xrange(start + c, len(s)):
         t = s[start:x]
         if colwidth(t) == c:
             return t
+    raise ValueError('substring not found')
 
 
 def trim(s, width, ellipsis=b'', leftside=False):
+    # type: (bytes, int, bytes, bool) -> bytes
     """Trim string 's' to at most 'width' columns (including 'ellipsis').
 
     If 'leftside' is True, left side of string 's' is trimmed.
@@ -393,6 +438,7 @@
 
 
 def lower(s):
+    # type: (bytes) -> bytes
     b"best-effort encoding-aware case-folding of local string s"
     try:
         return asciilower(s)
@@ -415,6 +461,7 @@
 
 
 def upper(s):
+    # type: (bytes) -> bytes
     b"best-effort encoding-aware case-folding of local string s"
     try:
         return asciiupper(s)
@@ -423,6 +470,7 @@
 
 
 def upperfallback(s):
+    # type: (Any) -> Any
     try:
         if isinstance(s, localstr):
             u = s._utf8.decode("utf-8")
@@ -457,6 +505,7 @@
 
 
 def jsonescape(s, paranoid=False):
+    # type: (Any, Any) -> Any
     '''returns a string suitable for JSON
 
     JSON is problematic for us because it doesn't support non-Unicode
@@ -520,6 +569,7 @@
 
 
 def getutf8char(s, pos):
+    # type: (bytes, int) -> bytes
     '''get the next full utf-8 character in the given string, starting at pos
 
     Raises a UnicodeError if the given location does not start a valid
@@ -538,6 +588,7 @@
 
 
 def toutf8b(s):
+    # type: (bytes) -> bytes
     '''convert a local, possibly-binary string into UTF-8b
 
     This is intended as a generic method to preserve data when working
@@ -606,6 +657,7 @@
 
 
 def fromutf8b(s):
+    # type: (bytes) -> bytes
     '''Given a UTF-8b string, return a local, possibly-binary string.
 
     return the original binary string. This
--- a/mercurial/error.py	Wed Nov 20 19:07:02 2019 +0100
+++ b/mercurial/error.py	Fri Nov 22 21:42:04 2019 +0900
@@ -34,7 +34,7 @@
     """
 
     def __init__(self, *args, **kw):
-        self.hint = kw.pop(r'hint', None)
+        self.hint = kw.pop('hint', None)
         super(Hint, self).__init__(*args, **kw)
 
 
--- a/mercurial/exchange.py	Wed Nov 20 19:07:02 2019 +0100
+++ b/mercurial/exchange.py	Fri Nov 22 21:42:04 2019 +0900
@@ -524,8 +524,8 @@
         # We can pick:
         # * missingheads part of common (::commonheads)
         common = self.outgoing.common
-        nm = self.repo.changelog.nodemap
-        cheads = [node for node in self.revs if nm[node] in common]
+        rev = self.repo.changelog.index.rev
+        cheads = [node for node in self.revs if rev(node) in common]
         # and
         # * commonheads parents on missing
         revset = unfi.set(
@@ -1851,7 +1851,7 @@
         pullop.repo, pullop.remote, heads=pullop.heads, force=pullop.force
     )
     common, fetch, rheads = tmp
-    nm = pullop.repo.unfiltered().changelog.nodemap
+    has_node = pullop.repo.unfiltered().changelog.index.has_node
     if fetch and rheads:
         # If a remote heads is filtered locally, put in back in common.
         #
@@ -1864,7 +1864,7 @@
         # but are not including a remote heads, we'll not be able to detect it,
         scommon = set(common)
         for n in rheads:
-            if n in nm:
+            if has_node(n):
                 if n not in scommon:
                     common.append(n)
         if set(rheads).issubset(set(common)):
@@ -2097,7 +2097,7 @@
         dheads = []
     unfi = pullop.repo.unfiltered()
     phase = unfi._phasecache.phase
-    rev = unfi.changelog.nodemap.get
+    rev = unfi.changelog.index.get_rev
     public = phases.public
     draft = phases.draft
 
@@ -2193,8 +2193,8 @@
         b'path:.' if p == b'*' else b'path:' + p for p in user_excludes
     ]
 
-    req_includes = set(kwargs.get(r'includepats', []))
-    req_excludes = set(kwargs.get(r'excludepats', []))
+    req_includes = set(kwargs.get('includepats', []))
+    req_excludes = set(kwargs.get('excludepats', []))
 
     req_includes, req_excludes, invalid_includes = narrowspec.restrictpatterns(
         req_includes, req_excludes, user_includes, user_excludes
@@ -2209,11 +2209,11 @@
 
     new_args = {}
     new_args.update(kwargs)
-    new_args[r'narrow'] = True
-    new_args[r'narrow_acl'] = True
-    new_args[r'includepats'] = req_includes
+    new_args['narrow'] = True
+    new_args['narrow_acl'] = True
+    new_args['includepats'] = req_includes
     if req_excludes:
-        new_args[r'excludepats'] = req_excludes
+        new_args['excludepats'] = req_excludes
 
     return new_args
 
@@ -2476,7 +2476,7 @@
     **kwargs
 ):
     """add a changegroup part to the requested bundle"""
-    if not kwargs.get(r'cg', True):
+    if not kwargs.get('cg', True):
         return
 
     version = b'01'
@@ -2495,9 +2495,9 @@
     if not outgoing.missing:
         return
 
-    if kwargs.get(r'narrow', False):
-        include = sorted(filter(bool, kwargs.get(r'includepats', [])))
-        exclude = sorted(filter(bool, kwargs.get(r'excludepats', [])))
+    if kwargs.get('narrow', False):
+        include = sorted(filter(bool, kwargs.get('includepats', [])))
+        exclude = sorted(filter(bool, kwargs.get('excludepats', [])))
         matcher = narrowspec.match(repo.root, include=include, exclude=exclude)
     else:
         matcher = None
@@ -2519,8 +2519,8 @@
         part.addparam(b'exp-sidedata', b'1')
 
     if (
-        kwargs.get(r'narrow', False)
-        and kwargs.get(r'narrow_acl', False)
+        kwargs.get('narrow', False)
+        and kwargs.get('narrow_acl', False)
         and (include or exclude)
     ):
         # this is mandatory because otherwise ACL clients won't work
@@ -2536,7 +2536,7 @@
     bundler, repo, source, bundlecaps=None, b2caps=None, **kwargs
 ):
     """add a bookmark part to the requested bundle"""
-    if not kwargs.get(r'bookmarks', False):
+    if not kwargs.get('bookmarks', False):
         return
     if b'bookmarks' not in b2caps:
         raise error.Abort(_(b'no common bookmarks exchange method'))
@@ -2551,7 +2551,7 @@
     bundler, repo, source, bundlecaps=None, b2caps=None, **kwargs
 ):
     """add parts containing listkeys namespaces to the requested bundle"""
-    listkeys = kwargs.get(r'listkeys', ())
+    listkeys = kwargs.get('listkeys', ())
     for namespace in listkeys:
         part = bundler.newpart(b'listkeys')
         part.addparam(b'namespace', namespace)
@@ -2564,7 +2564,7 @@
     bundler, repo, source, bundlecaps=None, b2caps=None, heads=None, **kwargs
 ):
     """add an obsolescence markers part to the requested bundle"""
-    if kwargs.get(r'obsmarkers', False):
+    if kwargs.get('obsmarkers', False):
         if heads is None:
             heads = repo.heads()
         subset = [c.node() for c in repo.set(b'::%ln', heads)]
@@ -2578,7 +2578,7 @@
     bundler, repo, source, bundlecaps=None, b2caps=None, heads=None, **kwargs
 ):
     """add phase heads part to the requested bundle"""
-    if kwargs.get(r'phases', False):
+    if kwargs.get('phases', False):
         if not b'heads' in b2caps.get(b'phases'):
             raise error.Abort(_(b'no common phases exchange method'))
         if heads is None:
@@ -2643,7 +2643,7 @@
     # Don't send unless:
     # - changeset are being exchanged,
     # - the client supports it.
-    if not (kwargs.get(r'cg', True) and b'hgtagsfnodes' in b2caps):
+    if not (kwargs.get('cg', True) and b'hgtagsfnodes' in b2caps):
         return
 
     outgoing = _computeoutgoing(repo, heads, common)
@@ -2676,9 +2676,9 @@
     # - the client supports it.
     # - narrow bundle isn't in play (not currently compatible).
     if (
-        not kwargs.get(r'cg', True)
+        not kwargs.get('cg', True)
         or b'rev-branch-cache' not in b2caps
-        or kwargs.get(r'narrow', False)
+        or kwargs.get('narrow', False)
         or repo.ui.has_section(_NARROWACL_SECTION)
     ):
         return
--- a/mercurial/exchangev2.py	Wed Nov 20 19:07:02 2019 +0100
+++ b/mercurial/exchangev2.py	Fri Nov 22 21:42:04 2019 +0900
@@ -291,9 +291,9 @@
     # See the comment in exchange._pulldiscoverychangegroup() for more.
 
     if fetch and remoteheads:
-        nodemap = repo.unfiltered().changelog.nodemap
+        has_node = repo.unfiltered().changelog.index.has_node
 
-        common |= {head for head in remoteheads if head in nodemap}
+        common |= {head for head in remoteheads if has_node(head)}
 
         if set(remoteheads).issubset(common):
             fetch = []
--- a/mercurial/extensions.py	Wed Nov 20 19:07:02 2019 +0100
+++ b/mercurial/extensions.py	Fri Nov 22 21:42:04 2019 +0900
@@ -92,7 +92,11 @@
         # module/__init__.py style
         d, f = os.path.split(path)
         fd, fpath, desc = imp.find_module(f, [d])
-        return imp.load_module(module_name, fd, fpath, desc)
+        # When https://github.com/python/typeshed/issues/3466 is fixed
+        # and in a pytype release we can drop this disable.
+        return imp.load_module(
+            module_name, fd, fpath, desc  # pytype: disable=wrong-arg-types
+        )
     else:
         try:
             return imp.load_source(module_name, path)
@@ -591,9 +595,7 @@
             break
 
     if currcls is object:
-        raise AttributeError(
-            r"type '%s' has no property '%s'" % (cls, propname)
-        )
+        raise AttributeError("type '%s' has no property '%s'" % (cls, propname))
 
 
 class wrappedfunction(object):
@@ -783,7 +785,7 @@
 def disabled():
     '''find disabled extensions from hgext. returns a dict of {name: desc}'''
     try:
-        from hgext import __index__
+        from hgext import __index__  # pytype: disable=import-error
 
         return dict(
             (name, gettext(desc))
@@ -809,7 +811,7 @@
 def disabledext(name):
     '''find a specific disabled extension from hgext. returns desc'''
     try:
-        from hgext import __index__
+        from hgext import __index__  # pytype: disable=import-error
 
         if name in _order:  # enabled
             return
@@ -836,7 +838,7 @@
                 continue
             if not isinstance(d.func, ast.Name):
                 continue
-            if d.func.id != r'command':
+            if d.func.id != 'command':
                 continue
             yield d
 
--- a/mercurial/fancyopts.py	Wed Nov 20 19:07:02 2019 +0100
+++ b/mercurial/fancyopts.py	Fri Nov 22 21:42:04 2019 +0900
@@ -205,7 +205,7 @@
     return parsedopts, parsedargs
 
 
-class customopt(object):
+class customopt(object):  # pytype: disable=ignored-metaclass
     """Manage defaults and mutations for any type of opt."""
 
     __metaclass__ = abc.ABCMeta
--- a/mercurial/filemerge.py	Wed Nov 20 19:07:02 2019 +0100
+++ b/mercurial/filemerge.py	Fri Nov 22 21:42:04 2019 +0900
@@ -934,10 +934,10 @@
             name = os.path.join(tmproot, pre)
             if ext:
                 name += ext
-            f = open(name, r"wb")
+            f = open(name, "wb")
         else:
             fd, name = pycompat.mkstemp(prefix=pre + b'.', suffix=ext)
-            f = os.fdopen(fd, r"wb")
+            f = os.fdopen(fd, "wb")
         return f, name
 
     def tempfromcontext(prefix, ctx):
--- a/mercurial/hbisect.py	Wed Nov 20 19:07:02 2019 +0100
+++ b/mercurial/hbisect.py	Fri Nov 22 21:42:04 2019 +0900
@@ -11,6 +11,7 @@
 from __future__ import absolute_import
 
 import collections
+import contextlib
 
 from .i18n import _
 from .node import (
@@ -180,6 +181,15 @@
         raise error.Abort(_(b'cannot bisect (no known bad revisions)'))
 
 
+@contextlib.contextmanager
+def restore_state(repo, state, node):
+    try:
+        yield
+    finally:
+        state[b'current'] = [node]
+        save_state(repo, state)
+
+
 def get(repo, status):
     """
     Return a list of revision(s) that match the given status:
--- a/mercurial/help.py	Wed Nov 20 19:07:02 2019 +0100
+++ b/mercurial/help.py	Fri Nov 22 21:42:04 2019 +0900
@@ -36,7 +36,10 @@
     util,
 )
 from .hgweb import webcommands
-from .utils import compression
+from .utils import (
+    compression,
+    resourceutil,
+)
 
 _exclkeywords = {
     b"(ADVANCED)",
@@ -311,7 +314,7 @@
     """Return a delayed loader for help/topic.txt."""
 
     def loader(ui):
-        docdir = os.path.join(util.datapath, b'help')
+        docdir = os.path.join(resourceutil.datapath, b'helptext')
         if subdir:
             docdir = os.path.join(docdir, subdir)
         path = os.path.join(docdir, topic + b".txt")
@@ -805,7 +808,7 @@
                     appendcmds(catfns)
 
         ex = opts.get
-        anyopts = ex(r'keyword') or not (ex(r'command') or ex(r'extension'))
+        anyopts = ex('keyword') or not (ex('command') or ex('extension'))
         if not name and anyopts:
             exts = listexts(
                 _(b'enabled extensions:'),
--- a/mercurial/help/bundlespec.txt	Wed Nov 20 19:07:02 2019 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,84 +0,0 @@
-Mercurial supports generating standalone "bundle" files that hold repository
-data. These "bundles" are typically saved locally and used later or exchanged
-between different repositories, possibly on different machines. Example
-commands using bundles are :hg:`bundle` and :hg:`unbundle`.
-
-Generation of bundle files is controlled by a "bundle specification"
-("bundlespec") string. This string tells the bundle generation process how
-to create the bundle.
-
-A "bundlespec" string is composed of the following elements:
-
-type
-    A string denoting the bundle format to use.
-
-compression
-    Denotes the compression engine to use compressing the raw bundle data.
-
-parameters
-    Arbitrary key-value parameters to further control bundle generation.
-
-A "bundlespec" string has the following formats:
-
-<type>
-    The literal bundle format string is used.
-
-<compression>-<type>
-    The compression engine and format are delimited by a hyphen (``-``).
-
-Optional parameters follow the ``<type>``. Parameters are URI escaped
-``key=value`` pairs. Each pair is delimited by a semicolon (``;``). The
-first parameter begins after a ``;`` immediately following the ``<type>``
-value.
-
-Available Types
-===============
-
-The following bundle <type> strings are available:
-
-v1
-    Produces a legacy "changegroup" version 1 bundle.
-
-    This format is compatible with nearly all Mercurial clients because it is
-    the oldest. However, it has some limitations, which is why it is no longer
-    the default for new repositories.
-
-    ``v1`` bundles can be used with modern repositories using the "generaldelta"
-    storage format. However, it may take longer to produce the bundle and the
-    resulting bundle may be significantly larger than a ``v2`` bundle.
-
-    ``v1`` bundles can only use the ``gzip``, ``bzip2``, and ``none`` compression
-    formats.
-
-v2
-    Produces a version 2 bundle.
-
-    Version 2 bundles are an extensible format that can store additional
-    repository data (such as bookmarks and phases information) and they can
-    store data more efficiently, resulting in smaller bundles.
-
-    Version 2 bundles can also use modern compression engines, such as
-    ``zstd``, making them faster to compress and often smaller.
-
-Available Compression Engines
-=============================
-
-The following bundle <compression> engines can be used:
-
-.. bundlecompressionmarker
-
-Examples
-========
-
-``v2``
-    Produce a ``v2`` bundle using default options, including compression.
-
-``none-v1``
-    Produce a ``v1`` bundle with no compression.
-
-``zstd-v2``
-    Produce a ``v2`` bundle with zstandard compression using default
-    settings.
-
-``zstd-v1``
-    This errors because ``zstd`` is not supported for ``v1`` types.
--- a/mercurial/help/color.txt	Wed Nov 20 19:07:02 2019 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,149 +0,0 @@
-Mercurial colorizes output from several commands.
-
-For example, the diff command shows additions in green and deletions
-in red, while the status command shows modified files in magenta. Many
-other commands have analogous colors. It is possible to customize
-these colors.
-
-To enable color (default) whenever possible use::
-
-  [ui]
-  color = yes
-
-To disable color use::
-
-  [ui]
-  color = no
-
-See :hg:`help config.ui.color` for details.
-
-.. container:: windows
-
-  The default pager on Windows does not support color, so enabling the pager
-  will effectively disable color.  See :hg:`help config.ui.paginate` to disable
-  the pager.  Alternately, MSYS and Cygwin shells provide `less` as a pager,
-  which can be configured to support ANSI color mode.  Windows 10 natively
-  supports ANSI color mode.
-
-Mode
-====
-
-Mercurial can use various systems to display color. The supported modes are
-``ansi``, ``win32``, and ``terminfo``.  See :hg:`help config.color` for details
-about how to control the mode.
-
-Effects
-=======
-
-Other effects in addition to color, like bold and underlined text, are
-also available. By default, the terminfo database is used to find the
-terminal codes used to change color and effect.  If terminfo is not
-available, then effects are rendered with the ECMA-48 SGR control
-function (aka ANSI escape codes).
-
-The available effects in terminfo mode are 'blink', 'bold', 'dim',
-'inverse', 'invisible', 'italic', 'standout', and 'underline'; in
-ECMA-48 mode, the options are 'bold', 'inverse', 'italic', and
-'underline'.  How each is rendered depends on the terminal emulator.
-Some may not be available for a given terminal type, and will be
-silently ignored.
-
-If the terminfo entry for your terminal is missing codes for an effect
-or has the wrong codes, you can add or override those codes in your
-configuration::
-
-  [color]
-  terminfo.dim = \E[2m
-
-where '\E' is substituted with an escape character.
-
-Labels
-======
-
-Text receives color effects depending on the labels that it has. Many
-default Mercurial commands emit labelled text. You can also define
-your own labels in templates using the label function, see :hg:`help
-templates`. A single portion of text may have more than one label. In
-that case, effects given to the last label will override any other
-effects. This includes the special "none" effect, which nullifies
-other effects.
-
-Labels are normally invisible. In order to see these labels and their
-position in the text, use the global --color=debug option. The same
-anchor text may be associated to multiple labels, e.g.
-
-  [log.changeset changeset.secret|changeset:   22611:6f0a53c8f587]
-
-The following are the default effects for some default labels. Default
-effects may be overridden from your configuration file::
-
-  [color]
-  status.modified = blue bold underline red_background
-  status.added = green bold
-  status.removed = red bold blue_background
-  status.deleted = cyan bold underline
-  status.unknown = magenta bold underline
-  status.ignored = black bold
-
-  # 'none' turns off all effects
-  status.clean = none
-  status.copied = none
-
-  qseries.applied = blue bold underline
-  qseries.unapplied = black bold
-  qseries.missing = red bold
-
-  diff.diffline = bold
-  diff.extended = cyan bold
-  diff.file_a = red bold
-  diff.file_b = green bold
-  diff.hunk = magenta
-  diff.deleted = red
-  diff.inserted = green
-  diff.changed = white
-  diff.tab =
-  diff.trailingwhitespace = bold red_background
-
-  # Blank so it inherits the style of the surrounding label
-  changeset.public =
-  changeset.draft =
-  changeset.secret =
-
-  resolve.unresolved = red bold
-  resolve.resolved = green bold
-
-  bookmarks.active = green
-
-  branches.active = none
-  branches.closed = black bold
-  branches.current = green
-  branches.inactive = none
-
-  tags.normal = green
-  tags.local = black bold
-
-  rebase.rebased = blue
-  rebase.remaining = red bold
-
-  shelve.age = cyan
-  shelve.newest = green bold
-  shelve.name = blue bold
-
-  histedit.remaining = red bold
-
-Custom colors
-=============
-
-Because there are only eight standard colors, Mercurial allows you
-to define color names for other color slots which might be available
-for your terminal type, assuming terminfo mode.  For instance::
-
-  color.brightblue = 12
-  color.pink = 207
-  color.orange = 202
-
-to set 'brightblue' to color slot 12 (useful for 16 color terminals
-that have brighter colors defined in the upper eight) and, 'pink' and
-'orange' to colors in 256-color xterm's default color cube.  These
-defined colors may then be used as any of the pre-defined eight,
-including appending '_background' to set the background to that color.
--- a/mercurial/help/common.txt	Wed Nov 20 19:07:02 2019 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,8 +0,0 @@
-.. Common link and substitution definitions.
-
-.. |hg(1)| replace:: **hg**\ (1)
-.. _hg(1): hg.1.html
-.. |hgrc(5)| replace:: **hgrc**\ (5)
-.. _hgrc(5): hgrc.5.html
-.. |hgignore(5)| replace:: **hgignore**\ (5)
-.. _hgignore(5): hgignore.5.html
--- a/mercurial/help/config.txt	Wed Nov 20 19:07:02 2019 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,2870 +0,0 @@
-The Mercurial system uses a set of configuration files to control
-aspects of its behavior.
-
-Troubleshooting
-===============
-
-If you're having problems with your configuration,
-:hg:`config --debug` can help you understand what is introducing
-a setting into your environment.
-
-See :hg:`help config.syntax` and :hg:`help config.files`
-for information about how and where to override things.
-
-Structure
-=========
-
-The configuration files use a simple ini-file format. A configuration
-file consists of sections, led by a ``[section]`` header and followed
-by ``name = value`` entries::
-
-  [ui]
-  username = Firstname Lastname <firstname.lastname@example.net>
-  verbose = True
-
-The above entries will be referred to as ``ui.username`` and
-``ui.verbose``, respectively. See :hg:`help config.syntax`.
-
-Files
-=====
-
-Mercurial reads configuration data from several files, if they exist.
-These files do not exist by default and you will have to create the
-appropriate configuration files yourself:
-
-Local configuration is put into the per-repository ``<repo>/.hg/hgrc`` file.
-
-Global configuration like the username setting is typically put into:
-
-.. container:: windows
-
-  - ``%USERPROFILE%\mercurial.ini`` (on Windows)
-
-.. container:: unix.plan9
-
-  - ``$HOME/.hgrc`` (on Unix, Plan9)
-
-The names of these files depend on the system on which Mercurial is
-installed. ``*.rc`` files from a single directory are read in
-alphabetical order, later ones overriding earlier ones. Where multiple
-paths are given below, settings from earlier paths override later
-ones.
-
-.. container:: verbose.unix
-
-  On Unix, the following files are consulted:
-
-  - ``<repo>/.hg/hgrc`` (per-repository)
-  - ``$HOME/.hgrc`` (per-user)
-  - ``${XDG_CONFIG_HOME:-$HOME/.config}/hg/hgrc`` (per-user)
-  - ``<install-root>/etc/mercurial/hgrc`` (per-installation)
-  - ``<install-root>/etc/mercurial/hgrc.d/*.rc`` (per-installation)
-  - ``/etc/mercurial/hgrc`` (per-system)
-  - ``/etc/mercurial/hgrc.d/*.rc`` (per-system)
-  - ``<internal>/default.d/*.rc`` (defaults)
-
-.. container:: verbose.windows
-
-  On Windows, the following files are consulted:
-
-  - ``<repo>/.hg/hgrc`` (per-repository)
-  - ``%USERPROFILE%\.hgrc`` (per-user)
-  - ``%USERPROFILE%\Mercurial.ini`` (per-user)
-  - ``%HOME%\.hgrc`` (per-user)
-  - ``%HOME%\Mercurial.ini`` (per-user)
-  - ``HKEY_LOCAL_MACHINE\SOFTWARE\Mercurial`` (per-installation)
-  - ``<install-dir>\hgrc.d\*.rc`` (per-installation)
-  - ``<install-dir>\Mercurial.ini`` (per-installation)
-  - ``<internal>/default.d/*.rc`` (defaults)
-
-  .. note::
-
-   The registry key ``HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Mercurial``
-   is used when running 32-bit Python on 64-bit Windows.
-
-.. container:: windows
-
-  On Windows 9x, ``%HOME%`` is replaced by ``%APPDATA%``.
-
-.. container:: verbose.plan9
-
-  On Plan9, the following files are consulted:
-
-  - ``<repo>/.hg/hgrc`` (per-repository)
-  - ``$home/lib/hgrc`` (per-user)
-  - ``<install-root>/lib/mercurial/hgrc`` (per-installation)
-  - ``<install-root>/lib/mercurial/hgrc.d/*.rc`` (per-installation)
-  - ``/lib/mercurial/hgrc`` (per-system)
-  - ``/lib/mercurial/hgrc.d/*.rc`` (per-system)
-  - ``<internal>/default.d/*.rc`` (defaults)
-
-Per-repository configuration options only apply in a
-particular repository. This file is not version-controlled, and
-will not get transferred during a "clone" operation. Options in
-this file override options in all other configuration files.
-
-.. container:: unix.plan9
-
-  On Plan 9 and Unix, most of this file will be ignored if it doesn't
-  belong to a trusted user or to a trusted group. See
-  :hg:`help config.trusted` for more details.
-
-Per-user configuration file(s) are for the user running Mercurial.  Options
-in these files apply to all Mercurial commands executed by this user in any
-directory. Options in these files override per-system and per-installation
-options.
-
-Per-installation configuration files are searched for in the
-directory where Mercurial is installed. ``<install-root>`` is the
-parent directory of the **hg** executable (or symlink) being run.
-
-.. container:: unix.plan9
-
-  For example, if installed in ``/shared/tools/bin/hg``, Mercurial
-  will look in ``/shared/tools/etc/mercurial/hgrc``. Options in these
-  files apply to all Mercurial commands executed by any user in any
-  directory.
-
-Per-installation configuration files are for the system on
-which Mercurial is running. Options in these files apply to all
-Mercurial commands executed by any user in any directory. Registry
-keys contain PATH-like strings, every part of which must reference
-a ``Mercurial.ini`` file or be a directory where ``*.rc`` files will
-be read.  Mercurial checks each of these locations in the specified
-order until one or more configuration files are detected.
-
-Per-system configuration files are for the system on which Mercurial
-is running. Options in these files apply to all Mercurial commands
-executed by any user in any directory. Options in these files
-override per-installation options.
-
-Mercurial comes with some default configuration. The default configuration
-files are installed with Mercurial and will be overwritten on upgrades. Default
-configuration files should never be edited by users or administrators but can
-be overridden in other configuration files. So far the directory only contains
-merge tool configuration but packagers can also put other default configuration
-there.
-
-Syntax
-======
-
-A configuration file consists of sections, led by a ``[section]`` header
-and followed by ``name = value`` entries (sometimes called
-``configuration keys``)::
-
-    [spam]
-    eggs=ham
-    green=
-       eggs
-
-Each line contains one entry. If the lines that follow are indented,
-they are treated as continuations of that entry. Leading whitespace is
-removed from values. Empty lines are skipped. Lines beginning with
-``#`` or ``;`` are ignored and may be used to provide comments.
-
-Configuration keys can be set multiple times, in which case Mercurial
-will use the value that was configured last. As an example::
-
-    [spam]
-    eggs=large
-    ham=serrano
-    eggs=small
-
-This would set the configuration key named ``eggs`` to ``small``.
-
-It is also possible to define a section multiple times. A section can
-be redefined on the same and/or on different configuration files. For
-example::
-
-    [foo]
-    eggs=large
-    ham=serrano
-    eggs=small
-
-    [bar]
-    eggs=ham
-    green=
-       eggs
-
-    [foo]
-    ham=prosciutto
-    eggs=medium
-    bread=toasted
-
-This would set the ``eggs``, ``ham``, and ``bread`` configuration keys
-of the ``foo`` section to ``medium``, ``prosciutto``, and ``toasted``,
-respectively. As you can see there only thing that matters is the last
-value that was set for each of the configuration keys.
-
-If a configuration key is set multiple times in different
-configuration files the final value will depend on the order in which
-the different configuration files are read, with settings from earlier
-paths overriding later ones as described on the ``Files`` section
-above.
-
-A line of the form ``%include file`` will include ``file`` into the
-current configuration file. The inclusion is recursive, which means
-that included files can include other files. Filenames are relative to
-the configuration file in which the ``%include`` directive is found.
-Environment variables and ``~user`` constructs are expanded in
-``file``. This lets you do something like::
-
-  %include ~/.hgrc.d/$HOST.rc
-
-to include a different configuration file on each computer you use.
-
-A line with ``%unset name`` will remove ``name`` from the current
-section, if it has been set previously.
-
-The values are either free-form text strings, lists of text strings,
-or Boolean values. Boolean values can be set to true using any of "1",
-"yes", "true", or "on" and to false using "0", "no", "false", or "off"
-(all case insensitive).
-
-List values are separated by whitespace or comma, except when values are
-placed in double quotation marks::
-
-  allow_read = "John Doe, PhD", brian, betty
-
-Quotation marks can be escaped by prefixing them with a backslash. Only
-quotation marks at the beginning of a word is counted as a quotation
-(e.g., ``foo"bar baz`` is the list of ``foo"bar`` and ``baz``).
-
-Sections
-========
-
-This section describes the different sections that may appear in a
-Mercurial configuration file, the purpose of each section, its possible
-keys, and their possible values.
-
-``alias``
----------
-
-Defines command aliases.
-
-Aliases allow you to define your own commands in terms of other
-commands (or aliases), optionally including arguments. Positional
-arguments in the form of ``$1``, ``$2``, etc. in the alias definition
-are expanded by Mercurial before execution. Positional arguments not
-already used by ``$N`` in the definition are put at the end of the
-command to be executed.
-
-Alias definitions consist of lines of the form::
-
-    <alias> = <command> [<argument>]...
-
-For example, this definition::
-
-    latest = log --limit 5
-
-creates a new command ``latest`` that shows only the five most recent
-changesets. You can define subsequent aliases using earlier ones::
-
-    stable5 = latest -b stable
-
-.. note::
-
-   It is possible to create aliases with the same names as
-   existing commands, which will then override the original
-   definitions. This is almost always a bad idea!
-
-An alias can start with an exclamation point (``!``) to make it a
-shell alias. A shell alias is executed with the shell and will let you
-run arbitrary commands. As an example, ::
-
-   echo = !echo $@
-
-will let you do ``hg echo foo`` to have ``foo`` printed in your
-terminal. A better example might be::
-
-   purge = !$HG status --no-status --unknown -0 re: | xargs -0 rm -f
-
-which will make ``hg purge`` delete all unknown files in the
-repository in the same manner as the purge extension.
-
-Positional arguments like ``$1``, ``$2``, etc. in the alias definition
-expand to the command arguments. Unmatched arguments are
-removed. ``$0`` expands to the alias name and ``$@`` expands to all
-arguments separated by a space. ``"$@"`` (with quotes) expands to all
-arguments quoted individually and separated by a space. These expansions
-happen before the command is passed to the shell.
-
-Shell aliases are executed in an environment where ``$HG`` expands to
-the path of the Mercurial that was used to execute the alias. This is
-useful when you want to call further Mercurial commands in a shell
-alias, as was done above for the purge alias. In addition,
-``$HG_ARGS`` expands to the arguments given to Mercurial. In the ``hg
-echo foo`` call above, ``$HG_ARGS`` would expand to ``echo foo``.
-
-.. note::
-
-   Some global configuration options such as ``-R`` are
-   processed before shell aliases and will thus not be passed to
-   aliases.
-
-
-``annotate``
-------------
-
-Settings used when displaying file annotations. All values are
-Booleans and default to False. See :hg:`help config.diff` for
-related options for the diff command.
-
-``ignorews``
-    Ignore white space when comparing lines.
-
-``ignorewseol``
-    Ignore white space at the end of a line when comparing lines.
-
-``ignorewsamount``
-    Ignore changes in the amount of white space.
-
-``ignoreblanklines``
-    Ignore changes whose lines are all blank.
-
-
-``auth``
---------
-
-Authentication credentials and other authentication-like configuration
-for HTTP connections. This section allows you to store usernames and
-passwords for use when logging *into* HTTP servers. See
-:hg:`help config.web` if you want to configure *who* can login to
-your HTTP server.
-
-The following options apply to all hosts.
-
-``cookiefile``
-    Path to a file containing HTTP cookie lines. Cookies matching a
-    host will be sent automatically.
-
-    The file format uses the Mozilla cookies.txt format, which defines cookies
-    on their own lines. Each line contains 7 fields delimited by the tab
-    character (domain, is_domain_cookie, path, is_secure, expires, name,
-    value). For more info, do an Internet search for "Netscape cookies.txt
-    format."
-
-    Note: the cookies parser does not handle port numbers on domains. You
-    will need to remove ports from the domain for the cookie to be recognized.
-    This could result in a cookie being disclosed to an unwanted server.
-
-    The cookies file is read-only.
-
-Other options in this section are grouped by name and have the following
-format::
-
-    <name>.<argument> = <value>
-
-where ``<name>`` is used to group arguments into authentication
-entries. Example::
-
-    foo.prefix = hg.intevation.de/mercurial
-    foo.username = foo
-    foo.password = bar
-    foo.schemes = http https
-
-    bar.prefix = secure.example.org
-    bar.key = path/to/file.key
-    bar.cert = path/to/file.cert
-    bar.schemes = https
-
-Supported arguments:
-
-``prefix``
-    Either ``*`` or a URI prefix with or without the scheme part.
-    The authentication entry with the longest matching prefix is used
-    (where ``*`` matches everything and counts as a match of length
-    1). If the prefix doesn't include a scheme, the match is performed
-    against the URI with its scheme stripped as well, and the schemes
-    argument, q.v., is then subsequently consulted.
-
-``username``
-    Optional. Username to authenticate with. If not given, and the
-    remote site requires basic or digest authentication, the user will
-    be prompted for it. Environment variables are expanded in the
-    username letting you do ``foo.username = $USER``. If the URI
-    includes a username, only ``[auth]`` entries with a matching
-    username or without a username will be considered.
-
-``password``
-    Optional. Password to authenticate with. If not given, and the
-    remote site requires basic or digest authentication, the user
-    will be prompted for it.
-
-``key``
-    Optional. PEM encoded client certificate key file. Environment
-    variables are expanded in the filename.
-
-``cert``
-    Optional. PEM encoded client certificate chain file. Environment
-    variables are expanded in the filename.
-
-``schemes``
-    Optional. Space separated list of URI schemes to use this
-    authentication entry with. Only used if the prefix doesn't include
-    a scheme. Supported schemes are http and https. They will match
-    static-http and static-https respectively, as well.
-    (default: https)
-
-If no suitable authentication entry is found, the user is prompted
-for credentials as usual if required by the remote.
-
-``color``
----------
-
-Configure the Mercurial color mode. For details about how to define your custom
-effect and style see :hg:`help color`.
-
-``mode``
-    String: control the method used to output color. One of ``auto``, ``ansi``,
-    ``win32``, ``terminfo`` or ``debug``. In auto mode, Mercurial will
-    use ANSI mode by default (or win32 mode prior to Windows 10) if it detects a
-    terminal. Any invalid value will disable color.
-
-``pagermode``
-    String: optional override of ``color.mode`` used with pager.
-
-    On some systems, terminfo mode may cause problems when using
-    color with ``less -R`` as a pager program. less with the -R option
-    will only display ECMA-48 color codes, and terminfo mode may sometimes
-    emit codes that less doesn't understand. You can work around this by
-    either using ansi mode (or auto mode), or by using less -r (which will
-    pass through all terminal control codes, not just color control
-    codes).
-
-    On some systems (such as MSYS in Windows), the terminal may support
-    a different color mode than the pager program.
-
-``commands``
-------------
-
-``commit.post-status``
-    Show status of files in the working directory after successful commit.
-    (default: False)
-
-``push.require-revs``
-    Require revisions to push be specified using one or more mechanisms such as
-    specifying them positionally on the command line, using ``-r``, ``-b``,
-    and/or ``-B`` on the command line, or using ``paths.<path>:pushrev`` in the
-    configuration. If this is enabled and revisions are not specified, the
-    command aborts.
-    (default: False)
-
-``resolve.confirm``
-    Confirm before performing action if no filename is passed.
-    (default: False)
-
-``resolve.explicit-re-merge``
-    Require uses of ``hg resolve`` to specify which action it should perform,
-    instead of re-merging files by default.
-    (default: False)
-
-``resolve.mark-check``
-    Determines what level of checking :hg:`resolve --mark` will perform before
-    marking files as resolved. Valid values are ``none`, ``warn``, and
-    ``abort``. ``warn`` will output a warning listing the file(s) that still
-    have conflict markers in them, but will still mark everything resolved.
-    ``abort`` will output the same warning but will not mark things as resolved.
-    If --all is passed and this is set to ``abort``, only a warning will be
-    shown (an error will not be raised).
-    (default: ``none``)
-
-``status.relative``
-    Make paths in :hg:`status` output relative to the current directory.
-    (default: False)
-
-``status.terse``
-    Default value for the --terse flag, which condenses status output.
-    (default: empty)
-
-``update.check``
-    Determines what level of checking :hg:`update` will perform before moving
-    to a destination revision. Valid values are ``abort``, ``none``,
-    ``linear``, and ``noconflict``. ``abort`` always fails if the working
-    directory has uncommitted changes. ``none`` performs no checking, and may
-    result in a merge with uncommitted changes. ``linear`` allows any update
-    as long as it follows a straight line in the revision history, and may
-    trigger a merge with uncommitted changes. ``noconflict`` will allow any
-    update which would not trigger a merge with uncommitted changes, if any
-    are present.
-    (default: ``linear``)
-
-``update.requiredest``
-    Require that the user pass a destination when running :hg:`update`.
-    For example, :hg:`update .::` will be allowed, but a plain :hg:`update`
-    will be disallowed.
-    (default: False)
-
-``committemplate``
-------------------
-
-``changeset``
-    String: configuration in this section is used as the template to
-    customize the text shown in the editor when committing.
-
-In addition to pre-defined template keywords, commit log specific one
-below can be used for customization:
-
-``extramsg``
-    String: Extra message (typically 'Leave message empty to abort
-    commit.'). This may be changed by some commands or extensions.
-
-For example, the template configuration below shows as same text as
-one shown by default::
-
-    [committemplate]
-    changeset = {desc}\n\n
-        HG: Enter commit message.  Lines beginning with 'HG:' are removed.
-        HG: {extramsg}
-        HG: --
-        HG: user: {author}\n{ifeq(p2rev, "-1", "",
-       "HG: branch merge\n")
-       }HG: branch '{branch}'\n{if(activebookmark,
-       "HG: bookmark '{activebookmark}'\n")   }{subrepos %
-       "HG: subrepo {subrepo}\n"              }{file_adds %
-       "HG: added {file}\n"                   }{file_mods %
-       "HG: changed {file}\n"                 }{file_dels %
-       "HG: removed {file}\n"                 }{if(files, "",
-       "HG: no files changed\n")}
-
-``diff()``
-    String: show the diff (see :hg:`help templates` for detail)
-
-Sometimes it is helpful to show the diff of the changeset in the editor without
-having to prefix 'HG: ' to each line so that highlighting works correctly. For
-this, Mercurial provides a special string which will ignore everything below
-it::
-
-     HG: ------------------------ >8 ------------------------
-
-For example, the template configuration below will show the diff below the
-extra message::
-
-    [committemplate]
-    changeset = {desc}\n\n
-        HG: Enter commit message.  Lines beginning with 'HG:' are removed.
-        HG: {extramsg}
-        HG: ------------------------ >8 ------------------------
-        HG: Do not touch the line above.
-        HG: Everything below will be removed.
-        {diff()}
-
-.. note::
-
-   For some problematic encodings (see :hg:`help win32mbcs` for
-   detail), this customization should be configured carefully, to
-   avoid showing broken characters.
-
-   For example, if a multibyte character ending with backslash (0x5c) is
-   followed by the ASCII character 'n' in the customized template,
-   the sequence of backslash and 'n' is treated as line-feed unexpectedly
-   (and the multibyte character is broken, too).
-
-Customized template is used for commands below (``--edit`` may be
-required):
-
-- :hg:`backout`
-- :hg:`commit`
-- :hg:`fetch` (for merge commit only)
-- :hg:`graft`
-- :hg:`histedit`
-- :hg:`import`
-- :hg:`qfold`, :hg:`qnew` and :hg:`qrefresh`
-- :hg:`rebase`
-- :hg:`shelve`
-- :hg:`sign`
-- :hg:`tag`
-- :hg:`transplant`
-
-Configuring items below instead of ``changeset`` allows showing
-customized message only for specific actions, or showing different
-messages for each action.
-
-- ``changeset.backout`` for :hg:`backout`
-- ``changeset.commit.amend.merge`` for :hg:`commit --amend` on merges
-- ``changeset.commit.amend.normal`` for :hg:`commit --amend` on other
-- ``changeset.commit.normal.merge`` for :hg:`commit` on merges
-- ``changeset.commit.normal.normal`` for :hg:`commit` on other
-- ``changeset.fetch`` for :hg:`fetch` (impling merge commit)
-- ``changeset.gpg.sign`` for :hg:`sign`
-- ``changeset.graft`` for :hg:`graft`
-- ``changeset.histedit.edit`` for ``edit`` of :hg:`histedit`
-- ``changeset.histedit.fold`` for ``fold`` of :hg:`histedit`
-- ``changeset.histedit.mess`` for ``mess`` of :hg:`histedit`
-- ``changeset.histedit.pick`` for ``pick`` of :hg:`histedit`
-- ``changeset.import.bypass`` for :hg:`import --bypass`
-- ``changeset.import.normal.merge`` for :hg:`import` on merges
-- ``changeset.import.normal.normal`` for :hg:`import` on other
-- ``changeset.mq.qnew`` for :hg:`qnew`
-- ``changeset.mq.qfold`` for :hg:`qfold`
-- ``changeset.mq.qrefresh`` for :hg:`qrefresh`
-- ``changeset.rebase.collapse`` for :hg:`rebase --collapse`
-- ``changeset.rebase.merge`` for :hg:`rebase` on merges
-- ``changeset.rebase.normal`` for :hg:`rebase` on other
-- ``changeset.shelve.shelve`` for :hg:`shelve`
-- ``changeset.tag.add`` for :hg:`tag` without ``--remove``
-- ``changeset.tag.remove`` for :hg:`tag --remove`
-- ``changeset.transplant.merge`` for :hg:`transplant` on merges
-- ``changeset.transplant.normal`` for :hg:`transplant` on other
-
-These dot-separated lists of names are treated as hierarchical ones.
-For example, ``changeset.tag.remove`` customizes the commit message
-only for :hg:`tag --remove`, but ``changeset.tag`` customizes the
-commit message for :hg:`tag` regardless of ``--remove`` option.
-
-When the external editor is invoked for a commit, the corresponding
-dot-separated list of names without the ``changeset.`` prefix
-(e.g. ``commit.normal.normal``) is in the ``HGEDITFORM`` environment
-variable.
-
-In this section, items other than ``changeset`` can be referred from
-others. For example, the configuration to list committed files up
-below can be referred as ``{listupfiles}``::
-
-    [committemplate]
-    listupfiles = {file_adds %
-       "HG: added {file}\n"     }{file_mods %
-       "HG: changed {file}\n"   }{file_dels %
-       "HG: removed {file}\n"   }{if(files, "",
-       "HG: no files changed\n")}
-
-``decode/encode``
------------------
-
-Filters for transforming files on checkout/checkin. This would
-typically be used for newline processing or other
-localization/canonicalization of files.
-
-Filters consist of a filter pattern followed by a filter command.
-Filter patterns are globs by default, rooted at the repository root.
-For example, to match any file ending in ``.txt`` in the root
-directory only, use the pattern ``*.txt``. To match any file ending
-in ``.c`` anywhere in the repository, use the pattern ``**.c``.
-For each file only the first matching filter applies.
-
-The filter command can start with a specifier, either ``pipe:`` or
-``tempfile:``. If no specifier is given, ``pipe:`` is used by default.
-
-A ``pipe:`` command must accept data on stdin and return the transformed
-data on stdout.
-
-Pipe example::
-
-  [encode]
-  # uncompress gzip files on checkin to improve delta compression
-  # note: not necessarily a good idea, just an example
-  *.gz = pipe: gunzip
-
-  [decode]
-  # recompress gzip files when writing them to the working dir (we
-  # can safely omit "pipe:", because it's the default)
-  *.gz = gzip
-
-A ``tempfile:`` command is a template. The string ``INFILE`` is replaced
-with the name of a temporary file that contains the data to be
-filtered by the command. The string ``OUTFILE`` is replaced with the name
-of an empty temporary file, where the filtered data must be written by
-the command.
-
-.. container:: windows
-
-   .. note::
-
-     The tempfile mechanism is recommended for Windows systems,
-     where the standard shell I/O redirection operators often have
-     strange effects and may corrupt the contents of your files.
-
-This filter mechanism is used internally by the ``eol`` extension to
-translate line ending characters between Windows (CRLF) and Unix (LF)
-format. We suggest you use the ``eol`` extension for convenience.
-
-
-``defaults``
-------------
-
-(defaults are deprecated. Don't use them. Use aliases instead.)
-
-Use the ``[defaults]`` section to define command defaults, i.e. the
-default options/arguments to pass to the specified commands.
-
-The following example makes :hg:`log` run in verbose mode, and
-:hg:`status` show only the modified files, by default::
-
-  [defaults]
-  log = -v
-  status = -m
-
-The actual commands, instead of their aliases, must be used when
-defining command defaults. The command defaults will also be applied
-to the aliases of the commands defined.
-
-
-``diff``
---------
-
-Settings used when displaying diffs. Everything except for ``unified``
-is a Boolean and defaults to False. See :hg:`help config.annotate`
-for related options for the annotate command.
-
-``git``
-    Use git extended diff format.
-
-``nobinary``
-    Omit git binary patches.
-
-``nodates``
-    Don't include dates in diff headers.
-
-``noprefix``
-    Omit 'a/' and 'b/' prefixes from filenames. Ignored in plain mode.
-
-``showfunc``
-    Show which function each change is in.
-
-``ignorews``
-    Ignore white space when comparing lines.
-
-``ignorewsamount``
-    Ignore changes in the amount of white space.
-
-``ignoreblanklines``
-    Ignore changes whose lines are all blank.
-
-``unified``
-    Number of lines of context to show.
-
-``word-diff``
-    Highlight changed words.
-
-``email``
----------
-
-Settings for extensions that send email messages.
-
-``from``
-    Optional. Email address to use in "From" header and SMTP envelope
-    of outgoing messages.
-
-``to``
-    Optional. Comma-separated list of recipients' email addresses.
-
-``cc``
-    Optional. Comma-separated list of carbon copy recipients'
-    email addresses.
-
-``bcc``
-    Optional. Comma-separated list of blind carbon copy recipients'
-    email addresses.
-
-``method``
-    Optional. Method to use to send email messages. If value is ``smtp``
-    (default), use SMTP (see the ``[smtp]`` section for configuration).
-    Otherwise, use as name of program to run that acts like sendmail
-    (takes ``-f`` option for sender, list of recipients on command line,
-    message on stdin). Normally, setting this to ``sendmail`` or
-    ``/usr/sbin/sendmail`` is enough to use sendmail to send messages.
-
-``charsets``
-    Optional. Comma-separated list of character sets considered
-    convenient for recipients. Addresses, headers, and parts not
-    containing patches of outgoing messages will be encoded in the
-    first character set to which conversion from local encoding
-    (``$HGENCODING``, ``ui.fallbackencoding``) succeeds. If correct
-    conversion fails, the text in question is sent as is.
-    (default: '')
-
-    Order of outgoing email character sets:
-
-    1. ``us-ascii``: always first, regardless of settings
-    2. ``email.charsets``: in order given by user
-    3. ``ui.fallbackencoding``: if not in email.charsets
-    4. ``$HGENCODING``: if not in email.charsets
-    5. ``utf-8``: always last, regardless of settings
-
-Email example::
-
-  [email]
-  from = Joseph User <joe.user@example.com>
-  method = /usr/sbin/sendmail
-  # charsets for western Europeans
-  # us-ascii, utf-8 omitted, as they are tried first and last
-  charsets = iso-8859-1, iso-8859-15, windows-1252
-
-
-``extensions``
---------------
-
-Mercurial has an extension mechanism for adding new features. To
-enable an extension, create an entry for it in this section.
-
-If you know that the extension is already in Python's search path,
-you can give the name of the module, followed by ``=``, with nothing
-after the ``=``.
-
-Otherwise, give a name that you choose, followed by ``=``, followed by
-the path to the ``.py`` file (including the file name extension) that
-defines the extension.
-
-To explicitly disable an extension that is enabled in an hgrc of
-broader scope, prepend its path with ``!``, as in ``foo = !/ext/path``
-or ``foo = !`` when path is not supplied.
-
-Example for ``~/.hgrc``::
-
-  [extensions]
-  # (the churn extension will get loaded from Mercurial's path)
-  churn =
-  # (this extension will get loaded from the file specified)
-  myfeature = ~/.hgext/myfeature.py
-
-
-``format``
-----------
-
-Configuration that controls the repository format. Newer format options are more
-powerful but incompatible with some older versions of Mercurial. Format options
-are considered at repository initialization only. You need to make a new clone
-for config change to be taken into account.
-
-For more details about repository format and version compatibility, see
-https://www.mercurial-scm.org/wiki/MissingRequirement
-
-``usegeneraldelta``
-    Enable or disable the "generaldelta" repository format which improves
-    repository compression by allowing "revlog" to store delta against arbitrary
-    revision instead of the previous stored one. This provides significant
-    improvement for repositories with branches.
-
-    Repositories with this on-disk format require Mercurial version 1.9.
-
-    Enabled by default.
-
-``dotencode``
-    Enable or disable the "dotencode" repository format which enhances
-    the "fncache" repository format (which has to be enabled to use
-    dotencode) to avoid issues with filenames starting with ._ on
-    Mac OS X and spaces on Windows.
-
-    Repositories with this on-disk format require Mercurial version 1.7.
-
-    Enabled by default.
-
-``usefncache``
-    Enable or disable the "fncache" repository format which enhances
-    the "store" repository format (which has to be enabled to use
-    fncache) to allow longer filenames and avoids using Windows
-    reserved names, e.g. "nul".
-
-    Repositories with this on-disk format require Mercurial version 1.1.
-
-    Enabled by default.
-
-``usestore``
-    Enable or disable the "store" repository format which improves
-    compatibility with systems that fold case or otherwise mangle
-    filenames. Disabling this option will allow you to store longer filenames
-    in some situations at the expense of compatibility.
-
-    Repositories with this on-disk format require Mercurial version 0.9.4.
-
-    Enabled by default.
-
-``sparse-revlog``
-    Enable or disable the ``sparse-revlog`` delta strategy. This format improves
-    delta re-use inside revlog. For very branchy repositories, it results in a
-    smaller store. For repositories with many revisions, it also helps
-    performance (by using shortened delta chains.)
-
-    Repositories with this on-disk format require Mercurial version 4.7
-
-    Enabled by default.
-
-``revlog-compression``
-    Compression algorithm used by revlog. Supported value are `zlib` and `zstd`.
-    The `zlib` engine is the historical default of Mercurial. `zstd` is a newer
-    format that is usually a net win over `zlib` operating faster at better
-    compression rate. Use `zstd` to reduce CPU usage.
-
-    On some system, Mercurial installation may lack `zstd` supports. Default is `zlib`.
-
-``bookmarks-in-store``
-    Store bookmarks in .hg/store/. This means that bookmarks are shared when
-    using `hg share` regardless of the `-B` option.
-
-    Repositories with this on-disk format require Mercurial version 5.1.
-
-    Disabled by default.
-
-
-``graph``
----------
-
-Web graph view configuration. This section let you change graph
-elements display properties by branches, for instance to make the
-``default`` branch stand out.
-
-Each line has the following format::
-
-    <branch>.<argument> = <value>
-
-where ``<branch>`` is the name of the branch being
-customized. Example::
-
-    [graph]
-    # 2px width
-    default.width = 2
-    # red color
-    default.color = FF0000
-
-Supported arguments:
-
-``width``
-    Set branch edges width in pixels.
-
-``color``
-    Set branch edges color in hexadecimal RGB notation.
-
-``hooks``
----------
-
-Commands or Python functions that get automatically executed by
-various actions such as starting or finishing a commit. Multiple
-hooks can be run for the same action by appending a suffix to the
-action. Overriding a site-wide hook can be done by changing its
-value or setting it to an empty string.  Hooks can be prioritized
-by adding a prefix of ``priority.`` to the hook name on a new line
-and setting the priority. The default priority is 0.
-
-Example ``.hg/hgrc``::
-
-  [hooks]
-  # update working directory after adding changesets
-  changegroup.update = hg update
-  # do not use the site-wide hook
-  incoming =
-  incoming.email = /my/email/hook
-  incoming.autobuild = /my/build/hook
-  # force autobuild hook to run before other incoming hooks
-  priority.incoming.autobuild = 1
-
-Most hooks are run with environment variables set that give useful
-additional information. For each hook below, the environment variables
-it is passed are listed with names in the form ``$HG_foo``. The
-``$HG_HOOKTYPE`` and ``$HG_HOOKNAME`` variables are set for all hooks.
-They contain the type of hook which triggered the run and the full name
-of the hook in the config, respectively. In the example above, this will
-be ``$HG_HOOKTYPE=incoming`` and ``$HG_HOOKNAME=incoming.email``.
-
-.. container:: windows
-
-  Some basic Unix syntax can be enabled for portability, including ``$VAR``
-  and ``${VAR}`` style variables.  A ``~`` followed by ``\`` or ``/`` will
-  be expanded to ``%USERPROFILE%`` to simulate a subset of tilde expansion
-  on Unix.  To use a literal ``$`` or ``~``, it must be escaped with a back
-  slash or inside of a strong quote.  Strong quotes will be replaced by
-  double quotes after processing.
-
-  This feature is enabled by adding a prefix of ``tonative.`` to the hook
-  name on a new line, and setting it to ``True``.  For example::
-
-    [hooks]
-    incoming.autobuild = /my/build/hook
-    # enable translation to cmd.exe syntax for autobuild hook
-    tonative.incoming.autobuild = True
-
-``changegroup``
-  Run after a changegroup has been added via push, pull or unbundle.  The ID of
-  the first new changeset is in ``$HG_NODE`` and last is in ``$HG_NODE_LAST``.
-  The URL from which changes came is in ``$HG_URL``.
-
-``commit``
-  Run after a changeset has been created in the local repository. The ID
-  of the newly created changeset is in ``$HG_NODE``. Parent changeset
-  IDs are in ``$HG_PARENT1`` and ``$HG_PARENT2``.
-
-``incoming``
-  Run after a changeset has been pulled, pushed, or unbundled into
-  the local repository. The ID of the newly arrived changeset is in
-  ``$HG_NODE``. The URL that was source of the changes is in ``$HG_URL``.
-
-``outgoing``
-  Run after sending changes from the local repository to another. The ID of
-  first changeset sent is in ``$HG_NODE``. The source of operation is in
-  ``$HG_SOURCE``. Also see :hg:`help config.hooks.preoutgoing`.
-
-``post-<command>``
-  Run after successful invocations of the associated command. The
-  contents of the command line are passed as ``$HG_ARGS`` and the result
-  code in ``$HG_RESULT``. Parsed command line arguments are passed as
-  ``$HG_PATS`` and ``$HG_OPTS``. These contain string representations of
-  the python data internally passed to <command>. ``$HG_OPTS`` is a
-  dictionary of options (with unspecified options set to their defaults).
-  ``$HG_PATS`` is a list of arguments. Hook failure is ignored.
-
-``fail-<command>``
-  Run after a failed invocation of an associated command. The contents
-  of the command line are passed as ``$HG_ARGS``. Parsed command line
-  arguments are passed as ``$HG_PATS`` and ``$HG_OPTS``. These contain
-  string representations of the python data internally passed to
-  <command>. ``$HG_OPTS`` is a dictionary of options (with unspecified
-  options set to their defaults). ``$HG_PATS`` is a list of arguments.
-  Hook failure is ignored.
-
-``pre-<command>``
-  Run before executing the associated command. The contents of the
-  command line are passed as ``$HG_ARGS``. Parsed command line arguments
-  are passed as ``$HG_PATS`` and ``$HG_OPTS``. These contain string
-  representations of the data internally passed to <command>. ``$HG_OPTS``
-  is a dictionary of options (with unspecified options set to their
-  defaults). ``$HG_PATS`` is a list of arguments. If the hook returns
-  failure, the command doesn't execute and Mercurial returns the failure
-  code.
-
-``prechangegroup``
-  Run before a changegroup is added via push, pull or unbundle. Exit
-  status 0 allows the changegroup to proceed. A non-zero status will
-  cause the push, pull or unbundle to fail. The URL from which changes
-  will come is in ``$HG_URL``.
-
-``precommit``
-  Run before starting a local commit. Exit status 0 allows the
-  commit to proceed. A non-zero status will cause the commit to fail.
-  Parent changeset IDs are in ``$HG_PARENT1`` and ``$HG_PARENT2``.
-
-``prelistkeys``
-  Run before listing pushkeys (like bookmarks) in the
-  repository. A non-zero status will cause failure. The key namespace is
-  in ``$HG_NAMESPACE``.
-
-``preoutgoing``
-  Run before collecting changes to send from the local repository to
-  another. A non-zero status will cause failure. This lets you prevent
-  pull over HTTP or SSH. It can also prevent propagating commits (via
-  local pull, push (outbound) or bundle commands), but not completely,
-  since you can just copy files instead. The source of operation is in
-  ``$HG_SOURCE``. If "serve", the operation is happening on behalf of a remote
-  SSH or HTTP repository. If "push", "pull" or "bundle", the operation
-  is happening on behalf of a repository on same system.
-
-``prepushkey``
-  Run before a pushkey (like a bookmark) is added to the
-  repository. A non-zero status will cause the key to be rejected. The
-  key namespace is in ``$HG_NAMESPACE``, the key is in ``$HG_KEY``,
-  the old value (if any) is in ``$HG_OLD``, and the new value is in
-  ``$HG_NEW``.
-
-``pretag``
-  Run before creating a tag. Exit status 0 allows the tag to be
-  created. A non-zero status will cause the tag to fail. The ID of the
-  changeset to tag is in ``$HG_NODE``. The name of tag is in ``$HG_TAG``. The
-  tag is local if ``$HG_LOCAL=1``, or in the repository if ``$HG_LOCAL=0``.
-
-``pretxnopen``
-  Run before any new repository transaction is open. The reason for the
-  transaction will be in ``$HG_TXNNAME``, and a unique identifier for the
-  transaction will be in ``HG_TXNID``. A non-zero status will prevent the
-  transaction from being opened.
-
-``pretxnclose``
-  Run right before the transaction is actually finalized. Any repository change
-  will be visible to the hook program. This lets you validate the transaction
-  content or change it. Exit status 0 allows the commit to proceed. A non-zero
-  status will cause the transaction to be rolled back. The reason for the
-  transaction opening will be in ``$HG_TXNNAME``, and a unique identifier for
-  the transaction will be in ``HG_TXNID``. The rest of the available data will
-  vary according the transaction type. New changesets will add ``$HG_NODE``
-  (the ID of the first added changeset), ``$HG_NODE_LAST`` (the ID of the last
-  added changeset), ``$HG_URL`` and ``$HG_SOURCE`` variables.  Bookmark and
-  phase changes will set ``HG_BOOKMARK_MOVED`` and ``HG_PHASES_MOVED`` to ``1``
-  respectively, etc.
-
-``pretxnclose-bookmark``
-  Run right before a bookmark change is actually finalized. Any repository
-  change will be visible to the hook program. This lets you validate the
-  transaction content or change it. Exit status 0 allows the commit to
-  proceed. A non-zero status will cause the transaction to be rolled back.
-  The name of the bookmark will be available in ``$HG_BOOKMARK``, the new
-  bookmark location will be available in ``$HG_NODE`` while the previous
-  location will be available in ``$HG_OLDNODE``. In case of a bookmark
-  creation ``$HG_OLDNODE`` will be empty. In case of deletion ``$HG_NODE``
-  will be empty.
-  In addition, the reason for the transaction opening will be in
-  ``$HG_TXNNAME``, and a unique identifier for the transaction will be in
-  ``HG_TXNID``.
-
-``pretxnclose-phase``
-  Run right before a phase change is actually finalized. Any repository change
-  will be visible to the hook program. This lets you validate the transaction
-  content or change it. Exit status 0 allows the commit to proceed.  A non-zero
-  status will cause the transaction to be rolled back. The hook is called
-  multiple times, once for each revision affected by a phase change.
-  The affected node is available in ``$HG_NODE``, the phase in ``$HG_PHASE``
-  while the previous ``$HG_OLDPHASE``. In case of new node, ``$HG_OLDPHASE``
-  will be empty.  In addition, the reason for the transaction opening will be in
-  ``$HG_TXNNAME``, and a unique identifier for the transaction will be in
-  ``HG_TXNID``. The hook is also run for newly added revisions. In this case
-  the ``$HG_OLDPHASE`` entry will be empty.
-
-``txnclose``
-  Run after any repository transaction has been committed. At this
-  point, the transaction can no longer be rolled back. The hook will run
-  after the lock is released. See :hg:`help config.hooks.pretxnclose` for
-  details about available variables.
-
-``txnclose-bookmark``
-  Run after any bookmark change has been committed. At this point, the
-  transaction can no longer be rolled back. The hook will run after the lock
-  is released. See :hg:`help config.hooks.pretxnclose-bookmark` for details
-  about available variables.
-
-``txnclose-phase``
-  Run after any phase change has been committed. At this point, the
-  transaction can no longer be rolled back. The hook will run after the lock
-  is released. See :hg:`help config.hooks.pretxnclose-phase` for details about
-  available variables.
-
-``txnabort``
-  Run when a transaction is aborted. See :hg:`help config.hooks.pretxnclose`
-  for details about available variables.
-
-``pretxnchangegroup``
-  Run after a changegroup has been added via push, pull or unbundle, but before
-  the transaction has been committed. The changegroup is visible to the hook
-  program. This allows validation of incoming changes before accepting them.
-  The ID of the first new changeset is in ``$HG_NODE`` and last is in
-  ``$HG_NODE_LAST``. Exit status 0 allows the transaction to commit. A non-zero
-  status will cause the transaction to be rolled back, and the push, pull or
-  unbundle will fail. The URL that was the source of changes is in ``$HG_URL``.
-
-``pretxncommit``
-  Run after a changeset has been created, but before the transaction is
-  committed. The changeset is visible to the hook program. This allows
-  validation of the commit message and changes. Exit status 0 allows the
-  commit to proceed. A non-zero status will cause the transaction to
-  be rolled back. The ID of the new changeset is in ``$HG_NODE``. The parent
-  changeset IDs are in ``$HG_PARENT1`` and ``$HG_PARENT2``.
-
-``preupdate``
-  Run before updating the working directory. Exit status 0 allows
-  the update to proceed. A non-zero status will prevent the update.
-  The changeset ID of first new parent is in ``$HG_PARENT1``. If updating to a
-  merge, the ID of second new parent is in ``$HG_PARENT2``.
-
-``listkeys``
-  Run after listing pushkeys (like bookmarks) in the repository. The
-  key namespace is in ``$HG_NAMESPACE``. ``$HG_VALUES`` is a
-  dictionary containing the keys and values.
-
-``pushkey``
-  Run after a pushkey (like a bookmark) is added to the
-  repository. The key namespace is in ``$HG_NAMESPACE``, the key is in
-  ``$HG_KEY``, the old value (if any) is in ``$HG_OLD``, and the new
-  value is in ``$HG_NEW``.
-
-``tag``
-  Run after a tag is created. The ID of the tagged changeset is in ``$HG_NODE``.
-  The name of tag is in ``$HG_TAG``. The tag is local if ``$HG_LOCAL=1``, or in
-  the repository if ``$HG_LOCAL=0``.
-
-``update``
-  Run after updating the working directory. The changeset ID of first
-  new parent is in ``$HG_PARENT1``. If updating to a merge, the ID of second new
-  parent is in ``$HG_PARENT2``. If the update succeeded, ``$HG_ERROR=0``. If the
-  update failed (e.g. because conflicts were not resolved), ``$HG_ERROR=1``.
-
-.. note::
-
-   It is generally better to use standard hooks rather than the
-   generic pre- and post- command hooks, as they are guaranteed to be
-   called in the appropriate contexts for influencing transactions.
-   Also, hooks like "commit" will be called in all contexts that
-   generate a commit (e.g. tag) and not just the commit command.
-
-.. note::
-
-   Environment variables with empty values may not be passed to
-   hooks on platforms such as Windows. As an example, ``$HG_PARENT2``
-   will have an empty value under Unix-like platforms for non-merge
-   changesets, while it will not be available at all under Windows.
-
-The syntax for Python hooks is as follows::
-
-  hookname = python:modulename.submodule.callable
-  hookname = python:/path/to/python/module.py:callable
-
-Python hooks are run within the Mercurial process. Each hook is
-called with at least three keyword arguments: a ui object (keyword
-``ui``), a repository object (keyword ``repo``), and a ``hooktype``
-keyword that tells what kind of hook is used. Arguments listed as
-environment variables above are passed as keyword arguments, with no
-``HG_`` prefix, and names in lower case.
-
-If a Python hook returns a "true" value or raises an exception, this
-is treated as a failure.
-
-
-``hostfingerprints``
---------------------
-
-(Deprecated. Use ``[hostsecurity]``'s ``fingerprints`` options instead.)
-
-Fingerprints of the certificates of known HTTPS servers.
-
-A HTTPS connection to a server with a fingerprint configured here will
-only succeed if the servers certificate matches the fingerprint.
-This is very similar to how ssh known hosts works.
-
-The fingerprint is the SHA-1 hash value of the DER encoded certificate.
-Multiple values can be specified (separated by spaces or commas). This can
-be used to define both old and new fingerprints while a host transitions
-to a new certificate.
-
-The CA chain and web.cacerts is not used for servers with a fingerprint.
-
-For example::
-
-    [hostfingerprints]
-    hg.intevation.de = fc:e2:8d:d9:51:cd:cb:c1:4d:18:6b:b7:44:8d:49:72:57:e6:cd:33
-    hg.intevation.org = fc:e2:8d:d9:51:cd:cb:c1:4d:18:6b:b7:44:8d:49:72:57:e6:cd:33
-
-``hostsecurity``
-----------------
-
-Used to specify global and per-host security settings for connecting to
-other machines.
-
-The following options control default behavior for all hosts.
-
-``ciphers``
-    Defines the cryptographic ciphers to use for connections.
-
-    Value must be a valid OpenSSL Cipher List Format as documented at
-    https://www.openssl.org/docs/manmaster/apps/ciphers.html#CIPHER-LIST-FORMAT.
-
-    This setting is for advanced users only. Setting to incorrect values
-    can significantly lower connection security or decrease performance.
-    You have been warned.
-
-    This option requires Python 2.7.
-
-``minimumprotocol``
-    Defines the minimum channel encryption protocol to use.
-
-    By default, the highest version of TLS supported by both client and server
-    is used.
-
-    Allowed values are: ``tls1.0``, ``tls1.1``, ``tls1.2``.
-
-    When running on an old Python version, only ``tls1.0`` is allowed since
-    old versions of Python only support up to TLS 1.0.
-
-    When running a Python that supports modern TLS versions, the default is
-    ``tls1.1``. ``tls1.0`` can still be used to allow TLS 1.0. However, this
-    weakens security and should only be used as a feature of last resort if
-    a server does not support TLS 1.1+.
-
-Options in the ``[hostsecurity]`` section can have the form
-``hostname``:``setting``. This allows multiple settings to be defined on a
-per-host basis.
-
-The following per-host settings can be defined.
-
-``ciphers``
-    This behaves like ``ciphers`` as described above except it only applies
-    to the host on which it is defined.
-
-``fingerprints``
-    A list of hashes of the DER encoded peer/remote certificate. Values have
-    the form ``algorithm``:``fingerprint``. e.g.
-    ``sha256:c3ab8ff13720e8ad9047dd39466b3c8974e592c2fa383d4a3960714caef0c4f2``.
-    In addition, colons (``:``) can appear in the fingerprint part.
-
-    The following algorithms/prefixes are supported: ``sha1``, ``sha256``,
-    ``sha512``.
-
-    Use of ``sha256`` or ``sha512`` is preferred.
-
-    If a fingerprint is specified, the CA chain is not validated for this
-    host and Mercurial will require the remote certificate to match one
-    of the fingerprints specified. This means if the server updates its
-    certificate, Mercurial will abort until a new fingerprint is defined.
-    This can provide stronger security than traditional CA-based validation
-    at the expense of convenience.
-
-    This option takes precedence over ``verifycertsfile``.
-
-``minimumprotocol``
-    This behaves like ``minimumprotocol`` as described above except it
-    only applies to the host on which it is defined.
-
-``verifycertsfile``
-    Path to file a containing a list of PEM encoded certificates used to
-    verify the server certificate. Environment variables and ``~user``
-    constructs are expanded in the filename.
-
-    The server certificate or the certificate's certificate authority (CA)
-    must match a certificate from this file or certificate verification
-    will fail and connections to the server will be refused.
-
-    If defined, only certificates provided by this file will be used:
-    ``web.cacerts`` and any system/default certificates will not be
-    used.
-
-    This option has no effect if the per-host ``fingerprints`` option
-    is set.
-
-    The format of the file is as follows::
-
-        -----BEGIN CERTIFICATE-----
-        ... (certificate in base64 PEM encoding) ...
-        -----END CERTIFICATE-----
-        -----BEGIN CERTIFICATE-----
-        ... (certificate in base64 PEM encoding) ...
-        -----END CERTIFICATE-----
-
-For example::
-
-    [hostsecurity]
-    hg.example.com:fingerprints = sha256:c3ab8ff13720e8ad9047dd39466b3c8974e592c2fa383d4a3960714caef0c4f2
-    hg2.example.com:fingerprints = sha1:914f1aff87249c09b6859b88b1906d30756491ca, sha1:fc:e2:8d:d9:51:cd:cb:c1:4d:18:6b:b7:44:8d:49:72:57:e6:cd:33
-    hg3.example.com:fingerprints = sha256:9a:b0:dc:e2:75:ad:8a:b7:84:58:e5:1f:07:32:f1:87:e6:bd:24:22:af:b7:ce:8e:9c:b4:10:cf:b9:f4:0e:d2
-    foo.example.com:verifycertsfile = /etc/ssl/trusted-ca-certs.pem
-
-To change the default minimum protocol version to TLS 1.2 but to allow TLS 1.1
-when connecting to ``hg.example.com``::
-
-    [hostsecurity]
-    minimumprotocol = tls1.2
-    hg.example.com:minimumprotocol = tls1.1
-
-``http_proxy``
---------------
-
-Used to access web-based Mercurial repositories through a HTTP
-proxy.
-
-``host``
-    Host name and (optional) port of the proxy server, for example
-    "myproxy:8000".
-
-``no``
-    Optional. Comma-separated list of host names that should bypass
-    the proxy.
-
-``passwd``
-    Optional. Password to authenticate with at the proxy server.
-
-``user``
-    Optional. User name to authenticate with at the proxy server.
-
-``always``
-    Optional. Always use the proxy, even for localhost and any entries
-    in ``http_proxy.no``. (default: False)
-
-``http``
-----------
-
-Used to configure access to Mercurial repositories via HTTP.
-
-``timeout``
-    If set, blocking operations will timeout after that many seconds.
-    (default: None)
-
-``merge``
----------
-
-This section specifies behavior during merges and updates.
-
-``checkignored``
-   Controls behavior when an ignored file on disk has the same name as a tracked
-   file in the changeset being merged or updated to, and has different
-   contents. Options are ``abort``, ``warn`` and ``ignore``. With ``abort``,
-   abort on such files. With ``warn``, warn on such files and back them up as
-   ``.orig``. With ``ignore``, don't print a warning and back them up as
-   ``.orig``. (default: ``abort``)
-
-``checkunknown``
-   Controls behavior when an unknown file that isn't ignored has the same name
-   as a tracked file in the changeset being merged or updated to, and has
-   different contents. Similar to ``merge.checkignored``, except for files that
-   are not ignored. (default: ``abort``)
-
-``on-failure``
-   When set to ``continue`` (the default), the merge process attempts to
-   merge all unresolved files using the merge chosen tool, regardless of
-   whether previous file merge attempts during the process succeeded or not.
-   Setting this to ``prompt`` will prompt after any merge failure continue
-   or halt the merge process. Setting this to ``halt`` will automatically
-   halt the merge process on any merge tool failure. The merge process
-   can be restarted by using the ``resolve`` command. When a merge is
-   halted, the repository is left in a normal ``unresolved`` merge state.
-   (default: ``continue``)
-
-``strict-capability-check``
-   Whether capabilities of internal merge tools are checked strictly
-   or not, while examining rules to decide merge tool to be used.
-   (default: False)
-
-``merge-patterns``
-------------------
-
-This section specifies merge tools to associate with particular file
-patterns. Tools matched here will take precedence over the default
-merge tool. Patterns are globs by default, rooted at the repository
-root.
-
-Example::
-
-  [merge-patterns]
-  **.c = kdiff3
-  **.jpg = myimgmerge
-
-``merge-tools``
----------------
-
-This section configures external merge tools to use for file-level
-merges. This section has likely been preconfigured at install time.
-Use :hg:`config merge-tools` to check the existing configuration.
-Also see :hg:`help merge-tools` for more details.
-
-Example ``~/.hgrc``::
-
-  [merge-tools]
-  # Override stock tool location
-  kdiff3.executable = ~/bin/kdiff3
-  # Specify command line
-  kdiff3.args = $base $local $other -o $output
-  # Give higher priority
-  kdiff3.priority = 1
-
-  # Changing the priority of preconfigured tool
-  meld.priority = 0
-
-  # Disable a preconfigured tool
-  vimdiff.disabled = yes
-
-  # Define new tool
-  myHtmlTool.args = -m $local $other $base $output
-  myHtmlTool.regkey = Software\FooSoftware\HtmlMerge
-  myHtmlTool.priority = 1
-
-Supported arguments:
-
-``priority``
-  The priority in which to evaluate this tool.
-  (default: 0)
-
-``executable``
-  Either just the name of the executable or its pathname.
-
-  .. container:: windows
-
-    On Windows, the path can use environment variables with ${ProgramFiles}
-    syntax.
-
-  (default: the tool name)
-
-``args``
-  The arguments to pass to the tool executable. You can refer to the
-  files being merged as well as the output file through these
-  variables: ``$base``, ``$local``, ``$other``, ``$output``.
-
-  The meaning of ``$local`` and ``$other`` can vary depending on which action is
-  being performed. During an update or merge, ``$local`` represents the original
-  state of the file, while ``$other`` represents the commit you are updating to or
-  the commit you are merging with. During a rebase, ``$local`` represents the
-  destination of the rebase, and ``$other`` represents the commit being rebased.
-
-  Some operations define custom labels to assist with identifying the revisions,
-  accessible via ``$labellocal``, ``$labelother``, and ``$labelbase``. If custom
-  labels are not available, these will be ``local``, ``other``, and ``base``,
-  respectively.
-  (default: ``$local $base $other``)
-
-``premerge``
-  Attempt to run internal non-interactive 3-way merge tool before
-  launching external tool.  Options are ``true``, ``false``, ``keep`` or
-  ``keep-merge3``. The ``keep`` option will leave markers in the file if the
-  premerge fails. The ``keep-merge3`` will do the same but include information
-  about the base of the merge in the marker (see internal :merge3 in
-  :hg:`help merge-tools`).
-  (default: True)
-
-``binary``
-  This tool can merge binary files. (default: False, unless tool
-  was selected by file pattern match)
-
-``symlink``
-  This tool can merge symlinks. (default: False)
-
-``check``
-  A list of merge success-checking options:
-
-  ``changed``
-    Ask whether merge was successful when the merged file shows no changes.
-  ``conflicts``
-    Check whether there are conflicts even though the tool reported success.
-  ``prompt``
-    Always prompt for merge success, regardless of success reported by tool.
-
-``fixeol``
-  Attempt to fix up EOL changes caused by the merge tool.
-  (default: False)
-
-``gui``
-  This tool requires a graphical interface to run. (default: False)
-
-``mergemarkers``
-  Controls whether the labels passed via ``$labellocal``, ``$labelother``, and
-  ``$labelbase`` are ``detailed`` (respecting ``mergemarkertemplate``) or
-  ``basic``. If ``premerge`` is ``keep`` or ``keep-merge3``, the conflict
-  markers generated during premerge will be ``detailed`` if either this option or
-  the corresponding option in the ``[ui]`` section is ``detailed``.
-  (default: ``basic``)
-
-``mergemarkertemplate``
-  This setting can be used to override ``mergemarkertemplate`` from the ``[ui]``
-  section on a per-tool basis; this applies to the ``$label``-prefixed variables
-  and to the conflict markers that are generated if ``premerge`` is ``keep` or
-  ``keep-merge3``. See the corresponding variable in ``[ui]`` for more
-  information.
-
-.. container:: windows
-
-  ``regkey``
-    Windows registry key which describes install location of this
-    tool. Mercurial will search for this key first under
-    ``HKEY_CURRENT_USER`` and then under ``HKEY_LOCAL_MACHINE``.
-    (default: None)
-
-  ``regkeyalt``
-    An alternate Windows registry key to try if the first key is not
-    found.  The alternate key uses the same ``regname`` and ``regappend``
-    semantics of the primary key.  The most common use for this key
-    is to search for 32bit applications on 64bit operating systems.
-    (default: None)
-
-  ``regname``
-    Name of value to read from specified registry key.
-    (default: the unnamed (default) value)
-
-  ``regappend``
-    String to append to the value read from the registry, typically
-    the executable name of the tool.
-    (default: None)
-
-``pager``
----------
-
-Setting used to control when to paginate and with what external tool. See
-:hg:`help pager` for details.
-
-``pager``
-    Define the external tool used as pager.
-
-    If no pager is set, Mercurial uses the environment variable $PAGER.
-    If neither pager.pager, nor $PAGER is set, a default pager will be
-    used, typically `less` on Unix and `more` on Windows. Example::
-
-      [pager]
-      pager = less -FRX
-
-``ignore``
-    List of commands to disable the pager for. Example::
-
-      [pager]
-      ignore = version, help, update
-
-``patch``
----------
-
-Settings used when applying patches, for instance through the 'import'
-command or with Mercurial Queues extension.
-
-``eol``
-    When set to 'strict' patch content and patched files end of lines
-    are preserved. When set to ``lf`` or ``crlf``, both files end of
-    lines are ignored when patching and the result line endings are
-    normalized to either LF (Unix) or CRLF (Windows). When set to
-    ``auto``, end of lines are again ignored while patching but line
-    endings in patched files are normalized to their original setting
-    on a per-file basis. If target file does not exist or has no end
-    of line, patch line endings are preserved.
-    (default: strict)
-
-``fuzz``
-    The number of lines of 'fuzz' to allow when applying patches. This
-    controls how much context the patcher is allowed to ignore when
-    trying to apply a patch.
-    (default: 2)
-
-``paths``
----------
-
-Assigns symbolic names and behavior to repositories.
-
-Options are symbolic names defining the URL or directory that is the
-location of the repository. Example::
-
-    [paths]
-    my_server = https://example.com/my_repo
-    local_path = /home/me/repo
-
-These symbolic names can be used from the command line. To pull
-from ``my_server``: :hg:`pull my_server`. To push to ``local_path``:
-:hg:`push local_path`.
-
-Options containing colons (``:``) denote sub-options that can influence
-behavior for that specific path. Example::
-
-    [paths]
-    my_server = https://example.com/my_path
-    my_server:pushurl = ssh://example.com/my_path
-
-The following sub-options can be defined:
-
-``pushurl``
-   The URL to use for push operations. If not defined, the location
-   defined by the path's main entry is used.
-
-``pushrev``
-   A revset defining which revisions to push by default.
-
-   When :hg:`push` is executed without a ``-r`` argument, the revset
-   defined by this sub-option is evaluated to determine what to push.
-
-   For example, a value of ``.`` will push the working directory's
-   revision by default.
-
-   Revsets specifying bookmarks will not result in the bookmark being
-   pushed.
-
-The following special named paths exist:
-
-``default``
-   The URL or directory to use when no source or remote is specified.
-
-   :hg:`clone` will automatically define this path to the location the
-   repository was cloned from.
-
-``default-push``
-   (deprecated) The URL or directory for the default :hg:`push` location.
-   ``default:pushurl`` should be used instead.
-
-``phases``
-----------
-
-Specifies default handling of phases. See :hg:`help phases` for more
-information about working with phases.
-
-``publish``
-    Controls draft phase behavior when working as a server. When true,
-    pushed changesets are set to public in both client and server and
-    pulled or cloned changesets are set to public in the client.
-    (default: True)
-
-``new-commit``
-    Phase of newly-created commits.
-    (default: draft)
-
-``checksubrepos``
-    Check the phase of the current revision of each subrepository. Allowed
-    values are "ignore", "follow" and "abort". For settings other than
-    "ignore", the phase of the current revision of each subrepository is
-    checked before committing the parent repository. If any of those phases is
-    greater than the phase of the parent repository (e.g. if a subrepo is in a
-    "secret" phase while the parent repo is in "draft" phase), the commit is
-    either aborted (if checksubrepos is set to "abort") or the higher phase is
-    used for the parent repository commit (if set to "follow").
-    (default: follow)
-
-
-``profiling``
--------------
-
-Specifies profiling type, format, and file output. Two profilers are
-supported: an instrumenting profiler (named ``ls``), and a sampling
-profiler (named ``stat``).
-
-In this section description, 'profiling data' stands for the raw data
-collected during profiling, while 'profiling report' stands for a
-statistical text report generated from the profiling data.
-
-``enabled``
-    Enable the profiler.
-    (default: false)
-
-    This is equivalent to passing ``--profile`` on the command line.
-
-``type``
-    The type of profiler to use.
-    (default: stat)
-
-    ``ls``
-      Use Python's built-in instrumenting profiler. This profiler
-      works on all platforms, but each line number it reports is the
-      first line of a function. This restriction makes it difficult to
-      identify the expensive parts of a non-trivial function.
-    ``stat``
-      Use a statistical profiler, statprof. This profiler is most
-      useful for profiling commands that run for longer than about 0.1
-      seconds.
-
-``format``
-    Profiling format.  Specific to the ``ls`` instrumenting profiler.
-    (default: text)
-
-    ``text``
-      Generate a profiling report. When saving to a file, it should be
-      noted that only the report is saved, and the profiling data is
-      not kept.
-    ``kcachegrind``
-      Format profiling data for kcachegrind use: when saving to a
-      file, the generated file can directly be loaded into
-      kcachegrind.
-
-``statformat``
-    Profiling format for the ``stat`` profiler.
-    (default: hotpath)
-
-    ``hotpath``
-      Show a tree-based display containing the hot path of execution (where
-      most time was spent).
-    ``bymethod``
-      Show a table of methods ordered by how frequently they are active.
-    ``byline``
-      Show a table of lines in files ordered by how frequently they are active.
-    ``json``
-      Render profiling data as JSON.
-
-``frequency``
-    Sampling frequency.  Specific to the ``stat`` sampling profiler.
-    (default: 1000)
-
-``output``
-    File path where profiling data or report should be saved. If the
-    file exists, it is replaced. (default: None, data is printed on
-    stderr)
-
-``sort``
-    Sort field.  Specific to the ``ls`` instrumenting profiler.
-    One of ``callcount``, ``reccallcount``, ``totaltime`` and
-    ``inlinetime``.
-    (default: inlinetime)
-
-``time-track``
-    Control if the stat profiler track ``cpu`` or ``real`` time.
-    (default: ``cpu`` on Windows, otherwise ``real``)
-
-``limit``
-    Number of lines to show. Specific to the ``ls`` instrumenting profiler.
-    (default: 30)
-
-``nested``
-    Show at most this number of lines of drill-down info after each main entry.
-    This can help explain the difference between Total and Inline.
-    Specific to the ``ls`` instrumenting profiler.
-    (default: 0)
-
-``showmin``
-    Minimum fraction of samples an entry must have for it to be displayed.
-    Can be specified as a float between ``0.0`` and ``1.0`` or can have a
-    ``%`` afterwards to allow values up to ``100``. e.g. ``5%``.
-
-    Only used by the ``stat`` profiler.
-
-    For the ``hotpath`` format, default is ``0.05``.
-    For the ``chrome`` format, default is ``0.005``.
-
-    The option is unused on other formats.
-
-``showmax``
-    Maximum fraction of samples an entry can have before it is ignored in
-    display. Values format is the same as ``showmin``.
-
-    Only used by the ``stat`` profiler.
-
-    For the ``chrome`` format, default is ``0.999``.
-
-    The option is unused on other formats.
-
-``showtime``
-    Show time taken as absolute durations, in addition to percentages.
-    Only used by the ``hotpath`` format.
-    (default: true)
-
-``progress``
-------------
-
-Mercurial commands can draw progress bars that are as informative as
-possible. Some progress bars only offer indeterminate information, while others
-have a definite end point.
-
-``debug``
-    Whether to print debug info when updating the progress bar. (default: False)
-
-``delay``
-    Number of seconds (float) before showing the progress bar. (default: 3)
-
-``changedelay``
-    Minimum delay before showing a new topic. When set to less than 3 * refresh,
-    that value will be used instead. (default: 1)
-
-``estimateinterval``
-    Maximum sampling interval in seconds for speed and estimated time
-    calculation. (default: 60)
-
-``refresh``
-    Time in seconds between refreshes of the progress bar. (default: 0.1)
-
-``format``
-    Format of the progress bar.
-
-    Valid entries for the format field are ``topic``, ``bar``, ``number``,
-    ``unit``, ``estimate``, ``speed``, and ``item``. ``item`` defaults to the
-    last 20 characters of the item, but this can be changed by adding either
-    ``-<num>`` which would take the last num characters, or ``+<num>`` for the
-    first num characters.
-
-    (default: topic bar number estimate)
-
-``width``
-    If set, the maximum width of the progress information (that is, min(width,
-    term width) will be used).
-
-``clear-complete``
-    Clear the progress bar after it's done. (default: True)
-
-``disable``
-    If true, don't show a progress bar.
-
-``assume-tty``
-    If true, ALWAYS show a progress bar, unless disable is given.
-
-``rebase``
-----------
-
-``evolution.allowdivergence``
-    Default to False, when True allow creating divergence when performing
-    rebase of obsolete changesets.
-
-``revsetalias``
----------------
-
-Alias definitions for revsets. See :hg:`help revsets` for details.
-
-``rewrite``
------------
-
-``backup-bundle``
-    Whether to save stripped changesets to a bundle file. (default: True)
-
-``update-timestamp``
-    If true, updates the date and time of the changeset to current. It is only
-    applicable for `hg amend`, `hg commit --amend` and `hg uncommit` in the
-    current version.
-
-``storage``
------------
-
-Control the strategy Mercurial uses internally to store history. Options in this
-category impact performance and repository size.
-
-``revlog.optimize-delta-parent-choice``
-    When storing a merge revision, both parents will be equally considered as
-    a possible delta base. This results in better delta selection and improved
-    revlog compression. This option is enabled by default.
-
-    Turning this option off can result in large increase of repository size for
-    repository with many merges.
-
-``revlog.reuse-external-delta-parent``
-    Control the order in which delta parents are considered when adding new
-    revisions from an external source.
-    (typically: apply bundle from `hg pull` or `hg push`).
-
-    New revisions are usually provided as a delta against other revisions. By
-    default, Mercurial will try to reuse this delta first, therefore using the
-    same "delta parent" as the source. Directly using delta's from the source
-    reduces CPU usage and usually speeds up operation. However, in some case,
-    the source might have sub-optimal delta bases and forcing their reevaluation
-    is useful. For example, pushes from an old client could have sub-optimal
-    delta's parent that the server want to optimize. (lack of general delta, bad
-    parents, choice, lack of sparse-revlog, etc).
-
-    This option is enabled by default. Turning it off will ensure bad delta
-    parent choices from older client do not propagate to this repository, at
-    the cost of a small increase in CPU consumption.
-
-    Note: this option only control the order in which delta parents are
-    considered.  Even when disabled, the existing delta from the source will be
-    reused if the same delta parent is selected.
-
-``revlog.reuse-external-delta``
-    Control the reuse of delta from external source.
-    (typically: apply bundle from `hg pull` or `hg push`).
-
-    New revisions are usually provided as a delta against another revision. By
-    default, Mercurial will not recompute the same delta again, trusting
-    externally provided deltas. There have been rare cases of small adjustment
-    to the diffing algorithm in the past. So in some rare case, recomputing
-    delta provided by ancient clients can provides better results. Disabling
-    this option means going through a full delta recomputation for all incoming
-    revisions. It means a large increase in CPU usage and will slow operations
-    down.
-
-    This option is enabled by default. When disabled, it also disables the
-    related ``storage.revlog.reuse-external-delta-parent`` option.
-
-``revlog.zlib.level``
-    Zlib compression level used when storing data into the repository. Accepted
-    Value range from 1 (lowest compression) to 9 (highest compression). Zlib
-    default value is 6.
-
-
-``revlog.zstd.level``
-    zstd compression level used when storing data into the repository. Accepted
-    Value range from 1 (lowest compression) to 22 (highest compression).
-    (default 3)
-
-``server``
-----------
-
-Controls generic server settings.
-
-``bookmarks-pushkey-compat``
-    Trigger pushkey hook when being pushed bookmark updates. This config exist
-    for compatibility purpose (default to True)
-
-    If you use ``pushkey`` and ``pre-pushkey`` hooks to control bookmark
-    movement we recommend you migrate them to ``txnclose-bookmark`` and
-    ``pretxnclose-bookmark``.
-
-``compressionengines``
-    List of compression engines and their relative priority to advertise
-    to clients.
-
-    The order of compression engines determines their priority, the first
-    having the highest priority. If a compression engine is not listed
-    here, it won't be advertised to clients.
-
-    If not set (the default), built-in defaults are used. Run
-    :hg:`debuginstall` to list available compression engines and their
-    default wire protocol priority.
-
-    Older Mercurial clients only support zlib compression and this setting
-    has no effect for legacy clients.
-
-``uncompressed``
-    Whether to allow clients to clone a repository using the
-    uncompressed streaming protocol. This transfers about 40% more
-    data than a regular clone, but uses less memory and CPU on both
-    server and client. Over a LAN (100 Mbps or better) or a very fast
-    WAN, an uncompressed streaming clone is a lot faster (~10x) than a
-    regular clone. Over most WAN connections (anything slower than
-    about 6 Mbps), uncompressed streaming is slower, because of the
-    extra data transfer overhead. This mode will also temporarily hold
-    the write lock while determining what data to transfer.
-    (default: True)
-
-``uncompressedallowsecret``
-    Whether to allow stream clones when the repository contains secret
-    changesets. (default: False)
-
-``preferuncompressed``
-    When set, clients will try to use the uncompressed streaming
-    protocol. (default: False)
-
-``disablefullbundle``
-    When set, servers will refuse attempts to do pull-based clones.
-    If this option is set, ``preferuncompressed`` and/or clone bundles
-    are highly recommended. Partial clones will still be allowed.
-    (default: False)
-
-``streamunbundle``
-    When set, servers will apply data sent from the client directly,
-    otherwise it will be written to a temporary file first. This option
-    effectively prevents concurrent pushes.
-
-``pullbundle``
-    When set, the server will check pullbundle.manifest for bundles
-    covering the requested heads and common nodes. The first matching
-    entry will be streamed to the client.
-
-    For HTTP transport, the stream will still use zlib compression
-    for older clients.
-
-``concurrent-push-mode``
-    Level of allowed race condition between two pushing clients.
-
-    - 'strict': push is abort if another client touched the repository
-      while the push was preparing. (default)
-    - 'check-related': push is only aborted if it affects head that got also
-      affected while the push was preparing.
-
-    This requires compatible client (version 4.3 and later). Old client will
-    use 'strict'.
-
-``validate``
-    Whether to validate the completeness of pushed changesets by
-    checking that all new file revisions specified in manifests are
-    present. (default: False)
-
-``maxhttpheaderlen``
-    Instruct HTTP clients not to send request headers longer than this
-    many bytes. (default: 1024)
-
-``bundle1``
-    Whether to allow clients to push and pull using the legacy bundle1
-    exchange format. (default: True)
-
-``bundle1gd``
-    Like ``bundle1`` but only used if the repository is using the
-    *generaldelta* storage format. (default: True)
-
-``bundle1.push``
-    Whether to allow clients to push using the legacy bundle1 exchange
-    format. (default: True)
-
-``bundle1gd.push``
-    Like ``bundle1.push`` but only used if the repository is using the
-    *generaldelta* storage format. (default: True)
-
-``bundle1.pull``
-    Whether to allow clients to pull using the legacy bundle1 exchange
-    format. (default: True)
-
-``bundle1gd.pull``
-    Like ``bundle1.pull`` but only used if the repository is using the
-    *generaldelta* storage format. (default: True)
-
-    Large repositories using the *generaldelta* storage format should
-    consider setting this option because converting *generaldelta*
-    repositories to the exchange format required by the bundle1 data
-    format can consume a lot of CPU.
-
-``bundle2.stream``
-    Whether to allow clients to pull using the bundle2 streaming protocol.
-    (default: True)
-
-``zliblevel``
-    Integer between ``-1`` and ``9`` that controls the zlib compression level
-    for wire protocol commands that send zlib compressed output (notably the
-    commands that send repository history data).
-
-    The default (``-1``) uses the default zlib compression level, which is
-    likely equivalent to ``6``. ``0`` means no compression. ``9`` means
-    maximum compression.
-
-    Setting this option allows server operators to make trade-offs between
-    bandwidth and CPU used. Lowering the compression lowers CPU utilization
-    but sends more bytes to clients.
-
-    This option only impacts the HTTP server.
-
-``zstdlevel``
-    Integer between ``1`` and ``22`` that controls the zstd compression level
-    for wire protocol commands. ``1`` is the minimal amount of compression and
-    ``22`` is the highest amount of compression.
-
-    The default (``3``) should be significantly faster than zlib while likely
-    delivering better compression ratios.
-
-    This option only impacts the HTTP server.
-
-    See also ``server.zliblevel``.
-
-``view``
-    Repository filter used when exchanging revisions with the peer.
-
-    The default view (``served``) excludes secret and hidden changesets.
-    Another useful value is ``immutable`` (no draft, secret or hidden
-    changesets). (EXPERIMENTAL)
-
-``smtp``
---------
-
-Configuration for extensions that need to send email messages.
-
-``host``
-    Host name of mail server, e.g. "mail.example.com".
-
-``port``
-    Optional. Port to connect to on mail server. (default: 465 if
-    ``tls`` is smtps; 25 otherwise)
-
-``tls``
-    Optional. Method to enable TLS when connecting to mail server: starttls,
-    smtps or none. (default: none)
-
-``username``
-    Optional. User name for authenticating with the SMTP server.
-    (default: None)
-
-``password``
-    Optional. Password for authenticating with the SMTP server. If not
-    specified, interactive sessions will prompt the user for a
-    password; non-interactive sessions will fail. (default: None)
-
-``local_hostname``
-    Optional. The hostname that the sender can use to identify
-    itself to the MTA.
-
-
-``subpaths``
-------------
-
-Subrepository source URLs can go stale if a remote server changes name
-or becomes temporarily unavailable. This section lets you define
-rewrite rules of the form::
-
-    <pattern> = <replacement>
-
-where ``pattern`` is a regular expression matching a subrepository
-source URL and ``replacement`` is the replacement string used to
-rewrite it. Groups can be matched in ``pattern`` and referenced in
-``replacements``. For instance::
-
-    http://server/(.*)-hg/ = http://hg.server/\1/
-
-rewrites ``http://server/foo-hg/`` into ``http://hg.server/foo/``.
-
-Relative subrepository paths are first made absolute, and the
-rewrite rules are then applied on the full (absolute) path. If ``pattern``
-doesn't match the full path, an attempt is made to apply it on the
-relative path alone. The rules are applied in definition order.
-
-``subrepos``
-------------
-
-This section contains options that control the behavior of the
-subrepositories feature. See also :hg:`help subrepos`.
-
-Security note: auditing in Mercurial is known to be insufficient to
-prevent clone-time code execution with carefully constructed Git
-subrepos. It is unknown if a similar detect is present in Subversion
-subrepos. Both Git and Subversion subrepos are disabled by default
-out of security concerns. These subrepo types can be enabled using
-the respective options below.
-
-``allowed``
-    Whether subrepositories are allowed in the working directory.
-
-    When false, commands involving subrepositories (like :hg:`update`)
-    will fail for all subrepository types.
-    (default: true)
-
-``hg:allowed``
-    Whether Mercurial subrepositories are allowed in the working
-    directory. This option only has an effect if ``subrepos.allowed``
-    is true.
-    (default: true)
-
-``git:allowed``
-    Whether Git subrepositories are allowed in the working directory.
-    This option only has an effect if ``subrepos.allowed`` is true.
-
-    See the security note above before enabling Git subrepos.
-    (default: false)
-
-``svn:allowed``
-    Whether Subversion subrepositories are allowed in the working
-    directory. This option only has an effect if ``subrepos.allowed``
-    is true.
-
-    See the security note above before enabling Subversion subrepos.
-    (default: false)
-
-``templatealias``
------------------
-
-Alias definitions for templates. See :hg:`help templates` for details.
-
-``templates``
--------------
-
-Use the ``[templates]`` section to define template strings.
-See :hg:`help templates` for details.
-
-``trusted``
------------
-
-Mercurial will not use the settings in the
-``.hg/hgrc`` file from a repository if it doesn't belong to a trusted
-user or to a trusted group, as various hgrc features allow arbitrary
-commands to be run. This issue is often encountered when configuring
-hooks or extensions for shared repositories or servers. However,
-the web interface will use some safe settings from the ``[web]``
-section.
-
-This section specifies what users and groups are trusted. The
-current user is always trusted. To trust everybody, list a user or a
-group with name ``*``. These settings must be placed in an
-*already-trusted file* to take effect, such as ``$HOME/.hgrc`` of the
-user or service running Mercurial.
-
-``users``
-  Comma-separated list of trusted users.
-
-``groups``
-  Comma-separated list of trusted groups.
-
-
-``ui``
-------
-
-User interface controls.
-
-``archivemeta``
-    Whether to include the .hg_archival.txt file containing meta data
-    (hashes for the repository base and for tip) in archives created
-    by the :hg:`archive` command or downloaded via hgweb.
-    (default: True)
-
-``askusername``
-    Whether to prompt for a username when committing. If True, and
-    neither ``$HGUSER`` nor ``$EMAIL`` has been specified, then the user will
-    be prompted to enter a username. If no username is entered, the
-    default ``USER@HOST`` is used instead.
-    (default: False)
-
-``clonebundles``
-    Whether the "clone bundles" feature is enabled.
-
-    When enabled, :hg:`clone` may download and apply a server-advertised
-    bundle file from a URL instead of using the normal exchange mechanism.
-
-    This can likely result in faster and more reliable clones.
-
-    (default: True)
-
-``clonebundlefallback``
-    Whether failure to apply an advertised "clone bundle" from a server
-    should result in fallback to a regular clone.
-
-    This is disabled by default because servers advertising "clone
-    bundles" often do so to reduce server load. If advertised bundles
-    start mass failing and clients automatically fall back to a regular
-    clone, this would add significant and unexpected load to the server
-    since the server is expecting clone operations to be offloaded to
-    pre-generated bundles. Failing fast (the default behavior) ensures
-    clients don't overwhelm the server when "clone bundle" application
-    fails.
-
-    (default: False)
-
-``clonebundleprefers``
-    Defines preferences for which "clone bundles" to use.
-
-    Servers advertising "clone bundles" may advertise multiple available
-    bundles. Each bundle may have different attributes, such as the bundle
-    type and compression format. This option is used to prefer a particular
-    bundle over another.
-
-    The following keys are defined by Mercurial:
-
-    BUNDLESPEC
-       A bundle type specifier. These are strings passed to :hg:`bundle -t`.
-       e.g. ``gzip-v2`` or ``bzip2-v1``.
-
-    COMPRESSION
-       The compression format of the bundle. e.g. ``gzip`` and ``bzip2``.
-
-    Server operators may define custom keys.
-
-    Example values: ``COMPRESSION=bzip2``,
-    ``BUNDLESPEC=gzip-v2, COMPRESSION=gzip``.
-
-    By default, the first bundle advertised by the server is used.
-
-``color``
-    When to colorize output. Possible value are Boolean ("yes" or "no"), or
-    "debug", or "always". (default: "yes"). "yes" will use color whenever it
-    seems possible. See :hg:`help color` for details.
-
-``commitsubrepos``
-    Whether to commit modified subrepositories when committing the
-    parent repository. If False and one subrepository has uncommitted
-    changes, abort the commit.
-    (default: False)
-
-``debug``
-    Print debugging information. (default: False)
-
-``editor``
-    The editor to use during a commit. (default: ``$EDITOR`` or ``vi``)
-
-``fallbackencoding``
-    Encoding to try if it's not possible to decode the changelog using
-    UTF-8. (default: ISO-8859-1)
-
-``graphnodetemplate``
-    The template used to print changeset nodes in an ASCII revision graph.
-    (default: ``{graphnode}``)
-
-``ignore``
-    A file to read per-user ignore patterns from. This file should be
-    in the same format as a repository-wide .hgignore file. Filenames
-    are relative to the repository root. This option supports hook syntax,
-    so if you want to specify multiple ignore files, you can do so by
-    setting something like ``ignore.other = ~/.hgignore2``. For details
-    of the ignore file format, see the ``hgignore(5)`` man page.
-
-``interactive``
-    Allow to prompt the user. (default: True)
-
-``interface``
-    Select the default interface for interactive features (default: text).
-    Possible values are 'text' and 'curses'.
-
-``interface.chunkselector``
-    Select the interface for change recording (e.g. :hg:`commit -i`).
-    Possible values are 'text' and 'curses'.
-    This config overrides the interface specified by ui.interface.
-
-``large-file-limit``
-    Largest file size that gives no memory use warning.
-    Possible values are integers or 0 to disable the check.
-    (default: 10000000)
-
-``logtemplate``
-    Template string for commands that print changesets.
-
-``merge``
-    The conflict resolution program to use during a manual merge.
-    For more information on merge tools see :hg:`help merge-tools`.
-    For configuring merge tools see the ``[merge-tools]`` section.
-
-``mergemarkers``
-    Sets the merge conflict marker label styling. The ``detailed``
-    style uses the ``mergemarkertemplate`` setting to style the labels.
-    The ``basic`` style just uses 'local' and 'other' as the marker label.
-    One of ``basic`` or ``detailed``.
-    (default: ``basic``)
-
-``mergemarkertemplate``
-    The template used to print the commit description next to each conflict
-    marker during merge conflicts. See :hg:`help templates` for the template
-    format.
-
-    Defaults to showing the hash, tags, branches, bookmarks, author, and
-    the first line of the commit description.
-
-    If you use non-ASCII characters in names for tags, branches, bookmarks,
-    authors, and/or commit descriptions, you must pay attention to encodings of
-    managed files. At template expansion, non-ASCII characters use the encoding
-    specified by the ``--encoding`` global option, ``HGENCODING`` or other
-    environment variables that govern your locale. If the encoding of the merge
-    markers is different from the encoding of the merged files,
-    serious problems may occur.
-
-    Can be overridden per-merge-tool, see the ``[merge-tools]`` section.
-
-``message-output``
-    Where to write status and error messages. (default: ``stdio``)
-
-    ``stderr``
-      Everything to stderr.
-    ``stdio``
-      Status to stdout, and error to stderr.
-
-``origbackuppath``
-    The path to a directory used to store generated .orig files. If the path is
-    not a directory, one will be created.  If set, files stored in this
-    directory have the same name as the original file and do not have a .orig
-    suffix.
-
-``paginate``
-  Control the pagination of command output (default: True). See :hg:`help pager`
-  for details.
-
-``patch``
-    An optional external tool that ``hg import`` and some extensions
-    will use for applying patches. By default Mercurial uses an
-    internal patch utility. The external tool must work as the common
-    Unix ``patch`` program. In particular, it must accept a ``-p``
-    argument to strip patch headers, a ``-d`` argument to specify the
-    current directory, a file name to patch, and a patch file to take
-    from stdin.
-
-    It is possible to specify a patch tool together with extra
-    arguments. For example, setting this option to ``patch --merge``
-    will use the ``patch`` program with its 2-way merge option.
-
-``portablefilenames``
-    Check for portable filenames. Can be ``warn``, ``ignore`` or ``abort``.
-    (default: ``warn``)
-
-    ``warn``
-      Print a warning message on POSIX platforms, if a file with a non-portable
-      filename is added (e.g. a file with a name that can't be created on
-      Windows because it contains reserved parts like ``AUX``, reserved
-      characters like ``:``, or would cause a case collision with an existing
-      file).
-
-    ``ignore``
-      Don't print a warning.
-
-    ``abort``
-      The command is aborted.
-
-    ``true``
-      Alias for ``warn``.
-
-    ``false``
-      Alias for ``ignore``.
-
-    .. container:: windows
-
-      On Windows, this configuration option is ignored and the command aborted.
-
-``pre-merge-tool-output-template``
-    A template that is printed before executing an external merge tool. This can
-    be used to print out additional context that might be useful to have during
-    the conflict resolution, such as the description of the various commits
-    involved or bookmarks/tags.
-
-    Additional information is available in the ``local`, ``base``, and ``other``
-    dicts. For example: ``{local.label}``, ``{base.name}``, or
-    ``{other.islink}``.
-
-``quiet``
-    Reduce the amount of output printed.
-    (default: False)
-
-``relative-paths``
-    Prefer relative paths in the UI.
-
-``remotecmd``
-    Remote command to use for clone/push/pull operations.
-    (default: ``hg``)
-
-``report_untrusted``
-    Warn if a ``.hg/hgrc`` file is ignored due to not being owned by a
-    trusted user or group.
-    (default: True)
-
-``slash``
-    (Deprecated. Use ``slashpath`` template filter instead.)
-
-    Display paths using a slash (``/``) as the path separator. This
-    only makes a difference on systems where the default path
-    separator is not the slash character (e.g. Windows uses the
-    backslash character (``\``)).
-    (default: False)
-
-``statuscopies``
-    Display copies in the status command.
-
-``ssh``
-    Command to use for SSH connections. (default: ``ssh``)
-
-``ssherrorhint``
-    A hint shown to the user in the case of SSH error (e.g.
-    ``Please see http://company/internalwiki/ssh.html``)
-
-``strict``
-    Require exact command names, instead of allowing unambiguous
-    abbreviations. (default: False)
-
-``style``
-    Name of style to use for command output.
-
-``supportcontact``
-    A URL where users should report a Mercurial traceback. Use this if you are a
-    large organisation with its own Mercurial deployment process and crash
-    reports should be addressed to your internal support.
-
-``textwidth``
-    Maximum width of help text. A longer line generated by ``hg help`` or
-    ``hg subcommand --help`` will be broken after white space to get this
-    width or the terminal width, whichever comes first.
-    A non-positive value will disable this and the terminal width will be
-    used. (default: 78)
-
-``timeout``
-    The timeout used when a lock is held (in seconds), a negative value
-    means no timeout. (default: 600)
-
-``timeout.warn``
-    Time (in seconds) before a warning is printed about held lock. A negative
-    value means no warning. (default: 0)
-
-``traceback``
-    Mercurial always prints a traceback when an unknown exception
-    occurs. Setting this to True will make Mercurial print a traceback
-    on all exceptions, even those recognized by Mercurial (such as
-    IOError or MemoryError). (default: False)
-
-``tweakdefaults``
-
-    By default Mercurial's behavior changes very little from release
-    to release, but over time the recommended config settings
-    shift. Enable this config to opt in to get automatic tweaks to
-    Mercurial's behavior over time. This config setting will have no
-    effect if ``HGPLAIN`` is set or ``HGPLAINEXCEPT`` is set and does
-    not include ``tweakdefaults``. (default: False)
-
-    It currently means::
-
-      .. tweakdefaultsmarker
-
-``username``
-    The committer of a changeset created when running "commit".
-    Typically a person's name and email address, e.g. ``Fred Widget
-    <fred@example.com>``. Environment variables in the
-    username are expanded.
-
-    (default: ``$EMAIL`` or ``username@hostname``. If the username in
-    hgrc is empty, e.g. if the system admin set ``username =`` in the
-    system hgrc, it has to be specified manually or in a different
-    hgrc file)
-
-``verbose``
-    Increase the amount of output printed. (default: False)
-
-
-``web``
--------
-
-Web interface configuration. The settings in this section apply to
-both the builtin webserver (started by :hg:`serve`) and the script you
-run through a webserver (``hgweb.cgi`` and the derivatives for FastCGI
-and WSGI).
-
-The Mercurial webserver does no authentication (it does not prompt for
-usernames and passwords to validate *who* users are), but it does do
-authorization (it grants or denies access for *authenticated users*
-based on settings in this section). You must either configure your
-webserver to do authentication for you, or disable the authorization
-checks.
-
-For a quick setup in a trusted environment, e.g., a private LAN, where
-you want it to accept pushes from anybody, you can use the following
-command line::
-
-    $ hg --config web.allow-push=* --config web.push_ssl=False serve
-
-Note that this will allow anybody to push anything to the server and
-that this should not be used for public servers.
-
-The full set of options is:
-
-``accesslog``
-    Where to output the access log. (default: stdout)
-
-``address``
-    Interface address to bind to. (default: all)
-
-``allow-archive``
-    List of archive format (bz2, gz, zip) allowed for downloading.
-    (default: empty)
-
-``allowbz2``
-    (DEPRECATED) Whether to allow .tar.bz2 downloading of repository
-    revisions.
-    (default: False)
-
-``allowgz``
-    (DEPRECATED) Whether to allow .tar.gz downloading of repository
-    revisions.
-    (default: False)
-
-``allow-pull``
-    Whether to allow pulling from the repository. (default: True)
-
-``allow-push``
-    Whether to allow pushing to the repository. If empty or not set,
-    pushing is not allowed. If the special value ``*``, any remote
-    user can push, including unauthenticated users. Otherwise, the
-    remote user must have been authenticated, and the authenticated
-    user name must be present in this list. The contents of the
-    allow-push list are examined after the deny_push list.
-
-``allow_read``
-    If the user has not already been denied repository access due to
-    the contents of deny_read, this list determines whether to grant
-    repository access to the user. If this list is not empty, and the
-    user is unauthenticated or not present in the list, then access is
-    denied for the user. If the list is empty or not set, then access
-    is permitted to all users by default. Setting allow_read to the
-    special value ``*`` is equivalent to it not being set (i.e. access
-    is permitted to all users). The contents of the allow_read list are
-    examined after the deny_read list.
-
-``allowzip``
-    (DEPRECATED) Whether to allow .zip downloading of repository
-    revisions. This feature creates temporary files.
-    (default: False)
-
-``archivesubrepos``
-    Whether to recurse into subrepositories when archiving.
-    (default: False)
-
-``baseurl``
-    Base URL to use when publishing URLs in other locations, so
-    third-party tools like email notification hooks can construct
-    URLs. Example: ``http://hgserver/repos/``.
-
-``cacerts``
-    Path to file containing a list of PEM encoded certificate
-    authority certificates. Environment variables and ``~user``
-    constructs are expanded in the filename. If specified on the
-    client, then it will verify the identity of remote HTTPS servers
-    with these certificates.
-
-    To disable SSL verification temporarily, specify ``--insecure`` from
-    command line.
-
-    You can use OpenSSL's CA certificate file if your platform has
-    one. On most Linux systems this will be
-    ``/etc/ssl/certs/ca-certificates.crt``. Otherwise you will have to
-    generate this file manually. The form must be as follows::
-
-        -----BEGIN CERTIFICATE-----
-        ... (certificate in base64 PEM encoding) ...
-        -----END CERTIFICATE-----
-        -----BEGIN CERTIFICATE-----
-        ... (certificate in base64 PEM encoding) ...
-        -----END CERTIFICATE-----
-
-``cache``
-    Whether to support caching in hgweb. (default: True)
-
-``certificate``
-    Certificate to use when running :hg:`serve`.
-
-``collapse``
-    With ``descend`` enabled, repositories in subdirectories are shown at
-    a single level alongside repositories in the current path. With
-    ``collapse`` also enabled, repositories residing at a deeper level than
-    the current path are grouped behind navigable directory entries that
-    lead to the locations of these repositories. In effect, this setting
-    collapses each collection of repositories found within a subdirectory
-    into a single entry for that subdirectory. (default: False)
-
-``comparisoncontext``
-    Number of lines of context to show in side-by-side file comparison. If
-    negative or the value ``full``, whole files are shown. (default: 5)
-
-    This setting can be overridden by a ``context`` request parameter to the
-    ``comparison`` command, taking the same values.
-
-``contact``
-    Name or email address of the person in charge of the repository.
-    (default: ui.username or ``$EMAIL`` or "unknown" if unset or empty)
-
-``csp``
-    Send a ``Content-Security-Policy`` HTTP header with this value.
-
-    The value may contain a special string ``%nonce%``, which will be replaced
-    by a randomly-generated one-time use value. If the value contains
-    ``%nonce%``, ``web.cache`` will be disabled, as caching undermines the
-    one-time property of the nonce. This nonce will also be inserted into
-    ``<script>`` elements containing inline JavaScript.
-
-    Note: lots of HTML content sent by the server is derived from repository
-    data. Please consider the potential for malicious repository data to
-    "inject" itself into generated HTML content as part of your security
-    threat model.
-
-``deny_push``
-    Whether to deny pushing to the repository. If empty or not set,
-    push is not denied. If the special value ``*``, all remote users are
-    denied push. Otherwise, unauthenticated users are all denied, and
-    any authenticated user name present in this list is also denied. The
-    contents of the deny_push list are examined before the allow-push list.
-
-``deny_read``
-    Whether to deny reading/viewing of the repository. If this list is
-    not empty, unauthenticated users are all denied, and any
-    authenticated user name present in this list is also denied access to
-    the repository. If set to the special value ``*``, all remote users
-    are denied access (rarely needed ;). If deny_read is empty or not set,
-    the determination of repository access depends on the presence and
-    content of the allow_read list (see description). If both
-    deny_read and allow_read are empty or not set, then access is
-    permitted to all users by default. If the repository is being
-    served via hgwebdir, denied users will not be able to see it in
-    the list of repositories. The contents of the deny_read list have
-    priority over (are examined before) the contents of the allow_read
-    list.
-
-``descend``
-    hgwebdir indexes will not descend into subdirectories. Only repositories
-    directly in the current path will be shown (other repositories are still
-    available from the index corresponding to their containing path).
-
-``description``
-    Textual description of the repository's purpose or contents.
-    (default: "unknown")
-
-``encoding``
-    Character encoding name. (default: the current locale charset)
-    Example: "UTF-8".
-
-``errorlog``
-    Where to output the error log. (default: stderr)
-
-``guessmime``
-    Control MIME types for raw download of file content.
-    Set to True to let hgweb guess the content type from the file
-    extension. This will serve HTML files as ``text/html`` and might
-    allow cross-site scripting attacks when serving untrusted
-    repositories. (default: False)
-
-``hidden``
-    Whether to hide the repository in the hgwebdir index.
-    (default: False)
-
-``ipv6``
-    Whether to use IPv6. (default: False)
-
-``labels``
-    List of string *labels* associated with the repository.
-
-    Labels are exposed as a template keyword and can be used to customize
-    output. e.g. the ``index`` template can group or filter repositories
-    by labels and the ``summary`` template can display additional content
-    if a specific label is present.
-
-``logoimg``
-    File name of the logo image that some templates display on each page.
-    The file name is relative to ``staticurl``. That is, the full path to
-    the logo image is "staticurl/logoimg".
-    If unset, ``hglogo.png`` will be used.
-
-``logourl``
-    Base URL to use for logos. If unset, ``https://mercurial-scm.org/``
-    will be used.
-
-``maxchanges``
-    Maximum number of changes to list on the changelog. (default: 10)
-
-``maxfiles``
-    Maximum number of files to list per changeset. (default: 10)
-
-``maxshortchanges``
-    Maximum number of changes to list on the shortlog, graph or filelog
-    pages. (default: 60)
-
-``name``
-    Repository name to use in the web interface.
-    (default: current working directory)
-
-``port``
-    Port to listen on. (default: 8000)
-
-``prefix``
-    Prefix path to serve from. (default: '' (server root))
-
-``push_ssl``
-    Whether to require that inbound pushes be transported over SSL to
-    prevent password sniffing. (default: True)
-
-``refreshinterval``
-    How frequently directory listings re-scan the filesystem for new
-    repositories, in seconds. This is relevant when wildcards are used
-    to define paths. Depending on how much filesystem traversal is
-    required, refreshing may negatively impact performance.
-
-    Values less than or equal to 0 always refresh.
-    (default: 20)
-
-``server-header``
-    Value for HTTP ``Server`` response header.
-
-``static``
-    Directory where static files are served from.
-
-``staticurl``
-    Base URL to use for static files. If unset, static files (e.g. the
-    hgicon.png favicon) will be served by the CGI script itself. Use
-    this setting to serve them directly with the HTTP server.
-    Example: ``http://hgserver/static/``.
-
-``stripes``
-    How many lines a "zebra stripe" should span in multi-line output.
-    Set to 0 to disable. (default: 1)
-
-``style``
-    Which template map style to use. The available options are the names of
-    subdirectories in the HTML templates path. (default: ``paper``)
-    Example: ``monoblue``.
-
-``templates``
-    Where to find the HTML templates. The default path to the HTML templates
-    can be obtained from ``hg debuginstall``.
-
-``websub``
-----------
-
-Web substitution filter definition. You can use this section to
-define a set of regular expression substitution patterns which
-let you automatically modify the hgweb server output.
-
-The default hgweb templates only apply these substitution patterns
-on the revision description fields. You can apply them anywhere
-you want when you create your own templates by adding calls to the
-"websub" filter (usually after calling the "escape" filter).
-
-This can be used, for example, to convert issue references to links
-to your issue tracker, or to convert "markdown-like" syntax into
-HTML (see the examples below).
-
-Each entry in this section names a substitution filter.
-The value of each entry defines the substitution expression itself.
-The websub expressions follow the old interhg extension syntax,
-which in turn imitates the Unix sed replacement syntax::
-
-    patternname = s/SEARCH_REGEX/REPLACE_EXPRESSION/[i]
-
-You can use any separator other than "/". The final "i" is optional
-and indicates that the search must be case insensitive.
-
-Examples::
-
-    [websub]
-    issues = s|issue(\d+)|<a href="http://bts.example.org/issue\1">issue\1</a>|i
-    italic = s/\b_(\S+)_\b/<i>\1<\/i>/
-    bold = s/\*\b(\S+)\b\*/<b>\1<\/b>/
-
-``worker``
-----------
-
-Parallel master/worker configuration. We currently perform working
-directory updates in parallel on Unix-like systems, which greatly
-helps performance.
-
-``enabled``
-    Whether to enable workers code to be used.
-    (default: true)
-
-``numcpus``
-    Number of CPUs to use for parallel operations. A zero or
-    negative value is treated as ``use the default``.
-    (default: 4 or the number of CPUs on the system, whichever is larger)
-
-``backgroundclose``
-    Whether to enable closing file handles on background threads during certain
-    operations. Some platforms aren't very efficient at closing file
-    handles that have been written or appended to. By performing file closing
-    on background threads, file write rate can increase substantially.
-    (default: true on Windows, false elsewhere)
-
-``backgroundcloseminfilecount``
-    Minimum number of files required to trigger background file closing.
-    Operations not writing this many files won't start background close
-    threads.
-    (default: 2048)
-
-``backgroundclosemaxqueue``
-    The maximum number of opened file handles waiting to be closed in the
-    background. This option only has an effect if ``backgroundclose`` is
-    enabled.
-    (default: 384)
-
-``backgroundclosethreadcount``
-    Number of threads to process background file closes. Only relevant if
-    ``backgroundclose`` is enabled.
-    (default: 4)
--- a/mercurial/help/dates.txt	Wed Nov 20 19:07:02 2019 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,39 +0,0 @@
-Some commands allow the user to specify a date, e.g.:
-
-- backout, commit, import, tag: Specify the commit date.
-- log, revert, update: Select revision(s) by date.
-
-Many date formats are valid. Here are some examples:
-
-- ``Wed Dec 6 13:18:29 2006`` (local timezone assumed)
-- ``Dec 6 13:18 -0600`` (year assumed, time offset provided)
-- ``Dec 6 13:18 UTC`` (UTC and GMT are aliases for +0000)
-- ``Dec 6`` (midnight)
-- ``13:18`` (today assumed)
-- ``3:39`` (3:39AM assumed)
-- ``3:39pm`` (15:39)
-- ``2006-12-06 13:18:29`` (ISO 8601 format)
-- ``2006-12-6 13:18``
-- ``2006-12-6``
-- ``12-6``
-- ``12/6``
-- ``12/6/6`` (Dec 6 2006)
-- ``today`` (midnight)
-- ``yesterday`` (midnight)
-- ``now`` - right now
-
-Lastly, there is Mercurial's internal format:
-
-- ``1165411109 0`` (Wed Dec 6 13:18:29 2006 UTC)
-
-This is the internal representation format for dates. The first number
-is the number of seconds since the epoch (1970-01-01 00:00 UTC). The
-second is the offset of the local timezone, in seconds west of UTC
-(negative if the timezone is east of UTC).
-
-The log command also accepts date ranges:
-
-- ``<DATE`` - at or before a given date/time
-- ``>DATE`` - on or after a given date/time
-- ``DATE to DATE`` - a date range, inclusive
-- ``-DAYS`` - within a given number of days of today
--- a/mercurial/help/deprecated.txt	Wed Nov 20 19:07:02 2019 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,30 +0,0 @@
-Mercurial evolves over time, some features, options, commands may be replaced by
-better and more secure alternatives. This topic will help you migrating your
-existing usage and/or configuration to newer features.
-
-Commands
-========
-
-The following commands are still available but their use are not recommended:
-
-``locate``
-
-This command has been replaced by `hg files`.
-
-``parents``
-
-This command can be replaced by `hg summary` or `hg log` with appropriate
-revsets. See `hg help revsets` for more information.
-
-``tip``
-
-The recommended alternative is `hg heads`.
-
-Options
-=======
-
-``web.allowpull``
-    Renamed to `allow-pull`.
-
-``web.allow_push``
-    Renamed to `allow-push`.
--- a/mercurial/help/diffs.txt	Wed Nov 20 19:07:02 2019 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,29 +0,0 @@
-Mercurial's default format for showing changes between two versions of
-a file is compatible with the unified format of GNU diff, which can be
-used by GNU patch and many other standard tools.
-
-While this standard format is often enough, it does not encode the
-following information:
-
-- executable status and other permission bits
-- copy or rename information
-- changes in binary files
-- creation or deletion of empty files
-
-Mercurial also supports the extended diff format from the git VCS
-which addresses these limitations. The git diff format is not produced
-by default because a few widespread tools still do not understand this
-format.
-
-This means that when generating diffs from a Mercurial repository
-(e.g. with :hg:`export`), you should be careful about things like file
-copies and renames or other things mentioned above, because when
-applying a standard diff to a different repository, this extra
-information is lost. Mercurial's internal operations (like push and
-pull) are not affected by this, because they use an internal binary
-format for communicating changes.
-
-To make Mercurial produce the git extended diff format, use the --git
-option available for many commands, or set 'git = True' in the [diff]
-section of your configuration file. You do not need to set this option
-when importing diffs in this format or using them in the mq extension.
--- a/mercurial/help/environment.txt	Wed Nov 20 19:07:02 2019 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,121 +0,0 @@
-HG
-    Path to the 'hg' executable, automatically passed when running
-    hooks, extensions or external tools. If unset or empty, this is
-    the hg executable's name if it's frozen, or an executable named
-    'hg' (with %PATHEXT% [defaulting to COM/EXE/BAT/CMD] extensions on
-    Windows) is searched.
-
-HGEDITOR
-    This is the name of the editor to run when committing. See EDITOR.
-
-    (deprecated, see :hg:`help config.ui.editor`)
-
-HGENCODING
-    This overrides the default locale setting detected by Mercurial.
-    This setting is used to convert data including usernames,
-    changeset descriptions, tag names, and branches. This setting can
-    be overridden with the --encoding command-line option.
-
-HGENCODINGMODE
-    This sets Mercurial's behavior for handling unknown characters
-    while transcoding user input. The default is "strict", which
-    causes Mercurial to abort if it can't map a character. Other
-    settings include "replace", which replaces unknown characters, and
-    "ignore", which drops them. This setting can be overridden with
-    the --encodingmode command-line option.
-
-HGENCODINGAMBIGUOUS
-    This sets Mercurial's behavior for handling characters with
-    "ambiguous" widths like accented Latin characters with East Asian
-    fonts. By default, Mercurial assumes ambiguous characters are
-    narrow, set this variable to "wide" if such characters cause
-    formatting problems.
-
-HGMERGE
-    An executable to use for resolving merge conflicts. The program
-    will be executed with three arguments: local file, remote file,
-    ancestor file.
-
-    (deprecated, see :hg:`help config.ui.merge`)
-
-HGRCPATH
-    A list of files or directories to search for configuration
-    files. Item separator is ":" on Unix, ";" on Windows. If HGRCPATH
-    is not set, platform default search path is used. If empty, only
-    the .hg/hgrc from the current repository is read.
-
-    For each element in HGRCPATH:
-
-    - if it's a directory, all files ending with .rc are added
-    - otherwise, the file itself will be added
-
-HGPLAIN
-    When set, this disables any configuration settings that might
-    change Mercurial's default output. This includes encoding,
-    defaults, verbose mode, debug mode, quiet mode, tracebacks, and
-    localization. This can be useful when scripting against Mercurial
-    in the face of existing user configuration.
-
-    In addition to the features disabled by ``HGPLAIN=``, the following
-    values can be specified to adjust behavior:
-
-    ``+strictflags``
-        Restrict parsing of command line flags.
-
-    Equivalent options set via command line flags or environment
-    variables are not overridden.
-
-    See :hg:`help scripting` for details.
-
-HGPLAINEXCEPT
-    This is a comma-separated list of features to preserve when
-    HGPLAIN is enabled. Currently the following values are supported:
-
-    ``alias``
-        Don't remove aliases.
-    ``color``
-        Don't disable colored output.
-    ``i18n``
-        Preserve internationalization.
-    ``revsetalias``
-        Don't remove revset aliases.
-    ``templatealias``
-        Don't remove template aliases.
-    ``progress``
-        Don't hide progress output.
-
-    Setting HGPLAINEXCEPT to anything (even an empty string) will
-    enable plain mode.
-
-HGUSER
-    This is the string used as the author of a commit. If not set,
-    available values will be considered in this order:
-
-    - HGUSER (deprecated)
-    - configuration files from the HGRCPATH
-    - EMAIL
-    - interactive prompt
-    - LOGNAME (with ``@hostname`` appended)
-
-    (deprecated, see :hg:`help config.ui.username`)
-
-EMAIL
-    May be used as the author of a commit; see HGUSER.
-
-LOGNAME
-    May be used as the author of a commit; see HGUSER.
-
-VISUAL
-    This is the name of the editor to use when committing. See EDITOR.
-
-EDITOR
-    Sometimes Mercurial needs to open a text file in an editor for a
-    user to modify, for example when writing commit messages. The
-    editor it uses is determined by looking at the environment
-    variables HGEDITOR, VISUAL and EDITOR, in that order. The first
-    non-empty one is chosen. If all of them are empty, the editor
-    defaults to 'vi'.
-
-PYTHONPATH
-    This is used by Python to find imported modules and may need to be
-    set appropriately if this Mercurial is not installed system-wide.
--- a/mercurial/help/extensions.txt	Wed Nov 20 19:07:02 2019 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,35 +0,0 @@
-Mercurial has the ability to add new features through the use of
-extensions. Extensions may add new commands, add options to
-existing commands, change the default behavior of commands, or
-implement hooks.
-
-To enable the "foo" extension, either shipped with Mercurial or in the
-Python search path, create an entry for it in your configuration file,
-like this::
-
-  [extensions]
-  foo =
-
-You may also specify the full path to an extension::
-
-  [extensions]
-  myfeature = ~/.hgext/myfeature.py
-
-See :hg:`help config` for more information on configuration files.
-
-Extensions are not loaded by default for a variety of reasons:
-they can increase startup overhead; they may be meant for advanced
-usage only; they may provide potentially dangerous abilities (such
-as letting you destroy or modify history); they might not be ready
-for prime time; or they may alter some usual behaviors of stock
-Mercurial. It is thus up to the user to activate extensions as
-needed.
-
-To explicitly disable an extension enabled in a configuration file of
-broader scope, prepend its path with !::
-
-  [extensions]
-  # disabling extension bar residing in /path/to/extension/bar.py
-  bar = !/path/to/extension/bar.py
-  # ditto, but no path was supplied for extension baz
-  baz = !
--- a/mercurial/help/filesets.txt	Wed Nov 20 19:07:02 2019 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,79 +0,0 @@
-Mercurial supports a functional language for selecting a set of
-files.
-
-Like other file patterns, this pattern type is indicated by a prefix,
-'set:'. The language supports a number of predicates which are joined
-by infix operators. Parenthesis can be used for grouping.
-
-Identifiers such as filenames or patterns must be quoted with single
-or double quotes if they contain characters outside of
-``[.*{}[]?/\_a-zA-Z0-9\x80-\xff]`` or if they match one of the
-predefined predicates. This generally applies to file patterns other
-than globs and arguments for predicates. Pattern prefixes such as
-``path:`` may be specified without quoting.
-
-Special characters can be used in quoted identifiers by escaping them,
-e.g., ``\n`` is interpreted as a newline. To prevent them from being
-interpreted, strings can be prefixed with ``r``, e.g. ``r'...'``.
-
-See also :hg:`help patterns`.
-
-Operators
-=========
-
-There is a single prefix operator:
-
-``not x``
-  Files not in x. Short form is ``! x``.
-
-These are the supported infix operators:
-
-``x and y``
-  The intersection of files in x and y. Short form is ``x & y``.
-
-``x or y``
-  The union of files in x and y. There are two alternative short
-  forms: ``x | y`` and ``x + y``.
-
-``x - y``
-  Files in x but not in y.
-
-Predicates
-==========
-
-The following predicates are supported:
-
-.. predicatesmarker
-
-Examples
-========
-
-Some sample queries:
-
-- Show status of files that appear to be binary in the working directory::
-
-    hg status -A "set:binary()"
-
-- Forget files that are in .hgignore but are already tracked::
-
-    hg forget "set:hgignore() and not ignored()"
-
-- Find text files that contain a string::
-
-    hg files "set:grep(magic) and not binary()"
-
-- Find C files in a non-standard encoding::
-
-    hg files "set:**.c and not encoding('UTF-8')"
-
-- Revert copies of large binary files::
-
-    hg revert "set:copied() and binary() and size('>1M')"
-
-- Revert files that were added to the working directory::
-
-    hg revert "set:revs('wdir()', added())"
-
-- Remove files listed in foo.lst that contain the letter a or b::
-
-    hg remove "set: listfile:foo.lst and (**a* or **b*)"
--- a/mercurial/help/flags.txt	Wed Nov 20 19:07:02 2019 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,104 +0,0 @@
-Most Mercurial commands accept various flags.
-
-Flag names
-==========
-
-Flags for each command are listed in :hg:`help` for that command.
-Additionally, some flags, such as --repository, are global and can be used with
-any command - those are seen in :hg:`help -v`, and can be specified before or
-after the command.
-
-Every flag has at least a long name, such as --repository. Some flags may also
-have a short one-letter name, such as the equivalent -R. Using the short or long
-name is equivalent and has the same effect.
-
-Flags that have a short name can also be bundled together - for instance, to
-specify both --edit (short -e) and --interactive (short -i), one could use::
-
-    hg commit -ei
-
-If any of the bundled flags takes a value (i.e. is not a boolean), it must be
-last, followed by the value::
-
-    hg commit -im 'Message'
-
-Flag types
-==========
-
-Mercurial command-line flags can be strings, numbers, booleans, or lists of
-strings.
-
-Specifying flag values
-======================
-
-The following syntaxes are allowed, assuming a flag 'flagname' with short name
-'f'::
-
-    --flagname=foo
-    --flagname foo
-    -f foo
-    -ffoo
-
-This syntax applies to all non-boolean flags (strings, numbers or lists).
-
-Specifying boolean flags
-========================
-
-Boolean flags do not take a value parameter. To specify a boolean, use the flag
-name to set it to true, or the same name prefixed with 'no-' to set it to
-false::
-
-    hg commit --interactive
-    hg commit --no-interactive
-
-Specifying list flags
-=====================
-
-List flags take multiple values. To specify them, pass the flag multiple times::
-
-    hg files --include mercurial --include tests
-
-Setting flag defaults
-=====================
-
-In order to set a default value for a flag in an hgrc file, it is recommended to
-use aliases::
-
-    [alias]
-    commit = commit --interactive
-
-For more information on hgrc files, see :hg:`help config`.
-
-Overriding flags on the command line
-====================================
-
-If the same non-list flag is specified multiple times on the command line, the
-latest specification is used::
-
-    hg commit -m "Ignored value" -m "Used value"
-
-This includes the use of aliases - e.g., if one has::
-
-    [alias]
-    committemp = commit -m "Ignored value"
-
-then the following command will override that -m::
-
-    hg committemp -m "Used value"
-
-Overriding flag defaults
-========================
-
-Every flag has a default value, and you may also set your own defaults in hgrc
-as described above.
-Except for list flags, defaults can be overridden on the command line simply by
-specifying the flag in that location.
-
-Hidden flags
-============
-
-Some flags are not shown in a command's help by default - specifically, those
-that are deemed to be experimental, deprecated or advanced. To show all flags,
-add the --verbose flag for the help command::
-
-    hg help --verbose commit
--- a/mercurial/help/glossary.txt	Wed Nov 20 19:07:02 2019 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,413 +0,0 @@
-Ancestor
-    Any changeset that can be reached by an unbroken chain of parent
-    changesets from a given changeset. More precisely, the ancestors
-    of a changeset can be defined by two properties: a parent of a
-    changeset is an ancestor, and a parent of an ancestor is an
-    ancestor. See also: 'Descendant'.
-
-Bookmark
-    Bookmarks are pointers to certain commits that move when
-    committing. They are similar to tags in that it is possible to use
-    bookmark names in all places where Mercurial expects a changeset
-    ID, e.g., with :hg:`update`. Unlike tags, bookmarks move along
-    when you make a commit.
-
-    Bookmarks can be renamed, copied and deleted. Bookmarks are local,
-    unless they are explicitly pushed or pulled between repositories.
-    Pushing and pulling bookmarks allow you to collaborate with others
-    on a branch without creating a named branch.
-
-Branch
-    (Noun) A child changeset that has been created from a parent that
-    is not a head. These are known as topological branches, see
-    'Branch, topological'. If a topological branch is named, it becomes
-    a named branch. If a topological branch is not named, it becomes
-    an anonymous branch. See 'Branch, anonymous' and 'Branch, named'.
-
-    Branches may be created when changes are pulled from or pushed to
-    a remote repository, since new heads may be created by these
-    operations. Note that the term branch can also be used informally
-    to describe a development process in which certain development is
-    done independently of other development. This is sometimes done
-    explicitly with a named branch, but it can also be done locally,
-    using bookmarks or clones and anonymous branches.
-
-    Example: "The experimental branch."
-
-    (Verb) The action of creating a child changeset which results in
-    its parent having more than one child.
-
-    Example: "I'm going to branch at X."
-
-Branch, anonymous
-    Every time a new child changeset is created from a parent that is not
-    a head and the name of the branch is not changed, a new anonymous
-    branch is created.
-
-Branch, closed
-    A named branch whose branch heads have all been closed.
-
-Branch, default
-    The branch assigned to a changeset when no name has previously been
-    assigned.
-
-Branch head
-    See 'Head, branch'.
-
-Branch, inactive
-    If a named branch has no topological heads, it is considered to be
-    inactive. As an example, a feature branch becomes inactive when it
-    is merged into the default branch. The :hg:`branches` command
-    shows inactive branches by default, though they can be hidden with
-    :hg:`branches --active`.
-
-    NOTE: this concept is deprecated because it is too implicit.
-    Branches should now be explicitly closed using :hg:`commit
-    --close-branch` when they are no longer needed.
-
-Branch, named
-    A collection of changesets which have the same branch name. By
-    default, children of a changeset in a named branch belong to the
-    same named branch. A child can be explicitly assigned to a
-    different branch. See :hg:`help branch`, :hg:`help branches` and
-    :hg:`commit --close-branch` for more information on managing
-    branches.
-
-    Named branches can be thought of as a kind of namespace, dividing
-    the collection of changesets that comprise the repository into a
-    collection of disjoint subsets. A named branch is not necessarily
-    a topological branch. If a new named branch is created from the
-    head of another named branch, or the default branch, but no
-    further changesets are added to that previous branch, then that
-    previous branch will be a branch in name only.
-
-Branch tip
-    See 'Tip, branch'.
-
-Branch, topological
-    Every time a new child changeset is created from a parent that is
-    not a head, a new topological branch is created. If a topological
-    branch is named, it becomes a named branch. If a topological
-    branch is not named, it becomes an anonymous branch of the
-    current, possibly default, branch.
-
-Changelog
-    A record of the changesets in the order in which they were added
-    to the repository. This includes details such as changeset id,
-    author, commit message, date, and list of changed files.
-
-Changeset
-    A snapshot of the state of the repository used to record a change.
-
-Changeset, child
-    The converse of parent changeset: if P is a parent of C, then C is
-    a child of P. There is no limit to the number of children that a
-    changeset may have.
-
-Changeset id
-    A SHA-1 hash that uniquely identifies a changeset. It may be
-    represented as either a "long" 40 hexadecimal digit string, or a
-    "short" 12 hexadecimal digit string.
-
-Changeset, merge
-    A changeset with two parents. This occurs when a merge is
-    committed.
-
-Changeset, parent
-    A revision upon which a child changeset is based. Specifically, a
-    parent changeset of a changeset C is a changeset whose node
-    immediately precedes C in the DAG. Changesets have at most two
-    parents.
-
-Checkout
-    (Noun) The working directory being updated to a specific
-    revision. This use should probably be avoided where possible, as
-    changeset is much more appropriate than checkout in this context.
-
-    Example: "I'm using checkout X."
-
-    (Verb) Updating the working directory to a specific changeset. See
-    :hg:`help update`.
-
-    Example: "I'm going to check out changeset X."
-
-Child changeset
-    See 'Changeset, child'.
-
-Close changeset
-    See 'Head, closed branch'.
-
-Closed branch
-    See 'Branch, closed'.
-
-Clone
-    (Noun) An entire or partial copy of a repository. The partial
-    clone must be in the form of a revision and its ancestors.
-
-    Example: "Is your clone up to date?"
-
-    (Verb) The process of creating a clone, using :hg:`clone`.
-
-    Example: "I'm going to clone the repository."
-
-Closed branch head
-    See 'Head, closed branch'.
-
-Commit
-    (Noun) A synonym for changeset.
-
-    Example: "Is the bug fixed in your recent commit?"
-
-    (Verb) The act of recording changes to a repository. When files
-    are committed in a working directory, Mercurial finds the
-    differences between the committed files and their parent
-    changeset, creating a new changeset in the repository.
-
-    Example: "You should commit those changes now."
-
-Cset
-    A common abbreviation of the term changeset.
-
-DAG
-    The repository of changesets of a distributed version control
-    system (DVCS) can be described as a directed acyclic graph (DAG),
-    consisting of nodes and edges, where nodes correspond to
-    changesets and edges imply a parent -> child relation. This graph
-    can be visualized by graphical tools such as :hg:`log --graph`. In
-    Mercurial, the DAG is limited by the requirement for children to
-    have at most two parents.
-
-Deprecated
-    Feature removed from documentation, but not scheduled for removal.
-
-Default branch
-    See 'Branch, default'.
-
-Descendant
-    Any changeset that can be reached by a chain of child changesets
-    from a given changeset. More precisely, the descendants of a
-    changeset can be defined by two properties: the child of a
-    changeset is a descendant, and the child of a descendant is a
-    descendant. See also: 'Ancestor'.
-
-Diff
-    (Noun) The difference between the contents and attributes of files
-    in two changesets or a changeset and the current working
-    directory. The difference is usually represented in a standard
-    form called a "diff" or "patch". The "git diff" format is used
-    when the changes include copies, renames, or changes to file
-    attributes, none of which can be represented/handled by classic
-    "diff" and "patch".
-
-    Example: "Did you see my correction in the diff?"
-
-    (Verb) Diffing two changesets is the action of creating a diff or
-    patch.
-
-    Example: "If you diff with changeset X, you will see what I mean."
-
-Directory, working
-    The working directory represents the state of the files tracked by
-    Mercurial, that will be recorded in the next commit. The working
-    directory initially corresponds to the snapshot at an existing
-    changeset, known as the parent of the working directory. See
-    'Parent, working directory'. The state may be modified by changes
-    to the files introduced manually or by a merge. The repository
-    metadata exists in the .hg directory inside the working directory.
-
-Draft
-    Changesets in the draft phase have not been shared with publishing
-    repositories and may thus be safely changed by history-modifying
-    extensions. See :hg:`help phases`.
-
-Experimental
-    Feature that may change or be removed at a later date.
-
-Graph
-    See DAG and :hg:`log --graph`.
-
-Head
-    The term 'head' may be used to refer to both a branch head or a
-    repository head, depending on the context. See 'Head, branch' and
-    'Head, repository' for specific definitions.
-
-    Heads are where development generally takes place and are the
-    usual targets for update and merge operations.
-
-Head, branch
-    A changeset with no descendants on the same named branch.
-
-Head, closed branch
-    A changeset that marks a head as no longer interesting. The closed
-    head is no longer listed by :hg:`heads`. A branch is considered
-    closed when all its heads are closed and consequently is not
-    listed by :hg:`branches`.
-
-    Closed heads can be re-opened by committing new changeset as the
-    child of the changeset that marks a head as closed.
-
-Head, repository
-    A topological head which has not been closed.
-
-Head, topological
-    A changeset with no children in the repository.
-
-History, immutable
-    Once committed, changesets cannot be altered.  Extensions which
-    appear to change history actually create new changesets that
-    replace existing ones, and then destroy the old changesets. Doing
-    so in public repositories can result in old changesets being
-    reintroduced to the repository.
-
-History, rewriting
-    The changesets in a repository are immutable. However, extensions
-    to Mercurial can be used to alter the repository, usually in such
-    a way as to preserve changeset contents.
-
-Immutable history
-    See 'History, immutable'.
-
-Merge changeset
-    See 'Changeset, merge'.
-
-Manifest
-    Each changeset has a manifest, which is the list of files that are
-    tracked by the changeset.
-
-Merge
-    Used to bring together divergent branches of work. When you update
-    to a changeset and then merge another changeset, you bring the
-    history of the latter changeset into your working directory. Once
-    conflicts are resolved (and marked), this merge may be committed
-    as a merge changeset, bringing two branches together in the DAG.
-
-Named branch
-    See 'Branch, named'.
-
-Null changeset
-    The empty changeset. It is the parent state of newly-initialized
-    repositories and repositories with no checked out revision. It is
-    thus the parent of root changesets and the effective ancestor when
-    merging unrelated changesets. Can be specified by the alias 'null'
-    or by the changeset ID '000000000000'.
-
-Parent
-    See 'Changeset, parent'.
-
-Parent changeset
-    See 'Changeset, parent'.
-
-Parent, working directory
-    The working directory parent reflects a virtual revision which is
-    the child of the changeset (or two changesets with an uncommitted
-    merge) shown by :hg:`parents`. This is changed with
-    :hg:`update`. Other commands to see the working directory parent
-    are :hg:`summary` and :hg:`id`. Can be specified by the alias ".".
-
-Patch
-    (Noun) The product of a diff operation.
-
-    Example: "I've sent you my patch."
-
-    (Verb) The process of using a patch file to transform one
-    changeset into another.
-
-    Example: "You will need to patch that revision."
-
-Phase
-    A per-changeset state tracking how the changeset has been or
-    should be shared. See :hg:`help phases`.
-
-Public
-    Changesets in the public phase have been shared with publishing
-    repositories and are therefore considered immutable. See :hg:`help
-    phases`.
-
-Pull
-    An operation in which changesets in a remote repository which are
-    not in the local repository are brought into the local
-    repository. Note that this operation without special arguments
-    only updates the repository, it does not update the files in the
-    working directory. See :hg:`help pull`.
-
-Push
-    An operation in which changesets in a local repository which are
-    not in a remote repository are sent to the remote repository. Note
-    that this operation only adds changesets which have been committed
-    locally to the remote repository. Uncommitted changes are not
-    sent. See :hg:`help push`.
-
-Repository
-    The metadata describing all recorded states of a collection of
-    files. Each recorded state is represented by a changeset. A
-    repository is usually (but not always) found in the ``.hg``
-    subdirectory of a working directory. Any recorded state can be
-    recreated by "updating" a working directory to a specific
-    changeset.
-
-Repository head
-    See 'Head, repository'.
-
-Revision
-    A state of the repository at some point in time. Earlier revisions
-    can be updated to by using :hg:`update`.  See also 'Revision
-    number'; See also 'Changeset'.
-
-Revision number
-    This integer uniquely identifies a changeset in a specific
-    repository. It represents the order in which changesets were added
-    to a repository, starting with revision number 0. Note that the
-    revision number may be different in each clone of a repository. To
-    identify changesets uniquely between different clones, see
-    'Changeset id'.
-
-Revlog
-    History storage mechanism used by Mercurial. It is a form of delta
-    encoding, with occasional full revision of data followed by delta
-    of each successive revision. It includes data and an index
-    pointing to the data.
-
-Rewriting history
-    See 'History, rewriting'.
-
-Root
-    A changeset that has only the null changeset as its parent. Most
-    repositories have only a single root changeset.
-
-Secret
-    Changesets in the secret phase may not be shared via push, pull,
-    or clone. See :hg:`help phases`.
-
-Tag
-    An alternative name given to a changeset. Tags can be used in all
-    places where Mercurial expects a changeset ID, e.g., with
-    :hg:`update`. The creation of a tag is stored in the history and
-    will thus automatically be shared with other using push and pull.
-
-Tip
-    The changeset with the highest revision number. It is the changeset
-    most recently added in a repository.
-
-Tip, branch
-    The head of a given branch with the highest revision number. When
-    a branch name is used as a revision identifier, it refers to the
-    branch tip. See also 'Branch, head'. Note that because revision
-    numbers may be different in different repository clones, the
-    branch tip may be different in different cloned repositories.
-
-Update
-    (Noun) Another synonym of changeset.
-
-    Example: "I've pushed an update."
-
-    (Verb) This term is usually used to describe updating the state of
-    the working directory to that of a specific changeset. See
-    :hg:`help update`.
-
-    Example: "You should update."
-
-Working directory
-    See 'Directory, working'.
-
-Working directory parent
-    See 'Parent, working directory'.
--- a/mercurial/help/hg-ssh.8.txt	Wed Nov 20 19:07:02 2019 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,71 +0,0 @@
-========
- hg-ssh
-========
-
-----------------------------------------
-restricted ssh login shell for Mercurial
-----------------------------------------
-
-:Author:         Thomas Arendsen Hein <thomas@intevation.de>
-:Organization:   Mercurial
-:Manual section: 8
-:Manual group:   Mercurial Manual
-
-.. contents::
-   :backlinks: top
-   :class: htmlonly
-   :depth: 1
-
-Synopsis
-""""""""
-**hg-ssh** repositories...
-
-Description
-"""""""""""
-**hg-ssh** is a wrapper for ssh access to a limited set of mercurial repos.
-
-To be used in ~/.ssh/authorized_keys with the "command" option, see sshd(8):
-command="hg-ssh path/to/repo1 /path/to/repo2 ~/repo3 ~user/repo4" ssh-dss ...
-(probably together with these other useful options:
-no-port-forwarding,no-X11-forwarding,no-agent-forwarding)
-
-This allows pull/push over ssh from/to the repositories given as arguments.
-
-If all your repositories are subdirectories of a common directory, you can
-allow shorter paths with:
-command="cd path/to/my/repositories && hg-ssh repo1 subdir/repo2"
-
-You can use pattern matching of your normal shell, e.g.:
-command="cd repos && hg-ssh user/thomas/* projects/{mercurial,foo}"
-
-You can also add a --read-only flag to allow read-only access to a key, e.g.:
-command="hg-ssh --read-only repos/\*"
-
-Bugs
-""""
-Probably lots, please post them to the mailing list (see Resources_
-below) when you find them.
-
-See Also
-""""""""
-|hg(1)|_
-
-Author
-""""""
-Written by Matt Mackall <mpm@selenic.com>
-
-Resources
-"""""""""
-Main Web Site: https://mercurial-scm.org/
-
-Source code repository: https://www.mercurial-scm.org/repo/hg
-
-Mailing list: https://www.mercurial-scm.org/mailman/listinfo/mercurial/
-
-Copying
-"""""""
-Copyright (C) 2005-2016 Matt Mackall.
-Free use of this software is granted under the terms of the GNU General
-Public License version 2 or any later version.
-
-.. include:: common.txt
--- a/mercurial/help/hg.1.txt	Wed Nov 20 19:07:02 2019 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,119 +0,0 @@
-====
- hg
-====
-
----------------------------------------
-Mercurial source code management system
----------------------------------------
-
-:Author:         Matt Mackall <mpm@selenic.com>
-:Organization:   Mercurial
-:Manual section: 1
-:Manual group:   Mercurial Manual
-
-.. contents::
-   :backlinks: top
-   :class: htmlonly
-   :depth: 1
-
-
-Synopsis
-""""""""
-**hg** *command* [*option*]... [*argument*]...
-
-Description
-"""""""""""
-The **hg** command provides a command line interface to the Mercurial
-system.
-
-Command Elements
-""""""""""""""""
-
-files...
-    indicates one or more filename or relative path filenames; see
-    `File Name Patterns`_ for information on pattern matching
-
-path
-    indicates a path on the local machine
-
-revision
-    indicates a changeset which can be specified as a changeset
-    revision number, a tag, or a unique substring of the changeset
-    hash value
-
-repository path
-    either the pathname of a local repository or the URI of a remote
-    repository.
-
-.. include:: hg.1.gendoc.txt
-
-Files
-"""""
-
-``/etc/mercurial/hgrc``, ``$HOME/.hgrc``, ``.hg/hgrc``
-    This file contains defaults and configuration. Values in
-    ``.hg/hgrc`` override those in ``$HOME/.hgrc``, and these override
-    settings made in the global ``/etc/mercurial/hgrc`` configuration.
-    See |hgrc(5)|_ for details of the contents and format of these
-    files.
-
-``.hgignore``
-    This file contains regular expressions (one per line) that
-    describe file names that should be ignored by **hg**. For details,
-    see |hgignore(5)|_.
-
-``.hgsub``
-    This file defines the locations of all subrepositories, and
-    tells where the subrepository checkouts came from. For details, see
-    :hg:`help subrepos`.
-
-``.hgsubstate``
-    This file is where Mercurial stores all nested repository states. *NB: This
-    file should not be edited manually.*
-
-``.hgtags``
-    This file contains changeset hash values and text tag names (one
-    of each separated by spaces) that correspond to tagged versions of
-    the repository contents. The file content is encoded using UTF-8.
-
-``.hg/last-message.txt``
-    This file is used by :hg:`commit` to store a backup of the commit message
-    in case the commit fails.
-
-``.hg/localtags``
-    This file can be used to define local tags which are not shared among
-    repositories. The file format is the same as for ``.hgtags``, but it is
-    encoded using the local system encoding.
-
-Some commands (e.g. revert) produce backup files ending in ``.orig``,
-if the ``.orig`` file already exists and is not tracked by Mercurial,
-it will be overwritten.
-
-Bugs
-""""
-Probably lots, please post them to the mailing list (see Resources_
-below) when you find them.
-
-See Also
-""""""""
-|hgignore(5)|_, |hgrc(5)|_
-
-Author
-""""""
-Written by Matt Mackall <mpm@selenic.com>
-
-Resources
-"""""""""
-Main Web Site: https://mercurial-scm.org/
-
-Source code repository: https://www.mercurial-scm.org/repo/hg
-
-Mailing list: https://www.mercurial-scm.org/mailman/listinfo/mercurial/
-
-Copying
-"""""""
-Copyright (C) 2005-2019 Matt Mackall.
-Free use of this software is granted under the terms of the GNU General
-Public License version 2 or any later version.
-
-.. include:: common.txt
--- a/mercurial/help/hgignore.5.txt	Wed Nov 20 19:07:02 2019 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,34 +0,0 @@
-==========
- hgignore
-==========
-
----------------------------------
-syntax for Mercurial ignore files
----------------------------------
-
-:Author:         Vadim Gelfer <vadim.gelfer@gmail.com>
-:Organization:   Mercurial
-:Manual section: 5
-:Manual group:   Mercurial Manual
-
-.. include:: hgignore.5.gendoc.txt
-
-Author
-======
-Vadim Gelfer <vadim.gelfer@gmail.com>
-
-Mercurial was written by Matt Mackall <mpm@selenic.com>.
-
-See Also
-========
-|hg(1)|_, |hgrc(5)|_
-
-Copying
-=======
-This manual page is copyright 2006 Vadim Gelfer.
-Mercurial is copyright 2005-2019 Matt Mackall.
-Free use of this software is granted under the terms of the GNU General
-Public License version 2 or any later version.
-
-.. include:: common.txt
-
--- a/mercurial/help/hgignore.txt	Wed Nov 20 19:07:02 2019 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,97 +0,0 @@
-Synopsis
-========
-
-The Mercurial system uses a file called ``.hgignore`` in the root
-directory of a repository to control its behavior when it searches
-for files that it is not currently tracking.
-
-Description
-===========
-
-The working directory of a Mercurial repository will often contain
-files that should not be tracked by Mercurial. These include backup
-files created by editors and build products created by compilers.
-These files can be ignored by listing them in a ``.hgignore`` file in
-the root of the working directory. The ``.hgignore`` file must be
-created manually. It is typically put under version control, so that
-the settings will propagate to other repositories with push and pull.
-
-An untracked file is ignored if its path relative to the repository
-root directory, or any prefix path of that path, is matched against
-any pattern in ``.hgignore``.
-
-For example, say we have an untracked file, ``file.c``, at
-``a/b/file.c`` inside our repository. Mercurial will ignore ``file.c``
-if any pattern in ``.hgignore`` matches ``a/b/file.c``, ``a/b`` or ``a``.
-
-In addition, a Mercurial configuration file can reference a set of
-per-user or global ignore files. See the ``ignore`` configuration
-key on the ``[ui]`` section of :hg:`help config` for details of how to
-configure these files.
-
-To control Mercurial's handling of files that it manages, many
-commands support the ``-I`` and ``-X`` options; see
-:hg:`help <command>` and :hg:`help patterns` for details.
-
-Files that are already tracked are not affected by .hgignore, even
-if they appear in .hgignore. An untracked file X can be explicitly
-added with :hg:`add X`, even if X would be excluded by a pattern
-in .hgignore.
-
-Syntax
-======
-
-An ignore file is a plain text file consisting of a list of patterns,
-with one pattern per line. Empty lines are skipped. The ``#``
-character is treated as a comment character, and the ``\`` character
-is treated as an escape character.
-
-Mercurial supports several pattern syntaxes. The default syntax used
-is Python/Perl-style regular expressions.
-
-To change the syntax used, use a line of the following form::
-
-  syntax: NAME
-
-where ``NAME`` is one of the following:
-
-``regexp``
-  Regular expression, Python/Perl syntax.
-``glob``
-  Shell-style glob.
-``rootglob``
-  A variant of ``glob`` that is rooted (see below).
-
-The chosen syntax stays in effect when parsing all patterns that
-follow, until another syntax is selected.
-
-Neither ``glob`` nor regexp patterns are rooted. A glob-syntax
-pattern of the form ``*.c`` will match a file ending in ``.c`` in any
-directory, and a regexp pattern of the form ``\.c$`` will do the
-same. To root a regexp pattern, start it with ``^``. To get the same
-effect with glob-syntax, you have to use ``rootglob``.
-
-Subdirectories can have their own .hgignore settings by adding
-``subinclude:path/to/subdir/.hgignore`` to the root ``.hgignore``. See
-:hg:`help patterns` for details on ``subinclude:`` and ``include:``.
-
-.. note::
-
-  Patterns specified in other than ``.hgignore`` are always rooted.
-  Please see :hg:`help patterns` for details.
-
-Example
-=======
-
-Here is an example ignore file. ::
-
-  # use glob syntax.
-  syntax: glob
-
-  *.elc
-  *.pyc
-  *~
-
-  # switch to regexp syntax.
-  syntax: regexp
-  ^\.pc/
--- a/mercurial/help/hgrc.5.txt	Wed Nov 20 19:07:02 2019 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,41 +0,0 @@
-======
- hgrc
-======
-
----------------------------------
-configuration files for Mercurial
----------------------------------
-
-:Author:         Bryan O'Sullivan <bos@serpentine.com>
-:Organization:   Mercurial
-:Manual section: 5
-:Manual group:   Mercurial Manual
-
-.. contents::
-   :backlinks: top
-   :class: htmlonly
-
-
-Description
-===========
-
-.. include:: hgrc.5.gendoc.txt
-
-Author
-======
-Bryan O'Sullivan <bos@serpentine.com>.
-
-Mercurial was written by Matt Mackall <mpm@selenic.com>.
-
-See Also
-========
-|hg(1)|_, |hgignore(5)|_
-
-Copying
-=======
-This manual page is copyright 2005 Bryan O'Sullivan.
-Mercurial is copyright 2005-2019 Matt Mackall.
-Free use of this software is granted under the terms of the GNU General
-Public License version 2 or any later version.
-
-.. include:: common.txt
--- a/mercurial/help/hgweb.txt	Wed Nov 20 19:07:02 2019 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,86 +0,0 @@
-Mercurial's internal web server, hgweb, can serve either a single
-repository, or a tree of repositories. In the second case, repository
-paths and global options can be defined using a dedicated
-configuration file common to :hg:`serve`, ``hgweb.wsgi``,
-``hgweb.cgi`` and ``hgweb.fcgi``.
-
-This file uses the same syntax as other Mercurial configuration files
-but recognizes only the following sections:
-
-  - web
-  - paths
-  - collections
-
-The ``web`` options are thoroughly described in :hg:`help config`.
-
-The ``paths`` section maps URL paths to paths of repositories in the
-filesystem. hgweb will not expose the filesystem directly - only
-Mercurial repositories can be published and only according to the
-configuration.
-
-The left hand side is the path in the URL. Note that hgweb reserves
-subpaths like ``rev`` or ``file``, try using different names for
-nested repositories to avoid confusing effects.
-
-The right hand side is the path in the filesystem. If the specified
-path ends with ``*`` or ``**`` the filesystem will be searched
-recursively for repositories below that point.
-With ``*`` it will not recurse into the repositories it finds (except for
-``.hg/patches``).
-With ``**`` it will also search inside repository working directories
-and possibly find subrepositories.
-
-In this example::
-
-  [paths]
-  /projects/a = /srv/tmprepos/a
-  /projects/b = c:/repos/b
-  / = /srv/repos/*
-  /user/bob = /home/bob/repos/**
-
-- The first two entries make two repositories in different directories
-  appear under the same directory in the web interface
-- The third entry will publish every Mercurial repository found in
-  ``/srv/repos/``, for instance the repository ``/srv/repos/quux/``
-  will appear as ``http://server/quux/``
-- The fourth entry will publish both ``http://server/user/bob/quux/``
-  and ``http://server/user/bob/quux/testsubrepo/``
-
-The ``collections`` section is deprecated and has been superseded by
-``paths``.
-
-URLs and Common Arguments
-=========================
-
-URLs under each repository have the form ``/{command}[/{arguments}]``
-where ``{command}`` represents the name of a command or handler and
-``{arguments}`` represents any number of additional URL parameters
-to that command.
-
-The web server has a default style associated with it. Styles map to
-a collection of named templates. Each template is used to render a
-specific piece of data, such as a changeset or diff.
-
-The style for the current request can be overwritten two ways. First,
-if ``{command}`` contains a hyphen (``-``), the text before the hyphen
-defines the style. For example, ``/atom-log`` will render the ``log``
-command handler with the ``atom`` style. The second way to set the
-style is with the ``style`` query string argument. For example,
-``/log?style=atom``. The hyphenated URL parameter is preferred.
-
-Not all templates are available for all styles. Attempting to use
-a style that doesn't have all templates defined may result in an error
-rendering the page.
-
-Many commands take a ``{revision}`` URL parameter. This defines the
-changeset to operate on. This is commonly specified as the short,
-12 digit hexadecimal abbreviation for the full 40 character unique
-revision identifier. However, any value described by
-:hg:`help revisions` typically works.
-
-Commands and URLs
-=================
-
-The following web commands and their URLs are available:
-
-  .. webcommandsmarker
--- a/mercurial/help/internals/bundle2.txt	Wed Nov 20 19:07:02 2019 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,677 +0,0 @@
-Bundle2 refers to a data format that is used for both on-disk storage
-and over-the-wire transfer of repository data and state.
-
-The data format allows the capture of multiple components of
-repository data. Contrast with the initial bundle format, which
-only captured *changegroup* data (and couldn't store bookmarks,
-phases, etc).
-
-Bundle2 is used for:
-
-* Transferring data from a repository (e.g. as part of an ``hg clone``
-  or ``hg pull`` operation).
-* Transferring data to a repository (e.g. as part of an ``hg push``
-  operation).
-* Storing data on disk (e.g. the result of an ``hg bundle``
-  operation).
-* Transferring the results of a repository operation (e.g. the
-  reply to an ``hg push`` operation).
-
-At its highest level, a bundle2 payload is a stream that begins
-with some metadata and consists of a series of *parts*, with each
-part describing repository data or state or the result of an
-operation. New bundle2 parts are introduced over time when there is
-a need to capture a new form of data. A *capabilities* mechanism
-exists to allow peers to understand which bundle2 parts the other
-understands.
-
-Stream Format
-=============
-
-A bundle2 payload consists of a magic string (``HG20``) followed by
-stream level parameters, followed by any number of payload *parts*.
-
-It may help to think of the stream level parameters as *headers* and the
-payload parts as the *body*.
-
-Stream Level Parameters
------------------------
-
-Following the magic string is data that defines parameters applicable to the
-entire payload.
-
-Stream level parameters begin with a 32-bit unsigned big-endian integer.
-The value of this integer defines the number of bytes of stream level
-parameters that follow.
-
-The *N* bytes of raw data contains a space separated list of parameters.
-Each parameter consists of a required name and an optional value.
-
-Parameters have the form ``<name>`` or ``<name>=<value>``.
-
-Both the parameter name and value are URL quoted.
-
-Names MUST start with a letter. If the first letter is lower case, the
-parameter is advisory and can safely be ignored. If the first letter
-is upper case, the parameter is mandatory and the handler MUST stop if
-it is unable to process it.
-
-Stream level parameters apply to the entire bundle2 payload. Lower-level
-options should go into a bundle2 part instead.
-
-The following stream level parameters are defined:
-
-Compression
-   Compression format of payload data. ``GZ`` denotes zlib. ``BZ``
-   denotes bzip2. ``ZS`` denotes zstandard.
-
-   When defined, all bytes after the stream level parameters are
-   compressed using the compression format defined by this parameter.
-
-   If this parameter isn't present, data is raw/uncompressed.
-
-   This parameter MUST be mandatory because attempting to consume
-   streams without knowing how to decode the underlying bytes will
-   result in errors.
-
-Payload Part
-------------
-
-Following the stream level parameters are 0 or more payload parts. Each
-payload part consists of a header and a body.
-
-The payload part header consists of a 32-bit unsigned big-endian integer
-defining the number of bytes in the header that follow. The special
-value ``0`` indicates the end of the bundle2 stream.
-
-The binary format of the part header is as follows:
-
-* 8-bit unsigned size of the part name
-* N-bytes alphanumeric part name
-* 32-bit unsigned big-endian part ID
-* N bytes part parameter data
-
-The *part name* identifies the type of the part. A part name with an
-UPPERCASE letter is mandatory. Otherwise, the part is advisory. A
-consumer should abort if it encounters a mandatory part it doesn't know
-how to process. See the sections below for each defined part type.
-
-The *part ID* is a unique identifier within the bundle used to refer to a
-specific part. It should be unique within the bundle2 payload.
-
-Part parameter data consists of:
-
-* 1 byte number of mandatory parameters
-* 1 byte number of advisory parameters
-* 2 * N bytes of sizes of parameter key and values
-* N * M blobs of values for parameter key and values
-
-Following the 2 bytes of mandatory and advisory parameter counts are
-2-tuples of bytes of the sizes of each parameter. e.g.
-(<key size>, <value size>).
-
-Following that are the raw values, without padding. Mandatory parameters
-come first, followed by advisory parameters.
-
-Each parameter's key MUST be unique within the part.
-
-Following the part parameter data is the part payload. The part payload
-consists of a series of framed chunks. The frame header is a 32-bit
-big-endian integer defining the size of the chunk. The N bytes of raw
-payload data follows.
-
-The part payload consists of 0 or more chunks.
-
-A chunk with size ``0`` denotes the end of the part payload. Therefore,
-there will always be at least 1 32-bit integer following the payload
-part header.
-
-A chunk size of ``-1`` is used to signal an *interrupt*. If such a chunk
-size is seen, the stream processor should process the next bytes as a new
-payload part. After this payload part, processing of the original,
-interrupted part should resume.
-
-Capabilities
-============
-
-Bundle2 is a dynamic format that can evolve over time. For example,
-when a new repository data concept is invented, a new bundle2 part
-is typically invented to hold that data. In addition, parts performing
-similar functionality may come into existence if there is a better
-mechanism for performing certain functionality.
-
-Because the bundle2 format evolves over time, peers need to understand
-what bundle2 features the other can understand. The *capabilities*
-mechanism is how those features are expressed.
-
-Bundle2 capabilities are logically expressed as a dictionary of
-string key-value pairs where the keys are strings and the values
-are lists of strings.
-
-Capabilities are encoded for exchange between peers. The encoded
-capabilities blob consists of a newline (``\n``) delimited list of
-entries. Each entry has the form ``<key>`` or ``<key>=<value>``,
-depending if the capability has a value.
-
-The capability name is URL quoted (``%XX`` encoding of URL unsafe
-characters).
-
-The value, if present, is formed by URL quoting each value in
-the capability list and concatenating the result with a comma (``,``).
-
-For example, the capabilities ``novaluekey`` and ``listvaluekey``
-with values ``value 1`` and ``value 2``. This would be encoded as:
-
-   listvaluekey=value%201,value%202\nnovaluekey
-
-The sections below detail the defined bundle2 capabilities.
-
-HG20
-----
-
-Denotes that the peer supports the bundle2 data format.
-
-bookmarks
----------
-
-Denotes that the peer supports the ``bookmarks`` part.
-
-Peers should not issue mandatory ``bookmarks`` parts unless this
-capability is present.
-
-changegroup
------------
-
-Denotes which versions of the *changegroup* format the peer can
-receive. Values include ``01``, ``02``, and ``03``.
-
-The peer should not generate changegroup data for a version not
-specified by this capability.
-
-checkheads
-----------
-
-Denotes which forms of heads checking the peer supports.
-
-If ``related`` is in the value, then the peer supports the ``check:heads``
-part and the peer is capable of detecting race conditions when applying
-changelog data.
-
-digests
--------
-
-Denotes which hashing formats the peer supports.
-
-Values are names of hashing function. Values include ``md5``, ``sha1``,
-and ``sha512``.
-
-error
------
-
-Denotes which ``error:`` parts the peer supports.
-
-Value is a list of strings of ``error:`` part names. Valid values
-include ``abort``, ``unsupportecontent``, ``pushraced``, and ``pushkey``.
-
-Peers should not issue an ``error:`` part unless the type of that
-part is listed as supported by this capability.
-
-listkeys
---------
-
-Denotes that the peer supports the ``listkeys`` part.
-
-hgtagsfnodes
-------------
-
-Denotes that the peer supports the ``hgtagsfnodes`` part.
-
-obsmarkers
-----------
-
-Denotes that the peer supports the ``obsmarker`` part and which versions
-of the obsolescence data format it can receive. Values are strings like
-``V<N>``. e.g. ``V1``.
-
-phases
-------
-
-Denotes that the peer supports the ``phases`` part.
-
-pushback
---------
-
-Denotes that the peer supports sending/receiving bundle2 data in response
-to a bundle2 request.
-
-This capability is typically used by servers that employ server-side
-rewriting of pushed repository data. For example, a server may wish to
-automatically rebase pushed changesets. When this capability is present,
-the server can send a bundle2 response containing the rewritten changeset
-data and the client will apply it.
-
-pushkey
--------
-
-Denotes that the peer supports the ``puskey`` part.
-
-remote-changegroup
-------------------
-
-Denotes that the peer supports the ``remote-changegroup`` part and
-which protocols it can use to fetch remote changegroup data.
-
-Values are protocol names. e.g. ``http`` and ``https``.
-
-stream
-------
-
-Denotes that the peer supports ``stream*`` parts in order to support
-*stream clone*.
-
-Values are which ``stream*`` parts the peer supports. ``v2`` denotes
-support for the ``stream2`` part.
-
-Bundle2 Part Types
-==================
-
-The sections below detail the various bundle2 part types.
-
-bookmarks
----------
-
-The ``bookmarks`` part holds bookmarks information.
-
-This part has no parameters.
-
-The payload consists of entries defining bookmarks. Each entry consists of:
-
-* 20 bytes binary changeset node.
-* 2 bytes big endian short defining bookmark name length.
-* N bytes defining bookmark name.
-
-Receivers typically update bookmarks to match the state specified in
-this part.
-
-changegroup
------------
-
-The ``changegroup`` part contains *changegroup* data (changelog, manifestlog,
-and filelog revision data).
-
-The following part parameters are defined for this part.
-
-version
-   Changegroup version string. e.g. ``01``, ``02``, and ``03``. This parameter
-   determines how to interpret the changegroup data within the part.
-
-nbchanges
-   The number of changesets in this changegroup. This parameter can be used
-   to aid in the display of progress bars, etc during part application.
-
-treemanifest
-   Whether the changegroup contains tree manifests.
-
-targetphase
-   The target phase of changesets in this part. Value is an integer of
-   the target phase.
-
-The payload of this part is raw changegroup data. See
-:hg:`help internals.changegroups` for the format of changegroup data.
-
-check:bookmarks
----------------
-
-The ``check:bookmarks`` part is inserted into a bundle as a means for the
-receiver to validate that the sender's known state of bookmarks matches
-the receiver's.
-
-This part has no parameters.
-
-The payload is a binary stream of bookmark data. Each entry in the stream
-consists of:
-
-* 20 bytes binary node that bookmark is associated with
-* 2 bytes unsigned short defining length of bookmark name
-* N bytes containing the bookmark name
-
-If all bits in the node value are ``1``, then this signifies a missing
-bookmark.
-
-When the receiver encounters this part, for each bookmark in the part
-payload, it should validate that the current bookmark state matches
-the specified state. If it doesn't, then the receiver should take
-appropriate action. (In the case of pushes, this mismatch signifies
-a race condition and the receiver should consider rejecting the push.)
-
-check:heads
------------
-
-The ``check:heads`` part is a means to validate that the sender's state
-of DAG heads matches the receiver's.
-
-This part has no parameters.
-
-The body of this part is an array of 20 byte binary nodes representing
-changeset heads.
-
-Receivers should compare the set of heads defined in this part to the
-current set of repo heads and take action if there is a mismatch in that
-set.
-
-Note that this part applies to *all* heads in the repo.
-
-check:phases
-------------
-
-The ``check:phases`` part validates that the sender's state of phase
-boundaries matches the receiver's.
-
-This part has no parameters.
-
-The payload consists of an array of 24 byte entries. Each entry is
-a big endian 32-bit integer defining the phase integer and 20 byte
-binary node value.
-
-For each changeset defined in this part, the receiver should validate
-that its current phase matches the phase defined in this part. The
-receiver should take appropriate action if a mismatch occurs.
-
-check:updated-heads
--------------------
-
-The ``check:updated-heads`` part validates that the sender's state of
-DAG heads updated by this bundle matches the receiver's.
-
-This type is nearly identical to ``check:heads`` except the heads
-in the payload are only a subset of heads in the repository. The
-receiver should validate that all nodes specified by the sender are
-branch heads and take appropriate action if not.
-
-error:abort
------------
-
-The ``error:abort`` part conveys a fatal error.
-
-The following part parameters are defined:
-
-message
-   The string content of the error message.
-
-hint
-   Supplemental string giving a hint on how to fix the problem.
-
-error:pushkey
--------------
-
-The ``error:pushkey`` part conveys an error in the *pushkey* protocol.
-
-The following part parameters are defined:
-
-namespace
-   The pushkey domain that exhibited the error.
-
-key
-   The key whose update failed.
-
-new
-   The value we tried to set the key to.
-
-old
-   The old value of the key (as supplied by the client).
-
-ret
-   The integer result code for the pushkey request.
-
-in-reply-to
-   Part ID that triggered this error.
-
-This part is generated if there was an error applying *pushkey* data.
-Pushkey data includes bookmarks, phases, and obsolescence markers.
-
-error:pushraced
----------------
-
-The ``error:pushraced`` part conveys that an error occurred and
-the likely cause is losing a race with another pusher.
-
-The following part parameters are defined:
-
-message
-   String error message.
-
-This part is typically emitted when a receiver examining ``check:*``
-parts encountered inconsistency between incoming state and local state.
-The likely cause of that inconsistency is another repository change
-operation (often another client performing an ``hg push``).
-
-error:unsupportedcontent
-------------------------
-
-The ``error:unsupportedcontent`` part conveys that a bundle2 receiver
-encountered a part or content it was not able to handle.
-
-The following part parameters are defined:
-
-parttype
-   The name of the part that triggered this error.
-
-params
-   ``\0`` delimited list of parameters.
-
-hgtagsfnodes
-------------
-
-The ``hgtagsfnodes`` type defines file nodes for the ``.hgtags`` file
-for various changesets.
-
-This part has no parameters.
-
-The payload is an array of pairs of 20 byte binary nodes. The first node
-is a changeset node. The second node is the ``.hgtags`` file node.
-
-Resolving tags requires resolving the ``.hgtags`` file node for changesets.
-On large repositories, this can be expensive. Repositories cache the
-mapping of changeset to ``.hgtags`` file node on disk as a performance
-optimization. This part allows that cached data to be transferred alongside
-changeset data.
-
-Receivers should update their ``.hgtags`` cache file node mappings with
-the incoming data.
-
-listkeys
---------
-
-The ``listkeys`` part holds content for a *pushkey* namespace.
-
-The following part parameters are defined:
-
-namespace
-   The pushkey domain this data belongs to.
-
-The part payload contains a newline (``\n``) delimited list of
-tab (``\t``) delimited key-value pairs defining entries in this pushkey
-namespace.
-
-obsmarkers
-----------
-
-The ``obsmarkers`` part defines obsolescence markers.
-
-This part has no parameters.
-
-The payload consists of obsolescence markers using the on-disk markers
-format. The first byte defines the version format.
-
-The receiver should apply the obsolescence markers defined in this
-part. A ``reply:obsmarkers`` part should be sent to the sender, if possible.
-
-output
-------
-
-The ``output`` part is used to display output on the receiver.
-
-This part has no parameters.
-
-The payload consists of raw data to be printed on the receiver.
-
-phase-heads
------------
-
-The ``phase-heads`` part defines phase boundaries.
-
-This part has no parameters.
-
-The payload consists of an array of 24 byte entries. Each entry is
-a big endian 32-bit integer defining the phase integer and 20 byte
-binary node value.
-
-pushkey
--------
-
-The ``pushkey`` part communicates an intent to perform a ``pushkey``
-request.
-
-The following part parameters are defined:
-
-namespace
-   The pushkey domain to operate on.
-
-key
-   The key within the pushkey namespace that is being changed.
-
-old
-   The old value for the key being changed.
-
-new
-   The new value for the key being changed.
-
-This part has no payload.
-
-The receiver should perform a pushkey operation as described by this
-part's parameters.
-
-If the pushey operation fails, a ``reply:pushkey`` part should be sent
-back to the sender, if possible. The ``in-reply-to`` part parameter
-should reference the source part.
-
-pushvars
---------
-
-The ``pushvars`` part defines environment variables that should be
-set when processing this bundle2 payload.
-
-The part's advisory parameters define environment variables.
-
-There is no part payload.
-
-When received, part parameters are prefixed with ``USERVAR_`` and the
-resulting variables are defined in the hooks context for the current
-bundle2 application. This part provides a mechanism for senders to
-inject extra state into the hook execution environment on the receiver.
-
-remote-changegroup
-------------------
-
-The ``remote-changegroup`` part defines an external location of a bundle
-to apply. This part can be used by servers to serve pre-generated bundles
-hosted at arbitrary URLs.
-
-The following part parameters are defined:
-
-url
-   The URL of the remote bundle.
-
-size
-   The size in bytes of the remote bundle.
-
-digests
-   A space separated list of the digest types provided in additional
-   part parameters.
-
-digest:<type>
-   The hexadecimal representation of the digest (hash) of the remote bundle.
-
-There is no payload for this part type.
-
-When encountered, clients should attempt to fetch the URL being advertised
-and read and apply it as a bundle.
-
-The ``size`` and ``digest:<type>`` parameters should be used to validate
-that the downloaded bundle matches what was advertised. If a mismatch occurs,
-the client should abort.
-
-reply:changegroup
------------------
-
-The ``reply:changegroup`` part conveys the results of application of a
-``changegroup`` part.
-
-The following part parameters are defined:
-
-return
-   Integer return code from changegroup application.
-
-in-reply-to
-   Part ID of part this reply is in response to.
-
-reply:obsmarkers
-----------------
-
-The ``reply:obsmarkers`` part conveys the results of applying an
-``obsmarkers`` part.
-
-The following part parameters are defined:
-
-new
-   The integer number of new markers that were applied.
-
-in-reply-to
-   The part ID that this part is in reply to.
-
-reply:pushkey
--------------
-
-The ``reply:pushkey`` part conveys the result of a *pushkey* operation.
-
-The following part parameters are defined:
-
-return
-   Integer result code from pushkey operation.
-
-in-reply-to
-   Part ID that triggered this pushkey operation.
-
-This part has no payload.
-
-replycaps
----------
-
-The ``replycaps`` part notifies the receiver that a reply bundle should
-be created.
-
-This part has no parameters.
-
-The payload consists of a bundle2 capabilities blob.
-
-stream2
--------
-
-The ``stream2`` part contains *streaming clone* version 2 data.
-
-The following part parameters are defined:
-
-requirements
-   URL quoted repository requirements string. Requirements are delimited by a
-   command (``,``).
-
-filecount
-   The total number of files being transferred in the payload.
-
-bytecount
-   The total size of file content being transferred in the payload.
-
-The payload consists of raw stream clone version 2 data.
-
-The ``filecount`` and ``bytecount`` parameters can be used for progress and
-reporting purposes. The values may not be exact.
--- a/mercurial/help/internals/bundles.txt	Wed Nov 20 19:07:02 2019 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,93 +0,0 @@
-A bundle is a container for repository data.
-
-Bundles are used as standalone files as well as the interchange format
-over the wire protocol used when two Mercurial peers communicate with
-each other.
-
-Headers
-=======
-
-Bundles produced since Mercurial 0.7 (September 2005) have a 4 byte
-header identifying the major bundle type. The header always begins with
-``HG`` and the follow 2 bytes indicate the bundle type/version. Some
-bundle types have additional data after this 4 byte header.
-
-The following sections describe each bundle header/type.
-
-HG10
-----
-
-``HG10`` headers indicate a *changegroup bundle*. This is the original
-bundle format, so it is sometimes referred to as *bundle1*. It has been
-present since version 0.7 (released September 2005).
-
-This header is followed by 2 bytes indicating the compression algorithm
-used for data that follows. All subsequent data following this
-compression identifier is compressed according to the algorithm/method
-specified.
-
-Supported algorithms include the following.
-
-``BZ``
-   *bzip2* compression.
-
-   Bzip2 compressors emit a leading ``BZ`` header. Mercurial uses this
-   leading ``BZ`` as part of the bundle header. Therefore consumers
-   of bzip2 bundles need to *seed* the bzip2 decompressor with ``BZ`` or
-   seek the input stream back to the beginning of the algorithm component
-   of the bundle header so that decompressor input is valid. This behavior
-   is unique among supported compression algorithms.
-
-   Supported since version 0.7 (released December 2006).
-
-``GZ``
-  *zlib* compression.
-
-   Supported since version 0.9.2 (released December 2006).
-
-``UN``
-  *Uncompressed* or no compression. Unmodified changegroup data follows.
-
-  Supported since version 0.9.2 (released December 2006).
-
-3rd party extensions may implement their own compression. However, no
-authority reserves values for their compression algorithm identifiers.
-
-HG2X
-----
-
-``HG2X`` headers (where ``X`` is any value) denote a *bundle2* bundle.
-Bundle2 bundles are a container format for various kinds of repository
-data and capabilities, beyond changegroup data (which was the only data
-supported by ``HG10`` bundles.
-
-``HG20`` is currently the only defined bundle2 version.
-
-The ``HG20`` format is documented at :hg:`help internals.bundle2`.
-
-Initial ``HG20`` support was added in Mercurial 3.0 (released May
-2014). However, bundle2 bundles were hidden behind an experimental flag
-until version 3.5 (released August 2015), when they were enabled in the
-wire protocol. Various commands (including ``hg bundle``) did not
-support generating bundle2 files until Mercurial 3.6 (released November
-2015).
-
-HGS1
-----
-
-*Experimental*
-
-A ``HGS1`` header indicates a *streaming clone bundle*. This is a bundle
-that contains raw revlog data from a repository store. (Typically revlog
-data is exchanged in the form of changegroups.)
-
-The purpose of *streaming clone bundles* are to *clone* repository data
-very efficiently.
-
-The ``HGS1`` header is always followed by 2 bytes indicating a
-compression algorithm of the data that follows. Only ``UN``
-(uncompressed data) is currently allowed.
-
-``HGS1UN`` support was added as an experimental feature in version 3.6
-(released November 2015) as part of the initial offering of the *clone
-bundles* feature.
--- a/mercurial/help/internals/cbor.txt	Wed Nov 20 19:07:02 2019 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,130 +0,0 @@
-Mercurial uses Concise Binary Object Representation (CBOR)
-(RFC 7049) for various data formats.
-
-This document describes the subset of CBOR that Mercurial uses and
-gives recommendations for appropriate use of CBOR within Mercurial.
-
-Type Limitations
-================
-
-Major types 0 and 1 (unsigned integers and negative integers) MUST be
-fully supported.
-
-Major type 2 (byte strings) MUST be fully supported. However, there
-are limitations around the use of indefinite-length byte strings.
-(See below.)
-
-Major type 3 (text strings) are NOT supported.
-
-Major type 4 (arrays) MUST be supported. However, values are limited
-to the set of types described in the "Container Types" section below.
-And indefinite-length arrays are NOT supported.
-
-Major type 5 (maps) MUST be supported. However, key values are limited
-to the set of types described in the "Container Types" section below.
-And indefinite-length maps are NOT supported.
-
-Major type 6 (semantic tagging of major types) can be used with the
-following semantic tag values:
-
-258
-   Mathematical finite set. Suitable for representing Python's
-   ``set`` type.
-
-All other semantic tag values are not allowed.
-
-Major type 7 (simple data types) can be used with the following
-type values:
-
-20
-   False
-21
-   True
-22
-   Null
-31
-   Break stop code (for indefinite-length items).
-
-All other simple data type values (including every value requiring the
-1 byte extension) are disallowed.
-
-Indefinite-Length Byte Strings
-==============================
-
-Indefinite-length byte strings (major type 2) are allowed. However,
-they MUST NOT occur inside a container type (such as an array or map).
-i.e. they can only occur as the "top-most" element in a stream of
-values.
-
-Encoders and decoders SHOULD *stream* indefinite-length byte strings.
-i.e. an encoder or decoder SHOULD NOT buffer the entirety of a long
-byte string value when indefinite-length byte strings are being used
-if it can be avoided. Mercurial MAY use extremely long indefinite-length
-byte strings and buffering the source or destination value COULD lead to
-memory exhaustion.
-
-Chunks in an indefinite-length byte string SHOULD NOT exceed 2^20
-bytes.
-
-Container Types
-===============
-
-Mercurial may use the array (major type 4), map (major type 5), and
-set (semantic tag 258 plus major type 4 array) container types.
-
-An array may contain any supported type as values.
-
-A map MUST only use the following types as keys:
-
-* unsigned integers (major type 0)
-* negative integers (major type 1)
-* byte strings (major type 2) (but not indefinite-length byte strings)
-* false (simple type 20)
-* true (simple type 21)
-* null (simple type 22)
-
-A map MUST only use the following types as values:
-
-* all types supported as map keys
-* arrays
-* maps
-* sets
-
-A set may only use the following types as values:
-
-* all types supported as map keys
-
-It is recommended that keys in maps and values in sets and arrays all
-be of a uniform type.
-
-Avoiding Large Byte Strings
-===========================
-
-The use of large byte strings is discouraged, especially in scenarios where
-the total size of the byte string may by unbound for some inputs (e.g. when
-representing the content of a tracked file). It is highly recommended to use
-indefinite-length byte strings for these purposes.
-
-Since indefinite-length byte strings cannot be nested within an outer
-container (such as an array or map), to associate a large byte string
-with another data structure, it is recommended to use an array or
-map followed immediately by an indefinite-length byte string. For example,
-instead of the following map::
-
-   {
-      "key1": "value1",
-      "key2": "value2",
-      "long_value": "some very large value...",
-   }
-
-Use a map followed by a byte string:
-
-   {
-      "key1": "value1",
-      "key2": "value2",
-      "value_follows": True,
-   }
-   <BEGIN INDEFINITE-LENGTH BYTE STRING>
-   "some very large value"
-   "..."
-   <END INDEFINITE-LENGTH BYTE STRING>
--- a/mercurial/help/internals/censor.txt	Wed Nov 20 19:07:02 2019 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,22 +0,0 @@
-The censor system allows retroactively removing content from
-files. Actually censoring a node requires using the censor extension,
-but the functionality for handling censored nodes is partially in core.
-
-Censored nodes in a filelog have the flag ``REVIDX_ISCENSORED`` set,
-and the contents of the censored node are replaced with a censor
-tombstone. For historical reasons, the tombstone is packed in the
-filelog metadata field ``censored``. This allows censored nodes to be
-(mostly) safely transmitted through old formats like changegroup
-versions 1 and 2. When using changegroup formats older than 3, the
-receiver is required to re-add the ``REVIDX_ISCENSORED`` flag when
-storing the revision. This depends on the ``censored`` metadata key
-never being used for anything other than censoring revisions, which is
-true as of January 2017. Note that the revlog flag is the
-authoritative marker of a censored node: the tombstone should only be
-consulted when looking for a reason a node was censored or when revlog
-flags are unavailable as mentioned above.
-
-The tombstone data is a free-form string. It's expected that users of
-censor will want to record the reason for censoring a node in the
-tombstone. Censored nodes must be able to fit in the size of the
-content being censored.
--- a/mercurial/help/internals/changegroups.txt	Wed Nov 20 19:07:02 2019 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,207 +0,0 @@
-Changegroups are representations of repository revlog data, specifically
-the changelog data, root/flat manifest data, treemanifest data, and
-filelogs.
-
-There are 3 versions of changegroups: ``1``, ``2``, and ``3``. From a
-high-level, versions ``1`` and ``2`` are almost exactly the same, with the
-only difference being an additional item in the *delta header*. Version
-``3`` adds support for storage flags in the *delta header* and optionally
-exchanging treemanifests (enabled by setting an option on the
-``changegroup`` part in the bundle2).
-
-Changegroups when not exchanging treemanifests consist of 3 logical
-segments::
-
-   +---------------------------------+
-   |           |          |          |
-   | changeset | manifest | filelogs |
-   |           |          |          |
-   |           |          |          |
-   +---------------------------------+
-
-When exchanging treemanifests, there are 4 logical segments::
-
-   +-------------------------------------------------+
-   |           |          |               |          |
-   | changeset |   root   | treemanifests | filelogs |
-   |           | manifest |               |          |
-   |           |          |               |          |
-   +-------------------------------------------------+
-
-The principle building block of each segment is a *chunk*. A *chunk*
-is a framed piece of data::
-
-   +---------------------------------------+
-   |           |                           |
-   |  length   |           data            |
-   | (4 bytes) |   (<length - 4> bytes)    |
-   |           |                           |
-   +---------------------------------------+
-
-All integers are big-endian signed integers. Each chunk starts with a 32-bit
-integer indicating the length of the entire chunk (including the length field
-itself).
-
-There is a special case chunk that has a value of 0 for the length
-(``0x00000000``). We call this an *empty chunk*.
-
-Delta Groups
-============
-
-A *delta group* expresses the content of a revlog as a series of deltas,
-or patches against previous revisions.
-
-Delta groups consist of 0 or more *chunks* followed by the *empty chunk*
-to signal the end of the delta group::
-
-  +------------------------------------------------------------------------+
-  |                |             |               |             |           |
-  | chunk0 length  | chunk0 data | chunk1 length | chunk1 data |    0x0    |
-  |   (4 bytes)    |  (various)  |   (4 bytes)   |  (various)  | (4 bytes) |
-  |                |             |               |             |           |
-  +------------------------------------------------------------------------+
-
-Each *chunk*'s data consists of the following::
-
-  +---------------------------------------+
-  |                        |              |
-  |     delta header       |  delta data  |
-  |  (various by version)  |  (various)   |
-  |                        |              |
-  +---------------------------------------+
-
-The *delta data* is a series of *delta*s that describe a diff from an existing
-entry (either that the recipient already has, or previously specified in the
-bundle/changegroup).
-
-The *delta header* is different between versions ``1``, ``2``, and
-``3`` of the changegroup format.
-
-Version 1 (headerlen=80)::
-
-   +------------------------------------------------------+
-   |            |             |             |             |
-   |    node    |   p1 node   |   p2 node   |  link node  |
-   | (20 bytes) |  (20 bytes) |  (20 bytes) |  (20 bytes) |
-   |            |             |             |             |
-   +------------------------------------------------------+
-
-Version 2 (headerlen=100)::
-
-   +------------------------------------------------------------------+
-   |            |             |             |            |            |
-   |    node    |   p1 node   |   p2 node   | base node  | link node  |
-   | (20 bytes) |  (20 bytes) |  (20 bytes) | (20 bytes) | (20 bytes) |
-   |            |             |             |            |            |
-   +------------------------------------------------------------------+
-
-Version 3 (headerlen=102)::
-
-   +------------------------------------------------------------------------------+
-   |            |             |             |            |            |           |
-   |    node    |   p1 node   |   p2 node   | base node  | link node  |   flags   |
-   | (20 bytes) |  (20 bytes) |  (20 bytes) | (20 bytes) | (20 bytes) | (2 bytes) |
-   |            |             |             |            |            |           |
-   +------------------------------------------------------------------------------+
-
-The *delta data* consists of ``chunklen - 4 - headerlen`` bytes, which contain a
-series of *delta*s, densely packed (no separators). These deltas describe a diff
-from an existing entry (either that the recipient already has, or previously
-specified in the bundle/changegroup). The format is described more fully in
-``hg help internals.bdiff``, but briefly::
-
-   +---------------------------------------------------------------+
-   |              |            |            |                      |
-   | start offset | end offset | new length |        content       |
-   |  (4 bytes)   |  (4 bytes) |  (4 bytes) | (<new length> bytes) |
-   |              |            |            |                      |
-   +---------------------------------------------------------------+
-
-Please note that the length field in the delta data does *not* include itself.
-
-In version 1, the delta is always applied against the previous node from
-the changegroup or the first parent if this is the first entry in the
-changegroup.
-
-In version 2 and up, the delta base node is encoded in the entry in the
-changegroup. This allows the delta to be expressed against any parent,
-which can result in smaller deltas and more efficient encoding of data.
-
-The *flags* field holds bitwise flags affecting the processing of revision
-data. The following flags are defined:
-
-32768
-   Censored revision. The revision's fulltext has been replaced by censor
-   metadata. May only occur on file revisions.
-16384
-   Ellipsis revision. Revision hash does not match data (likely due to rewritten
-   parents).
-8192
-   Externally stored. The revision fulltext contains ``key:value`` ``\n``
-   delimited metadata defining an object stored elsewhere. Used by the LFS
-   extension.
-
-For historical reasons, the integer values are identical to revlog version 1
-per-revision storage flags and correspond to bits being set in this 2-byte
-field. Bits were allocated starting from the most-significant bit, hence the
-reverse ordering and allocation of these flags.
-
-Changeset Segment
-=================
-
-The *changeset segment* consists of a single *delta group* holding
-changelog data. The *empty chunk* at the end of the *delta group* denotes
-the boundary to the *manifest segment*.
-
-Manifest Segment
-================
-
-The *manifest segment* consists of a single *delta group* holding manifest
-data. If treemanifests are in use, it contains only the manifest for the
-root directory of the repository. Otherwise, it contains the entire
-manifest data. The *empty chunk* at the end of the *delta group* denotes
-the boundary to the next segment (either the *treemanifests segment* or the
-*filelogs segment*, depending on version and the request options).
-
-Treemanifests Segment
----------------------
-
-The *treemanifests segment* only exists in changegroup version ``3``, and
-only if the 'treemanifest' param is part of the bundle2 changegroup part
-(it is not possible to use changegroup version 3 outside of bundle2).
-Aside from the filenames in the *treemanifests segment* containing a
-trailing ``/`` character, it behaves identically to the *filelogs segment*
-(see below). The final sub-segment is followed by an *empty chunk* (logically,
-a sub-segment with filename size 0). This denotes the boundary to the
-*filelogs segment*.
-
-Filelogs Segment
-================
-
-The *filelogs segment* consists of multiple sub-segments, each
-corresponding to an individual file whose data is being described::
-
-   +--------------------------------------------------+
-   |          |          |          |     |           |
-   | filelog0 | filelog1 | filelog2 | ... |    0x0    |
-   |          |          |          |     | (4 bytes) |
-   |          |          |          |     |           |
-   +--------------------------------------------------+
-
-The final filelog sub-segment is followed by an *empty chunk* (logically,
-a sub-segment with filename size 0). This denotes the end of the segment
-and of the overall changegroup.
-
-Each filelog sub-segment consists of the following::
-
-   +------------------------------------------------------+
-   |                 |                      |             |
-   | filename length |       filename       | delta group |
-   |    (4 bytes)    | (<length - 4> bytes) |  (various)  |
-   |                 |                      |             |
-   +------------------------------------------------------+
-
-That is, a *chunk* consisting of the filename (not terminated or padded)
-followed by N chunks constituting the *delta group* for this file. The
-*empty chunk* at the end of each *delta group* denotes the boundary to the
-next filelog sub-segment.
--- a/mercurial/help/internals/config.txt	Wed Nov 20 19:07:02 2019 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,109 +0,0 @@
-All config options used within Mercurial should be registered.
-
-Config Option in Core
-=====================
-
-Config options used by Mercurial core are registered in the
-``mercurial.configitems`` module.
-
-Simple entry
-------------
-
-A registration entry typically looks like::
-
-    coreconfigitem('section', 'option',
-        default=MyDefaultValue,
-    )
-
-Once registered, Mercurial will know that ``section.option`` is a legitimate
-config option and that ``MyDefaultValue`` should be used if no other values are
-defined in configuration files.
-
-Complex default value
----------------------
-
-If the default provided is a callable, it is called to retrieve the default
-value when accessing the config option. This is useful for default values that
-are mutable like the empty list::
-
-    coreconfigitem('pager', 'ignore',
-        default=list,
-    )
-
-In addition, there are cases where the default is not fixed, but computed from
-other properties. In this case, use the ``dynamicdefault`` object as the value
-for the ``default`` parameter. A default value is then explicitly required when
-reading the option::
-
-    # registration
-    coreconfigitem('web', 'name',
-        default=dynamicdefault,
-    )
-
-    # usage
-    ui.config('web', 'name', dirname)
-
-Free form options
------------------
-
-Some config sections use free form options (e.g. ``paths``). You can register
-them using the ``generic`` parameters::
-
-    coreconfigitem('paths', '.*',
-        default=None,
-        generic=True,
-    )
-
-When ``generic=True`` is set, the option name is matched as a regular expression
-(rooted to string start). It can be used to select specific sub parameters::
-
-    coreconfigitem('merge-tools', br'.*\.args$',
-        default="$local $base $other",
-        generic=True,
-        priority=-1,
-    )
-
-The ``priority`` parameter controls the order used to match the generic pattern
-(lower first).
-
-Config Option in Extensions
-===========================
-
-General case
-------------
-
-Extensions should register config items through the ``registrar`` API (also used
-for commands and others)::
-
-    configtable = {}
-    configitem = registrar.configitem(configtable)
-
-    configitem('blackbox', 'dirty',
-        default=False,
-    )
-
-The ``dynamicdefault`` object is then available as
-``configitem.dynamicdefault``.
-
-Supporting older versions
--------------------------
-
-The registrar was introduced in Mercurial 4.3, and the ``generic`` parameter was
-introduced in 4.4. Starting with Mercurial 4.4, all core options were registered
-and developer warnings are emitted when accessing unregistered option.
-
-Extensions supporting versions older than Mercurial 4.3 cannot rely on the
-default value being registered. The simplest way to register an option while
-still supporting an older version is to use ``dynamicdefault`` for options
-requiring a default value. The existing code passing an explicit default can
-then stay in use until compatibility with Mercurial 4.2 is dropped.
-
-As reminder, here are the default values for each config type:
-
-    - config:      None
-    - configbool:  False
-    - configbytes: 0
-    - configdate:  None
-    - configint:   None
-    - configlist:  []
-    - configpath:  None
--- a/mercurial/help/internals/extensions.txt	Wed Nov 20 19:07:02 2019 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,367 +0,0 @@
-Extensions allow the creation of new features and using them directly from
-the main hg command line as if they were built-in commands. The extensions
-have full access to the *internal* API.
-
-Use of Mercurial's internal API very likely makes your code subject to
-Mercurial's license. Before going any further, read the License page.
-
-There are NO guarantees that third-party code calling into Mercurial's
-internals won't break from release to release. If you do use Mercurial's API
-for published third-party code, we expect you to test your code before each
-major Mercurial release. This will prevent various bug reports from your users
-when they upgrade their copy of Mercurial.
-
-File Layout
-===========
-
-Extensions are usually written as simple python modules. Larger ones are
-better split into multiple modules of a single package (see the convert
-extension). The package root module gives its name to the extension and
-implements the ``cmdtable`` and optional callbacks described below.
-
-Command table
-=============
-
-To write your own extension, your python module can provide an optional dict
-named ``cmdtable`` with entries describing each command. A command should be
-registered to the ``cmdtable`` by ``@command`` decorator.
-
-Example using ``@command`` decorator (requires Mercurial 1.9)::
-
-    from mercurial.i18n import _
-
-    cmdtable = {}
-    try:
-        from mercurial import registrar
-        command = registrar.command(cmdtable)
-    except (AttributeError, ImportError):
-        # Fallback to hg < 4.3 support
-        from mercurial import cmdutil
-        command = cmdutil.command(cmdtable)
-
-    @command('print-parents',
-        [('s', 'short', None, _('print short form')),
-         ('l', 'long', None, _('print long form'))],
-        _('[options] node'))
-    def printparents(ui, repo, node, **opts):
-        ...
-
-The cmdtable dictionary
------------------------
-
-The ``cmdtable`` dictionary uses as key the new command names, and, as value,
-a tuple containing:
-
-1. the function to be called when the command is used.
-2. a list of options the command can take.
-3. a command line synopsis for the command (the function docstring is used for
-   the full help).
-
-List of options
----------------
-
-All the command flag options are documented in the mercurial/fancyopts.py
-sources.
-
-The options list is a list of tuples containing:
-
-1. the short option letter, or ``''`` if no short option is available
-   (for example, ``o`` for a ``-o`` option).
-2. the long option name (for example, ``option`` for a ``--option`` option).
-3. a default value for the option.
-4. a help string for the option (it's possible to omit the "hg newcommand"
-   part and only the options and parameter substring is needed).
-
-Command function signatures
----------------------------
-
-Functions that implement new commands always receive a ``ui`` and usually
-a ``repo`` parameter. The rest of parameters are taken from the command line
-items that don't start with a dash and are passed in the same order they were
-written. If no default value is given in the parameter list they are required.
-
-If there is no repo to be associated with the command and consequently no
-``repo`` passed, then ``norepo=True`` should be passed to the ``@command``
-decorator::
-
-    @command('mycommand', [], norepo=True)
-    def mycommand(ui, **opts):
-        ...
-
-For examples of ``norepo``, see the convert extension.
-
-Command function docstrings
-===========================
-
-The docstring of your function is used as the main help text, shown by
-``hg help mycommand``. The docstring should be formatted using a simple
-subset of reStructuredText markup. The supported constructs include:
-
-Paragraphs::
-
-    This is a paragraph.
-
-    Paragraphs are separated
-    by blank lines.
-
-A verbatim block is introduced with a double colon followed by an indented
-block. The double colon is turned into a single colon on display::
-
-    Some text::
-
-      verbatim
-        text
-         !!
-
-We have field lists::
-
-    :key1: value1
-    :key2: value2
-
-Bullet lists::
-
-    - foo
-    - bar
-
-Enumerated lists::
-
-    1. foo
-    2. bar
-
-Inline markup::
-
-    ``*bold*``, ``monospace``, :hg:`command`
-
-Mark Mercurial commands with ``:hg:`` to make a nice link to the corresponding
-documentation. We'll expand the support if new constructs can be parsed
-without too much trouble.
-
-Communicating with the user
-===========================
-
-Besides the ``ui`` methods, like ``ui.write(*msg)`` or
-``ui.prompt(msg, default="y")``, an extension can add help text for each
-of its commands and the extension itself.
-
-The module docstring will be used as help string when ``hg help extensionname``
-is used and, similarly, the help string for a command and the docstring
-belonging to the function that's wrapped by the command will be shown when
-``hg help command`` is invoked.
-
-Setup Callbacks
-===============
-
-Extensions are loaded in phases. All extensions are processed in a given phase
-before the next phase begins. In the first phase, all extension modules are
-loaded and registered with Mercurial. This means that you can find all enabled
-extensions with ``extensions.find`` in the following phases.
-
-Extension setup
----------------
-
-There are two callbacks to be called when extensions are loaded, named
-``uisetup`` and ``extsetup``. ``uisetup`` is called first for each extension,
-then ``extsetup`` is called. This means ``extsetup`` can be useful in case
-one extension optionally depends on another extension.
-
-Both ``uisetup`` and ``extsetup`` receive a ui object with the local
-repository configuration::
-
-    def uisetup(ui):
-        # ...
-
-    def extsetup(ui):
-        # ...
-
-Be aware that ``uisetup`` in NOT the function to configure a ``ui`` instance.
-It's called only once per process, not per ``ui`` instance. Also, any changes
-to the ``ui`` may be discarded because the ``ui`` here temporarily loaded
-local configuration. So, it's generally wrong to do `ui.setconfig()` in
-these callbacks. Notable exception is setting ``pre/post-<command>`` hooks
-and extending ``ui.__class__``.
-
-In Mercurial 1.3.1 or earlier, ``extsetup`` takes no argument.
-
-Command table setup
--------------------
-
-After ``extsetup``, the ``cmdtable`` is copied into the global command table
-in Mercurial.
-
-Ui instance setup
------------------
-
-The optional ``uipopulate`` is called for each ``ui`` instance after
-configuration is loaded, where extensions can set up additional ui members,
-update configuration by ``ui.setconfig()``, and extend the class dynamically.
-
-Typically there are three ``ui`` instances involved in command execution:
-
-``req.ui`` (or ``repo.baseui``)
-    Only system and user configurations are loaded into it.
-``lui``
-    Local repository configuration is loaded as well. This will be used at
-    early dispatching stage where a repository isn't available.
-``repo.ui``
-    The fully-loaded ``ui`` used after a repository is instantiated. This
-    will be created from the ``req.ui`` per repository.
-
-In command server and hgweb, this may be called more than once for the same
-``ui`` instance.
-
-(New in Mercurial 4.9)
-
-Repository setup
-----------------
-
-Extensions can implement an optional callback named ``reposetup``. It is
-called after the main Mercurial repository initialization, and can be used
-to setup any local state the extension might need.
-
-As other command functions it receives an ``ui`` object and a ``repo`` object
-(no additional parameters for this, though)::
-
-    def reposetup(ui, repo):
-        #do initialization here.
-
-It is important to take into account that the ``ui`` object that is received
-by the ``reposetup`` function is not the same as the one received by the
-``uisetup`` and ``extsetup`` functions. This is particularly important when
-setting up hooks as described in the following section, since not all hooks
-use the same ``ui`` object and hence different hooks must be configured in
-different setup functions.
-
-Wrapping methods on the ui and repo classes
--------------------------------------------
-
-Because extensions can be loaded *per repository*, you should avoid using
-``extensions.wrapfunction()`` on methods of the ``ui`` and ``repo`` objects.
-Instead, create a subclass of the specific class of the instance passed into
-the ``*setup()`` hook; e.g. use ``ui.__class__`` as the base class, then
-reassign your new class to ``ui.__class__`` again. Mercurial will then use
-your updated ``ui`` or ``repo`` instance only for repositories where your
-extension is enabled (or copies thereof, reusing your new class).
-
-For example::
-
-    def uisetup(ui):
-        class echologui(ui.__class__):
-            def log(self, service, *msg, **opts):
-                if msg:
-                    self.write('%s: %s\n' % (service, msg[0] % msg[1:]))
-                super(echologui, self).log(service, *msg, **opts)
-
-        ui.__class__ = echologui
-
-Configuring Hooks
-=================
-
-Some extensions must use hooks to do their work. These required hooks can
-be configured manually by the user by modifying the ``[hook]`` section of
-their hgrc, but they can also be configured automatically by calling the
-``ui.setconfig('hooks', ...)`` function in one of the setup functions
-described above.
-
-The main difference between manually modifying the hooks section in the hgrc
-and using ``ui.setconfig()`` is that when using ``ui.setconfig()`` you have
-access to the actual hook function object, which you can pass directly to
-``ui.setconfig()``, while when you use the hooks section of the hgrc file
-you must refer to the hook function by using the
-``python:modulename.functioname`` idiom (e.g. ``python:hgext.notify.hook``).
-
-For example::
-
-    # Define hooks -- note that the actual function name it irrelevant.
-    def preupdatehook(ui, repo, **kwargs):
-        ui.write("Pre-update hook triggered\n")
-
-    def updatehook(ui, repo, **kwargs):
-        ui.write("Update hook triggered\n")
-
-    def uisetup(ui):
-        # When pre-<cmd> and post-<cmd> hooks are configured by means of
-        # the ui.setconfig() function, you must use the ui object passed
-        # to uisetup or extsetup.
-        ui.setconfig("hooks", "pre-update.myextension", preupdatehook)
-
-    def reposetup(ui, repo):
-        # Repository-specific hooks can be configured here. These include
-        # the update hook.
-        ui.setconfig("hooks", "update.myextension", updatehook)
-
-Note how different hooks may need to be configured in different setup
-functions. In the example you can see that the ``update`` hook must be
-configured in the ``reposetup`` function, while the ``pre-update`` hook
-must be configured on the ``uisetup`` or the ``extsetup`` functions.
-
-Marking compatible versions
-===========================
-
-Every extension should use the ``testedwith`` variable to specify Mercurial
-releases it's known to be compatible with. This helps us and users diagnose
-where problems are coming from::
-
-    testedwith = '2.0 2.0.1 2.1 2.1.1 2.1.2'
-
-Do not use the ``internal`` marker in third-party extensions; we will
-immediately drop all bug reports mentioning your extension if we catch you
-doing this.
-
-Similarly, an extension can use the ``buglink`` variable to specify how users
-should report issues with the extension.  This link will be included in the
-error message if the extension produces errors::
-
-    buglink = 'https://bitbucket.org/USER/REPO/issues'
-
-If an extension requires a minimum version of Mercurial, it can be declared
-with the ``minimumhgversion`` variable::
-
-    minimumhgversion = '4.6'
-
-Older clients will print a warning that the extension requires a new version,
-instead of attempting to load it.
-
-Wrap up: what belongs where?
-============================
-
-You will find here a list of most common tasks, based on setups from the
-extensions included in Mercurial core.
-
-uisetup
--------
-
-* Changes to ``ui.__class__`` . The ``ui`` object that will be used to run
-  the command has not yet been created. Changes made here will affect ``ui``
-  objects created after this, and in particular the ``ui`` that will be passed
-  to ``runcommand``
-* Command wraps (``extensions.wrapcommand``)
-* Changes that need to be visible by other extensions: because initialization
-  occurs in phases (all extensions run ``uisetup``, then all run ``extsetup``),
-  a change made here will be visible by other extensions during ``extsetup``.
-* Monkeypatches or function wraps (``extensions.wrapfunction``) of ``dispatch``
-  module members
-* Set up ``pre-*`` and ``post-*`` hooks. (DEPRECATED. ``uipopulate`` is
-  preferred on Mercurial 4.9 and later.)
-* ``pushkey`` setup
-
-extsetup
---------
-
-* Changes depending on the status of other extensions. (``if extensions.find('mq')``)
-* Add a global option to all commands
-* Extend revsets
-
-uipopulate
-----------
-
-* Modify ``ui`` instance attributes and configuration variables.
-* Changes to ``ui.__class__`` per instance.
-* Set up all hooks per scoped configuration.
-
-reposetup
----------
-
-* Set up all hooks but ``pre-*`` and ``post-*``. (DEPRECATED. ``uipopulate`` is
-  preferred on Mercurial 4.9 and later.)
-* Modify configuration variables
-* Changes to ``repo.__class__``, ``repo.dirstate.__class__``
--- a/mercurial/help/internals/linelog.txt	Wed Nov 20 19:07:02 2019 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,302 +0,0 @@
-linelog is a storage format inspired by the "Interleaved deltas" idea. See
-https://en.wikipedia.org/wiki/Interleaved_deltas for its introduction.
-
-0. SCCS Weave
-
-  To understand what linelog is, first we have a quick look at a simplified
-  (with header removed) SCCS weave format, which is an implementation of the
-  "Interleaved deltas" idea.
-
-0.1 Basic SCCS Weave File Format
-
-  A SCCS weave file consists of plain text lines. Each line is either a
-  special instruction starting with "^A" or part of the content of the real
-  file the weave tracks. There are 3 important operations, where REV denotes
-  the revision number:
-
-    ^AI REV, marking the beginning of an insertion block introduced by REV
-    ^AD REV, marking the beginning of a deletion block introduced by REV
-    ^AE REV, marking the end of the block started by "^AI REV" or "^AD REV"
-
-  Note on revision numbers: For any two different revision numbers, one must
-  be an ancestor of the other to make them comparable. This enforces linear
-  history. Besides, the comparison functions (">=", "<") should be efficient.
-  This means, if revisions are strings like git or hg, an external map is
-  required to convert them into integers.
-
-  For example, to represent the following changes:
-
-    REV 1 | REV 2 | REV 3
-    ------+-------+-------
-    a     | a     | a
-    b     | b     | 2
-    c     | 1     | c
-          | 2     |
-          | c     |
-
-  A possible weave file looks like:
-
-    ^AI 1
-    a
-    ^AD 3
-    b
-    ^AI 2
-    1
-    ^AE 3
-    2
-    ^AE 2
-    c
-    ^AE 1
-
-  An "^AE" does not always match its nearest operation ("^AI" or "^AD"). In
-  the above example, "^AE 3" does not match the nearest "^AI 2" but "^AD 3".
-  Therefore we need some extra information for "^AE". The SCCS weave uses a
-  revision number. It could also be a boolean value about whether it is an
-  insertion or a deletion (see section 0.4).
-
-0.2 Checkout
-
-  The "checkout" operation is to retrieve file content at a given revision,
-  say X. It's doable by going through the file line by line and:
-
-    - If meet ^AI rev, and rev > X, find the corresponding ^AE and jump there
-    - If meet ^AD rev, and rev <= X, find the corresponding ^AE and jump there
-    - Ignore ^AE
-    - For normal lines, just output them
-
-0.3 Annotate
-
-  The "annotate" operation is to show extra metadata like the revision number
-  and the original line number a line comes from.
-
-  It's basically just a "Checkout". For the extra metadata, they can be stored
-  side by side with the line contents. Alternatively, we can infer the
-  revision number from "^AI"s.
-
-  Some SCM tools have to calculate diffs on the fly and thus are much slower
-  on this operation.
-
-0.4 Tree Structure
-
-  The word "interleaved" is used because "^AI" .. "^AE" and "^AD" .. "^AE"
-  blocks can be interleaved.
-
-  If we consider insertions and deletions separately, they can form tree
-  structures, respectively.
-
-    +--- ^AI 1        +--- ^AD 3
-    | +- ^AI 2        | +- ^AD 2
-    | |               | |
-    | +- ^AE 2        | +- ^AE 2
-    |                 |
-    +--- ^AE 1        +--- ^AE 3
-
-  More specifically, it's possible to build a tree for all insertions, where
-  the tree node has the structure "(rev, startline, endline)". "startline" is
-  the line number of "^AI" and "endline" is the line number of the matched
-  "^AE".  The tree will have these properties:
-
-    1. child.rev > parent.rev
-    2. child.startline > parent.startline
-    3. child.endline < parent.endline
-
-  A similar tree for all deletions can also be built with the first property
-  changed to:
-
-    1. child.rev < parent.rev
-
-0.5 Malformed Cases
-
-  The following cases are considered malformed in our implementation:
-
-    1. Interleaved insertions, or interleaved deletions.
-       It can be rewritten to a non-interleaved tree structure.
-
-       Take insertions as example, deletions are similar:
-
-       ^AI x         ^AI x
-       a             a
-       ^AI x + 1  -> ^AI x + 1
-       b             b
-       ^AE x         ^AE x + 1
-       c             ^AE x
-       ^AE x + 1     ^AI x + 1
-                     c
-                     ^AE x + 1
-
-    2. Nested insertions, where the inner one has a smaller revision number.
-       Or nested deletions, where the inner one has a larger revision number.
-       It can be rewritten to a non-nested form.
-
-       Take insertions as example, deletions are similar:
-
-       ^AI x + 1     ^AI x + 1
-       a             a
-       ^AI x      -> ^AE x + 1
-       b             ^AI x
-       ^AE x         b
-       c             ^AE x
-       ^AE x + 1     ^AI x + 1
-                     c
-                     ^AE x + 1
-
-    3. Insertion inside deletion with a smaller revision number.
-
-       Rewrite by duplicating the content inserted:
-
-       ^AD x          ^AD x
-       a              a
-       ^AI x + 1  ->  b
-       b              c
-       ^AE x + 1      ^AE x
-       c              ^AI x + 1
-       ^AE x          b
-                      ^AE x + 1
-
-       Note: If "annotate" purely depends on "^AI" information, then the
-       duplication content will lose track of where "b" is originally from.
-
-  Some of them may be valid in other implementations for special purposes. For
-  example, to "revive" a previously deleted block in a newer revision.
-
-0.6 Cases Can Be Optimized
-
-  It's always better to get things nested. For example, the left is more
-  efficient than the right while they represent the same content:
-
-    +--- ^AD 2          +- ^AD 1
-    | +- ^AD 1          |   LINE A
-    | |   LINE A        +- ^AE 1
-    | +- ^AE 1          +- ^AD 2
-    |     LINE B        |   LINE B
-    +--- ^AE 2          +- ^AE 2
-
-  Our implementation sometimes generates the less efficient data. To always
-  get the optimal form, it requires extra code complexity that seems unworthy.
-
-0.7 Inefficiency
-
-  The file format can be slow because:
-
-  - Inserting a new line at position P requires rewriting all data after P.
-  - Finding "^AE" requires walking through the content (O(N), where N is the
-    number of lines between "^AI/D" and "^AE").
-
-1. Linelog
-
-  The linelog is a binary format that dedicates to speed up mercurial (or
-  git)'s "annotate" operation. It's designed to avoid issues mentioned in
-  section 0.7.
-
-1.1 Content Stored
-
-  Linelog is not another storage for file contents. It only stores line
-  numbers and corresponding revision numbers, instead of actual line content.
-  This is okay for the "annotate" operation because usually the external
-  source is fast to checkout the content of a file at a specific revision.
-
-  A typical SCCS weave is also fast on the "grep" operation, which needs
-  random accesses to line contents from different revisions of a file. This
-  can be slow with linelog's no-line-content design. However we could use
-  an extra map ((rev, line num) -> line content) to speed it up.
-
-  Note the revision numbers in linelog should be independent from mercurial
-  integer revision numbers. There should be some mapping between linelog rev
-  and hg hash stored side by side, to make the files reusable after being
-  copied to another machine.
-
-1.2 Basic Format
-
-  A linelog file consists of "instruction"s. An "instruction" can be either:
-
-    - JGE  REV ADDR     # jump to ADDR if rev >= REV
-    - JL   REV ADDR     # jump to ADDR if rev < REV
-    - LINE REV LINENUM  # append the (LINENUM+1)-th line in revision REV
-
-  For example, here is the example linelog representing the same file with
-  3 revisions mentioned in section 0.1:
-
-    SCCS  |    Linelog
-    Weave | Addr : Instruction
-    ------+------+-------------
-    ^AI 1 |    0 : JL   1 8
-    a     |    1 : LINE 1 0
-    ^AD 3 |    2 : JGE  3 6
-    b     |    3 : LINE 1 1
-    ^AI 2 |    4 : JL   2 7
-    1     |    5 : LINE 2 2
-    ^AE 3 |
-    2     |    6 : LINE 2 3
-    ^AE 2 |
-    c     |    7 : LINE 1 2
-    ^AE 1 |
-          |    8 : END
-
-  This way, "find ^AE" is O(1) because we just jump there. And we can insert
-  new lines without rewriting most part of the file by appending new lines and
-  changing a single instruction to jump to them.
-
-  The current implementation uses 64 bits for an instruction: The opcode (JGE,
-  JL or LINE) takes 2 bits, REV takes 30 bits and ADDR or LINENUM takes 32
-  bits. It also stores the max revision number and buffer size at the first
-  64 bits for quick access to these values.
-
-1.3 Comparing with Mercurial's revlog format
-
-  Apparently, linelog is very different from revlog: linelog stores rev and
-  line numbers, while revlog has line contents and other metadata (like
-  parents, flags). However, the revlog format could also be used to store rev
-  and line numbers. For example, to speed up the annotate operation, we could
-  also pre-calculate annotate results and just store them using the revlog
-  format.
-
-  Therefore, linelog is actually somehow similar to revlog, with the important
-  trade-off that it only supports linear history (mentioned in section 0.1).
-  Essentially, the differences are:
-
-    a) Linelog is full of deltas, while revlog could contain full file
-       contents sometimes. So linelog is smaller. Revlog could trade
-       reconstruction speed for file size - best case, revlog is as small as
-       linelog.
-    b) The interleaved delta structure allows skipping large portion of
-       uninteresting deltas so linelog's content reconstruction is faster than
-       the delta-only version of revlog (however it's possible to construct
-       a case where interleaved deltas degrade to plain deltas, so linelog
-       worst case would be delta-only revlog). Revlog could trade file size
-       for reconstruction speed.
-    c) Linelog implicitly maintains the order of all lines it stores. So it
-       could dump all the lines from all revisions, with a reasonable order.
-       While revlog could also dump all line additions, it requires extra
-       computation to figure out the order putting those lines - that's some
-       kind of "merge".
-
-  "c" makes "hg absorb" easier to implement and makes it possible to do
-  "annotate --deleted".
-
-1.4 Malformed Cases Handling
-
-  The following "case 1", "case 2", and "case 3" refer to cases mentioned
-  in section 0.5.
-
-  Using the exposed API (replacelines), case 1 is impossible to generate,
-  although it's possible to generate it by constructing rawdata and load that
-  via linelog.fromdata.
-
-  Doing annotate(maxrev) before replacelines (aka. a1, a2 passed to
-  replacelines are related to the latest revision) eliminates the possibility
-  of case 3. That makes sense since usually you'd like to make edits on top of
-  the latest revision. Practically, both absorb and fastannotate do this.
-
-  Doing annotate(maxrev), plus replacelines(rev, ...) where rev >= maxrev
-  eliminates the possibility of case 2. That makes sense since usually the
-  edits belong to "new revisions", not "old revisions". Practically,
-  fastannotate does this. Absorb calls replacelines with rev < maxrev to edit
-  past revisions. So it needs some extra care to not generate case 2.
-
-  If case 1 occurs, that probably means linelog file corruption (assuming
-  linelog is edited via public APIs) the checkout or annotate result could
-  be less meaningful or even error out, but linelog wouldn't enter an infinite
-  loop.
-
-  If either case 2 or 3 occurs, linelog works as if the inner "^AI/D" and "^AE"
-  operations on the left side are silently ignored.
--- a/mercurial/help/internals/mergestate.txt	Wed Nov 20 19:07:02 2019 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,80 +0,0 @@
-The active mergestate is stored in ``.hg/merge`` when a merge is triggered
-by commands like ``hg merge``, ``hg rebase``, etc. until the merge is
-completed or aborted to track the 3-way merge state of individual files.
-
-The contents of the directory are:
-
-Conflicting files
------------------
-
-The local version of the conflicting files are stored with their
-filenames as the hash of their paths.
-
-state
------
-
-This mergestate file record is used by hg version prior to 2.9.1
-and contains less data than ``state2``. If there is no contradiction
-with ``state2``, we can assume that both are written at the same time.
-In this case, data from ``state2`` is used. Otherwise, we use ``state``.
-We read/write both ``state`` and ``state2`` records to ensure backward
-compatibility.
-
-state2
-------
-
-This record stores a superset of data in ``state``, including new kinds
-of records in the future.
-
-Each record can contain arbitrary content and has an associated type. This
-`type` should be a letter. If `type` is uppercase, the record is mandatory:
-versions of Mercurial that don't support it should abort. If `type` is
-lowercase, the record can be safely ignored.
-
-Currently known records:
-
-| * L: the node of the "local" part of the merge (hexified version)
-| * O: the node of the "other" part of the merge (hexified version)
-| * F: a file to be merged entry
-| * C: a change/delete or delete/change conflict
-| * D: a file that the external merge driver will merge internally
-|      (experimental)
-| * P: a path conflict (file vs directory)
-| * m: the external merge driver defined for this merge plus its run state
-|      (experimental)
-| * f: a (filename, dictionary) tuple of optional values for a given file
-| * X: unsupported mandatory record type (used in tests)
-| * x: unsupported advisory record type (used in tests)
-| * l: the labels for the parts of the merge.
-
-Merge driver run states (experimental):
-
-| * u: driver-resolved files unmarked -- needs to be run next time we're
-|      about to resolve or commit
-| * m: driver-resolved files marked -- only needs to be run before commit
-| * s: success/skipped -- does not need to be run any more
-
-Merge record states (indexed by filename):
-
-| * u: unresolved conflict
-| * r: resolved conflict
-| * pu: unresolved path conflict (file conflicts with directory)
-| * pr: resolved path conflict
-| * d: driver-resolved conflict
-
-The resolve command transitions between 'u' and 'r' for conflicts and
-'pu' and 'pr' for path conflicts.
-
-This format is a list of arbitrary records of the form:
-
-[type][length][content]
-
-`type` is a single character, `length` is a 4 byte integer, and
-`content` is an arbitrary byte sequence of length `length`.
-
-Mercurial versions prior to 3.7 have a bug where if there are
-unsupported mandatory merge records, attempting to clear out the merge
-state with hg update --clean or similar aborts. The 't' record type
-works around that by writing out what those versions treat as an
-advisory record, but later versions interpret as special: the first
-character is the 'real' record type and everything onwards is the data.
--- a/mercurial/help/internals/requirements.txt	Wed Nov 20 19:07:02 2019 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,144 +0,0 @@
-Repositories contain a file (``.hg/requires``) containing a list of
-features/capabilities that are *required* for clients to interface
-with the repository. This file has been present in Mercurial since
-version 0.9.2 (released December 2006).
-
-One of the first things clients do when opening a repository is read
-``.hg/requires`` and verify that all listed requirements are supported,
-aborting if not. Requirements are therefore a strong mechanism to
-prevent incompatible clients from reading from unknown repository
-formats or even corrupting them by writing to them.
-
-Extensions may add requirements. When they do this, clients not running
-an extension will be unable to read from repositories.
-
-The following sections describe the requirements defined by the
-Mercurial core distribution.
-
-revlogv1
-========
-
-When present, revlogs are version 1 (RevlogNG). RevlogNG was introduced
-in 2006. The ``revlogv1`` requirement has been enabled by default
-since the ``requires`` file was introduced in Mercurial 0.9.2.
-
-If this requirement is not present, version 0 revlogs are assumed.
-
-store
-=====
-
-The *store* repository layout should be used.
-
-This requirement has been enabled by default since the ``requires`` file
-was introduced in Mercurial 0.9.2.
-
-fncache
-=======
-
-The *fncache* repository layout should be used.
-
-The *fncache* layout hash encodes filenames with long paths and
-encodes reserved filenames.
-
-This requirement is enabled by default when the *store* requirement is
-enabled (which is the default behavior). It was introduced in Mercurial
-1.1 (released December 2008).
-
-shared
-======
-
-Denotes that the store for a repository is shared from another location
-(defined by the ``.hg/sharedpath`` file).
-
-This requirement is set when a repository is created via :hg:`share`.
-
-The requirement was added in Mercurial 1.3 (released July 2009).
-
-relshared
-=========
-
-Derivative of ``shared``; the location of the store is relative to the
-store of this repository.
-
-This requirement is set when a repository is created via :hg:`share`
-using the ``--relative`` option.
-
-The requirement was added in Mercurial 4.2 (released May 2017).
-
-dotencode
-=========
-
-The *dotencode* repository layout should be used.
-
-The *dotencode* layout encodes the first period or space in filenames
-to prevent issues on OS X and Windows.
-
-This requirement is enabled by default when the *store* requirement
-is enabled (which is the default behavior). It was introduced in
-Mercurial 1.7 (released November 2010).
-
-parentdelta
-===========
-
-Denotes a revlog delta encoding format that was experimental and
-replaced by *generaldelta*. It should not be seen in the wild because
-it was never enabled by default.
-
-This requirement was added in Mercurial 1.7 and removed in Mercurial
-1.9.
-
-generaldelta
-============
-
-Revlogs should be created with the *generaldelta* flag enabled. The
-generaldelta flag will cause deltas to be encoded against a parent
-revision instead of the previous revision in the revlog.
-
-Support for this requirement was added in Mercurial 1.9 (released
-July 2011). The requirement was disabled on new repositories by
-default until Mercurial 3.7 (released February 2016).
-
-manifestv2
-==========
-
-Denotes that version 2 of manifests are being used.
-
-Support for this requirement was added in Mercurial 3.4 (released
-May 2015). The new format failed to meet expectations and support
-for the format and requirement were removed in Mercurial 4.6
-(released May 2018) since the feature never graduated frome experiment
-status.
-
-treemanifest
-============
-
-Denotes that tree manifests are being used. Tree manifests are
-one manifest per directory (as opposed to a single flat manifest).
-
-Support for this requirement was added in Mercurial 3.4 (released
-August 2015). The requirement is currently experimental and is
-disabled by default.
-
-exp-sparse
-==========
-
-The working directory is sparse (only contains a subset of files).
-
-Support for this requirement was added in Mercurial 4.3 (released
-August 2017). This requirement and feature are experimental and may
-disappear in a future Mercurial release. The requirement will only
-be present on repositories that have opted in to a sparse working
-directory.
-
-bookmarksinstore
-==================
-
-Bookmarks are stored in ``.hg/store/`` instead of directly in ``.hg/``
-where they used to be stored. The active bookmark is still stored
-directly in ``.hg/``. This makes them always shared by ``hg share``,
-whether or not ``-B`` was passed.
-
-Support for this requirement was added in Mercurial 5.1 (released
-August 2019). The requirement will only be present on repositories
-that have opted in to this format (by having
-``format.bookmarks-in-store=true`` set when they were created).
--- a/mercurial/help/internals/revlogs.txt	Wed Nov 20 19:07:02 2019 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,239 +0,0 @@
-Revision logs - or *revlogs* - are an append only data structure for
-storing discrete entries, or *revisions*. They are the primary storage
-mechanism of repository data.
-
-Revlogs effectively model a directed acyclic graph (DAG). Each node
-has edges to 1 or 2 *parent* nodes. Each node contains metadata and
-the raw value for that node.
-
-Revlogs consist of entries which have metadata and revision data.
-Metadata includes the hash of the revision's content, sizes, and
-links to its *parent* entries. The collective metadata is referred
-to as the *index* and the revision data is the *data*.
-
-Revision data is stored as a series of compressed deltas against
-ancestor revisions.
-
-Revlogs are written in an append-only fashion. We never need to rewrite
-a file to insert nor do we need to remove data. Rolling back in-progress
-writes can be performed by truncating files. Read locks can be avoided
-using simple techniques. This means that references to other data in
-the same revlog *always* refer to a previous entry.
-
-Revlogs can be modeled as 0-indexed arrays. The first revision is
-revision #0 and the second is revision #1. The revision -1 is typically
-used to mean *does not exist* or *not defined*.
-
-File Format
-===========
-
-A revlog begins with a 32-bit big endian integer holding version info
-and feature flags. This integer overlaps with the first four bytes of
-the first revision entry.
-
-This integer is logically divided into 2 16-bit shorts. The least
-significant half of the integer is the format/version short. The other
-short holds feature flags that dictate behavior of the revlog.
-
-The following values for the format/version short are defined:
-
-0
-   The original revlog version.
-1
-   RevlogNG (*next generation*). It replaced version 0 when it was
-   implemented in 2006.
-2
-   In-development version incorporating accumulated knowledge and
-   missing features from 10+ years of revlog version 1.
-57005 (0xdead)
-   Reserved for internal testing of new versions. No defined format
-   beyond 32-bit header.
-
-The feature flags short consists of bit flags. Where 0 is the least
-significant bit. The bit flags vary by revlog version.
-
-Version 0 revlogs have no defined flags and the presence of a flag
-is considered an error.
-
-Version 1 revlogs have the following flags at the specified bit offsets:
-
-0
-   Store revision data inline.
-1
-   Generaldelta encoding.
-
-Version 2 revlogs have the following flags at the specified bit offsets:
-
-0
-   Store revision data inline.
-
-The following header values are common:
-
-00 00 00 01
-   v1
-00 01 00 01
-   v1 + inline
-00 02 00 01
-   v1 + generaldelta
-00 03 00 01
-   v1 + inline + generaldelta
-
-Following the 32-bit header is the remaining 60 bytes of the first index
-entry. Following that are additional *index* entries. Inlined revision
-data is possibly located between index entries. More on this inlined
-layout is described below.
-
-Version 1 Format
-================
-
-Version 1 (RevlogNG) begins with an index describing the revisions in
-the revlog. If the ``inline`` flag is set, revision data is stored inline,
-or between index entries (as opposed to in a separate container).
-
-Each index entry is 64 bytes. The byte layout of each entry is as
-follows, with byte 0 being the first byte (all data stored as big endian):
-
-0-3 (4 bytes) (rev 0 only)
-   Revlog header
-
-0-5 (6 bytes)
-   Absolute offset of revision data from beginning of revlog.
-
-6-7 (2 bytes)
-   Bit flags impacting revision behavior. The following bit offsets define:
-
-   0: REVIDX_ISCENSORED revision has censor metadata, must be verified.
-
-   1: REVIDX_ELLIPSIS revision hash does not match its data. Used by
-   narrowhg
-
-   2: REVIDX_EXTSTORED revision data is stored externally.
-
-8-11 (4 bytes)
-   Compressed length of revision data / chunk as stored in revlog.
-
-12-15 (4 bytes)
-   Uncompressed length of revision data. This is the size of the full
-   revision data, not the size of the chunk post decompression.
-
-16-19 (4 bytes)
-   Base or previous revision this revision's delta was produced against.
-   This revision holds full text (as opposed to a delta) if it points to
-   itself. For generaldelta repos, this is the previous revision in the
-   delta chain. For non-generaldelta repos, this is the base or first
-   revision in the delta chain.
-
-20-23 (4 bytes)
-   A revision this revision is *linked* to. This allows a revision in
-   one revlog to be forever associated with a revision in another
-   revlog. For example, a file's revlog may point to the changelog
-   revision that introduced it.
-
-24-27 (4 bytes)
-   Revision of 1st parent. -1 indicates no parent.
-
-28-31 (4 bytes)
-   Revision of 2nd parent. -1 indicates no 2nd parent.
-
-32-63 (32 bytes)
-   Hash of revision's full text. Currently, SHA-1 is used and only
-   the first 20 bytes of this field are used. The rest of the bytes
-   are ignored and should be stored as \0.
-
-If inline revision data is being stored, the compressed revision data
-(of length from bytes offset 8-11 from the index entry) immediately
-follows the index entry. There is no header on the revision data. There
-is no padding between it and the index entries before and after.
-
-If revision data is not inline, then raw revision data is stored in a
-separate byte container. The offsets from bytes 0-5 and the compressed
-length from bytes 8-11 define how to access this data.
-
-The 6 byte absolute offset field from the first revlog entry overlaps
-with the revlog header. That is, the first 6 bytes of the first revlog
-entry can be split into four bytes containing the header for the revlog
-file and an additional two bytes containing the offset for the first
-entry. Since this is the offset from the beginning of the file for the
-first revision entry, the two bytes will always be set to zero.
-
-Version 2 Format
-================
-
-(In development. Format not finalized or stable.)
-
-Version 2 is identical to version 2 with the following differences.
-
-There is no dedicated *generaldelta* revlog format flag. Instead,
-the feature is implied enabled by default.
-
-Delta Chains
-============
-
-Revision data is encoded as a chain of *chunks*. Each chain begins with
-the compressed original full text for that revision. Each subsequent
-*chunk* is a *delta* against the previous revision. We therefore call
-these chains of chunks/deltas *delta chains*.
-
-The full text for a revision is reconstructed by loading the original
-full text for the base revision of a *delta chain* and then applying
-*deltas* until the target revision is reconstructed.
-
-*Delta chains* are limited in length so lookup time is bound. They are
-limited to ~2x the length of the revision's data. The linear distance
-between the base chunk and the final chunk is also limited so the
-amount of read I/O to load all chunks in the delta chain is bound.
-
-Deltas and delta chains are either computed against the previous
-revision in the revlog or another revision (almost certainly one of
-the parents of the revision). Historically, deltas were computed against
-the previous revision. The *generaldelta* revlog feature flag (enabled
-by default in Mercurial 3.7) activates the mode where deltas are
-computed against an arbitrary revision (almost certainly a parent revision).
-
-File Storage
-============
-
-Revlogs logically consist of an index (metadata of entries) and
-revision data. This data may be stored together in a single file or in
-separate files. The mechanism used is indicated by the ``inline`` feature
-flag on the revlog.
-
-Mercurial's behavior is to use inline storage until a revlog reaches a
-certain size, at which point it will be converted to non-inline. The
-reason there is a size limit on inline storage is to establish an upper
-bound on how much data must be read to load the index. It would be a waste
-to read tens or hundreds of extra megabytes of data just to access the
-index data.
-
-The actual layout of revlog files on disk is governed by the repository's
-*store format*. Typically, a ``.i`` file represents the index revlog
-(possibly containing inline data) and a ``.d`` file holds the revision data.
-
-Revision Entries
-================
-
-Revision entries consist of an optional 1 byte header followed by an
-encoding of the revision data. The headers are as follows:
-
-\0 (0x00)
-   Revision data is the entirety of the entry, including this header.
-u (0x75)
-   Raw revision data follows.
-x (0x78)
-   zlib (RFC 1950) data.
-
-   The 0x78 value is actually the first byte of the zlib header (CMF byte).
-
-Hash Computation
-================
-
-The hash of the revision is stored in the index and is used both as a primary
-key and for data integrity verification.
-
-Currently, SHA-1 is the only supported hashing algorithm. To obtain the SHA-1
-hash of a revision:
-
-1. Hash the parent nodes
-2. Hash the fulltext of the revision
-
-The 20 byte node ids of the parents are fed into the hasher in ascending order.
--- a/mercurial/help/internals/wireprotocol.txt	Wed Nov 20 19:07:02 2019 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,1277 +0,0 @@
-The Mercurial wire protocol is a request-response based protocol
-with multiple wire representations.
-
-Each request is modeled as a command name, a dictionary of arguments, and
-optional raw input. Command arguments and their types are intrinsic
-properties of commands. So is the response type of the command. This means
-clients can't always send arbitrary arguments to servers and servers can't
-return multiple response types.
-
-The protocol is synchronous and does not support multiplexing (concurrent
-commands).
-
-Handshake
-=========
-
-It is required or common for clients to perform a *handshake* when connecting
-to a server. The handshake serves the following purposes:
-
-* Negotiating protocol/transport level options
-* Allows the client to learn about server capabilities to influence
-  future requests
-* Ensures the underlying transport channel is in a *clean* state
-
-An important goal of the handshake is to allow clients to use more modern
-wire protocol features. By default, clients must assume they are talking
-to an old version of Mercurial server (possibly even the very first
-implementation). So, clients should not attempt to call or utilize modern
-wire protocol features until they have confirmation that the server
-supports them. The handshake implementation is designed to allow both
-ends to utilize the latest set of features and capabilities with as
-few round trips as possible.
-
-The handshake mechanism varies by transport and protocol and is documented
-in the sections below.
-
-HTTP Protocol
-=============
-
-Handshake
----------
-
-The client sends a ``capabilities`` command request (``?cmd=capabilities``)
-as soon as HTTP requests may be issued.
-
-By default, the server responds with a version 1 capabilities string, which
-the client parses to learn about the server's abilities. The ``Content-Type``
-for this response is ``application/mercurial-0.1`` or
-``application/mercurial-0.2`` depending on whether the client advertised
-support for version ``0.2`` in its request. (Clients aren't supposed to
-advertise support for ``0.2`` until the capabilities response indicates
-the server's support for that media type. However, a client could
-conceivably cache this metadata and issue the capabilities request in such
-a way to elicit an ``application/mercurial-0.2`` response.)
-
-Clients wishing to switch to a newer API service may send an
-``X-HgUpgrade-<X>`` header containing a space-delimited list of API service
-names the client is capable of speaking. The request MUST also include an
-``X-HgProto-<X>`` header advertising a known serialization format for the
-response. ``cbor`` is currently the only defined serialization format.
-
-If the request contains these headers, the response ``Content-Type`` MAY
-be for a different media type. e.g. ``application/mercurial-cbor`` if the
-client advertises support for CBOR.
-
-The response MUST be deserializable to a map with the following keys:
-
-apibase
-   URL path to API services, relative to the repository root. e.g. ``api/``.
-
-apis
-   A map of API service names to API descriptors. An API descriptor contains
-   more details about that API. In the case of the HTTP Version 2 Transport,
-   it will be the normal response to a ``capabilities`` command.
-
-   Only the services advertised by the client that are also available on
-   the server are advertised.
-
-v1capabilities
-   The capabilities string that would be returned by a version 1 response.
-
-The client can then inspect the server-advertised APIs and decide which
-API to use, including continuing to use the HTTP Version 1 Transport.
-
-HTTP Version 1 Transport
-------------------------
-
-Commands are issued as HTTP/1.0 or HTTP/1.1 requests. Commands are
-sent to the base URL of the repository with the command name sent in
-the ``cmd`` query string parameter. e.g.
-``https://example.com/repo?cmd=capabilities``. The HTTP method is ``GET``
-or ``POST`` depending on the command and whether there is a request
-body.
-
-Command arguments can be sent multiple ways.
-
-The simplest is part of the URL query string using ``x-www-form-urlencoded``
-encoding (see Python's ``urllib.urlencode()``. However, many servers impose
-length limitations on the URL. So this mechanism is typically only used if
-the server doesn't support other mechanisms.
-
-If the server supports the ``httpheader`` capability, command arguments can
-be sent in HTTP request headers named ``X-HgArg-<N>`` where ``<N>`` is an
-integer starting at 1. A ``x-www-form-urlencoded`` representation of the
-arguments is obtained. This full string is then split into chunks and sent
-in numbered ``X-HgArg-<N>`` headers. The maximum length of each HTTP header
-is defined by the server in the ``httpheader`` capability value, which defaults
-to ``1024``. The server reassembles the encoded arguments string by
-concatenating the ``X-HgArg-<N>`` headers then URL decodes them into a
-dictionary.
-
-The list of ``X-HgArg-<N>`` headers should be added to the ``Vary`` request
-header to instruct caches to take these headers into consideration when caching
-requests.
-
-If the server supports the ``httppostargs`` capability, the client
-may send command arguments in the HTTP request body as part of an
-HTTP POST request. The command arguments will be URL encoded just like
-they would for sending them via HTTP headers. However, no splitting is
-performed: the raw arguments are included in the HTTP request body.
-
-The client sends a ``X-HgArgs-Post`` header with the string length of the
-encoded arguments data. Additional data may be included in the HTTP
-request body immediately following the argument data. The offset of the
-non-argument data is defined by the ``X-HgArgs-Post`` header. The
-``X-HgArgs-Post`` header is not required if there is no argument data.
-
-Additional command data can be sent as part of the HTTP request body. The
-default ``Content-Type`` when sending data is ``application/mercurial-0.1``.
-A ``Content-Length`` header is currently always sent.
-
-Example HTTP requests::
-
-    GET /repo?cmd=capabilities
-    X-HgArg-1: foo=bar&baz=hello%20world
-
-The request media type should be chosen based on server support. If the
-``httpmediatype`` server capability is present, the client should send
-the newest mutually supported media type. If this capability is absent,
-the client must assume the server only supports the
-``application/mercurial-0.1`` media type.
-
-The ``Content-Type`` HTTP response header identifies the response as coming
-from Mercurial and can also be used to signal an error has occurred.
-
-The ``application/mercurial-*`` media types indicate a generic Mercurial
-data type.
-
-The ``application/mercurial-0.1`` media type is raw Mercurial data. It is the
-predecessor of the format below.
-
-The ``application/mercurial-0.2`` media type is compression framed Mercurial
-data. The first byte of the payload indicates the length of the compression
-format identifier that follows. Next are N bytes indicating the compression
-format. e.g. ``zlib``. The remaining bytes are compressed according to that
-compression format. The decompressed data behaves the same as with
-``application/mercurial-0.1``.
-
-The ``application/hg-error`` media type indicates a generic error occurred.
-The content of the HTTP response body typically holds text describing the
-error.
-
-The ``application/mercurial-cbor`` media type indicates a CBOR payload
-and should be interpreted as identical to ``application/cbor``.
-
-Behavior of media types is further described in the ``Content Negotiation``
-section below.
-
-Clients should issue a ``User-Agent`` request header that identifies the client.
-The server should not use the ``User-Agent`` for feature detection.
-
-A command returning a ``string`` response issues a
-``application/mercurial-0.*`` media type and the HTTP response body contains
-the raw string value (after compression decoding, if used). A
-``Content-Length`` header is typically issued, but not required.
-
-A command returning a ``stream`` response issues a
-``application/mercurial-0.*`` media type and the HTTP response is typically
-using *chunked transfer* (``Transfer-Encoding: chunked``).
-
-HTTP Version 2 Transport
-------------------------
-
-**Experimental - feature under active development**
-
-Version 2 of the HTTP protocol is exposed under the ``/api/*`` URL space.
-It's final API name is not yet formalized.
-
-Commands are triggered by sending HTTP POST requests against URLs of the
-form ``<permission>/<command>``, where ``<permission>`` is ``ro`` or
-``rw``, meaning read-only and read-write, respectively and ``<command>``
-is a named wire protocol command.
-
-Non-POST request methods MUST be rejected by the server with an HTTP
-405 response.
-
-Commands that modify repository state in meaningful ways MUST NOT be
-exposed under the ``ro`` URL prefix. All available commands MUST be
-available under the ``rw`` URL prefix.
-
-Server adminstrators MAY implement blanket HTTP authentication keyed
-off the URL prefix. For example, a server may require authentication
-for all ``rw/*`` URLs and let unauthenticated requests to ``ro/*``
-URL proceed. A server MAY issue an HTTP 401, 403, or 407 response
-in accordance with RFC 7235. Clients SHOULD recognize the HTTP Basic
-(RFC 7617) and Digest (RFC 7616) authentication schemes. Clients SHOULD
-make an attempt to recognize unknown schemes using the
-``WWW-Authenticate`` response header on a 401 response, as defined by
-RFC 7235.
-
-Read-only commands are accessible under ``rw/*`` URLs so clients can
-signal the intent of the operation very early in the connection
-lifecycle. For example, a ``push`` operation - which consists of
-various read-only commands mixed with at least one read-write command -
-can perform all commands against ``rw/*`` URLs so that any server-side
-authentication requirements are discovered upon attempting the first
-command - not potentially several commands into the exchange. This
-allows clients to fail faster or prompt for credentials as soon as the
-exchange takes place. This provides a better end-user experience.
-
-Requests to unknown commands or URLS result in an HTTP 404.
-TODO formally define response type, how error is communicated, etc.
-
-HTTP request and response bodies use the ``hgrpc`` protocol for media
-exchange.` (See :hg:`help internals.wireprotocolrpc` for details of
-the protocol.) The entirety of the HTTP message body is 0 or more frames
-as defined by this protocol.
-
-Clients and servers MUST advertise the ``TBD`` media type via the
-``Content-Type`` request and response headers. In addition, clients MUST
-advertise this media type value in their ``Accept`` request header in all
-requests.
-TODO finalize the media type. For now, it is defined in wireprotoserver.py.
-
-Servers receiving requests without an ``Accept`` header SHOULD respond with
-an HTTP 406.
-
-Servers receiving requests with an invalid ``Content-Type`` header SHOULD
-respond with an HTTP 415.
-
-The command to run is specified in the POST payload as defined by ``hgrpc``.
-This is redundant with data already encoded in the URL. This is by design,
-so server operators can have better understanding about server activity from
-looking merely at HTTP access logs.
-
-In most circumstances, the command specified in the URL MUST match
-the command specified in the frame-based payload or the server will
-respond with an error. The exception to this is the special
-``multirequest`` URL. (See below.) In addition, HTTP requests
-are limited to one command invocation. The exception is the special
-``multirequest`` URL.
-
-The ``multirequest`` command endpoints (``ro/multirequest`` and
-``rw/multirequest``) are special in that they allow the execution of
-*any* command and allow the execution of multiple commands. If the
-HTTP request issues multiple commands across multiple frames, all
-issued commands will be processed by the server. Per the defined
-behavior of ``hgrpc```, commands may be issued interleaved and responses
-may come back in a different order than they were issued. Clients MUST
-be able to deal with this.
-
-SSH Protocol
-============
-
-Handshake
----------
-
-For all clients, the handshake consists of the client sending 1 or more
-commands to the server using version 1 of the transport. Servers respond
-to commands they know how to respond to and send an empty response (``0\n``)
-for unknown commands (per standard behavior of version 1 of the transport).
-Clients then typically look for a response to the newest sent command to
-determine which transport version to use and what the available features for
-the connection and server are.
-
-Preceding any response from client-issued commands, the server may print
-non-protocol output. It is common for SSH servers to print banners, message
-of the day announcements, etc when clients connect. It is assumed that any
-such *banner* output will precede any Mercurial server output. So clients
-must be prepared to handle server output on initial connect that isn't
-in response to any client-issued command and doesn't conform to Mercurial's
-wire protocol. This *banner* output should only be on stdout. However,
-some servers may send output on stderr.
-
-Pre 0.9.1 clients issue a ``between`` command with the ``pairs`` argument
-having the value
-``0000000000000000000000000000000000000000-0000000000000000000000000000000000000000``.
-
-The ``between`` command has been supported since the original Mercurial
-SSH server. Requesting the empty range will return a ``\n`` string response,
-which will be encoded as ``1\n\n`` (value length of ``1`` followed by a newline
-followed by the value, which happens to be a newline).
-
-For pre 0.9.1 clients and all servers, the exchange looks like::
-
-   c: between\n
-   c: pairs 81\n
-   c: 0000000000000000000000000000000000000000-0000000000000000000000000000000000000000
-   s: 1\n
-   s: \n
-
-0.9.1+ clients send a ``hello`` command (with no arguments) before the
-``between`` command. The response to this command allows clients to
-discover server capabilities and settings.
-
-An example exchange between 0.9.1+ clients and a ``hello`` aware server looks
-like::
-
-   c: hello\n
-   c: between\n
-   c: pairs 81\n
-   c: 0000000000000000000000000000000000000000-0000000000000000000000000000000000000000
-   s: 324\n
-   s: capabilities: lookup changegroupsubset branchmap pushkey known getbundle ...\n
-   s: 1\n
-   s: \n
-
-And a similar scenario but with servers sending a banner on connect::
-
-   c: hello\n
-   c: between\n
-   c: pairs 81\n
-   c: 0000000000000000000000000000000000000000-0000000000000000000000000000000000000000
-   s: welcome to the server\n
-   s: if you find any issues, email someone@somewhere.com\n
-   s: 324\n
-   s: capabilities: lookup changegroupsubset branchmap pushkey known getbundle ...\n
-   s: 1\n
-   s: \n
-
-Note that output from the ``hello`` command is terminated by a ``\n``. This is
-part of the response payload and not part of the wire protocol adding a newline
-after responses. In other words, the length of the response contains the
-trailing ``\n``.
-
-Clients supporting version 2 of the SSH transport send a line beginning
-with ``upgrade`` before the ``hello`` and ``between`` commands. The line
-(which isn't a well-formed command line because it doesn't consist of a
-single command name) serves to both communicate the client's intent to
-switch to transport version 2 (transports are version 1 by default) as
-well as to advertise the client's transport-level capabilities so the
-server may satisfy that request immediately.
-
-The upgrade line has the form:
-
-    upgrade <token> <transport capabilities>
-
-That is the literal string ``upgrade`` followed by a space, followed by
-a randomly generated string, followed by a space, followed by a string
-denoting the client's transport capabilities.
-
-The token can be anything. However, a random UUID is recommended. (Use
-of version 4 UUIDs is recommended because version 1 UUIDs can leak the
-client's MAC address.)
-
-The transport capabilities string is a URL/percent encoded string
-containing key-value pairs defining the client's transport-level
-capabilities. The following capabilities are defined:
-
-proto
-   A comma-delimited list of transport protocol versions the client
-   supports. e.g. ``ssh-v2``.
-
-If the server does not recognize the ``upgrade`` line, it should issue
-an empty response and continue processing the ``hello`` and ``between``
-commands. Here is an example handshake between a version 2 aware client
-and a non version 2 aware server:
-
-   c: upgrade 2e82ab3f-9ce3-4b4e-8f8c-6fd1c0e9e23a proto=ssh-v2
-   c: hello\n
-   c: between\n
-   c: pairs 81\n
-   c: 0000000000000000000000000000000000000000-0000000000000000000000000000000000000000
-   s: 0\n
-   s: 324\n
-   s: capabilities: lookup changegroupsubset branchmap pushkey known getbundle ...\n
-   s: 1\n
-   s: \n
-
-(The initial ``0\n`` line from the server indicates an empty response to
-the unknown ``upgrade ..`` command/line.)
-
-If the server recognizes the ``upgrade`` line and is willing to satisfy that
-upgrade request, it replies to with a payload of the following form:
-
-   upgraded <token> <transport name>\n
-
-This line is the literal string ``upgraded``, a space, the token that was
-specified by the client in its ``upgrade ...`` request line, a space, and the
-name of the transport protocol that was chosen by the server. The transport
-name MUST match one of the names the client specified in the ``proto`` field
-of its ``upgrade ...`` request line.
-
-If a server issues an ``upgraded`` response, it MUST also read and ignore
-the lines associated with the ``hello`` and ``between`` command requests
-that were issued by the server. It is assumed that the negotiated transport
-will respond with equivalent requested information following the transport
-handshake.
-
-All data following the ``\n`` terminating the ``upgraded`` line is the
-domain of the negotiated transport. It is common for the data immediately
-following to contain additional metadata about the state of the transport and
-the server. However, this isn't strictly speaking part of the transport
-handshake and isn't covered by this section.
-
-Here is an example handshake between a version 2 aware client and a version
-2 aware server:
-
-   c:  upgrade 2e82ab3f-9ce3-4b4e-8f8c-6fd1c0e9e23a proto=ssh-v2
-   c:  hello\n
-   c:  between\n
-   c:  pairs 81\n
-   c:  0000000000000000000000000000000000000000-0000000000000000000000000000000000000000
-   s: upgraded 2e82ab3f-9ce3-4b4e-8f8c-6fd1c0e9e23a ssh-v2\n
-   s: <additional transport specific data>
-
-The client-issued token that is echoed in the response provides a more
-resilient mechanism for differentiating *banner* output from Mercurial
-output. In version 1, properly formatted banner output could get confused
-for Mercurial server output. By submitting a randomly generated token
-that is then present in the response, the client can look for that token
-in response lines and have reasonable certainty that the line did not
-originate from a *banner* message.
-
-SSH Version 1 Transport
------------------------
-
-The SSH transport (version 1) is a custom text-based protocol suitable for
-use over any bi-directional stream transport. It is most commonly used with
-SSH.
-
-A SSH transport server can be started with ``hg serve --stdio``. The stdin,
-stderr, and stdout file descriptors of the started process are used to exchange
-data. When Mercurial connects to a remote server over SSH, it actually starts
-a ``hg serve --stdio`` process on the remote server.
-
-Commands are issued by sending the command name followed by a trailing newline
-``\n`` to the server. e.g. ``capabilities\n``.
-
-Command arguments are sent in the following format::
-
-    <argument> <length>\n<value>
-
-That is, the argument string name followed by a space followed by the
-integer length of the value (expressed as a string) followed by a newline
-(``\n``) followed by the raw argument value.
-
-Dictionary arguments are encoded differently::
-
-    <argument> <# elements>\n
-    <key1> <length1>\n<value1>
-    <key2> <length2>\n<value2>
-    ...
-
-Non-argument data is sent immediately after the final argument value. It is
-encoded in chunks::
-
-    <length>\n<data>
-
-Each command declares a list of supported arguments and their types. If a
-client sends an unknown argument to the server, the server should abort
-immediately. The special argument ``*`` in a command's definition indicates
-that all argument names are allowed.
-
-The definition of supported arguments and types is initially made when a
-new command is implemented. The client and server must initially independently
-agree on the arguments and their types. This initial set of arguments can be
-supplemented through the presence of *capabilities* advertised by the server.
-
-Each command has a defined expected response type.
-
-A ``string`` response type is a length framed value. The response consists of
-the string encoded integer length of a value followed by a newline (``\n``)
-followed by the value. Empty values are allowed (and are represented as
-``0\n``).
-
-A ``stream`` response type consists of raw bytes of data. There is no framing.
-
-A generic error response type is also supported. It consists of a an error
-message written to ``stderr`` followed by ``\n-\n``. In addition, ``\n`` is
-written to ``stdout``.
-
-If the server receives an unknown command, it will send an empty ``string``
-response.
-
-The server terminates if it receives an empty command (a ``\n`` character).
-
-If the server announces support for the ``protocaps`` capability, the client
-should issue a ``protocaps`` command after the initial handshake to annonunce
-its own capabilities. The client capabilities are persistent.
-
-SSH Version 2 Transport
------------------------
-
-**Experimental and under development**
-
-Version 2 of the SSH transport behaves identically to version 1 of the SSH
-transport with the exception of handshake semantics. See above for how
-version 2 of the SSH transport is negotiated.
-
-Immediately following the ``upgraded`` line signaling a switch to version
-2 of the SSH protocol, the server automatically sends additional details
-about the capabilities of the remote server. This has the form:
-
-   <integer length of value>\n
-   capabilities: ...\n
-
-e.g.
-
-   s: upgraded 2e82ab3f-9ce3-4b4e-8f8c-6fd1c0e9e23a ssh-v2\n
-   s: 240\n
-   s: capabilities: known getbundle batch ...\n
-
-Following capabilities advertisement, the peers communicate using version
-1 of the SSH transport.
-
-Capabilities
-============
-
-Servers advertise supported wire protocol features. This allows clients to
-probe for server features before blindly calling a command or passing a
-specific argument.
-
-The server's features are exposed via a *capabilities* string. This is a
-space-delimited string of tokens/features. Some features are single words
-like ``lookup`` or ``batch``. Others are complicated key-value pairs
-advertising sub-features. e.g. ``httpheader=2048``. When complex, non-word
-values are used, each feature name can define its own encoding of sub-values.
-Comma-delimited and ``x-www-form-urlencoded`` values are common.
-
-The following document capabilities defined by the canonical Mercurial server
-implementation.
-
-batch
------
-
-Whether the server supports the ``batch`` command.
-
-This capability/command was introduced in Mercurial 1.9 (released July 2011).
-
-branchmap
----------
-
-Whether the server supports the ``branchmap`` command.
-
-This capability/command was introduced in Mercurial 1.3 (released July 2009).
-
-bundle2-exp
------------
-
-Precursor to ``bundle2`` capability that was used before bundle2 was a
-stable feature.
-
-This capability was introduced in Mercurial 3.0 behind an experimental
-flag. This capability should not be observed in the wild.
-
-bundle2
--------
-
-Indicates whether the server supports the ``bundle2`` data exchange format.
-
-The value of the capability is a URL quoted, newline (``\n``) delimited
-list of keys or key-value pairs.
-
-A key is simply a URL encoded string.
-
-A key-value pair is a URL encoded key separated from a URL encoded value by
-an ``=``. If the value is a list, elements are delimited by a ``,`` after
-URL encoding.
-
-For example, say we have the values::
-
-  {'HG20': [], 'changegroup': ['01', '02'], 'digests': ['sha1', 'sha512']}
-
-We would first construct a string::
-
-  HG20\nchangegroup=01,02\ndigests=sha1,sha512
-
-We would then URL quote this string::
-
-  HG20%0Achangegroup%3D01%2C02%0Adigests%3Dsha1%2Csha512
-
-This capability was introduced in Mercurial 3.4 (released May 2015).
-
-changegroupsubset
------------------
-
-Whether the server supports the ``changegroupsubset`` command.
-
-This capability was introduced in Mercurial 0.9.2 (released December
-2006).
-
-This capability was introduced at the same time as the ``lookup``
-capability/command.
-
-compression
------------
-
-Declares support for negotiating compression formats.
-
-Presence of this capability indicates the server supports dynamic selection
-of compression formats based on the client request.
-
-Servers advertising this capability are required to support the
-``application/mercurial-0.2`` media type in response to commands returning
-streams. Servers may support this media type on any command.
-
-The value of the capability is a comma-delimited list of strings declaring
-supported compression formats. The order of the compression formats is in
-server-preferred order, most preferred first.
-
-The identifiers used by the official Mercurial distribution are:
-
-bzip2
-   bzip2
-none
-   uncompressed / raw data
-zlib
-   zlib (no gzip header)
-zstd
-   zstd
-
-This capability was introduced in Mercurial 4.1 (released February 2017).
-
-getbundle
----------
-
-Whether the server supports the ``getbundle`` command.
-
-This capability was introduced in Mercurial 1.9 (released July 2011).
-
-httpheader
-----------
-
-Whether the server supports receiving command arguments via HTTP request
-headers.
-
-The value of the capability is an integer describing the max header
-length that clients should send. Clients should ignore any content after a
-comma in the value, as this is reserved for future use.
-
-This capability was introduced in Mercurial 1.9 (released July 2011).
-
-httpmediatype
--------------
-
-Indicates which HTTP media types (``Content-Type`` header) the server is
-capable of receiving and sending.
-
-The value of the capability is a comma-delimited list of strings identifying
-support for media type and transmission direction. The following strings may
-be present:
-
-0.1rx
-   Indicates server support for receiving ``application/mercurial-0.1`` media
-   types.
-
-0.1tx
-   Indicates server support for sending ``application/mercurial-0.1`` media
-   types.
-
-0.2rx
-   Indicates server support for receiving ``application/mercurial-0.2`` media
-   types.
-
-0.2tx
-   Indicates server support for sending ``application/mercurial-0.2`` media
-   types.
-
-minrx=X
-   Minimum media type version the server is capable of receiving. Value is a
-   string like ``0.2``.
-
-   This capability can be used by servers to limit connections from legacy
-   clients not using the latest supported media type. However, only clients
-   with knowledge of this capability will know to consult this value. This
-   capability is present so the client may issue a more user-friendly error
-   when the server has locked out a legacy client.
-
-mintx=X
-   Minimum media type version the server is capable of sending. Value is a
-   string like ``0.1``.
-
-Servers advertising support for the ``application/mercurial-0.2`` media type
-should also advertise the ``compression`` capability.
-
-This capability was introduced in Mercurial 4.1 (released February 2017).
-
-httppostargs
-------------
-
-**Experimental**
-
-Indicates that the server supports and prefers clients send command arguments
-via a HTTP POST request as part of the request body.
-
-This capability was introduced in Mercurial 3.8 (released May 2016).
-
-known
------
-
-Whether the server supports the ``known`` command.
-
-This capability/command was introduced in Mercurial 1.9 (released July 2011).
-
-lfs
----
-
-Indicates that the LFS extension is enabled on the server.  It makes no claims
-about the repository actually having LFS blobs committed to it.
-
-This capability was introduced by the LFS extension in Mercurial 4.5 (released
-Feb 2018).
-
-lfs-serve
----------
-
-Indicates that the LFS extension is enabled on the server, and LFS blobs are
-committed to the remote repository.  (Specifically, it indicates that the 'lfs'
-requirement is present in the remote repository.)
-
-This capability was introduced by the LFS extension in Mercurial 4.8 (released
-Nov 2018).
-
-lookup
-------
-
-Whether the server supports the ``lookup`` command.
-
-This capability was introduced in Mercurial 0.9.2 (released December
-2006).
-
-This capability was introduced at the same time as the ``changegroupsubset``
-capability/command.
-
-partial-pull
-------------
-
-Indicates that the client can deal with partial answers to pull requests
-by repeating the request.
-
-If this parameter is not advertised, the server will not send pull bundles.
-
-This client capability was introduced in Mercurial 4.6.
-
-protocaps
----------
-
-Whether the server supports the ``protocaps`` command for SSH V1 transport.
-
-This capability was introduced in Mercurial 4.6.
-
-pushkey
--------
-
-Whether the server supports the ``pushkey`` and ``listkeys`` commands.
-
-This capability was introduced in Mercurial 1.6 (released July 2010).
-
-standardbundle
---------------
-
-**Unsupported**
-
-This capability was introduced during the Mercurial 0.9.2 development cycle in
-2006. It was never present in a release, as it was replaced by the ``unbundle``
-capability. This capability should not be encountered in the wild.
-
-stream-preferred
-----------------
-
-If present the server prefers that clients clone using the streaming clone
-protocol (``hg clone --stream``) rather than the standard
-changegroup/bundle based protocol.
-
-This capability was introduced in Mercurial 2.2 (released May 2012).
-
-streamreqs
-----------
-
-Indicates whether the server supports *streaming clones* and the *requirements*
-that clients must support to receive it.
-
-If present, the server supports the ``stream_out`` command, which transmits
-raw revlogs from the repository instead of changegroups. This provides a faster
-cloning mechanism at the expense of more bandwidth used.
-
-The value of this capability is a comma-delimited list of repo format
-*requirements*. These are requirements that impact the reading of data in
-the ``.hg/store`` directory. An example value is
-``streamreqs=generaldelta,revlogv1`` indicating the server repo requires
-the ``revlogv1`` and ``generaldelta`` requirements.
-
-If the only format requirement is ``revlogv1``, the server may expose the
-``stream`` capability instead of the ``streamreqs`` capability.
-
-This capability was introduced in Mercurial 1.7 (released November 2010).
-
-stream
-------
-
-Whether the server supports *streaming clones* from ``revlogv1`` repos.
-
-If present, the server supports the ``stream_out`` command, which transmits
-raw revlogs from the repository instead of changegroups. This provides a faster
-cloning mechanism at the expense of more bandwidth used.
-
-This capability was introduced in Mercurial 0.9.1 (released July 2006).
-
-When initially introduced, the value of the capability was the numeric
-revlog revision. e.g. ``stream=1``. This indicates the changegroup is using
-``revlogv1``. This simple integer value wasn't powerful enough, so the
-``streamreqs`` capability was invented to handle cases where the repo
-requirements have more than just ``revlogv1``. Newer servers omit the
-``=1`` since it was the only value supported and the value of ``1`` can
-be implied by clients.
-
-unbundlehash
-------------
-
-Whether the ``unbundle`` commands supports receiving a hash of all the
-heads instead of a list.
-
-For more, see the documentation for the ``unbundle`` command.
-
-This capability was introduced in Mercurial 1.9 (released July 2011).
-
-unbundle
---------
-
-Whether the server supports pushing via the ``unbundle`` command.
-
-This capability/command has been present since Mercurial 0.9.1 (released
-July 2006).
-
-Mercurial 0.9.2 (released December 2006) added values to the capability
-indicating which bundle types the server supports receiving. This value is a
-comma-delimited list. e.g. ``HG10GZ,HG10BZ,HG10UN``. The order of values
-reflects the priority/preference of that type, where the first value is the
-most preferred type.
-
-Content Negotiation
-===================
-
-The wire protocol has some mechanisms to help peers determine what content
-types and encoding the other side will accept. Historically, these mechanisms
-have been built into commands themselves because most commands only send a
-well-defined response type and only certain commands needed to support
-functionality like compression.
-
-Currently, only the HTTP version 1 transport supports content negotiation
-at the protocol layer.
-
-HTTP requests advertise supported response formats via the ``X-HgProto-<N>``
-request header, where ``<N>`` is an integer starting at 1 allowing the logical
-value to span multiple headers. This value consists of a list of
-space-delimited parameters. Each parameter denotes a feature or capability.
-
-The following parameters are defined:
-
-0.1
-   Indicates the client supports receiving ``application/mercurial-0.1``
-   responses.
-
-0.2
-   Indicates the client supports receiving ``application/mercurial-0.2``
-   responses.
-
-cbor
-   Indicates the client supports receiving ``application/mercurial-cbor``
-   responses.
-
-   (Only intended to be used with version 2 transports.)
-
-comp
-   Indicates compression formats the client can decode. Value is a list of
-   comma delimited strings identifying compression formats ordered from
-   most preferential to least preferential. e.g. ``comp=zstd,zlib,none``.
-
-   This parameter does not have an effect if only the ``0.1`` parameter
-   is defined, as support for ``application/mercurial-0.2`` or greater is
-   required to use arbitrary compression formats.
-
-   If this parameter is not advertised, the server interprets this as
-   equivalent to ``zlib,none``.
-
-Clients may choose to only send this header if the ``httpmediatype``
-server capability is present, as currently all server-side features
-consulting this header require the client to opt in to new protocol features
-advertised via the ``httpmediatype`` capability.
-
-A server that doesn't receive an ``X-HgProto-<N>`` header should infer a
-value of ``0.1``. This is compatible with legacy clients.
-
-A server receiving a request indicating support for multiple media type
-versions may respond with any of the supported media types. Not all servers
-may support all media types on all commands.
-
-Commands
-========
-
-This section contains a list of all wire protocol commands implemented by
-the canonical Mercurial server.
-
-See :hg:`help internals.wireprotocolv2` for information on commands exposed
-to the frame-based protocol.
-
-batch
------
-
-Issue multiple commands while sending a single command request. The purpose
-of this command is to allow a client to issue multiple commands while avoiding
-multiple round trips to the server therefore enabling commands to complete
-quicker.
-
-The command accepts a ``cmds`` argument that contains a list of commands to
-execute.
-
-The value of ``cmds`` is a ``;`` delimited list of strings. Each string has the
-form ``<command> <arguments>``. That is, the command name followed by a space
-followed by an argument string.
-
-The argument string is a ``,`` delimited list of ``<key>=<value>`` values
-corresponding to command arguments. Both the argument name and value are
-escaped using a special substitution map::
-
-   : -> :c
-   , -> :o
-   ; -> :s
-   = -> :e
-
-The response type for this command is ``string``. The value contains a
-``;`` delimited list of responses for each requested command. Each value
-in this list is escaped using the same substitution map used for arguments.
-
-If an error occurs, the generic error response may be sent.
-
-between
--------
-
-(Legacy command used for discovery in old clients)
-
-Obtain nodes between pairs of nodes.
-
-The ``pairs`` arguments contains a space-delimited list of ``-`` delimited
-hex node pairs. e.g.::
-
-   a072279d3f7fd3a4aa7ffa1a5af8efc573e1c896-6dc58916e7c070f678682bfe404d2e2d68291a18
-
-Return type is a ``string``. Value consists of lines corresponding to each
-requested range. Each line contains a space-delimited list of hex nodes.
-A newline ``\n`` terminates each line, including the last one.
-
-branchmap
----------
-
-Obtain heads in named branches.
-
-Accepts no arguments. Return type is a ``string``.
-
-Return value contains lines with URL encoded branch names followed by a space
-followed by a space-delimited list of hex nodes of heads on that branch.
-e.g.::
-
-    default a072279d3f7fd3a4aa7ffa1a5af8efc573e1c896 6dc58916e7c070f678682bfe404d2e2d68291a18
-    stable baae3bf31522f41dd5e6d7377d0edd8d1cf3fccc
-
-There is no trailing newline.
-
-branches
---------
-
-(Legacy command used for discovery in old clients. Clients with ``getbundle``
-use the ``known`` and ``heads`` commands instead.)
-
-Obtain ancestor changesets of specific nodes back to a branch point.
-
-Despite the name, this command has nothing to do with Mercurial named branches.
-Instead, it is related to DAG branches.
-
-The command accepts a ``nodes`` argument, which is a string of space-delimited
-hex nodes.
-
-For each node requested, the server will find the first ancestor node that is
-a DAG root or is a merge.
-
-Return type is a ``string``. Return value contains lines with result data for
-each requested node. Each line contains space-delimited nodes followed by a
-newline (``\n``). The 4 nodes reported on each line correspond to the requested
-node, the ancestor node found, and its 2 parent nodes (which may be the null
-node).
-
-capabilities
-------------
-
-Obtain the capabilities string for the repo.
-
-Unlike the ``hello`` command, the capabilities string is not prefixed.
-There is no trailing newline.
-
-This command does not accept any arguments. Return type is a ``string``.
-
-This command was introduced in Mercurial 0.9.1 (released July 2006).
-
-changegroup
------------
-
-(Legacy command: use ``getbundle`` instead)
-
-Obtain a changegroup version 1 with data for changesets that are
-descendants of client-specified changesets.
-
-The ``roots`` arguments contains a list of space-delimited hex nodes.
-
-The server responds with a changegroup version 1 containing all
-changesets between the requested root/base nodes and the repo's head nodes
-at the time of the request.
-
-The return type is a ``stream``.
-
-changegroupsubset
------------------
-
-(Legacy command: use ``getbundle`` instead)
-
-Obtain a changegroup version 1 with data for changesetsets between
-client specified base and head nodes.
-
-The ``bases`` argument contains a list of space-delimited hex nodes.
-The ``heads`` argument contains a list of space-delimited hex nodes.
-
-The server responds with a changegroup version 1 containing all
-changesets between the requested base and head nodes at the time of the
-request.
-
-The return type is a ``stream``.
-
-clonebundles
-------------
-
-Obtains a manifest of bundle URLs available to seed clones.
-
-Each returned line contains a URL followed by metadata. See the
-documentation in the ``clonebundles`` extension for more.
-
-The return type is a ``string``.
-
-getbundle
----------
-
-Obtain a bundle containing repository data.
-
-This command accepts the following arguments:
-
-heads
-   List of space-delimited hex nodes of heads to retrieve.
-common
-   List of space-delimited hex nodes that the client has in common with the
-   server.
-obsmarkers
-   Boolean indicating whether to include obsolescence markers as part
-   of the response. Only works with bundle2.
-bundlecaps
-   Comma-delimited set of strings defining client bundle capabilities.
-listkeys
-   Comma-delimited list of strings of ``pushkey`` namespaces. For each
-   namespace listed, a bundle2 part will be included with the content of
-   that namespace.
-cg
-   Boolean indicating whether changegroup data is requested.
-cbattempted
-   Boolean indicating whether the client attempted to use the *clone bundles*
-   feature before performing this request.
-bookmarks
-   Boolean indicating whether bookmark data is requested.
-phases
-   Boolean indicating whether phases data is requested.
-
-The return type on success is a ``stream`` where the value is bundle.
-On the HTTP version 1 transport, the response is zlib compressed.
-
-If an error occurs, a generic error response can be sent.
-
-Unless the client sends a false value for the ``cg`` argument, the returned
-bundle contains a changegroup with the nodes between the specified ``common``
-and ``heads`` nodes. Depending on the command arguments, the type and content
-of the returned bundle can vary significantly.
-
-The default behavior is for the server to send a raw changegroup version
-``01`` response.
-
-If the ``bundlecaps`` provided by the client contain a value beginning
-with ``HG2``, a bundle2 will be returned. The bundle2 data may contain
-additional repository data, such as ``pushkey`` namespace values.
-
-heads
------
-
-Returns a list of space-delimited hex nodes of repository heads followed
-by a newline. e.g.
-``a9eeb3adc7ddb5006c088e9eda61791c777cbf7c 31f91a3da534dc849f0d6bfc00a395a97cf218a1\n``
-
-This command does not accept any arguments. The return type is a ``string``.
-
-hello
------
-
-Returns lines describing interesting things about the server in an RFC-822
-like format.
-
-Currently, the only line defines the server capabilities. It has the form::
-
-    capabilities: <value>
-
-See above for more about the capabilities string.
-
-SSH clients typically issue this command as soon as a connection is
-established.
-
-This command does not accept any arguments. The return type is a ``string``.
-
-This command was introduced in Mercurial 0.9.1 (released July 2006).
-
-listkeys
---------
-
-List values in a specified ``pushkey`` namespace.
-
-The ``namespace`` argument defines the pushkey namespace to operate on.
-
-The return type is a ``string``. The value is an encoded dictionary of keys.
-
-Key-value pairs are delimited by newlines (``\n``). Within each line, keys and
-values are separated by a tab (``\t``). Keys and values are both strings.
-
-lookup
-------
-
-Try to resolve a value to a known repository revision.
-
-The ``key`` argument is converted from bytes to an
-``encoding.localstr`` instance then passed into
-``localrepository.__getitem__`` in an attempt to resolve it.
-
-The return type is a ``string``.
-
-Upon successful resolution, returns ``1 <hex node>\n``. On failure,
-returns ``0 <error string>\n``. e.g.::
-
-   1 273ce12ad8f155317b2c078ec75a4eba507f1fba\n
-
-   0 unknown revision 'foo'\n
-
-known
------
-
-Determine whether multiple nodes are known.
-
-The ``nodes`` argument is a list of space-delimited hex nodes to check
-for existence.
-
-The return type is ``string``.
-
-Returns a string consisting of ``0``s and ``1``s indicating whether nodes
-are known. If the Nth node specified in the ``nodes`` argument is known,
-a ``1`` will be returned at byte offset N. If the node isn't known, ``0``
-will be present at byte offset N.
-
-There is no trailing newline.
-
-protocaps
----------
-
-Notify the server about the client capabilities in the SSH V1 transport
-protocol.
-
-The ``caps`` argument is a space-delimited list of capabilities.
-
-The server will reply with the string ``OK``.
-
-pushkey
--------
-
-Set a value using the ``pushkey`` protocol.
-
-Accepts arguments ``namespace``, ``key``, ``old``, and ``new``, which
-correspond to the pushkey namespace to operate on, the key within that
-namespace to change, the old value (which may be empty), and the new value.
-All arguments are string types.
-
-The return type is a ``string``. The value depends on the transport protocol.
-
-The SSH version 1 transport sends a string encoded integer followed by a
-newline (``\n``) which indicates operation result. The server may send
-additional output on the ``stderr`` stream that should be displayed to the
-user.
-
-The HTTP version 1 transport sends a string encoded integer followed by a
-newline followed by additional server output that should be displayed to
-the user. This may include output from hooks, etc.
-
-The integer result varies by namespace. ``0`` means an error has occurred
-and there should be additional output to display to the user.
-
-stream_out
-----------
-
-Obtain *streaming clone* data.
-
-The return type is either a ``string`` or a ``stream``, depending on
-whether the request was fulfilled properly.
-
-A return value of ``1\n`` indicates the server is not configured to serve
-this data. If this is seen by the client, they may not have verified the
-``stream`` capability is set before making the request.
-
-A return value of ``2\n`` indicates the server was unable to lock the
-repository to generate data.
-
-All other responses are a ``stream`` of bytes. The first line of this data
-contains 2 space-delimited integers corresponding to the path count and
-payload size, respectively::
-
-    <path count> <payload size>\n
-
-The ``<payload size>`` is the total size of path data: it does not include
-the size of the per-path header lines.
-
-Following that header are ``<path count>`` entries. Each entry consists of a
-line with metadata followed by raw revlog data. The line consists of::
-
-    <store path>\0<size>\n
-
-The ``<store path>`` is the encoded store path of the data that follows.
-``<size>`` is the amount of data for this store path/revlog that follows the
-newline.
-
-There is no trailer to indicate end of data. Instead, the client should stop
-reading after ``<path count>`` entries are consumed.
-
-unbundle
---------
-
-Send a bundle containing data (usually changegroup data) to the server.
-
-Accepts the argument ``heads``, which is a space-delimited list of hex nodes
-corresponding to server repository heads observed by the client. This is used
-to detect race conditions and abort push operations before a server performs
-too much work or a client transfers too much data.
-
-The request payload consists of a bundle to be applied to the repository,
-similarly to as if :hg:`unbundle` were called.
-
-In most scenarios, a special ``push response`` type is returned. This type
-contains an integer describing the change in heads as a result of the
-operation. A value of ``0`` indicates nothing changed. ``1`` means the number
-of heads remained the same. Values ``2`` and larger indicate the number of
-added heads minus 1. e.g. ``3`` means 2 heads were added. Negative values
-indicate the number of fewer heads, also off by 1. e.g. ``-2`` means there
-is 1 fewer head.
-
-The encoding of the ``push response`` type varies by transport.
-
-For the SSH version 1 transport, this type is composed of 2 ``string``
-responses: an empty response (``0\n``) followed by the integer result value.
-e.g. ``1\n2``. So the full response might be ``0\n1\n2``.
-
-For the HTTP version 1 transport, the response is a ``string`` type composed
-of an integer result value followed by a newline (``\n``) followed by string
-content holding server output that should be displayed on the client (output
-hooks, etc).
-
-In some cases, the server may respond with a ``bundle2`` bundle. In this
-case, the response type is ``stream``. For the HTTP version 1 transport, the
-response is zlib compressed.
-
-The server may also respond with a generic error type, which contains a string
-indicating the failure.
--- a/mercurial/help/internals/wireprotocolrpc.txt	Wed Nov 20 19:07:02 2019 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,740 +0,0 @@
-**Experimental and under development**
-
-This document describe's Mercurial's transport-agnostic remote procedure
-call (RPC) protocol which is used to perform interactions with remote
-servers. This protocol is also referred to as ``hgrpc``.
-
-The protocol has the following high-level features:
-
-* Concurrent request and response support (multiple commands can be issued
-  simultaneously and responses can be streamed simultaneously).
-* Supports half-duplex and full-duplex connections.
-* All data is transmitted within *frames*, which have a well-defined
-  header and encode their length.
-* Side-channels for sending progress updates and printing output. Text
-  output from the remote can be localized locally.
-* Support for simultaneous and long-lived compression streams, even across
-  requests.
-* Uses CBOR for data exchange.
-
-The protocol is not specific to Mercurial and could be used by other
-applications.
-
-High-level Overview
-===================
-
-To operate the protocol, a bi-directional, half-duplex pipe supporting
-ordered sends and receives is required. That is, each peer has one pipe
-for sending data and another for receiving. Full-duplex pipes are also
-supported.
-
-All data is read and written in atomic units called *frames*. These
-are conceptually similar to TCP packets. Higher-level functionality
-is built on the exchange and processing of frames.
-
-All frames are associated with a *stream*. A *stream* provides a
-unidirectional grouping of frames. Streams facilitate two goals:
-content encoding and parallelism. There is a dedicated section on
-streams below.
-
-The protocol is request-response based: the client issues requests to
-the server, which issues replies to those requests. Server-initiated
-messaging is not currently supported, but this specification carves
-out room to implement it.
-
-All frames are associated with a numbered request. Frames can thus
-be logically grouped by their request ID.
-
-Frames
-======
-
-Frames begin with an 8 octet header followed by a variable length
-payload::
-
-    +------------------------------------------------+
-    |                 Length (24)                    |
-    +--------------------------------+---------------+
-    |         Request ID (16)        | Stream ID (8) |
-    +------------------+-------------+---------------+
-    | Stream Flags (8) |
-    +-----------+------+
-    | Type (4)  |
-    +-----------+
-    | Flags (4) |
-    +===========+===================================================|
-    |                     Frame Payload (0...)                    ...
-    +---------------------------------------------------------------+
-
-The length of the frame payload is expressed as an unsigned 24 bit
-little endian integer. Values larger than 65535 MUST NOT be used unless
-given permission by the server as part of the negotiated capabilities
-during the handshake. The frame header is not part of the advertised
-frame length. The payload length is the over-the-wire length. If there
-is content encoding applied to the payload as part of the frame's stream,
-the length is the output of that content encoding, not the input.
-
-The 16-bit ``Request ID`` field denotes the integer request identifier,
-stored as an unsigned little endian integer. Odd numbered requests are
-client-initiated. Even numbered requests are server-initiated. This
-refers to where the *request* was initiated - not where the *frame* was
-initiated, so servers will send frames with odd ``Request ID`` in
-response to client-initiated requests. Implementations are advised to
-start ordering request identifiers at ``1`` and ``0``, increment by
-``2``, and wrap around if all available numbers have been exhausted.
-
-The 8-bit ``Stream ID`` field denotes the stream that the frame is
-associated with. Frames belonging to a stream may have content
-encoding applied and the receiver may need to decode the raw frame
-payload to obtain the original data. Odd numbered IDs are
-client-initiated. Even numbered IDs are server-initiated.
-
-The 8-bit ``Stream Flags`` field defines stream processing semantics.
-See the section on streams below.
-
-The 4-bit ``Type`` field denotes the type of frame being sent.
-
-The 4-bit ``Flags`` field defines special, per-type attributes for
-the frame.
-
-The sections below define the frame types and their behavior.
-
-Command Request (``0x01``)
---------------------------
-
-This frame contains a request to run a command.
-
-The payload consists of a CBOR map defining the command request. The
-bytestring keys of that map are:
-
-name
-   Name of the command that should be executed (bytestring).
-args
-   Map of bytestring keys to various value types containing the named
-   arguments to this command.
-
-   Each command defines its own set of argument names and their expected
-   types.
-
-redirect (optional)
-   (map) Advertises client support for following response *redirects*.
-
-   This map has the following bytestring keys:
-
-   targets
-      (array of bytestring) List of named redirect targets supported by
-      this client. The names come from the targets advertised by the
-      server's *capabilities* message.
-
-   hashes
-      (array of bytestring) List of preferred hashing algorithms that can
-      be used for content integrity verification.
-
-   See the *Content Redirects* section below for more on content redirects.
-
-This frame type MUST ONLY be sent from clients to servers: it is illegal
-for a server to send this frame to a client.
-
-The following flag values are defined for this type:
-
-0x01
-   New command request. When set, this frame represents the beginning
-   of a new request to run a command. The ``Request ID`` attached to this
-   frame MUST NOT be active.
-0x02
-   Command request continuation. When set, this frame is a continuation
-   from a previous command request frame for its ``Request ID``. This
-   flag is set when the CBOR data for a command request does not fit
-   in a single frame.
-0x04
-   Additional frames expected. When set, the command request didn't fit
-   into a single frame and additional CBOR data follows in a subsequent
-   frame.
-0x08
-   Command data frames expected. When set, command data frames are
-   expected to follow the final command request frame for this request.
-
-``0x01`` MUST be set on the initial command request frame for a
-``Request ID``.
-
-``0x01`` or ``0x02`` MUST be set to indicate this frame's role in
-a series of command request frames.
-
-If command data frames are to be sent, ``0x08`` MUST be set on ALL
-command request frames.
-
-Command Data (``0x02``)
------------------------
-
-This frame contains raw data for a command.
-
-Most commands can be executed by specifying arguments. However,
-arguments have an upper bound to their length. For commands that
-accept data that is beyond this length or whose length isn't known
-when the command is initially sent, they will need to stream
-arbitrary data to the server. This frame type facilitates the sending
-of this data.
-
-The payload of this frame type consists of a stream of raw data to be
-consumed by the command handler on the server. The format of the data
-is command specific.
-
-The following flag values are defined for this type:
-
-0x01
-   Command data continuation. When set, the data for this command
-   continues into a subsequent frame.
-
-0x02
-   End of data. When set, command data has been fully sent to the
-   server. The command has been fully issued and no new data for this
-   command will be sent. The next frame will belong to a new command.
-
-Command Response Data (``0x03``)
---------------------------------
-
-This frame contains response data to an issued command.
-
-Response data ALWAYS consists of a series of 1 or more CBOR encoded
-values. A CBOR value may be using indefinite length encoding. And the
-bytes constituting the value may span several frames.
-
-The following flag values are defined for this type:
-
-0x01
-   Data continuation. When set, an additional frame containing response data
-   will follow.
-0x02
-   End of data. When set, the response data has been fully sent and
-   no additional frames for this response will be sent.
-
-The ``0x01`` flag is mutually exclusive with the ``0x02`` flag.
-
-Error Occurred (``0x05``)
--------------------------
-
-Some kind of error occurred.
-
-There are 3 general kinds of failures that can occur:
-
-* Command error encountered before any response issued
-* Command error encountered after a response was issued
-* Protocol or stream level error
-
-This frame type is used to capture the latter cases. (The general
-command error case is handled by the leading CBOR map in
-``Command Response`` frames.)
-
-The payload of this frame contains a CBOR map detailing the error. That
-map has the following bytestring keys:
-
-type
-   (bytestring) The overall type of error encountered. Can be one of the
-   following values:
-
-   protocol
-      A protocol-level error occurred. This typically means someone
-      is violating the framing protocol semantics and the server is
-      refusing to proceed.
-
-   server
-      A server-level error occurred. This typically indicates some kind of
-      logic error on the server, likely the fault of the server.
-
-   command
-      A command-level error, likely the fault of the client.
-
-message
-   (array of maps) A richly formatted message that is intended for
-   human consumption. See the ``Human Output Side-Channel`` frame
-   section for a description of the format of this data structure.
-
-Human Output Side-Channel (``0x06``)
-------------------------------------
-
-This frame contains a message that is intended to be displayed to
-people. Whereas most frames communicate machine readable data, this
-frame communicates textual data that is intended to be shown to
-humans.
-
-The frame consists of a series of *formatting requests*. Each formatting
-request consists of a formatting string, arguments for that formatting
-string, and labels to apply to that formatting string.
-
-A formatting string is a printf()-like string that allows variable
-substitution within the string. Labels allow the rendered text to be
-*decorated*. Assuming use of the canonical Mercurial code base, a
-formatting string can be the input to the ``i18n._`` function. This
-allows messages emitted from the server to be localized. So even if
-the server has different i18n settings, people could see messages in
-their *native* settings. Similarly, the use of labels allows
-decorations like coloring and underlining to be applied using the
-client's configured rendering settings.
-
-Formatting strings are similar to ``printf()`` strings or how
-Python's ``%`` operator works. The only supported formatting sequences
-are ``%s`` and ``%%``. ``%s`` will be replaced by whatever the string
-at that position resolves to. ``%%`` will be replaced by ``%``. All
-other 2-byte sequences beginning with ``%`` represent a literal
-``%`` followed by that character. However, future versions of the
-wire protocol reserve the right to allow clients to opt in to receiving
-formatting strings with additional formatters, hence why ``%%`` is
-required to represent the literal ``%``.
-
-The frame payload consists of a CBOR array of CBOR maps. Each map
-defines an *atom* of text data to print. Each *atom* has the following
-bytestring keys:
-
-msg
-   (bytestring) The formatting string. Content MUST be ASCII.
-args (optional)
-   Array of bytestrings defining arguments to the formatting string.
-labels (optional)
-   Array of bytestrings defining labels to apply to this atom.
-
-All data to be printed MUST be encoded into a single frame: this frame
-does not support spanning data across multiple frames.
-
-All textual data encoded in these frames is assumed to be line delimited.
-The last atom in the frame SHOULD end with a newline (``\n``). If it
-doesn't, clients MAY add a newline to facilitate immediate printing.
-
-Progress Update (``0x07``)
---------------------------
-
-This frame holds the progress of an operation on the peer. Consumption
-of these frames allows clients to display progress bars, estimated
-completion times, etc.
-
-Each frame defines the progress of a single operation on the peer. The
-payload consists of a CBOR map with the following bytestring keys:
-
-topic
-   Topic name (string)
-pos
-   Current numeric position within the topic (integer)
-total
-   Total/end numeric position of this topic (unsigned integer)
-label (optional)
-   Unit label (string)
-item (optional)
-   Item name (string)
-
-Progress state is created when a frame is received referencing a
-*topic* that isn't currently tracked. Progress tracking for that
-*topic* is finished when a frame is received reporting the current
-position of that topic as ``-1``.
-
-Multiple *topics* may be active at any given time.
-
-Rendering of progress information is not mandated or governed by this
-specification: implementations MAY render progress information however
-they see fit, including not at all.
-
-The string data describing the topic SHOULD be static strings to
-facilitate receivers localizing that string data. The emitter
-MUST normalize all string data to valid UTF-8 and receivers SHOULD
-validate that received data conforms to UTF-8. The topic name
-SHOULD be ASCII.
-
-Sender Protocol Settings (``0x08``)
------------------------------------
-
-This frame type advertises the sender's support for various protocol and
-stream level features. The data advertised in this frame is used to influence
-subsequent behavior of the current frame exchange channel.
-
-The frame payload consists of a CBOR map. It may contain the following
-bytestring keys:
-
-contentencodings
-   (array of bytestring) A list of content encodings supported by the
-   sender, in order of most to least preferred.
-
-   Peers are allowed to encode stream data using any of the listed
-   encodings.
-
-   See the ``Content Encoding Profiles`` section for an enumeration
-   of supported content encodings.
-
-   If not defined, the value is assumed to be a list with the single value
-   ``identity``, meaning only the no-op encoding is supported.
-
-   Senders MAY filter the set of advertised encodings against what it
-   knows the receiver supports (e.g. if the receiver advertised encodings
-   via the capabilities descriptor). However, doing so will prevent
-   servers from gaining an understanding of the aggregate capabilities
-   of clients. So clients are discouraged from doing so.
-
-When this frame is not sent/received, the receiver assumes default values
-for all keys.
-
-If encountered, this frame type MUST be sent before any other frame type
-in a channel.
-
-The following flag values are defined for this frame type:
-
-0x01
-   Data continuation. When set, an additional frame containing more protocol
-   settings immediately follows.
-0x02
-   End of data. When set, the protocol settings data has been completely
-   sent.
-
-The ``0x01`` flag is mutually exclusive with the ``0x02`` flag.
-
-Stream Encoding Settings (``0x09``)
------------------------------------
-
-This frame type holds information defining the content encoding
-settings for a *stream*.
-
-This frame type is likely consumed by the protocol layer and is not
-passed on to applications.
-
-This frame type MUST ONLY occur on frames having the *Beginning of Stream*
-``Stream Flag`` set.
-
-The payload of this frame defines what content encoding has (possibly)
-been applied to the payloads of subsequent frames in this stream.
-
-The payload consists of a series of CBOR values. The first value is a
-bytestring denoting the content encoding profile of the data in this
-stream. Subsequent CBOR values supplement this simple value in a
-profile-specific manner. See the ``Content Encoding Profiles`` section
-for more.
-
-In the absence of this frame on a stream, it is assumed the stream is
-using the ``identity`` content encoding.
-
-The following flag values are defined for this frame type:
-
-0x01
-   Data continuation. When set, an additional frame containing more encoding
-   settings immediately follows.
-0x02
-   End of data. When set, the encoding settings data has been completely
-   sent.
-
-The ``0x01`` flag is mutually exclusive with the ``0x02`` flag.
-
-Stream States and Flags
-=======================
-
-Streams can be in two states: *open* and *closed*. An *open* stream
-is active and frames attached to that stream could arrive at any time.
-A *closed* stream is not active. If a frame attached to a *closed*
-stream arrives, that frame MUST have an appropriate stream flag
-set indicating beginning of stream. All streams are in the *closed*
-state by default.
-
-The ``Stream Flags`` field denotes a set of bit flags for defining
-the relationship of this frame within a stream. The following flags
-are defined:
-
-0x01
-   Beginning of stream. The first frame in the stream MUST set this
-   flag. When received, the ``Stream ID`` this frame is attached to
-   becomes ``open``.
-
-0x02
-   End of stream. The last frame in a stream MUST set this flag. When
-   received, the ``Stream ID`` this frame is attached to becomes
-   ``closed``. Any content encoding context associated with this stream
-   can be destroyed after processing the payload of this frame.
-
-0x04
-   Apply content encoding. When set, any content encoding settings
-   defined by the stream should be applied when attempting to read
-   the frame. When not set, the frame payload isn't encoded.
-
-TODO consider making stream opening and closing communicated via
-explicit frame types (e.g. a "stream state change" frame) rather than
-flags on all frames. This would make stream state changes more explicit,
-as they could only occur on specific frame types.
-
-Streams
-=======
-
-Streams - along with ``Request IDs`` - facilitate grouping of frames.
-But the purpose of each is quite different and the groupings they
-constitute are independent.
-
-A ``Request ID`` is essentially a tag. It tells you which logical
-request a frame is associated with.
-
-A *stream* is a sequence of frames grouped for the express purpose
-of applying a stateful encoding or for denoting sub-groups of frames.
-
-Unlike ``Request ID``s which span the request and response, a stream
-is unidirectional and stream IDs are independent from client to
-server.
-
-There is no strict hierarchical relationship between ``Request IDs``
-and *streams*. A stream can contain frames having multiple
-``Request IDs``. Frames belonging to the same ``Request ID`` can
-span multiple streams.
-
-One goal of streams is to facilitate content encoding. A stream can
-define an encoding to be applied to frame payloads. For example, the
-payload transmitted over the wire may contain output from a
-zstandard compression operation and the receiving end may decompress
-that payload to obtain the original data.
-
-The other goal of streams is to facilitate concurrent execution. For
-example, a server could spawn 4 threads to service a request that can
-be easily parallelized. Each of those 4 threads could write into its
-own stream. Those streams could then in turn be delivered to 4 threads
-on the receiving end, with each thread consuming its stream in near
-isolation. The *main* thread on both ends merely does I/O and
-encodes/decodes frame headers: the bulk of the work is done by worker
-threads.
-
-In addition, since content encoding is defined per stream, each
-*worker thread* could perform potentially CPU bound work concurrently
-with other threads. This approach of applying encoding at the
-sub-protocol / stream level eliminates a potential resource constraint
-on the protocol stream as a whole (it is common for the throughput of
-a compression engine to be smaller than the throughput of a network).
-
-Having multiple streams - each with their own encoding settings - also
-facilitates the use of advanced data compression techniques. For
-example, a transmitter could see that it is generating data faster
-and slower than the receiving end is consuming it and adjust its
-compression settings to trade CPU for compression ratio accordingly.
-
-While streams can define a content encoding, not all frames within
-that stream must use that content encoding. This can be useful when
-data is being served from caches and being derived dynamically. A
-cache could pre-compressed data so the server doesn't have to
-recompress it. The ability to pick and choose which frames are
-compressed allows servers to easily send data to the wire without
-involving potentially expensive encoding overhead.
-
-Content Encoding Profiles
-=========================
-
-Streams can have named content encoding *profiles* associated with
-them. A profile defines a shared understanding of content encoding
-settings and behavior.
-
-Profiles are described in the following sections.
-
-identity
---------
-
-The ``identity`` profile is a no-op encoding: the encoded bytes are
-exactly the input bytes.
-
-This profile MUST be supported by all peers.
-
-In the absence of an identified profile, the ``identity`` profile is
-assumed.
-
-zstd-8mb
---------
-
-Zstandard encoding (RFC 8478). Zstandard is a fast and effective lossless
-compression format.
-
-This profile allows decompressor window sizes of up to 8 MB.
-
-zlib
-----
-
-zlib compressed data (RFC 1950). zlib is a widely-used and supported
-lossless compression format.
-
-It isn't as fast as zstandard and it is recommended to use zstandard instead,
-if possible.
-
-Command Protocol
-================
-
-A client can request that a remote run a command by sending it
-frames defining that command. This logical stream is composed of
-1 or more ``Command Request`` frames and and 0 or more ``Command Data``
-frames.
-
-All frames composing a single command request MUST be associated with
-the same ``Request ID``.
-
-Clients MAY send additional command requests without waiting on the
-response to a previous command request. If they do so, they MUST ensure
-that the ``Request ID`` field of outbound frames does not conflict
-with that of an active ``Request ID`` whose response has not yet been
-fully received.
-
-Servers MAY respond to commands in a different order than they were
-sent over the wire. Clients MUST be prepared to deal with this. Servers
-also MAY start executing commands in a different order than they were
-received, or MAY execute multiple commands concurrently.
-
-If there is a dependency between commands or a race condition between
-commands executing (e.g. a read-only command that depends on the results
-of a command that mutates the repository), then clients MUST NOT send
-frames issuing a command until a response to all dependent commands has
-been received.
-TODO think about whether we should express dependencies between commands
-to avoid roundtrip latency.
-
-A command is defined by a command name, 0 or more command arguments,
-and optional command data.
-
-Arguments are the recommended mechanism for transferring fixed sets of
-parameters to a command. Data is appropriate for transferring variable
-data. Thinking in terms of HTTP, arguments would be headers and data
-would be the message body.
-
-It is recommended for servers to delay the dispatch of a command
-until all argument have been received. Servers MAY impose limits on the
-maximum argument size.
-TODO define failure mechanism.
-
-Servers MAY dispatch to commands immediately once argument data
-is available or delay until command data is received in full.
-
-Once a ``Command Request`` frame is sent, a client must be prepared to
-receive any of the following frames associated with that request:
-``Command Response``, ``Error Response``, ``Human Output Side-Channel``,
-``Progress Update``.
-
-The *main* response for a command will be in ``Command Response`` frames.
-The payloads of these frames consist of 1 or more CBOR encoded values.
-The first CBOR value on the first ``Command Response`` frame is special
-and denotes the overall status of the command. This CBOR map contains
-the following bytestring keys:
-
-status
-   (bytestring) A well-defined message containing the overall status of
-   this command request. The following values are defined:
-
-   ok
-      The command was received successfully and its response follows.
-   error
-      There was an error processing the command. More details about the
-      error are encoded in the ``error`` key.
-   redirect
-      The response for this command is available elsewhere. Details on
-      where are in the ``location`` key.
-
-error (optional)
-   A map containing information about an encountered error. The map has the
-   following keys:
-
-   message
-      (array of maps) A message describing the error. The message uses the
-      same format as those in the ``Human Output Side-Channel`` frame.
-
-location (optional)
-   (map) Presence indicates that a *content redirect* has occurred. The map
-   provides the external location of the content.
-
-   This map contains the following bytestring keys:
-
-   url
-      (bytestring) URL from which this content may be requested.
-
-   mediatype
-      (bytestring) The media type for the fetched content. e.g.
-      ``application/mercurial-*``.
-
-      In some transports, this value is also advertised by the transport.
-      e.g. as the ``Content-Type`` HTTP header.
-
-   size (optional)
-      (unsigned integer) Total size of remote object in bytes. This is
-      the raw size of the entity that will be fetched, minus any
-      non-Mercurial protocol encoding (e.g. HTTP content or transfer
-      encoding.)
-
-   fullhashes (optional)
-      (array of arrays) Content hashes for the entire payload. Each entry
-      is an array of bytestrings containing the hash name and the hash value.
-
-   fullhashseed (optional)
-      (bytestring) Optional seed value to feed into hasher for full content
-      hash verification.
-
-   serverdercerts (optional)
-      (array of bytestring) DER encoded x509 certificates for the server. When
-      defined, clients MAY validate that the x509 certificate on the target
-      server exactly matches the certificate used here.
-
-   servercadercerts (optional)
-      (array of bytestring) DER encoded x509 certificates for the certificate
-      authority of the target server. When defined, clients MAY validate that
-      the x509 on the target server was signed by CA certificate in this set.
-
-   # TODO support for giving client an x509 certificate pair to be used as a
-   # client certificate.
-
-   # TODO support common authentication mechanisms (e.g. HTTP basic/digest
-   # auth).
-
-   # TODO support custom authentication mechanisms. This likely requires
-   # server to advertise required auth mechanism so client can filter.
-
-   # TODO support chained hashes. e.g. hash for each 1MB segment so client
-   # can iteratively validate data without having to consume all of it first.
-
-TODO formalize when error frames can be seen and how errors can be
-recognized midway through a command response.
-
-Content Redirects
-=================
-
-Servers have the ability to respond to ANY command request with a
-*redirect* to another location. Such a response is referred to as a *redirect
-response*. (This feature is conceptually similar to HTTP redirects, but is
-more powerful.)
-
-A *redirect response* MUST ONLY be issued if the client advertises support
-for a redirect *target*.
-
-A *redirect response* MUST NOT be issued unless the client advertises support
-for one.
-
-Clients advertise support for *redirect responses* after looking at the server's
-*capabilities* data, which is fetched during initial server connection
-handshake. The server's capabilities data advertises named *targets* for
-potential redirects.
-
-Each target is described by a protocol name, connection and protocol features,
-etc. The server also advertises target-agnostic redirect settings, such as
-which hash algorithms are supported for content integrity checking. (See
-the documentation for the *capabilities* command for more.)
-
-Clients examine the set of advertised redirect targets for compatibility.
-When sending a command request, the client advertises the set of redirect
-target names it is willing to follow, along with some other settings influencing
-behavior.
-
-For example, say the server is advertising a ``cdn`` redirect target that
-requires SNI and TLS 1.2. If the client supports those features, it will
-send command requests stating that the ``cdn`` target is acceptable to use.
-But if the client doesn't support SNI or TLS 1.2 (or maybe it encountered an
-error using this target from a previous request), then it omits this target
-name.
-
-If the client advertises support for a redirect target, the server MAY
-substitute the normal, inline response data for a *redirect response* -
-one where the initial CBOR map has a ``status`` key with value ``redirect``.
-
-The *redirect response* at a minimum advertises the URL where the response
-can be retrieved.
-
-The *redirect response* MAY also advertise additional details about that
-content and how to retrieve it. Notably, the response may contain the
-x509 public certificates for the server being redirected to or the
-certificate authority that signed that server's certificate. Unless the
-client has existing settings that offer stronger trust validation than what
-the server advertises, the client SHOULD use the server-provided certificates
-when validating the connection to the remote server in place of any default
-connection verification checks. This is because certificates coming from
-the server SHOULD establish a stronger chain of trust than what the default
-certification validation mechanism in most environments provides. (By default,
-certificate validation ensures the signer of the cert chains up to a set of
-trusted root certificates. And if an explicit certificate or CA certificate
-is presented, that greadly reduces the set of certificates that will be
-recognized as valid, thus reducing the potential for a "bad" certificate
-to be used and trusted.)
--- a/mercurial/help/internals/wireprotocolv2.txt	Wed Nov 20 19:07:02 2019 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,724 +0,0 @@
-**Experimental and under active development**
-
-This section documents the wire protocol commands exposed to transports
-using the frame-based protocol. The set of commands exposed through
-these transports is distinct from the set of commands exposed to legacy
-transports.
-
-The frame-based protocol uses CBOR to encode command execution requests.
-All command arguments must be mapped to a specific or set of CBOR data
-types.
-
-The response to many commands is also CBOR. There is no common response
-format: each command defines its own response format.
-
-TODOs
-=====
-
-* Add "node namespace" support to each command. In order to support
-  SHA-1 hash transition, we want servers to be able to expose different
-  "node namespaces" for the same data. Every command operating on nodes
-  should specify which "node namespace" it is operating on and responses
-  should encode the "node namespace" accordingly.
-
-Commands
-========
-
-The sections below detail all commands available to wire protocol version
-2.
-
-branchmap
----------
-
-Obtain heads in named branches.
-
-Receives no arguments.
-
-The response is a map with bytestring keys defining the branch name.
-Values are arrays of bytestring defining raw changeset nodes.
-
-capabilities
-------------
-
-Obtain the server's capabilities.
-
-Receives no arguments.
-
-This command is typically called only as part of the handshake during
-initial connection establishment.
-
-The response is a map with bytestring keys defining server information.
-
-The defined keys are:
-
-commands
-   A map defining available wire protocol commands on this server.
-
-   Keys in the map are the names of commands that can be invoked. Values
-   are maps defining information about that command. The bytestring keys
-   are:
-
-      args
-         (map) Describes arguments accepted by the command.
-
-         Keys are bytestrings denoting the argument name.
-
-         Values are maps describing the argument. The map has the following
-         bytestring keys:
-
-         default
-            (varied) The default value for this argument if not specified. Only
-            present if ``required`` is not true.
-
-         required
-            (boolean) Whether the argument must be specified. Failure to send
-            required arguments will result in an error executing the command.
-
-         type
-            (bytestring) The type of the argument. e.g. ``bytes`` or ``bool``.
-
-         validvalues
-            (set) Values that are recognized for this argument. Some arguments
-            only allow a fixed set of values to be specified. These arguments
-            may advertise that set in this key. If this set is advertised and
-            a value not in this set is specified, the command should result
-            in error.
-
-      permissions
-         An array of permissions required to execute this command.
-
-      *
-         (various) Individual commands may define extra keys that supplement
-         generic command metadata. See the command definition for more.
-
-framingmediatypes
-   An array of bytestrings defining the supported framing protocol
-   media types. Servers will not accept media types not in this list.
-
-pathfilterprefixes
-   (set of bytestring) Matcher prefixes that are recognized when performing
-   path filtering. Specifying a path filter whose type/prefix does not
-   match one in this set will likely be rejected by the server.
-
-rawrepoformats
-   An array of storage formats the repository is using. This set of
-   requirements can be used to determine whether a client can read a
-   *raw* copy of file data available.
-
-redirect
-   A map declaring potential *content redirects* that may be used by this
-   server. Contains the following bytestring keys:
-
-   targets
-      (array of maps) Potential redirect targets. Values are maps describing
-      this target in more detail. Each map has the following bytestring keys:
-
-      name
-         (bytestring) Identifier for this target. The identifier will be used
-         by clients to uniquely identify this target.
-
-      protocol
-         (bytestring) High-level network protocol. Values can be
-         ``http``, ```https``, ``ssh``, etc.
-
-      uris
-          (array of bytestrings) Representative URIs for this target.
-
-      snirequired (optional)
-          (boolean) Indicates whether Server Name Indication is required
-          to use this target. Defaults to False.
-
-      tlsversions (optional)
-          (array of bytestring) Indicates which TLS versions are supported by
-          this target. Values are ``1.1``, ``1.2``, ``1.3``, etc.
-
-   hashes
-      (array of bytestring) Indicates support for hashing algorithms that are
-      used to ensure content integrity. Values include ``sha1``, ``sha256``,
-      etc.
-
-changesetdata
--------------
-
-Obtain various data related to changesets.
-
-The command accepts the following arguments:
-
-revisions
-   (array of maps) Specifies revisions whose data is being requested. Each
-   value in the array is a map describing revisions. See the
-   *Revisions Specifiers* section below for the format of this map.
-
-   Data will be sent for the union of all revisions resolved by all
-   revision specifiers.
-
-   Only revision specifiers operating on changeset revisions are allowed.
-
-fields
-   (set of bytestring) Which data associated with changelog revisions to
-   fetch. The following values are recognized:
-
-   bookmarks
-      Bookmarks associated with a revision.
-
-   parents
-      Parent revisions.
-
-   phase
-      The phase state of a revision.
-
-   revision
-      The raw, revision data for the changelog entry. The hash of this data
-      will match the revision's node value.
-
-The response bytestream starts with a CBOR map describing the data that follows.
-This map has the following bytestring keys:
-
-totalitems
-   (unsigned integer) Total number of changelog revisions whose data is being
-   transferred. This maps to the set of revisions in the requested node
-   range, not the total number of records that follow (see below for why).
-
-Following the map header is a series of 0 or more CBOR values. If values
-are present, the first value will always be a map describing a single changeset
-revision.
-
-If the ``fieldsfollowing`` key is present, the map will immediately be followed
-by N CBOR bytestring values, where N is the number of elements in
-``fieldsfollowing``. Each bytestring value corresponds to a field denoted
-by ``fieldsfollowing``.
-
-Following the optional bytestring field values is the next revision descriptor
-map, or end of stream.
-
-Each revision descriptor map has the following bytestring keys:
-
-node
-   (bytestring) The node value for this revision. This is the SHA-1 hash of
-   the raw revision data.
-
-bookmarks (optional)
-   (array of bytestrings) Bookmarks attached to this revision. Only present
-   if ``bookmarks`` data is being requested and the revision has bookmarks
-   attached.
-
-fieldsfollowing (optional)
-   (array of 2-array) Denotes what fields immediately follow this map. Each
-   value is an array with 2 elements: the bytestring field name and an unsigned
-   integer describing the length of the data, in bytes.
-
-   If this key isn't present, no special fields will follow this map.
-
-   The following fields may be present:
-
-   revision
-      Raw, revision data for the changelog entry. Contains a serialized form
-      of the changeset data, including the author, date, commit message, set
-      of changed files, manifest node, and other metadata.
-
-      Only present if the ``revision`` field was requested.
-
-parents (optional)
-   (array of bytestrings) The nodes representing the parent revisions of this
-   revision. Only present if ``parents`` data is being requested.
-
-phase (optional)
-   (bytestring) The phase that a revision is in. Recognized values are
-   ``secret``, ``draft``, and ``public``. Only present if ``phase`` data
-   is being requested.
-
-The set of changeset revisions emitted may not match the exact set of
-changesets requested. Furthermore, the set of keys present on each
-map may vary. This is to facilitate emitting changeset updates as well
-as new revisions.
-
-For example, if the request wants ``phase`` and ``revision`` data,
-the response may contain entries for each changeset in the common nodes
-set with the ``phase`` key and without the ``revision`` key in order
-to reflect a phase-only update.
-
-TODO support different revision selection mechanisms (e.g. non-public, specific
-revisions)
-TODO support different hash "namespaces" for revisions (e.g. sha-1 versus other)
-TODO support emitting obsolescence data
-TODO support filtering based on relevant paths (narrow clone)
-TODO support hgtagsfnodes cache / tags data
-TODO support branch heads cache
-TODO consider unify query mechanism. e.g. as an array of "query descriptors"
-rather than a set of top-level arguments that have semantics when combined.
-
-filedata
---------
-
-Obtain various data related to an individual tracked file.
-
-The command accepts the following arguments:
-
-fields
-   (set of bytestring) Which data associated with a file to fetch.
-   The following values are recognized:
-
-   linknode
-      The changeset node introducing this revision.
-
-   parents
-      Parent nodes for the revision.
-
-   revision
-      The raw revision data for a file.
-
-haveparents
-   (bool) Whether the client has the parent revisions of all requested
-   nodes. If set, the server may emit revision data as deltas against
-   any parent revision. If not set, the server MUST only emit deltas for
-   revisions previously emitted by this command.
-
-   False is assumed in the absence of any value.
-
-nodes
-   (array of bytestrings) File nodes whose data to retrieve.
-
-path
-   (bytestring) Path of the tracked file whose data to retrieve.
-
-TODO allow specifying revisions via alternate means (such as from
-changeset revisions or ranges)
-
-The response bytestream starts with a CBOR map describing the data that
-follows. It has the following bytestream keys:
-
-totalitems
-   (unsigned integer) Total number of file revisions whose data is
-   being returned.
-
-Following the map header is a series of 0 or more CBOR values. If values
-are present, the first value will always be a map describing a single changeset
-revision.
-
-If the ``fieldsfollowing`` key is present, the map will immediately be followed
-by N CBOR bytestring values, where N is the number of elements in
-``fieldsfollowing``. Each bytestring value corresponds to a field denoted
-by ``fieldsfollowing``.
-
-Following the optional bytestring field values is the next revision descriptor
-map, or end of stream.
-
-Each revision descriptor map has the following bytestring keys:
-
-Each map has the following bytestring keys:
-
-node
-   (bytestring) The node of the file revision whose data is represented.
-
-deltabasenode
-   (bytestring) Node of the file revision the following delta is against.
-
-   Only present if the ``revision`` field is requested and delta data
-   follows this map.
-
-fieldsfollowing
-   (array of 2-array) Denotes extra bytestring fields that following this map.
-   See the documentation for ``changesetdata`` for semantics.
-
-   The following named fields may be present:
-
-   ``delta``
-      The delta data to use to construct the fulltext revision.
-
-      Only present if the ``revision`` field is requested and a delta is
-      being emitted. The ``deltabasenode`` top-level key will also be
-      present if this field is being emitted.
-
-   ``revision``
-      The fulltext revision data for this manifest. Only present if the
-      ``revision`` field is requested and a fulltext revision is being emitted.
-
-parents
-   (array of bytestring) The nodes of the parents of this file revision.
-
-   Only present if the ``parents`` field is requested.
-
-When ``revision`` data is requested, the server chooses to emit either fulltext
-revision data or a delta. What the server decides can be inferred by looking
-for the presence of the ``delta`` or ``revision`` keys in the
-``fieldsfollowing`` array.
-
-filesdata
----------
-
-Obtain various data related to multiple tracked files for specific changesets.
-
-This command is similar to ``filedata`` with the main difference being that
-individual requests operate on multiple file paths. This allows clients to
-request data for multiple paths by issuing a single command.
-
-The command accepts the following arguments:
-
-fields
-   (set of bytestring) Which data associated with a file to fetch.
-   The following values are recognized:
-
-   linknode
-      The changeset node introducing this revision.
-
-   parents
-      Parent nodes for the revision.
-
-   revision
-      The raw revision data for a file.
-
-haveparents
-   (bool) Whether the client has the parent revisions of all requested
-   nodes.
-
-pathfilter
-   (map) Defines a filter that determines what file paths are relevant.
-
-   See the *Path Filters* section for more.
-
-   If the argument is omitted, it is assumed that all paths are relevant.
-
-revisions
-   (array of maps) Specifies revisions whose data is being requested. Each value
-   in the array is a map describing revisions. See the *Revisions Specifiers*
-   section below for the format of this map.
-
-   Data will be sent for the union of all revisions resolved by all revision
-   specifiers.
-
-   Only revision specifiers operating on changeset revisions are allowed.
-
-The response bytestream starts with a CBOR map describing the data that
-follows. This map has the following bytestring keys:
-
-totalpaths
-   (unsigned integer) Total number of paths whose data is being transferred.
-
-totalitems
-   (unsigned integer) Total number of file revisions whose data is being
-   transferred.
-
-Following the map header are 0 or more sequences of CBOR values. Each sequence
-represents data for a specific tracked path. Each sequence begins with a CBOR
-map describing the file data that follows. Following that map is N CBOR values
-describing file revision data. The format of this data is identical to that
-returned by the ``filedata`` command.
-
-Each sequence's map header has the following bytestring keys:
-
-path
-   (bytestring) The tracked file path whose data follows.
-
-totalitems
-   (unsigned integer) Total number of file revisions whose data is being
-   transferred.
-
-The ``haveparents`` argument has significant implications on the data
-transferred.
-
-When ``haveparents`` is true, the command MAY only emit data for file
-revisions introduced by the set of changeset revisions whose data is being
-requested. In other words, the command may assume that all file revisions
-for all relevant paths for ancestors of the requested changeset revisions
-are present on the receiver.
-
-When ``haveparents`` is false, the command MUST assume that the receiver
-has no file revisions data. This means that all referenced file revisions
-in the queried set of changeset revisions will be sent.
-
-TODO we want a more complicated mechanism for the client to specify which
-ancestor revisions are known. This is needed so intelligent deltas can be
-emitted and so updated linknodes can be sent if the client needs to adjust
-its linknodes for existing file nodes to older changeset revisions.
-TODO we may want to make linknodes an array so multiple changesets can be
-marked as introducing a file revision, since this can occur with e.g. hidden
-changesets.
-
-heads
------
-
-Obtain DAG heads in the repository.
-
-The command accepts the following arguments:
-
-publiconly (optional)
-   (boolean) If set, operate on the DAG for public phase changesets only.
-   Non-public (i.e. draft) phase DAG heads will not be returned.
-
-The response is a CBOR array of bytestrings defining changeset nodes
-of DAG heads. The array can be empty if the repository is empty or no
-changesets satisfied the request.
-
-TODO consider exposing phase of heads in response
-
-known
------
-
-Determine whether a series of changeset nodes is known to the server.
-
-The command accepts the following arguments:
-
-nodes
-   (array of bytestrings) List of changeset nodes whose presence to
-   query.
-
-The response is a bytestring where each byte contains a 0 or 1 for the
-corresponding requested node at the same index.
-
-TODO use a bit array for even more compact response
-
-listkeys
---------
-
-List values in a specified ``pushkey`` namespace.
-
-The command receives the following arguments:
-
-namespace
-   (bytestring) Pushkey namespace to query.
-
-The response is a map with bytestring keys and values.
-
-TODO consider using binary to represent nodes in certain pushkey namespaces.
-
-lookup
-------
-
-Try to resolve a value to a changeset revision.
-
-Unlike ``known`` which operates on changeset nodes, lookup operates on
-node fragments and other names that a user may use.
-
-The command receives the following arguments:
-
-key
-   (bytestring) Value to try to resolve.
-
-On success, returns a bytestring containing the resolved node.
-
-manifestdata
-------------
-
-Obtain various data related to manifests (which are lists of files in
-a revision).
-
-The command accepts the following arguments:
-
-fields
-   (set of bytestring) Which data associated with manifests to fetch.
-   The following values are recognized:
-
-   parents
-      Parent nodes for the manifest.
-
-   revision
-      The raw revision data for the manifest.
-
-haveparents
-   (bool) Whether the client has the parent revisions of all requested
-   nodes. If set, the server may emit revision data as deltas against
-   any parent revision. If not set, the server MUST only emit deltas for
-   revisions previously emitted by this command.
-
-   False is assumed in the absence of any value.
-
-nodes
-   (array of bytestring) Manifest nodes whose data to retrieve.
-
-tree
-   (bytestring) Path to manifest to retrieve. The empty bytestring represents
-   the root manifest. All other values represent directories/trees within
-   the repository.
-
-TODO allow specifying revisions via alternate means (such as from changeset
-revisions or ranges)
-TODO consider recursive expansion of manifests (with path filtering for
-narrow use cases)
-
-The response bytestream starts with a CBOR map describing the data that
-follows. It has the following bytestring keys:
-
-totalitems
-   (unsigned integer) Total number of manifest revisions whose data is
-   being returned.
-
-Following the map header is a series of 0 or more CBOR values. If values
-are present, the first value will always be a map describing a single manifest
-revision.
-
-If the ``fieldsfollowing`` key is present, the map will immediately be followed
-by N CBOR bytestring values, where N is the number of elements in
-``fieldsfollowing``. Each bytestring value corresponds to a field denoted
-by ``fieldsfollowing``.
-
-Following the optional bytestring field values is the next revision descriptor
-map, or end of stream.
-
-Each revision descriptor map has the following bytestring keys:
-
-node
-   (bytestring) The node of the manifest revision whose data is represented.
-
-deltabasenode
-   (bytestring) The node that the delta representation of this revision is
-   computed against. Only present if the ``revision`` field is requested and
-   a delta is being emitted.
-
-fieldsfollowing
-   (array of 2-array) Denotes extra bytestring fields that following this map.
-   See the documentation for ``changesetdata`` for semantics.
-
-   The following named fields may be present:
-
-   ``delta``
-      The delta data to use to construct the fulltext revision.
-
-      Only present if the ``revision`` field is requested and a delta is
-      being emitted. The ``deltabasenode`` top-level key will also be
-      present if this field is being emitted.
-
-   ``revision``
-      The fulltext revision data for this manifest. Only present if the
-      ``revision`` field is requested and a fulltext revision is being emitted.
-
-parents
-   (array of bytestring) The nodes of the parents of this manifest revision.
-   Only present if the ``parents`` field is requested.
-
-When ``revision`` data is requested, the server chooses to emit either fulltext
-revision data or a delta. What the server decides can be inferred by looking
-for the presence of ``delta`` or ``revision`` in the ``fieldsfollowing`` array.
-
-Servers MAY advertise the following extra fields in the capabilities
-descriptor for this command:
-
-recommendedbatchsize
-   (unsigned integer) Number of revisions the server recommends as a batch
-   query size. If defined, clients needing to issue multiple ``manifestdata``
-   commands to obtain needed data SHOULD construct their commands to have
-   this many revisions per request.
-
-pushkey
--------
-
-Set a value using the ``pushkey`` protocol.
-
-The command receives the following arguments:
-
-namespace
-   (bytestring) Pushkey namespace to operate on.
-key
-   (bytestring) The pushkey key to set.
-old
-   (bytestring) Old value for this key.
-new
-   (bytestring) New value for this key.
-
-TODO consider using binary to represent nodes is certain pushkey namespaces.
-TODO better define response type and meaning.
-
-rawstorefiledata
-----------------
-
-Allows retrieving raw files used to store repository data.
-
-The command accepts the following arguments:
-
-files
-   (array of bytestring) Describes the files that should be retrieved.
-
-   The meaning of values in this array is dependent on the storage backend used
-   by the server.
-
-The response bytestream starts with a CBOR map describing the data that follows.
-This map has the following bytestring keys:
-
-filecount
-   (unsigned integer) Total number of files whose data is being transferred.
-
-totalsize
-   (unsigned integer) Total size in bytes of files data that will be
-   transferred. This is file on-disk size and not wire size.
-
-Following the map header are N file segments. Each file segment consists of a
-CBOR map followed by an indefinite length bytestring. Each map has the following
-bytestring keys:
-
-location
-   (bytestring) Denotes the location in the repository where the file should be
-   written. Values map to vfs instances to use for the writing.
-
-path
-   (bytestring) Path of file being transferred. Path is the raw store
-   path and can be any sequence of bytes that can be tracked in a Mercurial
-   manifest.
-
-size
-   (unsigned integer) Size of file data. This will be the final written
-   file size. The total size of the data that follows the CBOR map
-   will be greater due to encoding overhead of CBOR.
-
-TODO this command is woefully incomplete. If we are to move forward with a
-stream clone analog, it needs a lot more metadata around how to describe what
-files are available to retrieve, other semantics.
-
-Revision Specifiers
-===================
-
-A *revision specifier* is a map that evaluates to a set of revisions.
-
-A *revision specifier* has a ``type`` key that defines the revision
-selection type to perform. Other keys in the map are used in a
-type-specific manner.
-
-The following types are defined:
-
-changesetexplicit
-   An explicit set of enumerated changeset revisions.
-
-   The ``nodes`` key MUST contain an array of full binary nodes, expressed
-   as bytestrings.
-
-changesetexplicitdepth
-   Like ``changesetexplicit``, but contains a ``depth`` key defining the
-   unsigned integer number of ancestor revisions to also resolve. For each
-   value in ``nodes``, DAG ancestors will be walked until up to N total
-   revisions from that ancestry walk are present in the final resolved set.
-
-changesetdagrange
-   Defines revisions via a DAG range of changesets on the changelog.
-
-   The ``roots`` key MUST contain an array of full, binary node values
-   representing the *root* revisions.
-
-   The ``heads`` key MUST contain an array of full, binary nodes values
-   representing the *head* revisions.
-
-   The DAG range between ``roots`` and ``heads`` will be resolved and all
-   revisions between will be used. Nodes in ``roots`` are not part of the
-   resolved set. Nodes in ``heads`` are. The ``roots`` array may be empty.
-   The ``heads`` array MUST be defined.
-
-Path Filters
-============
-
-Various commands accept a *path filter* argument that defines the set of file
-paths relevant to the request.
-
-A *path filter* is defined as a map with the bytestring keys ``include`` and
-``exclude``. Each is an array of bytestring values. Each value defines a pattern
-rule (see :hg:`help patterns`) that is used to match file paths.
-
-A path matches the path filter if it is matched by a rule in the ``include``
-set but doesn't match a rule in the ``exclude`` set. In other words, a path
-matcher takes the union of all ``include`` patterns and then substracts the
-union of all ``exclude`` patterns.
-
-Patterns MUST be prefixed with their pattern type. Only the following pattern
-types are allowed: ``path:``, ``rootfilesin:``.
-
-If the ``include`` key is omitted, it is assumed that all paths are
-relevant. The patterns from ``exclude`` will still be used, if defined.
-
-An example value is ``path:tests/foo``, which would match a file named
-``tests/foo`` or a directory ``tests/foo`` and all files under it.
--- a/mercurial/help/merge-tools.txt	Wed Nov 20 19:07:02 2019 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,109 +0,0 @@
-To merge files Mercurial uses merge tools.
-
-A merge tool combines two different versions of a file into a merged
-file. Merge tools are given the two files and the greatest common
-ancestor of the two file versions, so they can determine the changes
-made on both branches.
-
-Merge tools are used both for :hg:`resolve`, :hg:`merge`, :hg:`update`,
-:hg:`backout` and in several extensions.
-
-Usually, the merge tool tries to automatically reconcile the files by
-combining all non-overlapping changes that occurred separately in
-the two different evolutions of the same initial base file. Furthermore, some
-interactive merge programs make it easier to manually resolve
-conflicting merges, either in a graphical way, or by inserting some
-conflict markers. Mercurial does not include any interactive merge
-programs but relies on external tools for that.
-
-Available merge tools
-=====================
-
-External merge tools and their properties are configured in the
-merge-tools configuration section - see hgrc(5) - but they can often just
-be named by their executable.
-
-A merge tool is generally usable if its executable can be found on the
-system and if it can handle the merge. The executable is found if it
-is an absolute or relative executable path or the name of an
-application in the executable search path. The tool is assumed to be
-able to handle the merge if it can handle symlinks if the file is a
-symlink, if it can handle binary files if the file is binary, and if a
-GUI is available if the tool requires a GUI.
-
-There are some internal merge tools which can be used. The internal
-merge tools are:
-
-.. internaltoolsmarker
-
-Internal tools are always available and do not require a GUI but will
-by default not handle symlinks or binary files. See next section for
-detail about "actual capabilities" described above.
-
-Choosing a merge tool
-=====================
-
-Mercurial uses these rules when deciding which merge tool to use:
-
-1. If a tool has been specified with the --tool option to merge or resolve, it
-   is used.  If it is the name of a tool in the merge-tools configuration, its
-   configuration is used. Otherwise the specified tool must be executable by
-   the shell.
-
-2. If the ``HGMERGE`` environment variable is present, its value is used and
-   must be executable by the shell.
-
-3. If the filename of the file to be merged matches any of the patterns in the
-   merge-patterns configuration section, the first usable merge tool
-   corresponding to a matching pattern is used.
-
-4. If ui.merge is set it will be considered next. If the value is not the name
-   of a configured tool, the specified value is used and must be executable by
-   the shell. Otherwise the named tool is used if it is usable.
-
-5. If any usable merge tools are present in the merge-tools configuration
-   section, the one with the highest priority is used.
-
-6. If a program named ``hgmerge`` can be found on the system, it is used - but
-   it will by default not be used for symlinks and binary files.
-
-7. If the file to be merged is not binary and is not a symlink, then
-   internal ``:merge`` is used.
-
-8. Otherwise, ``:prompt`` is used.
-
-For historical reason, Mercurial treats merge tools as below while
-examining rules above.
-
-==== =============== ====== =======
-step specified via   binary symlink
-==== =============== ====== =======
-1.   --tool          o/o    o/o
-2.   HGMERGE         o/o    o/o
-3.   merge-patterns  o/o(*) x/?(*)
-4.   ui.merge        x/?(*) x/?(*)
-==== =============== ====== =======
-
-Each capability column indicates Mercurial behavior for
-internal/external merge tools at examining each rule.
-
-- "o": "assume that a tool has capability"
-- "x": "assume that a tool does not have capability"
-- "?": "check actual capability of a tool"
-
-If ``merge.strict-capability-check`` configuration is true, Mercurial
-checks capabilities of merge tools strictly in (*) cases above (= each
-capability column becomes "?/?"). It is false by default for backward
-compatibility.
-
-.. note::
-
-   After selecting a merge program, Mercurial will by default attempt
-   to merge the files using a simple merge algorithm first. Only if it doesn't
-   succeed because of conflicting changes will Mercurial actually execute the
-   merge program. Whether to use the simple merge algorithm first can be
-   controlled by the premerge setting of the merge tool. Premerge is enabled by
-   default unless the file is binary or a symlink.
-
-See the merge-tools and ui sections of hgrc(5) for details on the
-configuration of merge tools.
--- a/mercurial/help/pager.txt	Wed Nov 20 19:07:02 2019 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,43 +0,0 @@
-Some Mercurial commands can produce a lot of output, and Mercurial will
-attempt to use a pager to make those commands more pleasant.
-
-To set the pager that should be used, set the application variable::
-
-  [pager]
-  pager = less -FRX
-
-If no pager is set in the user or repository configuration, Mercurial uses the
-environment variable $PAGER. If $PAGER is not set, pager.pager from the default
-or system configuration is used. If none of these are set, a default pager will
-be used, typically `less` on Unix and `more` on Windows.
-
-.. container:: windows
-
-  On Windows, `more` is not color aware, so using it effectively disables color.
-  MSYS and Cygwin shells provide `less` as a pager, which can be configured to
-  support ANSI color codes.  See :hg:`help config.color.pagermode` to configure
-  the color mode when invoking a pager.
-
-You can disable the pager for certain commands by adding them to the
-pager.ignore list::
-
-  [pager]
-  ignore = version, help, update
-
-To ignore global commands like :hg:`version` or :hg:`help`, you have
-to specify them in your user configuration file.
-
-To control whether the pager is used at all for an individual command,
-you can use --pager=<value>:
-
-  - use as needed: `auto`.
-  - require the pager: `yes` or `on`.
-  - suppress the pager: `no` or `off` (any unrecognized value
-    will also work).
-
-To globally turn off all attempts to use a pager, set::
-
-  [ui]
-  paginate = never
-
-which will prevent the pager from running.
--- a/mercurial/help/patterns.txt	Wed Nov 20 19:07:02 2019 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,86 +0,0 @@
-Mercurial accepts several notations for identifying one or more files
-at a time.
-
-By default, Mercurial treats filenames as shell-style extended glob
-patterns.
-
-Alternate pattern notations must be specified explicitly.
-
-.. note::
-
-  Patterns specified in ``.hgignore`` are not rooted.
-  Please see :hg:`help hgignore` for details.
-
-To use a plain path name without any pattern matching, start it with
-``path:``. These path names must completely match starting at the
-current repository root, and when the path points to a directory, it is matched
-recursively. To match all files in a directory non-recursively (not including
-any files in subdirectories), ``rootfilesin:`` can be used, specifying an
-absolute path (relative to the repository root).
-
-To use an extended glob, start a name with ``glob:``. Globs are rooted
-at the current directory; a glob such as ``*.c`` will only match files
-in the current directory ending with ``.c``. ``rootglob:`` can be used
-instead of ``glob:`` for a glob that is rooted at the root of the
-repository.
-
-The supported glob syntax extensions are ``**`` to match any string
-across path separators and ``{a,b}`` to mean "a or b".
-
-To use a Perl/Python regular expression, start a name with ``re:``.
-Regexp pattern matching is anchored at the root of the repository.
-
-To read name patterns from a file, use ``listfile:`` or ``listfile0:``.
-The latter expects null delimited patterns while the former expects line
-feeds. Each string read from the file is itself treated as a file
-pattern.
-
-To read a set of patterns from a file, use ``include:`` or ``subinclude:``.
-``include:`` will use all the patterns from the given file and treat them as if
-they had been passed in manually.  ``subinclude:`` will only apply the patterns
-against files that are under the subinclude file's directory. See :hg:`help
-hgignore` for details on the format of these files.
-
-All patterns, except for ``glob:`` specified in command line (not for
-``-I`` or ``-X`` options), can match also against directories: files
-under matched directories are treated as matched.
-For ``-I`` and ``-X`` options, ``glob:`` will match directories recursively.
-
-Plain examples::
-
-  path:foo/bar        a name bar in a directory named foo in the root
-                      of the repository
-  path:path:name      a file or directory named "path:name"
-  rootfilesin:foo/bar the files in a directory called foo/bar, but not any files
-                      in its subdirectories and not a file bar in directory foo
-
-Glob examples::
-
-  glob:*.c       any name ending in ".c" in the current directory
-  *.c            any name ending in ".c" in the current directory
-  **.c           any name ending in ".c" in any subdirectory of the
-                 current directory including itself.
-  foo/*          any file in directory foo
-  foo/**         any file in directory foo plus all its subdirectories,
-                 recursively
-  foo/*.c        any name ending in ".c" in the directory foo
-  foo/**.c       any name ending in ".c" in any subdirectory of foo
-                 including itself.
-  rootglob:*.c   any name ending in ".c" in the root of the repository
-
-Regexp examples::
-
-  re:.*\.c$      any name ending in ".c", anywhere in the repository
-
-File examples::
-
-  listfile:list.txt  read list from list.txt with one file pattern per line
-  listfile0:list.txt read list from list.txt with null byte delimiters
-
-See also :hg:`help filesets`.
-
-Include examples::
-
-  include:path/to/mypatternfile    reads patterns to be applied to all paths
-  subinclude:path/to/subignorefile reads patterns specifically for paths in the
-                                   subdirectory
--- a/mercurial/help/phases.txt	Wed Nov 20 19:07:02 2019 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,100 +0,0 @@
-What are phases?
-================
-
-Phases are a system for tracking which changesets have been or should
-be shared. This helps prevent common mistakes when modifying history
-(for instance, with the mq or rebase extensions).
-
-Each changeset in a repository is in one of the following phases:
-
- - public : changeset is visible on a public server
- - draft : changeset is not yet published
- - secret : changeset should not be pushed, pulled, or cloned
-
-These phases are ordered (public < draft < secret) and no changeset
-can be in a lower phase than its ancestors. For instance, if a
-changeset is public, all its ancestors are also public. Lastly,
-changeset phases should only be changed towards the public phase.
-
-How are phases managed?
-=======================
-
-For the most part, phases should work transparently. By default, a
-changeset is created in the draft phase and is moved into the public
-phase when it is pushed to another repository.
-
-Once changesets become public, extensions like mq and rebase will
-refuse to operate on them to prevent creating duplicate changesets.
-Phases can also be manually manipulated with the :hg:`phase` command
-if needed. See :hg:`help -v phase` for examples.
-
-To make your commits secret by default, put this in your
-configuration file::
-
-  [phases]
-  new-commit = secret
-
-Phases and servers
-==================
-
-Normally, all servers are ``publishing`` by default. This means::
-
- - all draft changesets that are pulled or cloned appear in phase
- public on the client
-
- - all draft changesets that are pushed appear as public on both
- client and server
-
- - secret changesets are neither pushed, pulled, or cloned
-
-.. note::
-
-  Pulling a draft changeset from a publishing server does not mark it
-  as public on the server side due to the read-only nature of pull.
-
-Sometimes it may be desirable to push and pull changesets in the draft
-phase to share unfinished work. This can be done by setting a
-repository to disable publishing in its configuration file::
-
-  [phases]
-  publish = False
-
-See :hg:`help config` for more information on configuration files.
-
-.. note::
-
-  Servers running older versions of Mercurial are treated as
-  publishing.
-
-.. note::
-
-   Changesets in secret phase are not exchanged with the server. This
-   applies to their content: file names, file contents, and changeset
-   metadata. For technical reasons, the identifier (e.g. d825e4025e39)
-   of the secret changeset may be communicated to the server.
-
-
-Examples
-========
-
- - list changesets in draft or secret phase::
-
-     hg log -r "not public()"
-
- - change all secret changesets to draft::
-
-     hg phase --draft "secret()"
-
- - forcibly move the current changeset and descendants from public to draft::
-
-     hg phase --force --draft .
-
- - show a list of changeset revisions and each corresponding phase::
-
-     hg log --template "{rev} {phase}\n"
-
- - resynchronize draft changesets relative to a remote repository::
-
-     hg phase -fd "outgoing(URL)"
-
-See :hg:`help phase` for more information on manually manipulating phases.
--- a/mercurial/help/revisions.txt	Wed Nov 20 19:07:02 2019 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,223 +0,0 @@
-Mercurial supports several ways to specify revisions.
-
-Specifying single revisions
-===========================
-
-A plain integer is treated as a revision number. Negative integers are
-treated as sequential offsets from the tip, with -1 denoting the tip,
--2 denoting the revision prior to the tip, and so forth.
-
-A 40-digit hexadecimal string is treated as a unique revision identifier.
-A hexadecimal string less than 40 characters long is treated as a
-unique revision identifier and is referred to as a short-form
-identifier. A short-form identifier is only valid if it is the prefix
-of exactly one full-length identifier.
-
-Any other string is treated as a bookmark, tag, or branch name. A
-bookmark is a movable pointer to a revision. A tag is a permanent name
-associated with a revision. A branch name denotes the tipmost open branch head
-of that branch - or if they are all closed, the tipmost closed head of the
-branch. Bookmark, tag, and branch names must not contain the ":" character.
-
-The reserved name "tip" always identifies the most recent revision.
-
-The reserved name "null" indicates the null revision. This is the
-revision of an empty repository, and the parent of revision 0.
-
-The reserved name "." indicates the working directory parent. If no
-working directory is checked out, it is equivalent to null. If an
-uncommitted merge is in progress, "." is the revision of the first
-parent.
-
-Finally, commands that expect a single revision (like ``hg update``) also
-accept revsets (see below for details). When given a revset, they use the
-last revision of the revset. A few commands accept two single revisions
-(like ``hg diff``). When given a revset, they use the first and the last
-revisions of the revset.
-
-Specifying multiple revisions
-=============================
-
-Mercurial supports a functional language for selecting a set of
-revisions. Expressions in this language are called revsets.
-
-The language supports a number of predicates which are joined by infix
-operators. Parenthesis can be used for grouping.
-
-Identifiers such as branch names may need quoting with single or
-double quotes if they contain characters like ``-`` or if they match
-one of the predefined predicates.
-
-Special characters can be used in quoted identifiers by escaping them,
-e.g., ``\n`` is interpreted as a newline. To prevent them from being
-interpreted, strings can be prefixed with ``r``, e.g. ``r'...'``.
-
-Operators
-=========
-
-There is a single prefix operator:
-
-``not x``
-  Changesets not in x. Short form is ``! x``.
-
-These are the supported infix operators:
-
-``x::y``
-  A DAG range, meaning all changesets that are descendants of x and
-  ancestors of y, including x and y themselves. If the first endpoint
-  is left out, this is equivalent to ``ancestors(y)``, if the second
-  is left out it is equivalent to ``descendants(x)``.
-
-  An alternative syntax is ``x..y``.
-
-``x:y``
-  All changesets with revision numbers between x and y, both
-  inclusive. Either endpoint can be left out, they default to 0 and
-  tip.
-
-``x and y``
-  The intersection of changesets in x and y. Short form is ``x & y``.
-
-``x or y``
-  The union of changesets in x and y. There are two alternative short
-  forms: ``x | y`` and ``x + y``.
-
-``x - y``
-  Changesets in x but not in y.
-
-``x % y``
-  Changesets that are ancestors of x but not ancestors of y (i.e. ::x - ::y).
-  This is shorthand notation for ``only(x, y)`` (see below). The second
-  argument is optional and, if left out, is equivalent to ``only(x)``.
-
-``x^n``
-  The nth parent of x, n == 0, 1, or 2.
-  For n == 0, x; for n == 1, the first parent of each changeset in x;
-  for n == 2, the second parent of changeset in x.
-
-``x~n``
-  The nth first ancestor of x; ``x~0`` is x; ``x~3`` is ``x^^^``.
-  For n < 0, the nth unambiguous descendent of x.
-
-``x ## y``
-  Concatenate strings and identifiers into one string.
-
-  All other prefix, infix and postfix operators have lower priority than
-  ``##``. For example, ``a1 ## a2~2`` is equivalent to ``(a1 ## a2)~2``.
-
-  For example::
-
-    [revsetalias]
-    issue(a1) = grep(r'\bissue[ :]?' ## a1 ## r'\b|\bbug\(' ## a1 ## r'\)')
-
-  ``issue(1234)`` is equivalent to
-  ``grep(r'\bissue[ :]?1234\b|\bbug\(1234\)')``
-  in this case. This matches against all of "issue 1234", "issue:1234",
-  "issue1234" and "bug(1234)".
-
-There is a single postfix operator:
-
-``x^``
-  Equivalent to ``x^1``, the first parent of each changeset in x.
-
-Patterns
-========
-
-Where noted, predicates that perform string matching can accept a pattern
-string. The pattern may be either a literal, or a regular expression. If the
-pattern starts with ``re:``, the remainder of the pattern is treated as a
-regular expression. Otherwise, it is treated as a literal. To match a pattern
-that actually starts with ``re:``, use the prefix ``literal:``.
-
-Matching is case-sensitive, unless otherwise noted.  To perform a case-
-insensitive match on a case-sensitive predicate, use a regular expression,
-prefixed with ``(?i)``.
-
-For example, ``tag(r're:(?i)release')`` matches "release" or "RELEASE"
-or "Release", etc.
-
-Predicates
-==========
-
-The following predicates are supported:
-
-.. predicatesmarker
-
-Aliases
-=======
-
-New predicates (known as "aliases") can be defined, using any combination of
-existing predicates or other aliases. An alias definition looks like::
-
-  <alias> = <definition>
-
-in the ``revsetalias`` section of a Mercurial configuration file. Arguments
-of the form `a1`, `a2`, etc. are substituted from the alias into the
-definition.
-
-For example,
-
-::
-
-  [revsetalias]
-  h = heads()
-  d(s) = sort(s, date)
-  rs(s, k) = reverse(sort(s, k))
-
-defines three aliases, ``h``, ``d``, and ``rs``. ``rs(0:tip, author)`` is
-exactly equivalent to ``reverse(sort(0:tip, author))``.
-
-Equivalents
-===========
-
-Command line equivalents for :hg:`log`::
-
-  -f    ->  ::.
-  -d x  ->  date(x)
-  -k x  ->  keyword(x)
-  -m    ->  merge()
-  -u x  ->  user(x)
-  -b x  ->  branch(x)
-  -P x  ->  !::x
-  -l x  ->  limit(expr, x)
-
-Examples
-========
-
-Some sample queries:
-
-- Changesets on the default branch::
-
-    hg log -r "branch(default)"
-
-- Changesets on the default branch since tag 1.5 (excluding merges)::
-
-    hg log -r "branch(default) and 1.5:: and not merge()"
-
-- Open branch heads::
-
-    hg log -r "head() and not closed()"
-
-- Changesets between tags 1.3 and 1.5 mentioning "bug" that affect
-  ``hgext/*``::
-
-    hg log -r "1.3::1.5 and keyword(bug) and file('hgext/*')"
-
-- Changesets committed in May 2008, sorted by user::
-
-    hg log -r "sort(date('May 2008'), user)"
-
-- Changesets mentioning "bug" or "issue" that are not in a tagged
-  release::
-
-    hg log -r "(keyword(bug) or keyword(issue)) and not ancestors(tag())"
-
-- Update to the commit that bookmark @ is pointing to, without activating the
-  bookmark (this works because the last revision of the revset is used)::
-
-    hg update :@
-
-- Show diff between tags 1.3 and 1.5 (this works because the first and the
-  last revisions of the revset are used)::
-
-    hg diff -r 1.3::1.5
--- a/mercurial/help/scripting.txt	Wed Nov 20 19:07:02 2019 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,202 +0,0 @@
-It is common for machines (as opposed to humans) to consume Mercurial.
-This help topic describes some of the considerations for interfacing
-machines with Mercurial.
-
-Choosing an Interface
-=====================
-
-Machines have a choice of several methods to interface with Mercurial.
-These include:
-
-- Executing the ``hg`` process
-- Querying a HTTP server
-- Calling out to a command server
-
-Executing ``hg`` processes is very similar to how humans interact with
-Mercurial in the shell. It should already be familiar to you.
-
-:hg:`serve` can be used to start a server. By default, this will start
-a "hgweb" HTTP server. This HTTP server has support for machine-readable
-output, such as JSON. For more, see :hg:`help hgweb`.
-
-:hg:`serve` can also start a "command server." Clients can connect
-to this server and issue Mercurial commands over a special protocol.
-For more details on the command server, including links to client
-libraries, see https://www.mercurial-scm.org/wiki/CommandServer.
-
-:hg:`serve` based interfaces (the hgweb and command servers) have the
-advantage over simple ``hg`` process invocations in that they are
-likely more efficient. This is because there is significant overhead
-to spawn new Python processes.
-
-.. tip::
-
-   If you need to invoke several ``hg`` processes in short order and/or
-   performance is important to you, use of a server-based interface
-   is highly recommended.
-
-Environment Variables
-=====================
-
-As documented in :hg:`help environment`, various environment variables
-influence the operation of Mercurial. The following are particularly
-relevant for machines consuming Mercurial:
-
-HGPLAIN
-    If not set, Mercurial's output could be influenced by configuration
-    settings that impact its encoding, verbose mode, localization, etc.
-
-    It is highly recommended for machines to set this variable when
-    invoking ``hg`` processes.
-
-HGENCODING
-    If not set, the locale used by Mercurial will be detected from the
-    environment. If the determined locale does not support display of
-    certain characters, Mercurial may render these character sequences
-    incorrectly (often by using "?" as a placeholder for invalid
-    characters in the current locale).
-
-    Explicitly setting this environment variable is a good practice to
-    guarantee consistent results. "utf-8" is a good choice on UNIX-like
-    environments.
-
-HGRCPATH
-    If not set, Mercurial will inherit config options from config files
-    using the process described in :hg:`help config`. This includes
-    inheriting user or system-wide config files.
-
-    When utmost control over the Mercurial configuration is desired, the
-    value of ``HGRCPATH`` can be set to an explicit file with known good
-    configs. In rare cases, the value can be set to an empty file or the
-    null device (often ``/dev/null``) to bypass loading of any user or
-    system config files. Note that these approaches can have unintended
-    consequences, as the user and system config files often define things
-    like the username and extensions that may be required to interface
-    with a repository.
-
-Command-line Flags
-==================
-
-Mercurial's default command-line parser is designed for humans, and is not
-robust against malicious input. For instance, you can start a debugger by
-passing ``--debugger`` as an option value::
-
-    $ REV=--debugger sh -c 'hg log -r "$REV"'
-
-This happens because several command-line flags need to be scanned without
-using a concrete command table, which may be modified while loading repository
-settings and extensions.
-
-Since Mercurial 4.4.2, the parsing of such flags may be restricted by setting
-``HGPLAIN=+strictflags``. When this feature is enabled, all early options
-(e.g. ``-R/--repository``, ``--cwd``, ``--config``) must be specified first
-amongst the other global options, and cannot be injected to an arbitrary
-location::
-
-    $ HGPLAIN=+strictflags hg -R "$REPO" log -r "$REV"
-
-In earlier Mercurial versions where ``+strictflags`` isn't available, you
-can mitigate the issue by concatenating an option value with its flag::
-
-    $ hg log -r"$REV" --keyword="$KEYWORD"
-
-Consuming Command Output
-========================
-
-It is common for machines to need to parse the output of Mercurial
-commands for relevant data. This section describes the various
-techniques for doing so.
-
-Parsing Raw Command Output
---------------------------
-
-Likely the simplest and most effective solution for consuming command
-output is to simply invoke ``hg`` commands as you would as a user and
-parse their output.
-
-The output of many commands can easily be parsed with tools like
-``grep``, ``sed``, and ``awk``.
-
-A potential downside with parsing command output is that the output
-of commands can change when Mercurial is upgraded. While Mercurial
-does generally strive for strong backwards compatibility, command
-output does occasionally change. Having tests for your automated
-interactions with ``hg`` commands is generally recommended, but is
-even more important when raw command output parsing is involved.
-
-Using Templates to Control Output
----------------------------------
-
-Many ``hg`` commands support templatized output via the
-``-T/--template`` argument. For more, see :hg:`help templates`.
-
-Templates are useful for explicitly controlling output so that
-you get exactly the data you want formatted how you want it. For
-example, ``log -T {node}\n`` can be used to print a newline
-delimited list of changeset nodes instead of a human-tailored
-output containing authors, dates, descriptions, etc.
-
-.. tip::
-
-   If parsing raw command output is too complicated, consider
-   using templates to make your life easier.
-
-The ``-T/--template`` argument allows specifying pre-defined styles.
-Mercurial ships with the machine-readable styles ``cbor``, ``json``,
-and ``xml``, which provide CBOR, JSON, and XML output, respectively.
-These are useful for producing output that is machine readable as-is.
-
-(Mercurial 5.0 is required for CBOR style.)
-
-.. important::
-
-   The ``json`` and ``xml`` styles are considered experimental. While
-   they may be attractive to use for easily obtaining machine-readable
-   output, their behavior may change in subsequent versions.
-
-   These styles may also exhibit unexpected results when dealing with
-   certain encodings. Mercurial treats things like filenames as a
-   series of bytes and normalizing certain byte sequences to JSON
-   or XML with certain encoding settings can lead to surprises.
-
-Command Server Output
----------------------
-
-If using the command server to interact with Mercurial, you are likely
-using an existing library/API that abstracts implementation details of
-the command server. If so, this interface layer may perform parsing for
-you, saving you the work of implementing it yourself.
-
-Output Verbosity
-----------------
-
-Commands often have varying output verbosity, even when machine
-readable styles are being used (e.g. ``-T json``). Adding
-``-v/--verbose`` and ``--debug`` to the command's arguments can
-increase the amount of data exposed by Mercurial.
-
-An alternate way to get the data you need is by explicitly specifying
-a template.
-
-Other Topics
-============
-
-revsets
-   Revisions sets is a functional query language for selecting a set
-   of revisions. Think of it as SQL for Mercurial repositories. Revsets
-   are useful for querying repositories for specific data.
-
-   See :hg:`help revsets` for more.
-
-share extension
-   The ``share`` extension provides functionality for sharing
-   repository data across several working copies. It can even
-   automatically "pool" storage for logically related repositories when
-   cloning.
-
-   Configuring the ``share`` extension can lead to significant resource
-   utilization reduction, particularly around disk space and the
-   network. This is especially true for continuous integration (CI)
-   environments.
-
-   See :hg:`help -e share` for more.
--- a/mercurial/help/subrepos.txt	Wed Nov 20 19:07:02 2019 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,171 +0,0 @@
-Subrepositories let you nest external repositories or projects into a
-parent Mercurial repository, and make commands operate on them as a
-group.
-
-Mercurial currently supports Mercurial, Git, and Subversion
-subrepositories.
-
-Subrepositories are made of three components:
-
-1. Nested repository checkouts. They can appear anywhere in the
-   parent working directory.
-
-2. Nested repository references. They are defined in ``.hgsub``, which
-   should be placed in the root of working directory, and
-   tell where the subrepository checkouts come from. Mercurial
-   subrepositories are referenced like::
-
-     path/to/nested = https://example.com/nested/repo/path
-
-   Git and Subversion subrepos are also supported::
-
-     path/to/nested = [git]git://example.com/nested/repo/path
-     path/to/nested = [svn]https://example.com/nested/trunk/path
-
-   where ``path/to/nested`` is the checkout location relatively to the
-   parent Mercurial root, and ``https://example.com/nested/repo/path``
-   is the source repository path. The source can also reference a
-   filesystem path.
-
-   Note that ``.hgsub`` does not exist by default in Mercurial
-   repositories, you have to create and add it to the parent
-   repository before using subrepositories.
-
-3. Nested repository states. They are defined in ``.hgsubstate``, which
-   is placed in the root of working directory, and
-   capture whatever information is required to restore the
-   subrepositories to the state they were committed in a parent
-   repository changeset. Mercurial automatically record the nested
-   repositories states when committing in the parent repository.
-
-   .. note::
-
-      The ``.hgsubstate`` file should not be edited manually.
-
-
-Adding a Subrepository
-======================
-
-If ``.hgsub`` does not exist, create it and add it to the parent
-repository. Clone or checkout the external projects where you want it
-to live in the parent repository. Edit ``.hgsub`` and add the
-subrepository entry as described above. At this point, the
-subrepository is tracked and the next commit will record its state in
-``.hgsubstate`` and bind it to the committed changeset.
-
-Synchronizing a Subrepository
-=============================
-
-Subrepos do not automatically track the latest changeset of their
-sources. Instead, they are updated to the changeset that corresponds
-with the changeset checked out in the top-level changeset. This is so
-developers always get a consistent set of compatible code and
-libraries when they update.
-
-Thus, updating subrepos is a manual process. Simply check out target
-subrepo at the desired revision, test in the top-level repo, then
-commit in the parent repository to record the new combination.
-
-Deleting a Subrepository
-========================
-
-To remove a subrepository from the parent repository, delete its
-reference from ``.hgsub``, then remove its files.
-
-Interaction with Mercurial Commands
-===================================
-
-:add: add does not recurse in subrepos unless -S/--subrepos is
-    specified.  However, if you specify the full path of a file in a
-    subrepo, it will be added even without -S/--subrepos specified.
-    Subversion subrepositories are currently silently
-    ignored.
-
-:addremove: addremove does not recurse into subrepos unless
-    -S/--subrepos is specified.  However, if you specify the full
-    path of a directory in a subrepo, addremove will be performed on
-    it even without -S/--subrepos being specified.  Git and
-    Subversion subrepositories will print a warning and continue.
-
-:archive: archive does not recurse in subrepositories unless
-    -S/--subrepos is specified.
-
-:cat: Git subrepositories only support exact file matches.
-    Subversion subrepositories are currently ignored.
-
-:commit: commit creates a consistent snapshot of the state of the
-    entire project and its subrepositories. If any subrepositories
-    have been modified, Mercurial will abort.  Mercurial can be made
-    to instead commit all modified subrepositories by specifying
-    -S/--subrepos, or setting "ui.commitsubrepos=True" in a
-    configuration file (see :hg:`help config`).  After there are no
-    longer any modified subrepositories, it records their state and
-    finally commits it in the parent repository.  The --addremove
-    option also honors the -S/--subrepos option.  However, Git and
-    Subversion subrepositories will print a warning and abort.
-
-:diff: diff does not recurse in subrepos unless -S/--subrepos is
-    specified.  However, if you specify the full path of a file or
-    directory in a subrepo, it will be diffed even without
-    -S/--subrepos being specified.  Subversion subrepositories are
-    currently silently ignored.
-
-:files: files does not recurse into subrepos unless -S/--subrepos is
-    specified.  However, if you specify the full path of a file or
-    directory in a subrepo, it will be displayed even without
-    -S/--subrepos being specified.  Git and Subversion subrepositories
-    are currently silently ignored.
-
-:forget: forget currently only handles exact file matches in subrepos.
-    Git and Subversion subrepositories are currently silently ignored.
-
-:incoming: incoming does not recurse in subrepos unless -S/--subrepos
-    is specified. Git and Subversion subrepositories are currently
-    silently ignored.
-
-:outgoing: outgoing does not recurse in subrepos unless -S/--subrepos
-    is specified. Git and Subversion subrepositories are currently
-    silently ignored.
-
-:pull: pull is not recursive since it is not clear what to pull prior
-    to running :hg:`update`. Listing and retrieving all
-    subrepositories changes referenced by the parent repository pulled
-    changesets is expensive at best, impossible in the Subversion
-    case.
-
-:push: Mercurial will automatically push all subrepositories first
-    when the parent repository is being pushed. This ensures new
-    subrepository changes are available when referenced by top-level
-    repositories.  Push is a no-op for Subversion subrepositories.
-
-:serve: serve does not recurse into subrepositories unless
-    -S/--subrepos is specified.  Git and Subversion subrepositories
-    are currently silently ignored.
-
-:status: status does not recurse into subrepositories unless
-    -S/--subrepos is specified. Subrepository changes are displayed as
-    regular Mercurial changes on the subrepository
-    elements. Subversion subrepositories are currently silently
-    ignored.
-
-:remove: remove does not recurse into subrepositories unless
-    -S/--subrepos is specified.  However, if you specify a file or
-    directory path in a subrepo, it will be removed even without
-    -S/--subrepos.  Git and Subversion subrepositories are currently
-    silently ignored.
-
-:update: update restores the subrepos in the state they were
-    originally committed in target changeset. If the recorded
-    changeset is not available in the current subrepository, Mercurial
-    will pull it in first before updating.  This means that updating
-    can require network access when using subrepositories.
-
-Remapping Subrepositories Sources
-=================================
-
-A subrepository source location may change during a project life,
-invalidating references stored in the parent repository history. To
-fix this, rewriting rules can be defined in parent repository ``hgrc``
-file or in Mercurial configuration. See the ``[subpaths]`` section in
-hgrc(5) for more details.
-
--- a/mercurial/help/templates.txt	Wed Nov 20 19:07:02 2019 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,215 +0,0 @@
-Mercurial allows you to customize output of commands through
-templates. You can either pass in a template or select an existing
-template-style from the command line, via the --template option.
-
-You can customize output for any "log-like" command: log,
-outgoing, incoming, tip, parents, and heads.
-
-Some built-in styles are packaged with Mercurial. These can be listed
-with :hg:`log --template list`. Example usage::
-
-    $ hg log -r1.0::1.1 --template changelog
-
-A template is a piece of text, with markup to invoke variable
-expansion::
-
-    $ hg log -r1 --template "{node}\n"
-    b56ce7b07c52de7d5fd79fb89701ea538af65746
-
-Keywords
-========
-
-Strings in curly braces are called keywords. The availability of
-keywords depends on the exact context of the templater. These
-keywords are usually available for templating a log-like command:
-
-.. keywordsmarker
-
-The "date" keyword does not produce human-readable output. If you
-want to use a date in your output, you can use a filter to process
-it. Filters are functions which return a string based on the input
-variable. Be sure to use the stringify filter first when you're
-applying a string-input filter to a list-like input variable.
-You can also use a chain of filters to get the desired output::
-
-   $ hg tip --template "{date|isodate}\n"
-   2008-08-21 18:22 +0000
-
-Filters
-=======
-
-List of filters:
-
-.. filtersmarker
-
-Note that a filter is nothing more than a function call, i.e.
-``expr|filter`` is equivalent to ``filter(expr)``.
-
-Functions
-=========
-
-In addition to filters, there are some basic built-in functions:
-
-.. functionsmarker
-
-Operators
-=========
-
-We provide a limited set of infix arithmetic operations on integers::
-
-  + for addition
-  - for subtraction
-  * for multiplication
-  / for floor division (division rounded to integer nearest -infinity)
-
-Division fulfills the law x = x / y + mod(x, y).
-
-Also, for any expression that returns a list, there is a list operator::
-
-    expr % "{template}"
-
-As seen in the above example, ``{template}`` is interpreted as a template.
-To prevent it from being interpreted, you can use an escape character ``\{``
-or a raw string prefix, ``r'...'``.
-
-The dot operator can be used as a shorthand for accessing a sub item:
-
-- ``expr.member`` is roughly equivalent to ``expr % '{member}'`` if ``expr``
-  returns a non-list/dict. The returned value is not stringified.
-- ``dict.key`` is identical to ``get(dict, 'key')``.
-
-Aliases
-=======
-
-New keywords and functions can be defined in the ``templatealias`` section of
-a Mercurial configuration file::
-
-  <alias> = <definition>
-
-Arguments of the form `a1`, `a2`, etc. are substituted from the alias into
-the definition.
-
-For example,
-
-::
-
-  [templatealias]
-  r = rev
-  rn = "{r}:{node|short}"
-  leftpad(s, w) = pad(s, w, ' ', True)
-
-defines two symbol aliases, ``r`` and ``rn``, and a function alias
-``leftpad()``.
-
-It's also possible to specify complete template strings, using the
-``templates`` section. The syntax used is the general template string syntax.
-
-For example,
-
-::
-
-  [templates]
-  nodedate = "{node|short}: {date(date, "%Y-%m-%d")}\n"
-
-defines a template, ``nodedate``, which can be called like::
-
-  $ hg log -r . -Tnodedate
-
-A template defined in ``templates`` section can also be referenced from
-another template::
-
-  $ hg log -r . -T "{rev} {nodedate}"
-
-but be aware that the keywords cannot be overridden by templates. For example,
-a template defined as ``templates.rev`` cannot be referenced as ``{rev}``.
-
-A template defined in ``templates`` section may have sub templates which
-are inserted before/after/between items::
-
-  [templates]
-  myjson = ' {dict(rev, node|short)|json}'
-  myjson:docheader = '\{\n'
-  myjson:docfooter = '\n}\n'
-  myjson:separator = ',\n'
-
-Examples
-========
-
-Some sample command line templates:
-
-- Format lists, e.g. files::
-
-   $ hg log -r 0 --template "files:\n{files % '  {file}\n'}"
-
-- Join the list of files with a ", "::
-
-   $ hg log -r 0 --template "files: {join(files, ', ')}\n"
-
-- Join the list of files ending with ".py" with a ", "::
-
-   $ hg log -r 0 --template "pythonfiles: {join(files('**.py'), ', ')}\n"
-
-- Separate non-empty arguments by a " "::
-
-   $ hg log -r 0 --template "{separate(' ', node, bookmarks, tags}\n"
-
-- Modify each line of a commit description::
-
-   $ hg log --template "{splitlines(desc) % '**** {line}\n'}"
-
-- Format date::
-
-   $ hg log -r 0 --template "{date(date, '%Y')}\n"
-
-- Display date in UTC::
-
-   $ hg log -r 0 --template "{localdate(date, 'UTC')|date}\n"
-
-- Output the description set to a fill-width of 30::
-
-   $ hg log -r 0 --template "{fill(desc, 30)}"
-
-- Use a conditional to test for the default branch::
-
-   $ hg log -r 0 --template "{ifeq(branch, 'default', 'on the main branch',
-   'on branch {branch}')}\n"
-
-- Append a newline if not empty::
-
-   $ hg tip --template "{if(author, '{author}\n')}"
-
-- Label the output for use with the color extension::
-
-   $ hg log -r 0 --template "{label('changeset.{phase}', node|short)}\n"
-
-- Invert the firstline filter, i.e. everything but the first line::
-
-   $ hg log -r 0 --template "{sub(r'^.*\n?\n?', '', desc)}\n"
-
-- Display the contents of the 'extra' field, one per line::
-
-   $ hg log -r 0 --template "{join(extras, '\n')}\n"
-
-- Mark the active bookmark with '*'::
-
-   $ hg log --template "{bookmarks % '{bookmark}{ifeq(bookmark, active, '*')} '}\n"
-
-- Find the previous release candidate tag, the distance and changes since the tag::
-
-   $ hg log -r . --template "{latesttag('re:^.*-rc$') % '{tag}, {changes}, {distance}'}\n"
-
-- Mark the working copy parent with '@'::
-
-   $ hg log --template "{ifcontains(rev, revset('.'), '@')}\n"
-
-- Show details of parent revisions::
-
-   $ hg log --template "{revset('parents(%d)', rev) % '{desc|firstline}\n'}"
-
-- Show only commit descriptions that start with "template"::
-
-   $ hg log --template "{startswith('template', firstline(desc))}\n"
-
-- Print the first word of each line of a commit message::
-
-   $ hg log --template "{word(0, desc)}\n"
--- a/mercurial/help/urls.txt	Wed Nov 20 19:07:02 2019 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,66 +0,0 @@
-Valid URLs are of the form::
-
-  local/filesystem/path[#revision]
-  file://local/filesystem/path[#revision]
-  http://[user[:pass]@]host[:port]/[path][#revision]
-  https://[user[:pass]@]host[:port]/[path][#revision]
-  ssh://[user@]host[:port]/[path][#revision]
-
-Paths in the local filesystem can either point to Mercurial
-repositories or to bundle files (as created by :hg:`bundle` or
-:hg:`incoming --bundle`). See also :hg:`help paths`.
-
-An optional identifier after # indicates a particular branch, tag, or
-changeset to use from the remote repository. See also :hg:`help
-revisions`.
-
-Some features, such as pushing to http:// and https:// URLs are only
-possible if the feature is explicitly enabled on the remote Mercurial
-server.
-
-Note that the security of HTTPS URLs depends on proper configuration of
-web.cacerts.
-
-Some notes about using SSH with Mercurial:
-
-- SSH requires an accessible shell account on the destination machine
-  and a copy of hg in the remote path or specified with remotecmd.
-- path is relative to the remote user's home directory by default. Use
-  an extra slash at the start of a path to specify an absolute path::
-
-    ssh://example.com//tmp/repository
-
-- Mercurial doesn't use its own compression via SSH; the right thing
-  to do is to configure it in your ~/.ssh/config, e.g.::
-
-    Host *.mylocalnetwork.example.com
-      Compression no
-    Host *
-      Compression yes
-
-  Alternatively specify "ssh -C" as your ssh command in your
-  configuration file or with the --ssh command line option.
-
-These URLs can all be stored in your configuration file with path
-aliases under the [paths] section like so::
-
-  [paths]
-  alias1 = URL1
-  alias2 = URL2
-  ...
-
-You can then use the alias for any command that uses a URL (for
-example :hg:`pull alias1` will be treated as :hg:`pull URL1`).
-
-Two path aliases are special because they are used as defaults when
-you do not provide the URL to a command:
-
-default:
-  When you create a repository with hg clone, the clone command saves
-  the location of the source repository as the new repository's
-  'default' path. This is then used when you omit path from push- and
-  pull-like commands (including incoming and outgoing).
-
-default-push:
-  The push command will look for a path named 'default-push', and
-  prefer it over 'default' if both are defined.
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mercurial/helptext/bundlespec.txt	Fri Nov 22 21:42:04 2019 +0900
@@ -0,0 +1,84 @@
+Mercurial supports generating standalone "bundle" files that hold repository
+data. These "bundles" are typically saved locally and used later or exchanged
+between different repositories, possibly on different machines. Example
+commands using bundles are :hg:`bundle` and :hg:`unbundle`.
+
+Generation of bundle files is controlled by a "bundle specification"
+("bundlespec") string. This string tells the bundle generation process how
+to create the bundle.
+
+A "bundlespec" string is composed of the following elements:
+
+type
+    A string denoting the bundle format to use.
+
+compression
+    Denotes the compression engine to use compressing the raw bundle data.
+
+parameters
+    Arbitrary key-value parameters to further control bundle generation.
+
+A "bundlespec" string has the following formats:
+
+<type>
+    The literal bundle format string is used.
+
+<compression>-<type>
+    The compression engine and format are delimited by a hyphen (``-``).
+
+Optional parameters follow the ``<type>``. Parameters are URI escaped
+``key=value`` pairs. Each pair is delimited by a semicolon (``;``). The
+first parameter begins after a ``;`` immediately following the ``<type>``
+value.
+
+Available Types
+===============
+
+The following bundle <type> strings are available:
+
+v1
+    Produces a legacy "changegroup" version 1 bundle.
+
+    This format is compatible with nearly all Mercurial clients because it is
+    the oldest. However, it has some limitations, which is why it is no longer
+    the default for new repositories.
+
+    ``v1`` bundles can be used with modern repositories using the "generaldelta"
+    storage format. However, it may take longer to produce the bundle and the
+    resulting bundle may be significantly larger than a ``v2`` bundle.
+
+    ``v1`` bundles can only use the ``gzip``, ``bzip2``, and ``none`` compression
+    formats.
+
+v2
+    Produces a version 2 bundle.
+
+    Version 2 bundles are an extensible format that can store additional
+    repository data (such as bookmarks and phases information) and they can
+    store data more efficiently, resulting in smaller bundles.
+
+    Version 2 bundles can also use modern compression engines, such as
+    ``zstd``, making them faster to compress and often smaller.
+
+Available Compression Engines
+=============================
+
+The following bundle <compression> engines can be used:
+
+.. bundlecompressionmarker
+
+Examples
+========
+
+``v2``
+    Produce a ``v2`` bundle using default options, including compression.
+
+``none-v1``
+    Produce a ``v1`` bundle with no compression.
+
+``zstd-v2``
+    Produce a ``v2`` bundle with zstandard compression using default
+    settings.
+
+``zstd-v1``
+    This errors because ``zstd`` is not supported for ``v1`` types.
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mercurial/helptext/color.txt	Fri Nov 22 21:42:04 2019 +0900
@@ -0,0 +1,149 @@
+Mercurial colorizes output from several commands.
+
+For example, the diff command shows additions in green and deletions
+in red, while the status command shows modified files in magenta. Many
+other commands have analogous colors. It is possible to customize
+these colors.
+
+To enable color (default) whenever possible use::
+
+  [ui]
+  color = yes
+
+To disable color use::
+
+  [ui]
+  color = no
+
+See :hg:`help config.ui.color` for details.
+
+.. container:: windows
+
+  The default pager on Windows does not support color, so enabling the pager
+  will effectively disable color.  See :hg:`help config.ui.paginate` to disable
+  the pager.  Alternately, MSYS and Cygwin shells provide `less` as a pager,
+  which can be configured to support ANSI color mode.  Windows 10 natively
+  supports ANSI color mode.
+
+Mode
+====
+
+Mercurial can use various systems to display color. The supported modes are
+``ansi``, ``win32``, and ``terminfo``.  See :hg:`help config.color` for details
+about how to control the mode.
+
+Effects
+=======
+
+Other effects in addition to color, like bold and underlined text, are
+also available. By default, the terminfo database is used to find the
+terminal codes used to change color and effect.  If terminfo is not
+available, then effects are rendered with the ECMA-48 SGR control
+function (aka ANSI escape codes).
+
+The available effects in terminfo mode are 'blink', 'bold', 'dim',
+'inverse', 'invisible', 'italic', 'standout', and 'underline'; in
+ECMA-48 mode, the options are 'bold', 'inverse', 'italic', and
+'underline'.  How each is rendered depends on the terminal emulator.
+Some may not be available for a given terminal type, and will be
+silently ignored.
+
+If the terminfo entry for your terminal is missing codes for an effect
+or has the wrong codes, you can add or override those codes in your
+configuration::
+
+  [color]
+  terminfo.dim = \E[2m
+
+where '\E' is substituted with an escape character.
+
+Labels
+======
+
+Text receives color effects depending on the labels that it has. Many
+default Mercurial commands emit labelled text. You can also define
+your own labels in templates using the label function, see :hg:`help
+templates`. A single portion of text may have more than one label. In
+that case, effects given to the last label will override any other
+effects. This includes the special "none" effect, which nullifies
+other effects.
+
+Labels are normally invisible. In order to see these labels and their
+position in the text, use the global --color=debug option. The same
+anchor text may be associated to multiple labels, e.g.
+
+  [log.changeset changeset.secret|changeset:   22611:6f0a53c8f587]
+
+The following are the default effects for some default labels. Default
+effects may be overridden from your configuration file::
+
+  [color]
+  status.modified = blue bold underline red_background
+  status.added = green bold
+  status.removed = red bold blue_background
+  status.deleted = cyan bold underline
+  status.unknown = magenta bold underline
+  status.ignored = black bold
+
+  # 'none' turns off all effects
+  status.clean = none
+  status.copied = none
+
+  qseries.applied = blue bold underline
+  qseries.unapplied = black bold
+  qseries.missing = red bold
+
+  diff.diffline = bold
+  diff.extended = cyan bold
+  diff.file_a = red bold
+  diff.file_b = green bold
+  diff.hunk = magenta
+  diff.deleted = red
+  diff.inserted = green
+  diff.changed = white
+  diff.tab =
+  diff.trailingwhitespace = bold red_background
+
+  # Blank so it inherits the style of the surrounding label
+  changeset.public =
+  changeset.draft =
+  changeset.secret =
+
+  resolve.unresolved = red bold
+  resolve.resolved = green bold
+
+  bookmarks.active = green
+
+  branches.active = none
+  branches.closed = black bold
+  branches.current = green
+  branches.inactive = none
+
+  tags.normal = green
+  tags.local = black bold
+
+  rebase.rebased = blue
+  rebase.remaining = red bold
+
+  shelve.age = cyan
+  shelve.newest = green bold
+  shelve.name = blue bold
+
+  histedit.remaining = red bold
+
+Custom colors
+=============
+
+Because there are only eight standard colors, Mercurial allows you
+to define color names for other color slots which might be available
+for your terminal type, assuming terminfo mode.  For instance::
+
+  color.brightblue = 12
+  color.pink = 207
+  color.orange = 202
+
+to set 'brightblue' to color slot 12 (useful for 16 color terminals
+that have brighter colors defined in the upper eight) and, 'pink' and
+'orange' to colors in 256-color xterm's default color cube.  These
+defined colors may then be used as any of the pre-defined eight,
+including appending '_background' to set the background to that color.
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mercurial/helptext/common.txt	Fri Nov 22 21:42:04 2019 +0900
@@ -0,0 +1,8 @@
+.. Common link and substitution definitions.
+
+.. |hg(1)| replace:: **hg**\ (1)
+.. _hg(1): hg.1.html
+.. |hgrc(5)| replace:: **hgrc**\ (5)
+.. _hgrc(5): hgrc.5.html
+.. |hgignore(5)| replace:: **hgignore**\ (5)
+.. _hgignore(5): hgignore.5.html
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mercurial/helptext/config.txt	Fri Nov 22 21:42:04 2019 +0900
@@ -0,0 +1,2870 @@
+The Mercurial system uses a set of configuration files to control
+aspects of its behavior.
+
+Troubleshooting
+===============
+
+If you're having problems with your configuration,
+:hg:`config --debug` can help you understand what is introducing
+a setting into your environment.
+
+See :hg:`help config.syntax` and :hg:`help config.files`
+for information about how and where to override things.
+
+Structure
+=========
+
+The configuration files use a simple ini-file format. A configuration
+file consists of sections, led by a ``[section]`` header and followed
+by ``name = value`` entries::
+
+  [ui]
+  username = Firstname Lastname <firstname.lastname@example.net>
+  verbose = True
+
+The above entries will be referred to as ``ui.username`` and
+``ui.verbose``, respectively. See :hg:`help config.syntax`.
+
+Files
+=====
+
+Mercurial reads configuration data from several files, if they exist.
+These files do not exist by default and you will have to create the
+appropriate configuration files yourself:
+
+Local configuration is put into the per-repository ``<repo>/.hg/hgrc`` file.
+
+Global configuration like the username setting is typically put into:
+
+.. container:: windows
+
+  - ``%USERPROFILE%\mercurial.ini`` (on Windows)
+
+.. container:: unix.plan9
+
+  - ``$HOME/.hgrc`` (on Unix, Plan9)
+
+The names of these files depend on the system on which Mercurial is
+installed. ``*.rc`` files from a single directory are read in
+alphabetical order, later ones overriding earlier ones. Where multiple
+paths are given below, settings from earlier paths override later
+ones.
+
+.. container:: verbose.unix
+
+  On Unix, the following files are consulted:
+
+  - ``<repo>/.hg/hgrc`` (per-repository)
+  - ``$HOME/.hgrc`` (per-user)
+  - ``${XDG_CONFIG_HOME:-$HOME/.config}/hg/hgrc`` (per-user)
+  - ``<install-root>/etc/mercurial/hgrc`` (per-installation)
+  - ``<install-root>/etc/mercurial/hgrc.d/*.rc`` (per-installation)
+  - ``/etc/mercurial/hgrc`` (per-system)
+  - ``/etc/mercurial/hgrc.d/*.rc`` (per-system)
+  - ``<internal>/*.rc`` (defaults)
+
+.. container:: verbose.windows
+
+  On Windows, the following files are consulted:
+
+  - ``<repo>/.hg/hgrc`` (per-repository)
+  - ``%USERPROFILE%\.hgrc`` (per-user)
+  - ``%USERPROFILE%\Mercurial.ini`` (per-user)
+  - ``%HOME%\.hgrc`` (per-user)
+  - ``%HOME%\Mercurial.ini`` (per-user)
+  - ``HKEY_LOCAL_MACHINE\SOFTWARE\Mercurial`` (per-installation)
+  - ``<install-dir>\hgrc.d\*.rc`` (per-installation)
+  - ``<install-dir>\Mercurial.ini`` (per-installation)
+  - ``<internal>/*.rc`` (defaults)
+
+  .. note::
+
+   The registry key ``HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Mercurial``
+   is used when running 32-bit Python on 64-bit Windows.
+
+.. container:: windows
+
+  On Windows 9x, ``%HOME%`` is replaced by ``%APPDATA%``.
+
+.. container:: verbose.plan9
+
+  On Plan9, the following files are consulted:
+
+  - ``<repo>/.hg/hgrc`` (per-repository)
+  - ``$home/lib/hgrc`` (per-user)
+  - ``<install-root>/lib/mercurial/hgrc`` (per-installation)
+  - ``<install-root>/lib/mercurial/hgrc.d/*.rc`` (per-installation)
+  - ``/lib/mercurial/hgrc`` (per-system)
+  - ``/lib/mercurial/hgrc.d/*.rc`` (per-system)
+  - ``<internal>/*.rc`` (defaults)
+
+Per-repository configuration options only apply in a
+particular repository. This file is not version-controlled, and
+will not get transferred during a "clone" operation. Options in
+this file override options in all other configuration files.
+
+.. container:: unix.plan9
+
+  On Plan 9 and Unix, most of this file will be ignored if it doesn't
+  belong to a trusted user or to a trusted group. See
+  :hg:`help config.trusted` for more details.
+
+Per-user configuration file(s) are for the user running Mercurial.  Options
+in these files apply to all Mercurial commands executed by this user in any
+directory. Options in these files override per-system and per-installation
+options.
+
+Per-installation configuration files are searched for in the
+directory where Mercurial is installed. ``<install-root>`` is the
+parent directory of the **hg** executable (or symlink) being run.
+
+.. container:: unix.plan9
+
+  For example, if installed in ``/shared/tools/bin/hg``, Mercurial
+  will look in ``/shared/tools/etc/mercurial/hgrc``. Options in these
+  files apply to all Mercurial commands executed by any user in any
+  directory.
+
+Per-installation configuration files are for the system on
+which Mercurial is running. Options in these files apply to all
+Mercurial commands executed by any user in any directory. Registry
+keys contain PATH-like strings, every part of which must reference
+a ``Mercurial.ini`` file or be a directory where ``*.rc`` files will
+be read.  Mercurial checks each of these locations in the specified
+order until one or more configuration files are detected.
+
+Per-system configuration files are for the system on which Mercurial
+is running. Options in these files apply to all Mercurial commands
+executed by any user in any directory. Options in these files
+override per-installation options.
+
+Mercurial comes with some default configuration. The default configuration
+files are installed with Mercurial and will be overwritten on upgrades. Default
+configuration files should never be edited by users or administrators but can
+be overridden in other configuration files. So far the directory only contains
+merge tool configuration but packagers can also put other default configuration
+there.
+
+Syntax
+======
+
+A configuration file consists of sections, led by a ``[section]`` header
+and followed by ``name = value`` entries (sometimes called
+``configuration keys``)::
+
+    [spam]
+    eggs=ham
+    green=
+       eggs
+
+Each line contains one entry. If the lines that follow are indented,
+they are treated as continuations of that entry. Leading whitespace is
+removed from values. Empty lines are skipped. Lines beginning with
+``#`` or ``;`` are ignored and may be used to provide comments.
+
+Configuration keys can be set multiple times, in which case Mercurial
+will use the value that was configured last. As an example::
+
+    [spam]
+    eggs=large
+    ham=serrano
+    eggs=small
+
+This would set the configuration key named ``eggs`` to ``small``.
+
+It is also possible to define a section multiple times. A section can
+be redefined on the same and/or on different configuration files. For
+example::
+
+    [foo]
+    eggs=large
+    ham=serrano
+    eggs=small
+
+    [bar]
+    eggs=ham
+    green=
+       eggs
+
+    [foo]
+    ham=prosciutto
+    eggs=medium
+    bread=toasted
+
+This would set the ``eggs``, ``ham``, and ``bread`` configuration keys
+of the ``foo`` section to ``medium``, ``prosciutto``, and ``toasted``,
+respectively. As you can see there only thing that matters is the last
+value that was set for each of the configuration keys.
+
+If a configuration key is set multiple times in different
+configuration files the final value will depend on the order in which
+the different configuration files are read, with settings from earlier
+paths overriding later ones as described on the ``Files`` section
+above.
+
+A line of the form ``%include file`` will include ``file`` into the
+current configuration file. The inclusion is recursive, which means
+that included files can include other files. Filenames are relative to
+the configuration file in which the ``%include`` directive is found.
+Environment variables and ``~user`` constructs are expanded in
+``file``. This lets you do something like::
+
+  %include ~/.hgrc.d/$HOST.rc
+
+to include a different configuration file on each computer you use.
+
+A line with ``%unset name`` will remove ``name`` from the current
+section, if it has been set previously.
+
+The values are either free-form text strings, lists of text strings,
+or Boolean values. Boolean values can be set to true using any of "1",
+"yes", "true", or "on" and to false using "0", "no", "false", or "off"
+(all case insensitive).
+
+List values are separated by whitespace or comma, except when values are
+placed in double quotation marks::
+
+  allow_read = "John Doe, PhD", brian, betty
+
+Quotation marks can be escaped by prefixing them with a backslash. Only
+quotation marks at the beginning of a word is counted as a quotation
+(e.g., ``foo"bar baz`` is the list of ``foo"bar`` and ``baz``).
+
+Sections
+========
+
+This section describes the different sections that may appear in a
+Mercurial configuration file, the purpose of each section, its possible
+keys, and their possible values.
+
+``alias``
+---------
+
+Defines command aliases.
+
+Aliases allow you to define your own commands in terms of other
+commands (or aliases), optionally including arguments. Positional
+arguments in the form of ``$1``, ``$2``, etc. in the alias definition
+are expanded by Mercurial before execution. Positional arguments not
+already used by ``$N`` in the definition are put at the end of the
+command to be executed.
+
+Alias definitions consist of lines of the form::
+
+    <alias> = <command> [<argument>]...
+
+For example, this definition::
+
+    latest = log --limit 5
+
+creates a new command ``latest`` that shows only the five most recent
+changesets. You can define subsequent aliases using earlier ones::
+
+    stable5 = latest -b stable
+
+.. note::
+
+   It is possible to create aliases with the same names as
+   existing commands, which will then override the original
+   definitions. This is almost always a bad idea!
+
+An alias can start with an exclamation point (``!``) to make it a
+shell alias. A shell alias is executed with the shell and will let you
+run arbitrary commands. As an example, ::
+
+   echo = !echo $@
+
+will let you do ``hg echo foo`` to have ``foo`` printed in your
+terminal. A better example might be::
+
+   purge = !$HG status --no-status --unknown -0 re: | xargs -0 rm -f
+
+which will make ``hg purge`` delete all unknown files in the
+repository in the same manner as the purge extension.
+
+Positional arguments like ``$1``, ``$2``, etc. in the alias definition
+expand to the command arguments. Unmatched arguments are
+removed. ``$0`` expands to the alias name and ``$@`` expands to all
+arguments separated by a space. ``"$@"`` (with quotes) expands to all
+arguments quoted individually and separated by a space. These expansions
+happen before the command is passed to the shell.
+
+Shell aliases are executed in an environment where ``$HG`` expands to
+the path of the Mercurial that was used to execute the alias. This is
+useful when you want to call further Mercurial commands in a shell
+alias, as was done above for the purge alias. In addition,
+``$HG_ARGS`` expands to the arguments given to Mercurial. In the ``hg
+echo foo`` call above, ``$HG_ARGS`` would expand to ``echo foo``.
+
+.. note::
+
+   Some global configuration options such as ``-R`` are
+   processed before shell aliases and will thus not be passed to
+   aliases.
+
+
+``annotate``
+------------
+
+Settings used when displaying file annotations. All values are
+Booleans and default to False. See :hg:`help config.diff` for
+related options for the diff command.
+
+``ignorews``
+    Ignore white space when comparing lines.
+
+``ignorewseol``
+    Ignore white space at the end of a line when comparing lines.
+
+``ignorewsamount``
+    Ignore changes in the amount of white space.
+
+``ignoreblanklines``
+    Ignore changes whose lines are all blank.
+
+
+``auth``
+--------
+
+Authentication credentials and other authentication-like configuration
+for HTTP connections. This section allows you to store usernames and
+passwords for use when logging *into* HTTP servers. See
+:hg:`help config.web` if you want to configure *who* can login to
+your HTTP server.
+
+The following options apply to all hosts.
+
+``cookiefile``
+    Path to a file containing HTTP cookie lines. Cookies matching a
+    host will be sent automatically.
+
+    The file format uses the Mozilla cookies.txt format, which defines cookies
+    on their own lines. Each line contains 7 fields delimited by the tab
+    character (domain, is_domain_cookie, path, is_secure, expires, name,
+    value). For more info, do an Internet search for "Netscape cookies.txt
+    format."
+
+    Note: the cookies parser does not handle port numbers on domains. You
+    will need to remove ports from the domain for the cookie to be recognized.
+    This could result in a cookie being disclosed to an unwanted server.
+
+    The cookies file is read-only.
+
+Other options in this section are grouped by name and have the following
+format::
+
+    <name>.<argument> = <value>
+
+where ``<name>`` is used to group arguments into authentication
+entries. Example::
+
+    foo.prefix = hg.intevation.de/mercurial
+    foo.username = foo
+    foo.password = bar
+    foo.schemes = http https
+
+    bar.prefix = secure.example.org
+    bar.key = path/to/file.key
+    bar.cert = path/to/file.cert
+    bar.schemes = https
+
+Supported arguments:
+
+``prefix``
+    Either ``*`` or a URI prefix with or without the scheme part.
+    The authentication entry with the longest matching prefix is used
+    (where ``*`` matches everything and counts as a match of length
+    1). If the prefix doesn't include a scheme, the match is performed
+    against the URI with its scheme stripped as well, and the schemes
+    argument, q.v., is then subsequently consulted.
+
+``username``
+    Optional. Username to authenticate with. If not given, and the
+    remote site requires basic or digest authentication, the user will
+    be prompted for it. Environment variables are expanded in the
+    username letting you do ``foo.username = $USER``. If the URI
+    includes a username, only ``[auth]`` entries with a matching
+    username or without a username will be considered.
+
+``password``
+    Optional. Password to authenticate with. If not given, and the
+    remote site requires basic or digest authentication, the user
+    will be prompted for it.
+
+``key``
+    Optional. PEM encoded client certificate key file. Environment
+    variables are expanded in the filename.
+
+``cert``
+    Optional. PEM encoded client certificate chain file. Environment
+    variables are expanded in the filename.
+
+``schemes``
+    Optional. Space separated list of URI schemes to use this
+    authentication entry with. Only used if the prefix doesn't include
+    a scheme. Supported schemes are http and https. They will match
+    static-http and static-https respectively, as well.
+    (default: https)
+
+If no suitable authentication entry is found, the user is prompted
+for credentials as usual if required by the remote.
+
+``color``
+---------
+
+Configure the Mercurial color mode. For details about how to define your custom
+effect and style see :hg:`help color`.
+
+``mode``
+    String: control the method used to output color. One of ``auto``, ``ansi``,
+    ``win32``, ``terminfo`` or ``debug``. In auto mode, Mercurial will
+    use ANSI mode by default (or win32 mode prior to Windows 10) if it detects a
+    terminal. Any invalid value will disable color.
+
+``pagermode``
+    String: optional override of ``color.mode`` used with pager.
+
+    On some systems, terminfo mode may cause problems when using
+    color with ``less -R`` as a pager program. less with the -R option
+    will only display ECMA-48 color codes, and terminfo mode may sometimes
+    emit codes that less doesn't understand. You can work around this by
+    either using ansi mode (or auto mode), or by using less -r (which will
+    pass through all terminal control codes, not just color control
+    codes).
+
+    On some systems (such as MSYS in Windows), the terminal may support
+    a different color mode than the pager program.
+
+``commands``
+------------
+
+``commit.post-status``
+    Show status of files in the working directory after successful commit.
+    (default: False)
+
+``push.require-revs``
+    Require revisions to push be specified using one or more mechanisms such as
+    specifying them positionally on the command line, using ``-r``, ``-b``,
+    and/or ``-B`` on the command line, or using ``paths.<path>:pushrev`` in the
+    configuration. If this is enabled and revisions are not specified, the
+    command aborts.
+    (default: False)
+
+``resolve.confirm``
+    Confirm before performing action if no filename is passed.
+    (default: False)
+
+``resolve.explicit-re-merge``
+    Require uses of ``hg resolve`` to specify which action it should perform,
+    instead of re-merging files by default.
+    (default: False)
+
+``resolve.mark-check``
+    Determines what level of checking :hg:`resolve --mark` will perform before
+    marking files as resolved. Valid values are ``none`, ``warn``, and
+    ``abort``. ``warn`` will output a warning listing the file(s) that still
+    have conflict markers in them, but will still mark everything resolved.
+    ``abort`` will output the same warning but will not mark things as resolved.
+    If --all is passed and this is set to ``abort``, only a warning will be
+    shown (an error will not be raised).
+    (default: ``none``)
+
+``status.relative``
+    Make paths in :hg:`status` output relative to the current directory.
+    (default: False)
+
+``status.terse``
+    Default value for the --terse flag, which condenses status output.
+    (default: empty)
+
+``update.check``
+    Determines what level of checking :hg:`update` will perform before moving
+    to a destination revision. Valid values are ``abort``, ``none``,
+    ``linear``, and ``noconflict``. ``abort`` always fails if the working
+    directory has uncommitted changes. ``none`` performs no checking, and may
+    result in a merge with uncommitted changes. ``linear`` allows any update
+    as long as it follows a straight line in the revision history, and may
+    trigger a merge with uncommitted changes. ``noconflict`` will allow any
+    update which would not trigger a merge with uncommitted changes, if any
+    are present.
+    (default: ``linear``)
+
+``update.requiredest``
+    Require that the user pass a destination when running :hg:`update`.
+    For example, :hg:`update .::` will be allowed, but a plain :hg:`update`
+    will be disallowed.
+    (default: False)
+
+``committemplate``
+------------------
+
+``changeset``
+    String: configuration in this section is used as the template to
+    customize the text shown in the editor when committing.
+
+In addition to pre-defined template keywords, commit log specific one
+below can be used for customization:
+
+``extramsg``
+    String: Extra message (typically 'Leave message empty to abort
+    commit.'). This may be changed by some commands or extensions.
+
+For example, the template configuration below shows as same text as
+one shown by default::
+
+    [committemplate]
+    changeset = {desc}\n\n
+        HG: Enter commit message.  Lines beginning with 'HG:' are removed.
+        HG: {extramsg}
+        HG: --
+        HG: user: {author}\n{ifeq(p2rev, "-1", "",
+       "HG: branch merge\n")
+       }HG: branch '{branch}'\n{if(activebookmark,
+       "HG: bookmark '{activebookmark}'\n")   }{subrepos %
+       "HG: subrepo {subrepo}\n"              }{file_adds %
+       "HG: added {file}\n"                   }{file_mods %
+       "HG: changed {file}\n"                 }{file_dels %
+       "HG: removed {file}\n"                 }{if(files, "",
+       "HG: no files changed\n")}
+
+``diff()``
+    String: show the diff (see :hg:`help templates` for detail)
+
+Sometimes it is helpful to show the diff of the changeset in the editor without
+having to prefix 'HG: ' to each line so that highlighting works correctly. For
+this, Mercurial provides a special string which will ignore everything below
+it::
+
+     HG: ------------------------ >8 ------------------------
+
+For example, the template configuration below will show the diff below the
+extra message::
+
+    [committemplate]
+    changeset = {desc}\n\n
+        HG: Enter commit message.  Lines beginning with 'HG:' are removed.
+        HG: {extramsg}
+        HG: ------------------------ >8 ------------------------
+        HG: Do not touch the line above.
+        HG: Everything below will be removed.
+        {diff()}
+
+.. note::
+
+   For some problematic encodings (see :hg:`help win32mbcs` for
+   detail), this customization should be configured carefully, to
+   avoid showing broken characters.
+
+   For example, if a multibyte character ending with backslash (0x5c) is
+   followed by the ASCII character 'n' in the customized template,
+   the sequence of backslash and 'n' is treated as line-feed unexpectedly
+   (and the multibyte character is broken, too).
+
+Customized template is used for commands below (``--edit`` may be
+required):
+
+- :hg:`backout`
+- :hg:`commit`
+- :hg:`fetch` (for merge commit only)
+- :hg:`graft`
+- :hg:`histedit`
+- :hg:`import`
+- :hg:`qfold`, :hg:`qnew` and :hg:`qrefresh`
+- :hg:`rebase`
+- :hg:`shelve`
+- :hg:`sign`
+- :hg:`tag`
+- :hg:`transplant`
+
+Configuring items below instead of ``changeset`` allows showing
+customized message only for specific actions, or showing different
+messages for each action.
+
+- ``changeset.backout`` for :hg:`backout`
+- ``changeset.commit.amend.merge`` for :hg:`commit --amend` on merges
+- ``changeset.commit.amend.normal`` for :hg:`commit --amend` on other
+- ``changeset.commit.normal.merge`` for :hg:`commit` on merges
+- ``changeset.commit.normal.normal`` for :hg:`commit` on other
+- ``changeset.fetch`` for :hg:`fetch` (impling merge commit)
+- ``changeset.gpg.sign`` for :hg:`sign`
+- ``changeset.graft`` for :hg:`graft`
+- ``changeset.histedit.edit`` for ``edit`` of :hg:`histedit`
+- ``changeset.histedit.fold`` for ``fold`` of :hg:`histedit`
+- ``changeset.histedit.mess`` for ``mess`` of :hg:`histedit`
+- ``changeset.histedit.pick`` for ``pick`` of :hg:`histedit`
+- ``changeset.import.bypass`` for :hg:`import --bypass`
+- ``changeset.import.normal.merge`` for :hg:`import` on merges
+- ``changeset.import.normal.normal`` for :hg:`import` on other
+- ``changeset.mq.qnew`` for :hg:`qnew`
+- ``changeset.mq.qfold`` for :hg:`qfold`
+- ``changeset.mq.qrefresh`` for :hg:`qrefresh`
+- ``changeset.rebase.collapse`` for :hg:`rebase --collapse`
+- ``changeset.rebase.merge`` for :hg:`rebase` on merges
+- ``changeset.rebase.normal`` for :hg:`rebase` on other
+- ``changeset.shelve.shelve`` for :hg:`shelve`
+- ``changeset.tag.add`` for :hg:`tag` without ``--remove``
+- ``changeset.tag.remove`` for :hg:`tag --remove`
+- ``changeset.transplant.merge`` for :hg:`transplant` on merges
+- ``changeset.transplant.normal`` for :hg:`transplant` on other
+
+These dot-separated lists of names are treated as hierarchical ones.
+For example, ``changeset.tag.remove`` customizes the commit message
+only for :hg:`tag --remove`, but ``changeset.tag`` customizes the
+commit message for :hg:`tag` regardless of ``--remove`` option.
+
+When the external editor is invoked for a commit, the corresponding
+dot-separated list of names without the ``changeset.`` prefix
+(e.g. ``commit.normal.normal``) is in the ``HGEDITFORM`` environment
+variable.
+
+In this section, items other than ``changeset`` can be referred from
+others. For example, the configuration to list committed files up
+below can be referred as ``{listupfiles}``::
+
+    [committemplate]
+    listupfiles = {file_adds %
+       "HG: added {file}\n"     }{file_mods %
+       "HG: changed {file}\n"   }{file_dels %
+       "HG: removed {file}\n"   }{if(files, "",
+       "HG: no files changed\n")}
+
+``decode/encode``
+-----------------
+
+Filters for transforming files on checkout/checkin. This would
+typically be used for newline processing or other
+localization/canonicalization of files.
+
+Filters consist of a filter pattern followed by a filter command.
+Filter patterns are globs by default, rooted at the repository root.
+For example, to match any file ending in ``.txt`` in the root
+directory only, use the pattern ``*.txt``. To match any file ending
+in ``.c`` anywhere in the repository, use the pattern ``**.c``.
+For each file only the first matching filter applies.
+
+The filter command can start with a specifier, either ``pipe:`` or
+``tempfile:``. If no specifier is given, ``pipe:`` is used by default.
+
+A ``pipe:`` command must accept data on stdin and return the transformed
+data on stdout.
+
+Pipe example::
+
+  [encode]
+  # uncompress gzip files on checkin to improve delta compression
+  # note: not necessarily a good idea, just an example
+  *.gz = pipe: gunzip
+
+  [decode]
+  # recompress gzip files when writing them to the working dir (we
+  # can safely omit "pipe:", because it's the default)
+  *.gz = gzip
+
+A ``tempfile:`` command is a template. The string ``INFILE`` is replaced
+with the name of a temporary file that contains the data to be
+filtered by the command. The string ``OUTFILE`` is replaced with the name
+of an empty temporary file, where the filtered data must be written by
+the command.
+
+.. container:: windows
+
+   .. note::
+
+     The tempfile mechanism is recommended for Windows systems,
+     where the standard shell I/O redirection operators often have
+     strange effects and may corrupt the contents of your files.
+
+This filter mechanism is used internally by the ``eol`` extension to
+translate line ending characters between Windows (CRLF) and Unix (LF)
+format. We suggest you use the ``eol`` extension for convenience.
+
+
+``defaults``
+------------
+
+(defaults are deprecated. Don't use them. Use aliases instead.)
+
+Use the ``[defaults]`` section to define command defaults, i.e. the
+default options/arguments to pass to the specified commands.
+
+The following example makes :hg:`log` run in verbose mode, and
+:hg:`status` show only the modified files, by default::
+
+  [defaults]
+  log = -v
+  status = -m
+
+The actual commands, instead of their aliases, must be used when
+defining command defaults. The command defaults will also be applied
+to the aliases of the commands defined.
+
+
+``diff``
+--------
+
+Settings used when displaying diffs. Everything except for ``unified``
+is a Boolean and defaults to False. See :hg:`help config.annotate`
+for related options for the annotate command.
+
+``git``
+    Use git extended diff format.
+
+``nobinary``
+    Omit git binary patches.
+
+``nodates``
+    Don't include dates in diff headers.
+
+``noprefix``
+    Omit 'a/' and 'b/' prefixes from filenames. Ignored in plain mode.
+
+``showfunc``
+    Show which function each change is in.
+
+``ignorews``
+    Ignore white space when comparing lines.
+
+``ignorewsamount``
+    Ignore changes in the amount of white space.
+
+``ignoreblanklines``
+    Ignore changes whose lines are all blank.
+
+``unified``
+    Number of lines of context to show.
+
+``word-diff``
+    Highlight changed words.
+
+``email``
+---------
+
+Settings for extensions that send email messages.
+
+``from``
+    Optional. Email address to use in "From" header and SMTP envelope
+    of outgoing messages.
+
+``to``
+    Optional. Comma-separated list of recipients' email addresses.
+
+``cc``
+    Optional. Comma-separated list of carbon copy recipients'
+    email addresses.
+
+``bcc``
+    Optional. Comma-separated list of blind carbon copy recipients'
+    email addresses.
+
+``method``
+    Optional. Method to use to send email messages. If value is ``smtp``
+    (default), use SMTP (see the ``[smtp]`` section for configuration).
+    Otherwise, use as name of program to run that acts like sendmail
+    (takes ``-f`` option for sender, list of recipients on command line,
+    message on stdin). Normally, setting this to ``sendmail`` or
+    ``/usr/sbin/sendmail`` is enough to use sendmail to send messages.
+
+``charsets``
+    Optional. Comma-separated list of character sets considered
+    convenient for recipients. Addresses, headers, and parts not
+    containing patches of outgoing messages will be encoded in the
+    first character set to which conversion from local encoding
+    (``$HGENCODING``, ``ui.fallbackencoding``) succeeds. If correct
+    conversion fails, the text in question is sent as is.
+    (default: '')
+
+    Order of outgoing email character sets:
+
+    1. ``us-ascii``: always first, regardless of settings
+    2. ``email.charsets``: in order given by user
+    3. ``ui.fallbackencoding``: if not in email.charsets
+    4. ``$HGENCODING``: if not in email.charsets
+    5. ``utf-8``: always last, regardless of settings
+
+Email example::
+
+  [email]
+  from = Joseph User <joe.user@example.com>
+  method = /usr/sbin/sendmail
+  # charsets for western Europeans
+  # us-ascii, utf-8 omitted, as they are tried first and last
+  charsets = iso-8859-1, iso-8859-15, windows-1252
+
+
+``extensions``
+--------------
+
+Mercurial has an extension mechanism for adding new features. To
+enable an extension, create an entry for it in this section.
+
+If you know that the extension is already in Python's search path,
+you can give the name of the module, followed by ``=``, with nothing
+after the ``=``.
+
+Otherwise, give a name that you choose, followed by ``=``, followed by
+the path to the ``.py`` file (including the file name extension) that
+defines the extension.
+
+To explicitly disable an extension that is enabled in an hgrc of
+broader scope, prepend its path with ``!``, as in ``foo = !/ext/path``
+or ``foo = !`` when path is not supplied.
+
+Example for ``~/.hgrc``::
+
+  [extensions]
+  # (the churn extension will get loaded from Mercurial's path)
+  churn =
+  # (this extension will get loaded from the file specified)
+  myfeature = ~/.hgext/myfeature.py
+
+
+``format``
+----------
+
+Configuration that controls the repository format. Newer format options are more
+powerful but incompatible with some older versions of Mercurial. Format options
+are considered at repository initialization only. You need to make a new clone
+for config change to be taken into account.
+
+For more details about repository format and version compatibility, see
+https://www.mercurial-scm.org/wiki/MissingRequirement
+
+``usegeneraldelta``
+    Enable or disable the "generaldelta" repository format which improves
+    repository compression by allowing "revlog" to store delta against arbitrary
+    revision instead of the previous stored one. This provides significant
+    improvement for repositories with branches.
+
+    Repositories with this on-disk format require Mercurial version 1.9.
+
+    Enabled by default.
+
+``dotencode``
+    Enable or disable the "dotencode" repository format which enhances
+    the "fncache" repository format (which has to be enabled to use
+    dotencode) to avoid issues with filenames starting with ._ on
+    Mac OS X and spaces on Windows.
+
+    Repositories with this on-disk format require Mercurial version 1.7.
+
+    Enabled by default.
+
+``usefncache``
+    Enable or disable the "fncache" repository format which enhances
+    the "store" repository format (which has to be enabled to use
+    fncache) to allow longer filenames and avoids using Windows
+    reserved names, e.g. "nul".
+
+    Repositories with this on-disk format require Mercurial version 1.1.
+
+    Enabled by default.
+
+``usestore``
+    Enable or disable the "store" repository format which improves
+    compatibility with systems that fold case or otherwise mangle
+    filenames. Disabling this option will allow you to store longer filenames
+    in some situations at the expense of compatibility.
+
+    Repositories with this on-disk format require Mercurial version 0.9.4.
+
+    Enabled by default.
+
+``sparse-revlog``
+    Enable or disable the ``sparse-revlog`` delta strategy. This format improves
+    delta re-use inside revlog. For very branchy repositories, it results in a
+    smaller store. For repositories with many revisions, it also helps
+    performance (by using shortened delta chains.)
+
+    Repositories with this on-disk format require Mercurial version 4.7
+
+    Enabled by default.
+
+``revlog-compression``
+    Compression algorithm used by revlog. Supported value are `zlib` and `zstd`.
+    The `zlib` engine is the historical default of Mercurial. `zstd` is a newer
+    format that is usually a net win over `zlib` operating faster at better
+    compression rate. Use `zstd` to reduce CPU usage.
+
+    On some system, Mercurial installation may lack `zstd` supports. Default is `zlib`.
+
+``bookmarks-in-store``
+    Store bookmarks in .hg/store/. This means that bookmarks are shared when
+    using `hg share` regardless of the `-B` option.
+
+    Repositories with this on-disk format require Mercurial version 5.1.
+
+    Disabled by default.
+
+
+``graph``
+---------
+
+Web graph view configuration. This section let you change graph
+elements display properties by branches, for instance to make the
+``default`` branch stand out.
+
+Each line has the following format::
+
+    <branch>.<argument> = <value>
+
+where ``<branch>`` is the name of the branch being
+customized. Example::
+
+    [graph]
+    # 2px width
+    default.width = 2
+    # red color
+    default.color = FF0000
+
+Supported arguments:
+
+``width``
+    Set branch edges width in pixels.
+
+``color``
+    Set branch edges color in hexadecimal RGB notation.
+
+``hooks``
+---------
+
+Commands or Python functions that get automatically executed by
+various actions such as starting or finishing a commit. Multiple
+hooks can be run for the same action by appending a suffix to the
+action. Overriding a site-wide hook can be done by changing its
+value or setting it to an empty string.  Hooks can be prioritized
+by adding a prefix of ``priority.`` to the hook name on a new line
+and setting the priority. The default priority is 0.
+
+Example ``.hg/hgrc``::
+
+  [hooks]
+  # update working directory after adding changesets
+  changegroup.update = hg update
+  # do not use the site-wide hook
+  incoming =
+  incoming.email = /my/email/hook
+  incoming.autobuild = /my/build/hook
+  # force autobuild hook to run before other incoming hooks
+  priority.incoming.autobuild = 1
+
+Most hooks are run with environment variables set that give useful
+additional information. For each hook below, the environment variables
+it is passed are listed with names in the form ``$HG_foo``. The
+``$HG_HOOKTYPE`` and ``$HG_HOOKNAME`` variables are set for all hooks.
+They contain the type of hook which triggered the run and the full name
+of the hook in the config, respectively. In the example above, this will
+be ``$HG_HOOKTYPE=incoming`` and ``$HG_HOOKNAME=incoming.email``.
+
+.. container:: windows
+
+  Some basic Unix syntax can be enabled for portability, including ``$VAR``
+  and ``${VAR}`` style variables.  A ``~`` followed by ``\`` or ``/`` will
+  be expanded to ``%USERPROFILE%`` to simulate a subset of tilde expansion
+  on Unix.  To use a literal ``$`` or ``~``, it must be escaped with a back
+  slash or inside of a strong quote.  Strong quotes will be replaced by
+  double quotes after processing.
+
+  This feature is enabled by adding a prefix of ``tonative.`` to the hook
+  name on a new line, and setting it to ``True``.  For example::
+
+    [hooks]
+    incoming.autobuild = /my/build/hook
+    # enable translation to cmd.exe syntax for autobuild hook
+    tonative.incoming.autobuild = True
+
+``changegroup``
+  Run after a changegroup has been added via push, pull or unbundle.  The ID of
+  the first new changeset is in ``$HG_NODE`` and last is in ``$HG_NODE_LAST``.
+  The URL from which changes came is in ``$HG_URL``.
+
+``commit``
+  Run after a changeset has been created in the local repository. The ID
+  of the newly created changeset is in ``$HG_NODE``. Parent changeset
+  IDs are in ``$HG_PARENT1`` and ``$HG_PARENT2``.
+
+``incoming``
+  Run after a changeset has been pulled, pushed, or unbundled into
+  the local repository. The ID of the newly arrived changeset is in
+  ``$HG_NODE``. The URL that was source of the changes is in ``$HG_URL``.
+
+``outgoing``
+  Run after sending changes from the local repository to another. The ID of
+  first changeset sent is in ``$HG_NODE``. The source of operation is in
+  ``$HG_SOURCE``. Also see :hg:`help config.hooks.preoutgoing`.
+
+``post-<command>``
+  Run after successful invocations of the associated command. The
+  contents of the command line are passed as ``$HG_ARGS`` and the result
+  code in ``$HG_RESULT``. Parsed command line arguments are passed as
+  ``$HG_PATS`` and ``$HG_OPTS``. These contain string representations of
+  the python data internally passed to <command>. ``$HG_OPTS`` is a
+  dictionary of options (with unspecified options set to their defaults).
+  ``$HG_PATS`` is a list of arguments. Hook failure is ignored.
+
+``fail-<command>``
+  Run after a failed invocation of an associated command. The contents
+  of the command line are passed as ``$HG_ARGS``. Parsed command line
+  arguments are passed as ``$HG_PATS`` and ``$HG_OPTS``. These contain
+  string representations of the python data internally passed to
+  <command>. ``$HG_OPTS`` is a dictionary of options (with unspecified
+  options set to their defaults). ``$HG_PATS`` is a list of arguments.
+  Hook failure is ignored.
+
+``pre-<command>``
+  Run before executing the associated command. The contents of the
+  command line are passed as ``$HG_ARGS``. Parsed command line arguments
+  are passed as ``$HG_PATS`` and ``$HG_OPTS``. These contain string
+  representations of the data internally passed to <command>. ``$HG_OPTS``
+  is a dictionary of options (with unspecified options set to their
+  defaults). ``$HG_PATS`` is a list of arguments. If the hook returns
+  failure, the command doesn't execute and Mercurial returns the failure
+  code.
+
+``prechangegroup``
+  Run before a changegroup is added via push, pull or unbundle. Exit
+  status 0 allows the changegroup to proceed. A non-zero status will
+  cause the push, pull or unbundle to fail. The URL from which changes
+  will come is in ``$HG_URL``.
+
+``precommit``
+  Run before starting a local commit. Exit status 0 allows the
+  commit to proceed. A non-zero status will cause the commit to fail.
+  Parent changeset IDs are in ``$HG_PARENT1`` and ``$HG_PARENT2``.
+
+``prelistkeys``
+  Run before listing pushkeys (like bookmarks) in the
+  repository. A non-zero status will cause failure. The key namespace is
+  in ``$HG_NAMESPACE``.
+
+``preoutgoing``
+  Run before collecting changes to send from the local repository to
+  another. A non-zero status will cause failure. This lets you prevent
+  pull over HTTP or SSH. It can also prevent propagating commits (via
+  local pull, push (outbound) or bundle commands), but not completely,
+  since you can just copy files instead. The source of operation is in
+  ``$HG_SOURCE``. If "serve", the operation is happening on behalf of a remote
+  SSH or HTTP repository. If "push", "pull" or "bundle", the operation
+  is happening on behalf of a repository on same system.
+
+``prepushkey``
+  Run before a pushkey (like a bookmark) is added to the
+  repository. A non-zero status will cause the key to be rejected. The
+  key namespace is in ``$HG_NAMESPACE``, the key is in ``$HG_KEY``,
+  the old value (if any) is in ``$HG_OLD``, and the new value is in
+  ``$HG_NEW``.
+
+``pretag``
+  Run before creating a tag. Exit status 0 allows the tag to be
+  created. A non-zero status will cause the tag to fail. The ID of the
+  changeset to tag is in ``$HG_NODE``. The name of tag is in ``$HG_TAG``. The
+  tag is local if ``$HG_LOCAL=1``, or in the repository if ``$HG_LOCAL=0``.
+
+``pretxnopen``
+  Run before any new repository transaction is open. The reason for the
+  transaction will be in ``$HG_TXNNAME``, and a unique identifier for the
+  transaction will be in ``HG_TXNID``. A non-zero status will prevent the
+  transaction from being opened.
+
+``pretxnclose``
+  Run right before the transaction is actually finalized. Any repository change
+  will be visible to the hook program. This lets you validate the transaction
+  content or change it. Exit status 0 allows the commit to proceed. A non-zero
+  status will cause the transaction to be rolled back. The reason for the
+  transaction opening will be in ``$HG_TXNNAME``, and a unique identifier for
+  the transaction will be in ``HG_TXNID``. The rest of the available data will
+  vary according the transaction type. New changesets will add ``$HG_NODE``
+  (the ID of the first added changeset), ``$HG_NODE_LAST`` (the ID of the last
+  added changeset), ``$HG_URL`` and ``$HG_SOURCE`` variables.  Bookmark and
+  phase changes will set ``HG_BOOKMARK_MOVED`` and ``HG_PHASES_MOVED`` to ``1``
+  respectively, etc.
+
+``pretxnclose-bookmark``
+  Run right before a bookmark change is actually finalized. Any repository
+  change will be visible to the hook program. This lets you validate the
+  transaction content or change it. Exit status 0 allows the commit to
+  proceed. A non-zero status will cause the transaction to be rolled back.
+  The name of the bookmark will be available in ``$HG_BOOKMARK``, the new
+  bookmark location will be available in ``$HG_NODE`` while the previous
+  location will be available in ``$HG_OLDNODE``. In case of a bookmark
+  creation ``$HG_OLDNODE`` will be empty. In case of deletion ``$HG_NODE``
+  will be empty.
+  In addition, the reason for the transaction opening will be in
+  ``$HG_TXNNAME``, and a unique identifier for the transaction will be in
+  ``HG_TXNID``.
+
+``pretxnclose-phase``
+  Run right before a phase change is actually finalized. Any repository change
+  will be visible to the hook program. This lets you validate the transaction
+  content or change it. Exit status 0 allows the commit to proceed.  A non-zero
+  status will cause the transaction to be rolled back. The hook is called
+  multiple times, once for each revision affected by a phase change.
+  The affected node is available in ``$HG_NODE``, the phase in ``$HG_PHASE``
+  while the previous ``$HG_OLDPHASE``. In case of new node, ``$HG_OLDPHASE``
+  will be empty.  In addition, the reason for the transaction opening will be in
+  ``$HG_TXNNAME``, and a unique identifier for the transaction will be in
+  ``HG_TXNID``. The hook is also run for newly added revisions. In this case
+  the ``$HG_OLDPHASE`` entry will be empty.
+
+``txnclose``
+  Run after any repository transaction has been committed. At this
+  point, the transaction can no longer be rolled back. The hook will run
+  after the lock is released. See :hg:`help config.hooks.pretxnclose` for
+  details about available variables.
+
+``txnclose-bookmark``
+  Run after any bookmark change has been committed. At this point, the
+  transaction can no longer be rolled back. The hook will run after the lock
+  is released. See :hg:`help config.hooks.pretxnclose-bookmark` for details
+  about available variables.
+
+``txnclose-phase``
+  Run after any phase change has been committed. At this point, the
+  transaction can no longer be rolled back. The hook will run after the lock
+  is released. See :hg:`help config.hooks.pretxnclose-phase` for details about
+  available variables.
+
+``txnabort``
+  Run when a transaction is aborted. See :hg:`help config.hooks.pretxnclose`
+  for details about available variables.
+
+``pretxnchangegroup``
+  Run after a changegroup has been added via push, pull or unbundle, but before
+  the transaction has been committed. The changegroup is visible to the hook
+  program. This allows validation of incoming changes before accepting them.
+  The ID of the first new changeset is in ``$HG_NODE`` and last is in
+  ``$HG_NODE_LAST``. Exit status 0 allows the transaction to commit. A non-zero
+  status will cause the transaction to be rolled back, and the push, pull or
+  unbundle will fail. The URL that was the source of changes is in ``$HG_URL``.
+
+``pretxncommit``
+  Run after a changeset has been created, but before the transaction is
+  committed. The changeset is visible to the hook program. This allows
+  validation of the commit message and changes. Exit status 0 allows the
+  commit to proceed. A non-zero status will cause the transaction to
+  be rolled back. The ID of the new changeset is in ``$HG_NODE``. The parent
+  changeset IDs are in ``$HG_PARENT1`` and ``$HG_PARENT2``.
+
+``preupdate``
+  Run before updating the working directory. Exit status 0 allows
+  the update to proceed. A non-zero status will prevent the update.
+  The changeset ID of first new parent is in ``$HG_PARENT1``. If updating to a
+  merge, the ID of second new parent is in ``$HG_PARENT2``.
+
+``listkeys``
+  Run after listing pushkeys (like bookmarks) in the repository. The
+  key namespace is in ``$HG_NAMESPACE``. ``$HG_VALUES`` is a
+  dictionary containing the keys and values.
+
+``pushkey``
+  Run after a pushkey (like a bookmark) is added to the
+  repository. The key namespace is in ``$HG_NAMESPACE``, the key is in
+  ``$HG_KEY``, the old value (if any) is in ``$HG_OLD``, and the new
+  value is in ``$HG_NEW``.
+
+``tag``
+  Run after a tag is created. The ID of the tagged changeset is in ``$HG_NODE``.
+  The name of tag is in ``$HG_TAG``. The tag is local if ``$HG_LOCAL=1``, or in
+  the repository if ``$HG_LOCAL=0``.
+
+``update``
+  Run after updating the working directory. The changeset ID of first
+  new parent is in ``$HG_PARENT1``. If updating to a merge, the ID of second new
+  parent is in ``$HG_PARENT2``. If the update succeeded, ``$HG_ERROR=0``. If the
+  update failed (e.g. because conflicts were not resolved), ``$HG_ERROR=1``.
+
+.. note::
+
+   It is generally better to use standard hooks rather than the
+   generic pre- and post- command hooks, as they are guaranteed to be
+   called in the appropriate contexts for influencing transactions.
+   Also, hooks like "commit" will be called in all contexts that
+   generate a commit (e.g. tag) and not just the commit command.
+
+.. note::
+
+   Environment variables with empty values may not be passed to
+   hooks on platforms such as Windows. As an example, ``$HG_PARENT2``
+   will have an empty value under Unix-like platforms for non-merge
+   changesets, while it will not be available at all under Windows.
+
+The syntax for Python hooks is as follows::
+
+  hookname = python:modulename.submodule.callable
+  hookname = python:/path/to/python/module.py:callable
+
+Python hooks are run within the Mercurial process. Each hook is
+called with at least three keyword arguments: a ui object (keyword
+``ui``), a repository object (keyword ``repo``), and a ``hooktype``
+keyword that tells what kind of hook is used. Arguments listed as
+environment variables above are passed as keyword arguments, with no
+``HG_`` prefix, and names in lower case.
+
+If a Python hook returns a "true" value or raises an exception, this
+is treated as a failure.
+
+
+``hostfingerprints``
+--------------------
+
+(Deprecated. Use ``[hostsecurity]``'s ``fingerprints`` options instead.)
+
+Fingerprints of the certificates of known HTTPS servers.
+
+A HTTPS connection to a server with a fingerprint configured here will
+only succeed if the servers certificate matches the fingerprint.
+This is very similar to how ssh known hosts works.
+
+The fingerprint is the SHA-1 hash value of the DER encoded certificate.
+Multiple values can be specified (separated by spaces or commas). This can
+be used to define both old and new fingerprints while a host transitions
+to a new certificate.
+
+The CA chain and web.cacerts is not used for servers with a fingerprint.
+
+For example::
+
+    [hostfingerprints]
+    hg.intevation.de = fc:e2:8d:d9:51:cd:cb:c1:4d:18:6b:b7:44:8d:49:72:57:e6:cd:33
+    hg.intevation.org = fc:e2:8d:d9:51:cd:cb:c1:4d:18:6b:b7:44:8d:49:72:57:e6:cd:33
+
+``hostsecurity``
+----------------
+
+Used to specify global and per-host security settings for connecting to
+other machines.
+
+The following options control default behavior for all hosts.
+
+``ciphers``
+    Defines the cryptographic ciphers to use for connections.
+
+    Value must be a valid OpenSSL Cipher List Format as documented at
+    https://www.openssl.org/docs/manmaster/apps/ciphers.html#CIPHER-LIST-FORMAT.
+
+    This setting is for advanced users only. Setting to incorrect values
+    can significantly lower connection security or decrease performance.
+    You have been warned.
+
+    This option requires Python 2.7.
+
+``minimumprotocol``
+    Defines the minimum channel encryption protocol to use.
+
+    By default, the highest version of TLS supported by both client and server
+    is used.
+
+    Allowed values are: ``tls1.0``, ``tls1.1``, ``tls1.2``.
+
+    When running on an old Python version, only ``tls1.0`` is allowed since
+    old versions of Python only support up to TLS 1.0.
+
+    When running a Python that supports modern TLS versions, the default is
+    ``tls1.1``. ``tls1.0`` can still be used to allow TLS 1.0. However, this
+    weakens security and should only be used as a feature of last resort if
+    a server does not support TLS 1.1+.
+
+Options in the ``[hostsecurity]`` section can have the form
+``hostname``:``setting``. This allows multiple settings to be defined on a
+per-host basis.
+
+The following per-host settings can be defined.
+
+``ciphers``
+    This behaves like ``ciphers`` as described above except it only applies
+    to the host on which it is defined.
+
+``fingerprints``
+    A list of hashes of the DER encoded peer/remote certificate. Values have
+    the form ``algorithm``:``fingerprint``. e.g.
+    ``sha256:c3ab8ff13720e8ad9047dd39466b3c8974e592c2fa383d4a3960714caef0c4f2``.
+    In addition, colons (``:``) can appear in the fingerprint part.
+
+    The following algorithms/prefixes are supported: ``sha1``, ``sha256``,
+    ``sha512``.
+
+    Use of ``sha256`` or ``sha512`` is preferred.
+
+    If a fingerprint is specified, the CA chain is not validated for this
+    host and Mercurial will require the remote certificate to match one
+    of the fingerprints specified. This means if the server updates its
+    certificate, Mercurial will abort until a new fingerprint is defined.
+    This can provide stronger security than traditional CA-based validation
+    at the expense of convenience.
+
+    This option takes precedence over ``verifycertsfile``.
+
+``minimumprotocol``
+    This behaves like ``minimumprotocol`` as described above except it
+    only applies to the host on which it is defined.
+
+``verifycertsfile``
+    Path to file a containing a list of PEM encoded certificates used to
+    verify the server certificate. Environment variables and ``~user``
+    constructs are expanded in the filename.
+
+    The server certificate or the certificate's certificate authority (CA)
+    must match a certificate from this file or certificate verification
+    will fail and connections to the server will be refused.
+
+    If defined, only certificates provided by this file will be used:
+    ``web.cacerts`` and any system/default certificates will not be
+    used.
+
+    This option has no effect if the per-host ``fingerprints`` option
+    is set.
+
+    The format of the file is as follows::
+
+        -----BEGIN CERTIFICATE-----
+        ... (certificate in base64 PEM encoding) ...
+        -----END CERTIFICATE-----
+        -----BEGIN CERTIFICATE-----
+        ... (certificate in base64 PEM encoding) ...
+        -----END CERTIFICATE-----
+
+For example::
+
+    [hostsecurity]
+    hg.example.com:fingerprints = sha256:c3ab8ff13720e8ad9047dd39466b3c8974e592c2fa383d4a3960714caef0c4f2
+    hg2.example.com:fingerprints = sha1:914f1aff87249c09b6859b88b1906d30756491ca, sha1:fc:e2:8d:d9:51:cd:cb:c1:4d:18:6b:b7:44:8d:49:72:57:e6:cd:33
+    hg3.example.com:fingerprints = sha256:9a:b0:dc:e2:75:ad:8a:b7:84:58:e5:1f:07:32:f1:87:e6:bd:24:22:af:b7:ce:8e:9c:b4:10:cf:b9:f4:0e:d2
+    foo.example.com:verifycertsfile = /etc/ssl/trusted-ca-certs.pem
+
+To change the default minimum protocol version to TLS 1.2 but to allow TLS 1.1
+when connecting to ``hg.example.com``::
+
+    [hostsecurity]
+    minimumprotocol = tls1.2
+    hg.example.com:minimumprotocol = tls1.1
+
+``http_proxy``
+--------------
+
+Used to access web-based Mercurial repositories through a HTTP
+proxy.
+
+``host``
+    Host name and (optional) port of the proxy server, for example
+    "myproxy:8000".
+
+``no``
+    Optional. Comma-separated list of host names that should bypass
+    the proxy.
+
+``passwd``
+    Optional. Password to authenticate with at the proxy server.
+
+``user``
+    Optional. User name to authenticate with at the proxy server.
+
+``always``
+    Optional. Always use the proxy, even for localhost and any entries
+    in ``http_proxy.no``. (default: False)
+
+``http``
+----------
+
+Used to configure access to Mercurial repositories via HTTP.
+
+``timeout``
+    If set, blocking operations will timeout after that many seconds.
+    (default: None)
+
+``merge``
+---------
+
+This section specifies behavior during merges and updates.
+
+``checkignored``
+   Controls behavior when an ignored file on disk has the same name as a tracked
+   file in the changeset being merged or updated to, and has different
+   contents. Options are ``abort``, ``warn`` and ``ignore``. With ``abort``,
+   abort on such files. With ``warn``, warn on such files and back them up as
+   ``.orig``. With ``ignore``, don't print a warning and back them up as
+   ``.orig``. (default: ``abort``)
+
+``checkunknown``
+   Controls behavior when an unknown file that isn't ignored has the same name
+   as a tracked file in the changeset being merged or updated to, and has
+   different contents. Similar to ``merge.checkignored``, except for files that
+   are not ignored. (default: ``abort``)
+
+``on-failure``
+   When set to ``continue`` (the default), the merge process attempts to
+   merge all unresolved files using the merge chosen tool, regardless of
+   whether previous file merge attempts during the process succeeded or not.
+   Setting this to ``prompt`` will prompt after any merge failure continue
+   or halt the merge process. Setting this to ``halt`` will automatically
+   halt the merge process on any merge tool failure. The merge process
+   can be restarted by using the ``resolve`` command. When a merge is
+   halted, the repository is left in a normal ``unresolved`` merge state.
+   (default: ``continue``)
+
+``strict-capability-check``
+   Whether capabilities of internal merge tools are checked strictly
+   or not, while examining rules to decide merge tool to be used.
+   (default: False)
+
+``merge-patterns``
+------------------
+
+This section specifies merge tools to associate with particular file
+patterns. Tools matched here will take precedence over the default
+merge tool. Patterns are globs by default, rooted at the repository
+root.
+
+Example::
+
+  [merge-patterns]
+  **.c = kdiff3
+  **.jpg = myimgmerge
+
+``merge-tools``
+---------------
+
+This section configures external merge tools to use for file-level
+merges. This section has likely been preconfigured at install time.
+Use :hg:`config merge-tools` to check the existing configuration.
+Also see :hg:`help merge-tools` for more details.
+
+Example ``~/.hgrc``::
+
+  [merge-tools]
+  # Override stock tool location
+  kdiff3.executable = ~/bin/kdiff3
+  # Specify command line
+  kdiff3.args = $base $local $other -o $output
+  # Give higher priority
+  kdiff3.priority = 1
+
+  # Changing the priority of preconfigured tool
+  meld.priority = 0
+
+  # Disable a preconfigured tool
+  vimdiff.disabled = yes
+
+  # Define new tool
+  myHtmlTool.args = -m $local $other $base $output
+  myHtmlTool.regkey = Software\FooSoftware\HtmlMerge
+  myHtmlTool.priority = 1
+
+Supported arguments:
+
+``priority``
+  The priority in which to evaluate this tool.
+  (default: 0)
+
+``executable``
+  Either just the name of the executable or its pathname.
+
+  .. container:: windows
+
+    On Windows, the path can use environment variables with ${ProgramFiles}
+    syntax.
+
+  (default: the tool name)
+
+``args``
+  The arguments to pass to the tool executable. You can refer to the
+  files being merged as well as the output file through these
+  variables: ``$base``, ``$local``, ``$other``, ``$output``.
+
+  The meaning of ``$local`` and ``$other`` can vary depending on which action is
+  being performed. During an update or merge, ``$local`` represents the original
+  state of the file, while ``$other`` represents the commit you are updating to or
+  the commit you are merging with. During a rebase, ``$local`` represents the
+  destination of the rebase, and ``$other`` represents the commit being rebased.
+
+  Some operations define custom labels to assist with identifying the revisions,
+  accessible via ``$labellocal``, ``$labelother``, and ``$labelbase``. If custom
+  labels are not available, these will be ``local``, ``other``, and ``base``,
+  respectively.
+  (default: ``$local $base $other``)
+
+``premerge``
+  Attempt to run internal non-interactive 3-way merge tool before
+  launching external tool.  Options are ``true``, ``false``, ``keep`` or
+  ``keep-merge3``. The ``keep`` option will leave markers in the file if the
+  premerge fails. The ``keep-merge3`` will do the same but include information
+  about the base of the merge in the marker (see internal :merge3 in
+  :hg:`help merge-tools`).
+  (default: True)
+
+``binary``
+  This tool can merge binary files. (default: False, unless tool
+  was selected by file pattern match)
+
+``symlink``
+  This tool can merge symlinks. (default: False)
+
+``check``
+  A list of merge success-checking options:
+
+  ``changed``
+    Ask whether merge was successful when the merged file shows no changes.
+  ``conflicts``
+    Check whether there are conflicts even though the tool reported success.
+  ``prompt``
+    Always prompt for merge success, regardless of success reported by tool.
+
+``fixeol``
+  Attempt to fix up EOL changes caused by the merge tool.
+  (default: False)
+
+``gui``
+  This tool requires a graphical interface to run. (default: False)
+
+``mergemarkers``
+  Controls whether the labels passed via ``$labellocal``, ``$labelother``, and
+  ``$labelbase`` are ``detailed`` (respecting ``mergemarkertemplate``) or
+  ``basic``. If ``premerge`` is ``keep`` or ``keep-merge3``, the conflict
+  markers generated during premerge will be ``detailed`` if either this option or
+  the corresponding option in the ``[ui]`` section is ``detailed``.
+  (default: ``basic``)
+
+``mergemarkertemplate``
+  This setting can be used to override ``mergemarkertemplate`` from the ``[ui]``
+  section on a per-tool basis; this applies to the ``$label``-prefixed variables
+  and to the conflict markers that are generated if ``premerge`` is ``keep` or
+  ``keep-merge3``. See the corresponding variable in ``[ui]`` for more
+  information.
+
+.. container:: windows
+
+  ``regkey``
+    Windows registry key which describes install location of this
+    tool. Mercurial will search for this key first under
+    ``HKEY_CURRENT_USER`` and then under ``HKEY_LOCAL_MACHINE``.
+    (default: None)
+
+  ``regkeyalt``
+    An alternate Windows registry key to try if the first key is not
+    found.  The alternate key uses the same ``regname`` and ``regappend``
+    semantics of the primary key.  The most common use for this key
+    is to search for 32bit applications on 64bit operating systems.
+    (default: None)
+
+  ``regname``
+    Name of value to read from specified registry key.
+    (default: the unnamed (default) value)
+
+  ``regappend``
+    String to append to the value read from the registry, typically
+    the executable name of the tool.
+    (default: None)
+
+``pager``
+---------
+
+Setting used to control when to paginate and with what external tool. See
+:hg:`help pager` for details.
+
+``pager``
+    Define the external tool used as pager.
+
+    If no pager is set, Mercurial uses the environment variable $PAGER.
+    If neither pager.pager, nor $PAGER is set, a default pager will be
+    used, typically `less` on Unix and `more` on Windows. Example::
+
+      [pager]
+      pager = less -FRX
+
+``ignore``
+    List of commands to disable the pager for. Example::
+
+      [pager]
+      ignore = version, help, update
+
+``patch``
+---------
+
+Settings used when applying patches, for instance through the 'import'
+command or with Mercurial Queues extension.
+
+``eol``
+    When set to 'strict' patch content and patched files end of lines
+    are preserved. When set to ``lf`` or ``crlf``, both files end of
+    lines are ignored when patching and the result line endings are
+    normalized to either LF (Unix) or CRLF (Windows). When set to
+    ``auto``, end of lines are again ignored while patching but line
+    endings in patched files are normalized to their original setting
+    on a per-file basis. If target file does not exist or has no end
+    of line, patch line endings are preserved.
+    (default: strict)
+
+``fuzz``
+    The number of lines of 'fuzz' to allow when applying patches. This
+    controls how much context the patcher is allowed to ignore when
+    trying to apply a patch.
+    (default: 2)
+
+``paths``
+---------
+
+Assigns symbolic names and behavior to repositories.
+
+Options are symbolic names defining the URL or directory that is the
+location of the repository. Example::
+
+    [paths]
+    my_server = https://example.com/my_repo
+    local_path = /home/me/repo
+
+These symbolic names can be used from the command line. To pull
+from ``my_server``: :hg:`pull my_server`. To push to ``local_path``:
+:hg:`push local_path`.
+
+Options containing colons (``:``) denote sub-options that can influence
+behavior for that specific path. Example::
+
+    [paths]
+    my_server = https://example.com/my_path
+    my_server:pushurl = ssh://example.com/my_path
+
+The following sub-options can be defined:
+
+``pushurl``
+   The URL to use for push operations. If not defined, the location
+   defined by the path's main entry is used.
+
+``pushrev``
+   A revset defining which revisions to push by default.
+
+   When :hg:`push` is executed without a ``-r`` argument, the revset
+   defined by this sub-option is evaluated to determine what to push.
+
+   For example, a value of ``.`` will push the working directory's
+   revision by default.
+
+   Revsets specifying bookmarks will not result in the bookmark being
+   pushed.
+
+The following special named paths exist:
+
+``default``
+   The URL or directory to use when no source or remote is specified.
+
+   :hg:`clone` will automatically define this path to the location the
+   repository was cloned from.
+
+``default-push``
+   (deprecated) The URL or directory for the default :hg:`push` location.
+   ``default:pushurl`` should be used instead.
+
+``phases``
+----------
+
+Specifies default handling of phases. See :hg:`help phases` for more
+information about working with phases.
+
+``publish``
+    Controls draft phase behavior when working as a server. When true,
+    pushed changesets are set to public in both client and server and
+    pulled or cloned changesets are set to public in the client.
+    (default: True)
+
+``new-commit``
+    Phase of newly-created commits.
+    (default: draft)
+
+``checksubrepos``
+    Check the phase of the current revision of each subrepository. Allowed
+    values are "ignore", "follow" and "abort". For settings other than
+    "ignore", the phase of the current revision of each subrepository is
+    checked before committing the parent repository. If any of those phases is
+    greater than the phase of the parent repository (e.g. if a subrepo is in a
+    "secret" phase while the parent repo is in "draft" phase), the commit is
+    either aborted (if checksubrepos is set to "abort") or the higher phase is
+    used for the parent repository commit (if set to "follow").
+    (default: follow)
+
+
+``profiling``
+-------------
+
+Specifies profiling type, format, and file output. Two profilers are
+supported: an instrumenting profiler (named ``ls``), and a sampling
+profiler (named ``stat``).
+
+In this section description, 'profiling data' stands for the raw data
+collected during profiling, while 'profiling report' stands for a
+statistical text report generated from the profiling data.
+
+``enabled``
+    Enable the profiler.
+    (default: false)
+
+    This is equivalent to passing ``--profile`` on the command line.
+
+``type``
+    The type of profiler to use.
+    (default: stat)
+
+    ``ls``
+      Use Python's built-in instrumenting profiler. This profiler
+      works on all platforms, but each line number it reports is the
+      first line of a function. This restriction makes it difficult to
+      identify the expensive parts of a non-trivial function.
+    ``stat``
+      Use a statistical profiler, statprof. This profiler is most
+      useful for profiling commands that run for longer than about 0.1
+      seconds.
+
+``format``
+    Profiling format.  Specific to the ``ls`` instrumenting profiler.
+    (default: text)
+
+    ``text``
+      Generate a profiling report. When saving to a file, it should be
+      noted that only the report is saved, and the profiling data is
+      not kept.
+    ``kcachegrind``
+      Format profiling data for kcachegrind use: when saving to a
+      file, the generated file can directly be loaded into
+      kcachegrind.
+
+``statformat``
+    Profiling format for the ``stat`` profiler.
+    (default: hotpath)
+
+    ``hotpath``
+      Show a tree-based display containing the hot path of execution (where
+      most time was spent).
+    ``bymethod``
+      Show a table of methods ordered by how frequently they are active.
+    ``byline``
+      Show a table of lines in files ordered by how frequently they are active.
+    ``json``
+      Render profiling data as JSON.
+
+``frequency``
+    Sampling frequency.  Specific to the ``stat`` sampling profiler.
+    (default: 1000)
+
+``output``
+    File path where profiling data or report should be saved. If the
+    file exists, it is replaced. (default: None, data is printed on
+    stderr)
+
+``sort``
+    Sort field.  Specific to the ``ls`` instrumenting profiler.
+    One of ``callcount``, ``reccallcount``, ``totaltime`` and
+    ``inlinetime``.
+    (default: inlinetime)
+
+``time-track``
+    Control if the stat profiler track ``cpu`` or ``real`` time.
+    (default: ``cpu`` on Windows, otherwise ``real``)
+
+``limit``
+    Number of lines to show. Specific to the ``ls`` instrumenting profiler.
+    (default: 30)
+
+``nested``
+    Show at most this number of lines of drill-down info after each main entry.
+    This can help explain the difference between Total and Inline.
+    Specific to the ``ls`` instrumenting profiler.
+    (default: 0)
+
+``showmin``
+    Minimum fraction of samples an entry must have for it to be displayed.
+    Can be specified as a float between ``0.0`` and ``1.0`` or can have a
+    ``%`` afterwards to allow values up to ``100``. e.g. ``5%``.
+
+    Only used by the ``stat`` profiler.
+
+    For the ``hotpath`` format, default is ``0.05``.
+    For the ``chrome`` format, default is ``0.005``.
+
+    The option is unused on other formats.
+
+``showmax``
+    Maximum fraction of samples an entry can have before it is ignored in
+    display. Values format is the same as ``showmin``.
+
+    Only used by the ``stat`` profiler.
+
+    For the ``chrome`` format, default is ``0.999``.
+
+    The option is unused on other formats.
+
+``showtime``
+    Show time taken as absolute durations, in addition to percentages.
+    Only used by the ``hotpath`` format.
+    (default: true)
+
+``progress``
+------------
+
+Mercurial commands can draw progress bars that are as informative as
+possible. Some progress bars only offer indeterminate information, while others
+have a definite end point.
+
+``debug``
+    Whether to print debug info when updating the progress bar. (default: False)
+
+``delay``
+    Number of seconds (float) before showing the progress bar. (default: 3)
+
+``changedelay``
+    Minimum delay before showing a new topic. When set to less than 3 * refresh,
+    that value will be used instead. (default: 1)
+
+``estimateinterval``
+    Maximum sampling interval in seconds for speed and estimated time
+    calculation. (default: 60)
+
+``refresh``
+    Time in seconds between refreshes of the progress bar. (default: 0.1)
+
+``format``
+    Format of the progress bar.
+
+    Valid entries for the format field are ``topic``, ``bar``, ``number``,
+    ``unit``, ``estimate``, ``speed``, and ``item``. ``item`` defaults to the
+    last 20 characters of the item, but this can be changed by adding either
+    ``-<num>`` which would take the last num characters, or ``+<num>`` for the
+    first num characters.
+
+    (default: topic bar number estimate)
+
+``width``
+    If set, the maximum width of the progress information (that is, min(width,
+    term width) will be used).
+
+``clear-complete``
+    Clear the progress bar after it's done. (default: True)
+
+``disable``
+    If true, don't show a progress bar.
+
+``assume-tty``
+    If true, ALWAYS show a progress bar, unless disable is given.
+
+``rebase``
+----------
+
+``evolution.allowdivergence``
+    Default to False, when True allow creating divergence when performing
+    rebase of obsolete changesets.
+
+``revsetalias``
+---------------
+
+Alias definitions for revsets. See :hg:`help revsets` for details.
+
+``rewrite``
+-----------
+
+``backup-bundle``
+    Whether to save stripped changesets to a bundle file. (default: True)
+
+``update-timestamp``
+    If true, updates the date and time of the changeset to current. It is only
+    applicable for `hg amend`, `hg commit --amend` and `hg uncommit` in the
+    current version.
+
+``storage``
+-----------
+
+Control the strategy Mercurial uses internally to store history. Options in this
+category impact performance and repository size.
+
+``revlog.optimize-delta-parent-choice``
+    When storing a merge revision, both parents will be equally considered as
+    a possible delta base. This results in better delta selection and improved
+    revlog compression. This option is enabled by default.
+
+    Turning this option off can result in large increase of repository size for
+    repository with many merges.
+
+``revlog.reuse-external-delta-parent``
+    Control the order in which delta parents are considered when adding new
+    revisions from an external source.
+    (typically: apply bundle from `hg pull` or `hg push`).
+
+    New revisions are usually provided as a delta against other revisions. By
+    default, Mercurial will try to reuse this delta first, therefore using the
+    same "delta parent" as the source. Directly using delta's from the source
+    reduces CPU usage and usually speeds up operation. However, in some case,
+    the source might have sub-optimal delta bases and forcing their reevaluation
+    is useful. For example, pushes from an old client could have sub-optimal
+    delta's parent that the server want to optimize. (lack of general delta, bad
+    parents, choice, lack of sparse-revlog, etc).
+
+    This option is enabled by default. Turning it off will ensure bad delta
+    parent choices from older client do not propagate to this repository, at
+    the cost of a small increase in CPU consumption.
+
+    Note: this option only control the order in which delta parents are
+    considered.  Even when disabled, the existing delta from the source will be
+    reused if the same delta parent is selected.
+
+``revlog.reuse-external-delta``
+    Control the reuse of delta from external source.
+    (typically: apply bundle from `hg pull` or `hg push`).
+
+    New revisions are usually provided as a delta against another revision. By
+    default, Mercurial will not recompute the same delta again, trusting
+    externally provided deltas. There have been rare cases of small adjustment
+    to the diffing algorithm in the past. So in some rare case, recomputing
+    delta provided by ancient clients can provides better results. Disabling
+    this option means going through a full delta recomputation for all incoming
+    revisions. It means a large increase in CPU usage and will slow operations
+    down.
+
+    This option is enabled by default. When disabled, it also disables the
+    related ``storage.revlog.reuse-external-delta-parent`` option.
+
+``revlog.zlib.level``
+    Zlib compression level used when storing data into the repository. Accepted
+    Value range from 1 (lowest compression) to 9 (highest compression). Zlib
+    default value is 6.
+
+
+``revlog.zstd.level``
+    zstd compression level used when storing data into the repository. Accepted
+    Value range from 1 (lowest compression) to 22 (highest compression).
+    (default 3)
+
+``server``
+----------
+
+Controls generic server settings.
+
+``bookmarks-pushkey-compat``
+    Trigger pushkey hook when being pushed bookmark updates. This config exist
+    for compatibility purpose (default to True)
+
+    If you use ``pushkey`` and ``pre-pushkey`` hooks to control bookmark
+    movement we recommend you migrate them to ``txnclose-bookmark`` and
+    ``pretxnclose-bookmark``.
+
+``compressionengines``
+    List of compression engines and their relative priority to advertise
+    to clients.
+
+    The order of compression engines determines their priority, the first
+    having the highest priority. If a compression engine is not listed
+    here, it won't be advertised to clients.
+
+    If not set (the default), built-in defaults are used. Run
+    :hg:`debuginstall` to list available compression engines and their
+    default wire protocol priority.
+
+    Older Mercurial clients only support zlib compression and this setting
+    has no effect for legacy clients.
+
+``uncompressed``
+    Whether to allow clients to clone a repository using the
+    uncompressed streaming protocol. This transfers about 40% more
+    data than a regular clone, but uses less memory and CPU on both
+    server and client. Over a LAN (100 Mbps or better) or a very fast
+    WAN, an uncompressed streaming clone is a lot faster (~10x) than a
+    regular clone. Over most WAN connections (anything slower than
+    about 6 Mbps), uncompressed streaming is slower, because of the
+    extra data transfer overhead. This mode will also temporarily hold
+    the write lock while determining what data to transfer.
+    (default: True)
+
+``uncompressedallowsecret``
+    Whether to allow stream clones when the repository contains secret
+    changesets. (default: False)
+
+``preferuncompressed``
+    When set, clients will try to use the uncompressed streaming
+    protocol. (default: False)
+
+``disablefullbundle``
+    When set, servers will refuse attempts to do pull-based clones.
+    If this option is set, ``preferuncompressed`` and/or clone bundles
+    are highly recommended. Partial clones will still be allowed.
+    (default: False)
+
+``streamunbundle``
+    When set, servers will apply data sent from the client directly,
+    otherwise it will be written to a temporary file first. This option
+    effectively prevents concurrent pushes.
+
+``pullbundle``
+    When set, the server will check pullbundle.manifest for bundles
+    covering the requested heads and common nodes. The first matching
+    entry will be streamed to the client.
+
+    For HTTP transport, the stream will still use zlib compression
+    for older clients.
+
+``concurrent-push-mode``
+    Level of allowed race condition between two pushing clients.
+
+    - 'strict': push is abort if another client touched the repository
+      while the push was preparing. (default)
+    - 'check-related': push is only aborted if it affects head that got also
+      affected while the push was preparing.
+
+    This requires compatible client (version 4.3 and later). Old client will
+    use 'strict'.
+
+``validate``
+    Whether to validate the completeness of pushed changesets by
+    checking that all new file revisions specified in manifests are
+    present. (default: False)
+
+``maxhttpheaderlen``
+    Instruct HTTP clients not to send request headers longer than this
+    many bytes. (default: 1024)
+
+``bundle1``
+    Whether to allow clients to push and pull using the legacy bundle1
+    exchange format. (default: True)
+
+``bundle1gd``
+    Like ``bundle1`` but only used if the repository is using the
+    *generaldelta* storage format. (default: True)
+
+``bundle1.push``
+    Whether to allow clients to push using the legacy bundle1 exchange
+    format. (default: True)
+
+``bundle1gd.push``
+    Like ``bundle1.push`` but only used if the repository is using the
+    *generaldelta* storage format. (default: True)
+
+``bundle1.pull``
+    Whether to allow clients to pull using the legacy bundle1 exchange
+    format. (default: True)
+
+``bundle1gd.pull``
+    Like ``bundle1.pull`` but only used if the repository is using the
+    *generaldelta* storage format. (default: True)
+
+    Large repositories using the *generaldelta* storage format should
+    consider setting this option because converting *generaldelta*
+    repositories to the exchange format required by the bundle1 data
+    format can consume a lot of CPU.
+
+``bundle2.stream``
+    Whether to allow clients to pull using the bundle2 streaming protocol.
+    (default: True)
+
+``zliblevel``
+    Integer between ``-1`` and ``9`` that controls the zlib compression level
+    for wire protocol commands that send zlib compressed output (notably the
+    commands that send repository history data).
+
+    The default (``-1``) uses the default zlib compression level, which is
+    likely equivalent to ``6``. ``0`` means no compression. ``9`` means
+    maximum compression.
+
+    Setting this option allows server operators to make trade-offs between
+    bandwidth and CPU used. Lowering the compression lowers CPU utilization
+    but sends more bytes to clients.
+
+    This option only impacts the HTTP server.
+
+``zstdlevel``
+    Integer between ``1`` and ``22`` that controls the zstd compression level
+    for wire protocol commands. ``1`` is the minimal amount of compression and
+    ``22`` is the highest amount of compression.
+
+    The default (``3``) should be significantly faster than zlib while likely
+    delivering better compression ratios.
+
+    This option only impacts the HTTP server.
+
+    See also ``server.zliblevel``.
+
+``view``
+    Repository filter used when exchanging revisions with the peer.
+
+    The default view (``served``) excludes secret and hidden changesets.
+    Another useful value is ``immutable`` (no draft, secret or hidden
+    changesets). (EXPERIMENTAL)
+
+``smtp``
+--------
+
+Configuration for extensions that need to send email messages.
+
+``host``
+    Host name of mail server, e.g. "mail.example.com".
+
+``port``
+    Optional. Port to connect to on mail server. (default: 465 if
+    ``tls`` is smtps; 25 otherwise)
+
+``tls``
+    Optional. Method to enable TLS when connecting to mail server: starttls,
+    smtps or none. (default: none)
+
+``username``
+    Optional. User name for authenticating with the SMTP server.
+    (default: None)
+
+``password``
+    Optional. Password for authenticating with the SMTP server. If not
+    specified, interactive sessions will prompt the user for a
+    password; non-interactive sessions will fail. (default: None)
+
+``local_hostname``
+    Optional. The hostname that the sender can use to identify
+    itself to the MTA.
+
+
+``subpaths``
+------------
+
+Subrepository source URLs can go stale if a remote server changes name
+or becomes temporarily unavailable. This section lets you define
+rewrite rules of the form::
+
+    <pattern> = <replacement>
+
+where ``pattern`` is a regular expression matching a subrepository
+source URL and ``replacement`` is the replacement string used to
+rewrite it. Groups can be matched in ``pattern`` and referenced in
+``replacements``. For instance::
+
+    http://server/(.*)-hg/ = http://hg.server/\1/
+
+rewrites ``http://server/foo-hg/`` into ``http://hg.server/foo/``.
+
+Relative subrepository paths are first made absolute, and the
+rewrite rules are then applied on the full (absolute) path. If ``pattern``
+doesn't match the full path, an attempt is made to apply it on the
+relative path alone. The rules are applied in definition order.
+
+``subrepos``
+------------
+
+This section contains options that control the behavior of the
+subrepositories feature. See also :hg:`help subrepos`.
+
+Security note: auditing in Mercurial is known to be insufficient to
+prevent clone-time code execution with carefully constructed Git
+subrepos. It is unknown if a similar detect is present in Subversion
+subrepos. Both Git and Subversion subrepos are disabled by default
+out of security concerns. These subrepo types can be enabled using
+the respective options below.
+
+``allowed``
+    Whether subrepositories are allowed in the working directory.
+
+    When false, commands involving subrepositories (like :hg:`update`)
+    will fail for all subrepository types.
+    (default: true)
+
+``hg:allowed``
+    Whether Mercurial subrepositories are allowed in the working
+    directory. This option only has an effect if ``subrepos.allowed``
+    is true.
+    (default: true)
+
+``git:allowed``
+    Whether Git subrepositories are allowed in the working directory.
+    This option only has an effect if ``subrepos.allowed`` is true.
+
+    See the security note above before enabling Git subrepos.
+    (default: false)
+
+``svn:allowed``
+    Whether Subversion subrepositories are allowed in the working
+    directory. This option only has an effect if ``subrepos.allowed``
+    is true.
+
+    See the security note above before enabling Subversion subrepos.
+    (default: false)
+
+``templatealias``
+-----------------
+
+Alias definitions for templates. See :hg:`help templates` for details.
+
+``templates``
+-------------
+
+Use the ``[templates]`` section to define template strings.
+See :hg:`help templates` for details.
+
+``trusted``
+-----------
+
+Mercurial will not use the settings in the
+``.hg/hgrc`` file from a repository if it doesn't belong to a trusted
+user or to a trusted group, as various hgrc features allow arbitrary
+commands to be run. This issue is often encountered when configuring
+hooks or extensions for shared repositories or servers. However,
+the web interface will use some safe settings from the ``[web]``
+section.
+
+This section specifies what users and groups are trusted. The
+current user is always trusted. To trust everybody, list a user or a
+group with name ``*``. These settings must be placed in an
+*already-trusted file* to take effect, such as ``$HOME/.hgrc`` of the
+user or service running Mercurial.
+
+``users``
+  Comma-separated list of trusted users.
+
+``groups``
+  Comma-separated list of trusted groups.
+
+
+``ui``
+------
+
+User interface controls.
+
+``archivemeta``
+    Whether to include the .hg_archival.txt file containing meta data
+    (hashes for the repository base and for tip) in archives created
+    by the :hg:`archive` command or downloaded via hgweb.
+    (default: True)
+
+``askusername``
+    Whether to prompt for a username when committing. If True, and
+    neither ``$HGUSER`` nor ``$EMAIL`` has been specified, then the user will
+    be prompted to enter a username. If no username is entered, the
+    default ``USER@HOST`` is used instead.
+    (default: False)
+
+``clonebundles``
+    Whether the "clone bundles" feature is enabled.
+
+    When enabled, :hg:`clone` may download and apply a server-advertised
+    bundle file from a URL instead of using the normal exchange mechanism.
+
+    This can likely result in faster and more reliable clones.
+
+    (default: True)
+
+``clonebundlefallback``
+    Whether failure to apply an advertised "clone bundle" from a server
+    should result in fallback to a regular clone.
+
+    This is disabled by default because servers advertising "clone
+    bundles" often do so to reduce server load. If advertised bundles
+    start mass failing and clients automatically fall back to a regular
+    clone, this would add significant and unexpected load to the server
+    since the server is expecting clone operations to be offloaded to
+    pre-generated bundles. Failing fast (the default behavior) ensures
+    clients don't overwhelm the server when "clone bundle" application
+    fails.
+
+    (default: False)
+
+``clonebundleprefers``
+    Defines preferences for which "clone bundles" to use.
+
+    Servers advertising "clone bundles" may advertise multiple available
+    bundles. Each bundle may have different attributes, such as the bundle
+    type and compression format. This option is used to prefer a particular
+    bundle over another.
+
+    The following keys are defined by Mercurial:
+
+    BUNDLESPEC
+       A bundle type specifier. These are strings passed to :hg:`bundle -t`.
+       e.g. ``gzip-v2`` or ``bzip2-v1``.
+
+    COMPRESSION
+       The compression format of the bundle. e.g. ``gzip`` and ``bzip2``.
+
+    Server operators may define custom keys.
+
+    Example values: ``COMPRESSION=bzip2``,
+    ``BUNDLESPEC=gzip-v2, COMPRESSION=gzip``.
+
+    By default, the first bundle advertised by the server is used.
+
+``color``
+    When to colorize output. Possible value are Boolean ("yes" or "no"), or
+    "debug", or "always". (default: "yes"). "yes" will use color whenever it
+    seems possible. See :hg:`help color` for details.
+
+``commitsubrepos``
+    Whether to commit modified subrepositories when committing the
+    parent repository. If False and one subrepository has uncommitted
+    changes, abort the commit.
+    (default: False)
+
+``debug``
+    Print debugging information. (default: False)
+
+``editor``
+    The editor to use during a commit. (default: ``$EDITOR`` or ``vi``)
+
+``fallbackencoding``
+    Encoding to try if it's not possible to decode the changelog using
+    UTF-8. (default: ISO-8859-1)
+
+``graphnodetemplate``
+    The template used to print changeset nodes in an ASCII revision graph.
+    (default: ``{graphnode}``)
+
+``ignore``
+    A file to read per-user ignore patterns from. This file should be
+    in the same format as a repository-wide .hgignore file. Filenames
+    are relative to the repository root. This option supports hook syntax,
+    so if you want to specify multiple ignore files, you can do so by
+    setting something like ``ignore.other = ~/.hgignore2``. For details
+    of the ignore file format, see the ``hgignore(5)`` man page.
+
+``interactive``
+    Allow to prompt the user. (default: True)
+
+``interface``
+    Select the default interface for interactive features (default: text).
+    Possible values are 'text' and 'curses'.
+
+``interface.chunkselector``
+    Select the interface for change recording (e.g. :hg:`commit -i`).
+    Possible values are 'text' and 'curses'.
+    This config overrides the interface specified by ui.interface.
+
+``large-file-limit``
+    Largest file size that gives no memory use warning.
+    Possible values are integers or 0 to disable the check.
+    (default: 10000000)
+
+``logtemplate``
+    Template string for commands that print changesets.
+
+``merge``
+    The conflict resolution program to use during a manual merge.
+    For more information on merge tools see :hg:`help merge-tools`.
+    For configuring merge tools see the ``[merge-tools]`` section.
+
+``mergemarkers``
+    Sets the merge conflict marker label styling. The ``detailed``
+    style uses the ``mergemarkertemplate`` setting to style the labels.
+    The ``basic`` style just uses 'local' and 'other' as the marker label.
+    One of ``basic`` or ``detailed``.
+    (default: ``basic``)
+
+``mergemarkertemplate``
+    The template used to print the commit description next to each conflict
+    marker during merge conflicts. See :hg:`help templates` for the template
+    format.
+
+    Defaults to showing the hash, tags, branches, bookmarks, author, and
+    the first line of the commit description.
+
+    If you use non-ASCII characters in names for tags, branches, bookmarks,
+    authors, and/or commit descriptions, you must pay attention to encodings of
+    managed files. At template expansion, non-ASCII characters use the encoding
+    specified by the ``--encoding`` global option, ``HGENCODING`` or other
+    environment variables that govern your locale. If the encoding of the merge
+    markers is different from the encoding of the merged files,
+    serious problems may occur.
+
+    Can be overridden per-merge-tool, see the ``[merge-tools]`` section.
+
+``message-output``
+    Where to write status and error messages. (default: ``stdio``)
+
+    ``stderr``
+      Everything to stderr.
+    ``stdio``
+      Status to stdout, and error to stderr.
+
+``origbackuppath``
+    The path to a directory used to store generated .orig files. If the path is
+    not a directory, one will be created.  If set, files stored in this
+    directory have the same name as the original file and do not have a .orig
+    suffix.
+
+``paginate``
+  Control the pagination of command output (default: True). See :hg:`help pager`
+  for details.
+
+``patch``
+    An optional external tool that ``hg import`` and some extensions
+    will use for applying patches. By default Mercurial uses an
+    internal patch utility. The external tool must work as the common
+    Unix ``patch`` program. In particular, it must accept a ``-p``
+    argument to strip patch headers, a ``-d`` argument to specify the
+    current directory, a file name to patch, and a patch file to take
+    from stdin.
+
+    It is possible to specify a patch tool together with extra
+    arguments. For example, setting this option to ``patch --merge``
+    will use the ``patch`` program with its 2-way merge option.
+
+``portablefilenames``
+    Check for portable filenames. Can be ``warn``, ``ignore`` or ``abort``.
+    (default: ``warn``)
+
+    ``warn``
+      Print a warning message on POSIX platforms, if a file with a non-portable
+      filename is added (e.g. a file with a name that can't be created on
+      Windows because it contains reserved parts like ``AUX``, reserved
+      characters like ``:``, or would cause a case collision with an existing
+      file).
+
+    ``ignore``
+      Don't print a warning.
+
+    ``abort``
+      The command is aborted.
+
+    ``true``
+      Alias for ``warn``.
+
+    ``false``
+      Alias for ``ignore``.
+
+    .. container:: windows
+
+      On Windows, this configuration option is ignored and the command aborted.
+
+``pre-merge-tool-output-template``
+    A template that is printed before executing an external merge tool. This can
+    be used to print out additional context that might be useful to have during
+    the conflict resolution, such as the description of the various commits
+    involved or bookmarks/tags.
+
+    Additional information is available in the ``local`, ``base``, and ``other``
+    dicts. For example: ``{local.label}``, ``{base.name}``, or
+    ``{other.islink}``.
+
+``quiet``
+    Reduce the amount of output printed.
+    (default: False)
+
+``relative-paths``
+    Prefer relative paths in the UI.
+
+``remotecmd``
+    Remote command to use for clone/push/pull operations.
+    (default: ``hg``)
+
+``report_untrusted``
+    Warn if a ``.hg/hgrc`` file is ignored due to not being owned by a
+    trusted user or group.
+    (default: True)
+
+``slash``
+    (Deprecated. Use ``slashpath`` template filter instead.)
+
+    Display paths using a slash (``/``) as the path separator. This
+    only makes a difference on systems where the default path
+    separator is not the slash character (e.g. Windows uses the
+    backslash character (``\``)).
+    (default: False)
+
+``statuscopies``
+    Display copies in the status command.
+
+``ssh``
+    Command to use for SSH connections. (default: ``ssh``)
+
+``ssherrorhint``
+    A hint shown to the user in the case of SSH error (e.g.
+    ``Please see http://company/internalwiki/ssh.html``)
+
+``strict``
+    Require exact command names, instead of allowing unambiguous
+    abbreviations. (default: False)
+
+``style``
+    Name of style to use for command output.
+
+``supportcontact``
+    A URL where users should report a Mercurial traceback. Use this if you are a
+    large organisation with its own Mercurial deployment process and crash
+    reports should be addressed to your internal support.
+
+``textwidth``
+    Maximum width of help text. A longer line generated by ``hg help`` or
+    ``hg subcommand --help`` will be broken after white space to get this
+    width or the terminal width, whichever comes first.
+    A non-positive value will disable this and the terminal width will be
+    used. (default: 78)
+
+``timeout``
+    The timeout used when a lock is held (in seconds), a negative value
+    means no timeout. (default: 600)
+
+``timeout.warn``
+    Time (in seconds) before a warning is printed about held lock. A negative
+    value means no warning. (default: 0)
+
+``traceback``
+    Mercurial always prints a traceback when an unknown exception
+    occurs. Setting this to True will make Mercurial print a traceback
+    on all exceptions, even those recognized by Mercurial (such as
+    IOError or MemoryError). (default: False)
+
+``tweakdefaults``
+
+    By default Mercurial's behavior changes very little from release
+    to release, but over time the recommended config settings
+    shift. Enable this config to opt in to get automatic tweaks to
+    Mercurial's behavior over time. This config setting will have no
+    effect if ``HGPLAIN`` is set or ``HGPLAINEXCEPT`` is set and does
+    not include ``tweakdefaults``. (default: False)
+
+    It currently means::
+
+      .. tweakdefaultsmarker
+
+``username``
+    The committer of a changeset created when running "commit".
+    Typically a person's name and email address, e.g. ``Fred Widget
+    <fred@example.com>``. Environment variables in the
+    username are expanded.
+
+    (default: ``$EMAIL`` or ``username@hostname``. If the username in
+    hgrc is empty, e.g. if the system admin set ``username =`` in the
+    system hgrc, it has to be specified manually or in a different
+    hgrc file)
+
+``verbose``
+    Increase the amount of output printed. (default: False)
+
+
+``web``
+-------
+
+Web interface configuration. The settings in this section apply to
+both the builtin webserver (started by :hg:`serve`) and the script you
+run through a webserver (``hgweb.cgi`` and the derivatives for FastCGI
+and WSGI).
+
+The Mercurial webserver does no authentication (it does not prompt for
+usernames and passwords to validate *who* users are), but it does do
+authorization (it grants or denies access for *authenticated users*
+based on settings in this section). You must either configure your
+webserver to do authentication for you, or disable the authorization
+checks.
+
+For a quick setup in a trusted environment, e.g., a private LAN, where
+you want it to accept pushes from anybody, you can use the following
+command line::
+
+    $ hg --config web.allow-push=* --config web.push_ssl=False serve
+
+Note that this will allow anybody to push anything to the server and
+that this should not be used for public servers.
+
+The full set of options is:
+
+``accesslog``
+    Where to output the access log. (default: stdout)
+
+``address``
+    Interface address to bind to. (default: all)
+
+``allow-archive``
+    List of archive format (bz2, gz, zip) allowed for downloading.
+    (default: empty)
+
+``allowbz2``
+    (DEPRECATED) Whether to allow .tar.bz2 downloading of repository
+    revisions.
+    (default: False)
+
+``allowgz``
+    (DEPRECATED) Whether to allow .tar.gz downloading of repository
+    revisions.
+    (default: False)
+
+``allow-pull``
+    Whether to allow pulling from the repository. (default: True)
+
+``allow-push``
+    Whether to allow pushing to the repository. If empty or not set,
+    pushing is not allowed. If the special value ``*``, any remote
+    user can push, including unauthenticated users. Otherwise, the
+    remote user must have been authenticated, and the authenticated
+    user name must be present in this list. The contents of the
+    allow-push list are examined after the deny_push list.
+
+``allow_read``
+    If the user has not already been denied repository access due to
+    the contents of deny_read, this list determines whether to grant
+    repository access to the user. If this list is not empty, and the
+    user is unauthenticated or not present in the list, then access is
+    denied for the user. If the list is empty or not set, then access
+    is permitted to all users by default. Setting allow_read to the
+    special value ``*`` is equivalent to it not being set (i.e. access
+    is permitted to all users). The contents of the allow_read list are
+    examined after the deny_read list.
+
+``allowzip``
+    (DEPRECATED) Whether to allow .zip downloading of repository
+    revisions. This feature creates temporary files.
+    (default: False)
+
+``archivesubrepos``
+    Whether to recurse into subrepositories when archiving.
+    (default: False)
+
+``baseurl``
+    Base URL to use when publishing URLs in other locations, so
+    third-party tools like email notification hooks can construct
+    URLs. Example: ``http://hgserver/repos/``.
+
+``cacerts``
+    Path to file containing a list of PEM encoded certificate
+    authority certificates. Environment variables and ``~user``
+    constructs are expanded in the filename. If specified on the
+    client, then it will verify the identity of remote HTTPS servers
+    with these certificates.
+
+    To disable SSL verification temporarily, specify ``--insecure`` from
+    command line.
+
+    You can use OpenSSL's CA certificate file if your platform has
+    one. On most Linux systems this will be
+    ``/etc/ssl/certs/ca-certificates.crt``. Otherwise you will have to
+    generate this file manually. The form must be as follows::
+
+        -----BEGIN CERTIFICATE-----
+        ... (certificate in base64 PEM encoding) ...
+        -----END CERTIFICATE-----
+        -----BEGIN CERTIFICATE-----
+        ... (certificate in base64 PEM encoding) ...
+        -----END CERTIFICATE-----
+
+``cache``
+    Whether to support caching in hgweb. (default: True)
+
+``certificate``
+    Certificate to use when running :hg:`serve`.
+
+``collapse``
+    With ``descend`` enabled, repositories in subdirectories are shown at
+    a single level alongside repositories in the current path. With
+    ``collapse`` also enabled, repositories residing at a deeper level than
+    the current path are grouped behind navigable directory entries that
+    lead to the locations of these repositories. In effect, this setting
+    collapses each collection of repositories found within a subdirectory
+    into a single entry for that subdirectory. (default: False)
+
+``comparisoncontext``
+    Number of lines of context to show in side-by-side file comparison. If
+    negative or the value ``full``, whole files are shown. (default: 5)
+
+    This setting can be overridden by a ``context`` request parameter to the
+    ``comparison`` command, taking the same values.
+
+``contact``
+    Name or email address of the person in charge of the repository.
+    (default: ui.username or ``$EMAIL`` or "unknown" if unset or empty)
+
+``csp``
+    Send a ``Content-Security-Policy`` HTTP header with this value.
+
+    The value may contain a special string ``%nonce%``, which will be replaced
+    by a randomly-generated one-time use value. If the value contains
+    ``%nonce%``, ``web.cache`` will be disabled, as caching undermines the
+    one-time property of the nonce. This nonce will also be inserted into
+    ``<script>`` elements containing inline JavaScript.
+
+    Note: lots of HTML content sent by the server is derived from repository
+    data. Please consider the potential for malicious repository data to
+    "inject" itself into generated HTML content as part of your security
+    threat model.
+
+``deny_push``
+    Whether to deny pushing to the repository. If empty or not set,
+    push is not denied. If the special value ``*``, all remote users are
+    denied push. Otherwise, unauthenticated users are all denied, and
+    any authenticated user name present in this list is also denied. The
+    contents of the deny_push list are examined before the allow-push list.
+
+``deny_read``
+    Whether to deny reading/viewing of the repository. If this list is
+    not empty, unauthenticated users are all denied, and any
+    authenticated user name present in this list is also denied access to
+    the repository. If set to the special value ``*``, all remote users
+    are denied access (rarely needed ;). If deny_read is empty or not set,
+    the determination of repository access depends on the presence and
+    content of the allow_read list (see description). If both
+    deny_read and allow_read are empty or not set, then access is
+    permitted to all users by default. If the repository is being
+    served via hgwebdir, denied users will not be able to see it in
+    the list of repositories. The contents of the deny_read list have
+    priority over (are examined before) the contents of the allow_read
+    list.
+
+``descend``
+    hgwebdir indexes will not descend into subdirectories. Only repositories
+    directly in the current path will be shown (other repositories are still
+    available from the index corresponding to their containing path).
+
+``description``
+    Textual description of the repository's purpose or contents.
+    (default: "unknown")
+
+``encoding``
+    Character encoding name. (default: the current locale charset)
+    Example: "UTF-8".
+
+``errorlog``
+    Where to output the error log. (default: stderr)
+
+``guessmime``
+    Control MIME types for raw download of file content.
+    Set to True to let hgweb guess the content type from the file
+    extension. This will serve HTML files as ``text/html`` and might
+    allow cross-site scripting attacks when serving untrusted
+    repositories. (default: False)
+
+``hidden``
+    Whether to hide the repository in the hgwebdir index.
+    (default: False)
+
+``ipv6``
+    Whether to use IPv6. (default: False)
+
+``labels``
+    List of string *labels* associated with the repository.
+
+    Labels are exposed as a template keyword and can be used to customize
+    output. e.g. the ``index`` template can group or filter repositories
+    by labels and the ``summary`` template can display additional content
+    if a specific label is present.
+
+``logoimg``
+    File name of the logo image that some templates display on each page.
+    The file name is relative to ``staticurl``. That is, the full path to
+    the logo image is "staticurl/logoimg".
+    If unset, ``hglogo.png`` will be used.
+
+``logourl``
+    Base URL to use for logos. If unset, ``https://mercurial-scm.org/``
+    will be used.
+
+``maxchanges``
+    Maximum number of changes to list on the changelog. (default: 10)
+
+``maxfiles``
+    Maximum number of files to list per changeset. (default: 10)
+
+``maxshortchanges``
+    Maximum number of changes to list on the shortlog, graph or filelog
+    pages. (default: 60)
+
+``name``
+    Repository name to use in the web interface.
+    (default: current working directory)
+
+``port``
+    Port to listen on. (default: 8000)
+
+``prefix``
+    Prefix path to serve from. (default: '' (server root))
+
+``push_ssl``
+    Whether to require that inbound pushes be transported over SSL to
+    prevent password sniffing. (default: True)
+
+``refreshinterval``
+    How frequently directory listings re-scan the filesystem for new
+    repositories, in seconds. This is relevant when wildcards are used
+    to define paths. Depending on how much filesystem traversal is
+    required, refreshing may negatively impact performance.
+
+    Values less than or equal to 0 always refresh.
+    (default: 20)
+
+``server-header``
+    Value for HTTP ``Server`` response header.
+
+``static``
+    Directory where static files are served from.
+
+``staticurl``
+    Base URL to use for static files. If unset, static files (e.g. the
+    hgicon.png favicon) will be served by the CGI script itself. Use
+    this setting to serve them directly with the HTTP server.
+    Example: ``http://hgserver/static/``.
+
+``stripes``
+    How many lines a "zebra stripe" should span in multi-line output.
+    Set to 0 to disable. (default: 1)
+
+``style``
+    Which template map style to use. The available options are the names of
+    subdirectories in the HTML templates path. (default: ``paper``)
+    Example: ``monoblue``.
+
+``templates``
+    Where to find the HTML templates. The default path to the HTML templates
+    can be obtained from ``hg debuginstall``.
+
+``websub``
+----------
+
+Web substitution filter definition. You can use this section to
+define a set of regular expression substitution patterns which
+let you automatically modify the hgweb server output.
+
+The default hgweb templates only apply these substitution patterns
+on the revision description fields. You can apply them anywhere
+you want when you create your own templates by adding calls to the
+"websub" filter (usually after calling the "escape" filter).
+
+This can be used, for example, to convert issue references to links
+to your issue tracker, or to convert "markdown-like" syntax into
+HTML (see the examples below).
+
+Each entry in this section names a substitution filter.
+The value of each entry defines the substitution expression itself.
+The websub expressions follow the old interhg extension syntax,
+which in turn imitates the Unix sed replacement syntax::
+
+    patternname = s/SEARCH_REGEX/REPLACE_EXPRESSION/[i]
+
+You can use any separator other than "/". The final "i" is optional
+and indicates that the search must be case insensitive.
+
+Examples::
+
+    [websub]
+    issues = s|issue(\d+)|<a href="http://bts.example.org/issue\1">issue\1</a>|i
+    italic = s/\b_(\S+)_\b/<i>\1<\/i>/
+    bold = s/\*\b(\S+)\b\*/<b>\1<\/b>/
+
+``worker``
+----------
+
+Parallel master/worker configuration. We currently perform working
+directory updates in parallel on Unix-like systems, which greatly
+helps performance.
+
+``enabled``
+    Whether to enable workers code to be used.
+    (default: true)
+
+``numcpus``
+    Number of CPUs to use for parallel operations. A zero or
+    negative value is treated as ``use the default``.
+    (default: 4 or the number of CPUs on the system, whichever is larger)
+
+``backgroundclose``
+    Whether to enable closing file handles on background threads during certain
+    operations. Some platforms aren't very efficient at closing file
+    handles that have been written or appended to. By performing file closing
+    on background threads, file write rate can increase substantially.
+    (default: true on Windows, false elsewhere)
+
+``backgroundcloseminfilecount``
+    Minimum number of files required to trigger background file closing.
+    Operations not writing this many files won't start background close
+    threads.
+    (default: 2048)
+
+``backgroundclosemaxqueue``
+    The maximum number of opened file handles waiting to be closed in the
+    background. This option only has an effect if ``backgroundclose`` is
+    enabled.
+    (default: 384)
+
+``backgroundclosethreadcount``
+    Number of threads to process background file closes. Only relevant if
+    ``backgroundclose`` is enabled.
+    (default: 4)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mercurial/helptext/dates.txt	Fri Nov 22 21:42:04 2019 +0900
@@ -0,0 +1,39 @@
+Some commands allow the user to specify a date, e.g.:
+
+- backout, commit, import, tag: Specify the commit date.
+- log, revert, update: Select revision(s) by date.
+
+Many date formats are valid. Here are some examples:
+
+- ``Wed Dec 6 13:18:29 2006`` (local timezone assumed)
+- ``Dec 6 13:18 -0600`` (year assumed, time offset provided)
+- ``Dec 6 13:18 UTC`` (UTC and GMT are aliases for +0000)
+- ``Dec 6`` (midnight)
+- ``13:18`` (today assumed)
+- ``3:39`` (3:39AM assumed)
+- ``3:39pm`` (15:39)
+- ``2006-12-06 13:18:29`` (ISO 8601 format)
+- ``2006-12-6 13:18``
+- ``2006-12-6``
+- ``12-6``
+- ``12/6``
+- ``12/6/6`` (Dec 6 2006)
+- ``today`` (midnight)
+- ``yesterday`` (midnight)
+- ``now`` - right now
+
+Lastly, there is Mercurial's internal format:
+
+- ``1165411109 0`` (Wed Dec 6 13:18:29 2006 UTC)
+
+This is the internal representation format for dates. The first number
+is the number of seconds since the epoch (1970-01-01 00:00 UTC). The
+second is the offset of the local timezone, in seconds west of UTC
+(negative if the timezone is east of UTC).
+
+The log command also accepts date ranges:
+
+- ``<DATE`` - at or before a given date/time
+- ``>DATE`` - on or after a given date/time
+- ``DATE to DATE`` - a date range, inclusive
+- ``-DAYS`` - within a given number of days of today
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mercurial/helptext/deprecated.txt	Fri Nov 22 21:42:04 2019 +0900
@@ -0,0 +1,30 @@
+Mercurial evolves over time, some features, options, commands may be replaced by
+better and more secure alternatives. This topic will help you migrating your
+existing usage and/or configuration to newer features.
+
+Commands
+========
+
+The following commands are still available but their use are not recommended:
+
+``locate``
+
+This command has been replaced by `hg files`.
+
+``parents``
+
+This command can be replaced by `hg summary` or `hg log` with appropriate
+revsets. See `hg help revsets` for more information.
+
+``tip``
+
+The recommended alternative is `hg heads`.
+
+Options
+=======
+
+``web.allowpull``
+    Renamed to `allow-pull`.
+
+``web.allow_push``
+    Renamed to `allow-push`.
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mercurial/helptext/diffs.txt	Fri Nov 22 21:42:04 2019 +0900
@@ -0,0 +1,29 @@
+Mercurial's default format for showing changes between two versions of
+a file is compatible with the unified format of GNU diff, which can be
+used by GNU patch and many other standard tools.
+
+While this standard format is often enough, it does not encode the
+following information:
+
+- executable status and other permission bits
+- copy or rename information
+- changes in binary files
+- creation or deletion of empty files
+
+Mercurial also supports the extended diff format from the git VCS
+which addresses these limitations. The git diff format is not produced
+by default because a few widespread tools still do not understand this
+format.
+
+This means that when generating diffs from a Mercurial repository
+(e.g. with :hg:`export`), you should be careful about things like file
+copies and renames or other things mentioned above, because when
+applying a standard diff to a different repository, this extra
+information is lost. Mercurial's internal operations (like push and
+pull) are not affected by this, because they use an internal binary
+format for communicating changes.
+
+To make Mercurial produce the git extended diff format, use the --git
+option available for many commands, or set 'git = True' in the [diff]
+section of your configuration file. You do not need to set this option
+when importing diffs in this format or using them in the mq extension.
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mercurial/helptext/environment.txt	Fri Nov 22 21:42:04 2019 +0900
@@ -0,0 +1,121 @@
+HG
+    Path to the 'hg' executable, automatically passed when running
+    hooks, extensions or external tools. If unset or empty, this is
+    the hg executable's name if it's frozen, or an executable named
+    'hg' (with %PATHEXT% [defaulting to COM/EXE/BAT/CMD] extensions on
+    Windows) is searched.
+
+HGEDITOR
+    This is the name of the editor to run when committing. See EDITOR.
+
+    (deprecated, see :hg:`help config.ui.editor`)
+
+HGENCODING
+    This overrides the default locale setting detected by Mercurial.
+    This setting is used to convert data including usernames,
+    changeset descriptions, tag names, and branches. This setting can
+    be overridden with the --encoding command-line option.
+
+HGENCODINGMODE
+    This sets Mercurial's behavior for handling unknown characters
+    while transcoding user input. The default is "strict", which
+    causes Mercurial to abort if it can't map a character. Other
+    settings include "replace", which replaces unknown characters, and
+    "ignore", which drops them. This setting can be overridden with
+    the --encodingmode command-line option.
+
+HGENCODINGAMBIGUOUS
+    This sets Mercurial's behavior for handling characters with
+    "ambiguous" widths like accented Latin characters with East Asian
+    fonts. By default, Mercurial assumes ambiguous characters are
+    narrow, set this variable to "wide" if such characters cause
+    formatting problems.
+
+HGMERGE
+    An executable to use for resolving merge conflicts. The program
+    will be executed with three arguments: local file, remote file,
+    ancestor file.
+
+    (deprecated, see :hg:`help config.ui.merge`)
+
+HGRCPATH
+    A list of files or directories to search for configuration
+    files. Item separator is ":" on Unix, ";" on Windows. If HGRCPATH
+    is not set, platform default search path is used. If empty, only
+    the .hg/hgrc from the current repository is read.
+
+    For each element in HGRCPATH:
+
+    - if it's a directory, all files ending with .rc are added
+    - otherwise, the file itself will be added
+
+HGPLAIN
+    When set, this disables any configuration settings that might
+    change Mercurial's default output. This includes encoding,
+    defaults, verbose mode, debug mode, quiet mode, tracebacks, and
+    localization. This can be useful when scripting against Mercurial
+    in the face of existing user configuration.
+
+    In addition to the features disabled by ``HGPLAIN=``, the following
+    values can be specified to adjust behavior:
+
+    ``+strictflags``
+        Restrict parsing of command line flags.
+
+    Equivalent options set via command line flags or environment
+    variables are not overridden.
+
+    See :hg:`help scripting` for details.
+
+HGPLAINEXCEPT
+    This is a comma-separated list of features to preserve when
+    HGPLAIN is enabled. Currently the following values are supported:
+
+    ``alias``
+        Don't remove aliases.
+    ``color``
+        Don't disable colored output.
+    ``i18n``
+        Preserve internationalization.
+    ``revsetalias``
+        Don't remove revset aliases.
+    ``templatealias``
+        Don't remove template aliases.
+    ``progress``
+        Don't hide progress output.
+
+    Setting HGPLAINEXCEPT to anything (even an empty string) will
+    enable plain mode.
+
+HGUSER
+    This is the string used as the author of a commit. If not set,
+    available values will be considered in this order:
+
+    - HGUSER (deprecated)
+    - configuration files from the HGRCPATH
+    - EMAIL
+    - interactive prompt
+    - LOGNAME (with ``@hostname`` appended)
+
+    (deprecated, see :hg:`help config.ui.username`)
+
+EMAIL
+    May be used as the author of a commit; see HGUSER.
+
+LOGNAME
+    May be used as the author of a commit; see HGUSER.
+
+VISUAL
+    This is the name of the editor to use when committing. See EDITOR.
+
+EDITOR
+    Sometimes Mercurial needs to open a text file in an editor for a
+    user to modify, for example when writing commit messages. The
+    editor it uses is determined by looking at the environment
+    variables HGEDITOR, VISUAL and EDITOR, in that order. The first
+    non-empty one is chosen. If all of them are empty, the editor
+    defaults to 'vi'.
+
+PYTHONPATH
+    This is used by Python to find imported modules and may need to be
+    set appropriately if this Mercurial is not installed system-wide.
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mercurial/helptext/extensions.txt	Fri Nov 22 21:42:04 2019 +0900
@@ -0,0 +1,35 @@
+Mercurial has the ability to add new features through the use of
+extensions. Extensions may add new commands, add options to
+existing commands, change the default behavior of commands, or
+implement hooks.
+
+To enable the "foo" extension, either shipped with Mercurial or in the
+Python search path, create an entry for it in your configuration file,
+like this::
+
+  [extensions]
+  foo =
+
+You may also specify the full path to an extension::
+
+  [extensions]
+  myfeature = ~/.hgext/myfeature.py
+
+See :hg:`help config` for more information on configuration files.
+
+Extensions are not loaded by default for a variety of reasons:
+they can increase startup overhead; they may be meant for advanced
+usage only; they may provide potentially dangerous abilities (such
+as letting you destroy or modify history); they might not be ready
+for prime time; or they may alter some usual behaviors of stock
+Mercurial. It is thus up to the user to activate extensions as
+needed.
+
+To explicitly disable an extension enabled in a configuration file of
+broader scope, prepend its path with !::
+
+  [extensions]
+  # disabling extension bar residing in /path/to/extension/bar.py
+  bar = !/path/to/extension/bar.py
+  # ditto, but no path was supplied for extension baz
+  baz = !
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mercurial/helptext/filesets.txt	Fri Nov 22 21:42:04 2019 +0900
@@ -0,0 +1,79 @@
+Mercurial supports a functional language for selecting a set of
+files.
+
+Like other file patterns, this pattern type is indicated by a prefix,
+'set:'. The language supports a number of predicates which are joined
+by infix operators. Parenthesis can be used for grouping.
+
+Identifiers such as filenames or patterns must be quoted with single
+or double quotes if they contain characters outside of
+``[.*{}[]?/\_a-zA-Z0-9\x80-\xff]`` or if they match one of the
+predefined predicates. This generally applies to file patterns other
+than globs and arguments for predicates. Pattern prefixes such as
+``path:`` may be specified without quoting.
+
+Special characters can be used in quoted identifiers by escaping them,
+e.g., ``\n`` is interpreted as a newline. To prevent them from being
+interpreted, strings can be prefixed with ``r``, e.g. ``r'...'``.
+
+See also :hg:`help patterns`.
+
+Operators
+=========
+
+There is a single prefix operator:
+
+``not x``
+  Files not in x. Short form is ``! x``.
+
+These are the supported infix operators:
+
+``x and y``
+  The intersection of files in x and y. Short form is ``x & y``.
+
+``x or y``
+  The union of files in x and y. There are two alternative short
+  forms: ``x | y`` and ``x + y``.
+
+``x - y``
+  Files in x but not in y.
+
+Predicates
+==========
+
+The following predicates are supported:
+
+.. predicatesmarker
+
+Examples
+========
+
+Some sample queries:
+
+- Show status of files that appear to be binary in the working directory::
+
+    hg status -A "set:binary()"
+
+- Forget files that are in .hgignore but are already tracked::
+
+    hg forget "set:hgignore() and not ignored()"
+
+- Find text files that contain a string::
+
+    hg files "set:grep(magic) and not binary()"
+
+- Find C files in a non-standard encoding::
+
+    hg files "set:**.c and not encoding('UTF-8')"
+
+- Revert copies of large binary files::
+
+    hg revert "set:copied() and binary() and size('>1M')"
+
+- Revert files that were added to the working directory::
+
+    hg revert "set:revs('wdir()', added())"
+
+- Remove files listed in foo.lst that contain the letter a or b::
+
+    hg remove "set: listfile:foo.lst and (**a* or **b*)"
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mercurial/helptext/flags.txt	Fri Nov 22 21:42:04 2019 +0900
@@ -0,0 +1,104 @@
+Most Mercurial commands accept various flags.
+
+Flag names
+==========
+
+Flags for each command are listed in :hg:`help` for that command.
+Additionally, some flags, such as --repository, are global and can be used with
+any command - those are seen in :hg:`help -v`, and can be specified before or
+after the command.
+
+Every flag has at least a long name, such as --repository. Some flags may also
+have a short one-letter name, such as the equivalent -R. Using the short or long
+name is equivalent and has the same effect.
+
+Flags that have a short name can also be bundled together - for instance, to
+specify both --edit (short -e) and --interactive (short -i), one could use::
+
+    hg commit -ei
+
+If any of the bundled flags takes a value (i.e. is not a boolean), it must be
+last, followed by the value::
+
+    hg commit -im 'Message'
+
+Flag types
+==========
+
+Mercurial command-line flags can be strings, numbers, booleans, or lists of
+strings.
+
+Specifying flag values
+======================
+
+The following syntaxes are allowed, assuming a flag 'flagname' with short name
+'f'::
+
+    --flagname=foo
+    --flagname foo
+    -f foo
+    -ffoo
+
+This syntax applies to all non-boolean flags (strings, numbers or lists).
+
+Specifying boolean flags
+========================
+
+Boolean flags do not take a value parameter. To specify a boolean, use the flag
+name to set it to true, or the same name prefixed with 'no-' to set it to
+false::
+
+    hg commit --interactive
+    hg commit --no-interactive
+
+Specifying list flags
+=====================
+
+List flags take multiple values. To specify them, pass the flag multiple times::
+
+    hg files --include mercurial --include tests
+
+Setting flag defaults
+=====================
+
+In order to set a default value for a flag in an hgrc file, it is recommended to
+use aliases::
+
+    [alias]
+    commit = commit --interactive
+
+For more information on hgrc files, see :hg:`help config`.
+
+Overriding flags on the command line
+====================================
+
+If the same non-list flag is specified multiple times on the command line, the
+latest specification is used::
+
+    hg commit -m "Ignored value" -m "Used value"
+
+This includes the use of aliases - e.g., if one has::
+
+    [alias]
+    committemp = commit -m "Ignored value"
+
+then the following command will override that -m::
+
+    hg committemp -m "Used value"
+
+Overriding flag defaults
+========================
+
+Every flag has a default value, and you may also set your own defaults in hgrc
+as described above.
+Except for list flags, defaults can be overridden on the command line simply by
+specifying the flag in that location.
+
+Hidden flags
+============
+
+Some flags are not shown in a command's help by default - specifically, those
+that are deemed to be experimental, deprecated or advanced. To show all flags,
+add the --verbose flag for the help command::
+
+    hg help --verbose commit
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mercurial/helptext/glossary.txt	Fri Nov 22 21:42:04 2019 +0900
@@ -0,0 +1,413 @@
+Ancestor
+    Any changeset that can be reached by an unbroken chain of parent
+    changesets from a given changeset. More precisely, the ancestors
+    of a changeset can be defined by two properties: a parent of a
+    changeset is an ancestor, and a parent of an ancestor is an
+    ancestor. See also: 'Descendant'.
+
+Bookmark
+    Bookmarks are pointers to certain commits that move when
+    committing. They are similar to tags in that it is possible to use
+    bookmark names in all places where Mercurial expects a changeset
+    ID, e.g., with :hg:`update`. Unlike tags, bookmarks move along
+    when you make a commit.
+
+    Bookmarks can be renamed, copied and deleted. Bookmarks are local,
+    unless they are explicitly pushed or pulled between repositories.
+    Pushing and pulling bookmarks allow you to collaborate with others
+    on a branch without creating a named branch.
+
+Branch
+    (Noun) A child changeset that has been created from a parent that
+    is not a head. These are known as topological branches, see
+    'Branch, topological'. If a topological branch is named, it becomes
+    a named branch. If a topological branch is not named, it becomes
+    an anonymous branch. See 'Branch, anonymous' and 'Branch, named'.
+
+    Branches may be created when changes are pulled from or pushed to
+    a remote repository, since new heads may be created by these
+    operations. Note that the term branch can also be used informally
+    to describe a development process in which certain development is
+    done independently of other development. This is sometimes done
+    explicitly with a named branch, but it can also be done locally,
+    using bookmarks or clones and anonymous branches.
+
+    Example: "The experimental branch."
+
+    (Verb) The action of creating a child changeset which results in
+    its parent having more than one child.
+
+    Example: "I'm going to branch at X."
+
+Branch, anonymous
+    Every time a new child changeset is created from a parent that is not
+    a head and the name of the branch is not changed, a new anonymous
+    branch is created.
+
+Branch, closed
+    A named branch whose branch heads have all been closed.
+
+Branch, default
+    The branch assigned to a changeset when no name has previously been
+    assigned.
+
+Branch head
+    See 'Head, branch'.
+
+Branch, inactive
+    If a named branch has no topological heads, it is considered to be
+    inactive. As an example, a feature branch becomes inactive when it
+    is merged into the default branch. The :hg:`branches` command
+    shows inactive branches by default, though they can be hidden with
+    :hg:`branches --active`.
+
+    NOTE: this concept is deprecated because it is too implicit.
+    Branches should now be explicitly closed using :hg:`commit
+    --close-branch` when they are no longer needed.
+
+Branch, named
+    A collection of changesets which have the same branch name. By
+    default, children of a changeset in a named branch belong to the
+    same named branch. A child can be explicitly assigned to a
+    different branch. See :hg:`help branch`, :hg:`help branches` and
+    :hg:`commit --close-branch` for more information on managing
+    branches.
+
+    Named branches can be thought of as a kind of namespace, dividing
+    the collection of changesets that comprise the repository into a
+    collection of disjoint subsets. A named branch is not necessarily
+    a topological branch. If a new named branch is created from the
+    head of another named branch, or the default branch, but no
+    further changesets are added to that previous branch, then that
+    previous branch will be a branch in name only.
+
+Branch tip
+    See 'Tip, branch'.
+
+Branch, topological
+    Every time a new child changeset is created from a parent that is
+    not a head, a new topological branch is created. If a topological
+    branch is named, it becomes a named branch. If a topological
+    branch is not named, it becomes an anonymous branch of the
+    current, possibly default, branch.
+
+Changelog
+    A record of the changesets in the order in which they were added
+    to the repository. This includes details such as changeset id,
+    author, commit message, date, and list of changed files.
+
+Changeset
+    A snapshot of the state of the repository used to record a change.
+
+Changeset, child
+    The converse of parent changeset: if P is a parent of C, then C is
+    a child of P. There is no limit to the number of children that a
+    changeset may have.
+
+Changeset id
+    A SHA-1 hash that uniquely identifies a changeset. It may be
+    represented as either a "long" 40 hexadecimal digit string, or a
+    "short" 12 hexadecimal digit string.
+
+Changeset, merge
+    A changeset with two parents. This occurs when a merge is
+    committed.
+
+Changeset, parent
+    A revision upon which a child changeset is based. Specifically, a
+    parent changeset of a changeset C is a changeset whose node
+    immediately precedes C in the DAG. Changesets have at most two
+    parents.
+
+Checkout
+    (Noun) The working directory being updated to a specific
+    revision. This use should probably be avoided where possible, as
+    changeset is much more appropriate than checkout in this context.
+
+    Example: "I'm using checkout X."
+
+    (Verb) Updating the working directory to a specific changeset. See
+    :hg:`help update`.
+
+    Example: "I'm going to check out changeset X."
+
+Child changeset
+    See 'Changeset, child'.
+
+Close changeset
+    See 'Head, closed branch'.
+
+Closed branch
+    See 'Branch, closed'.
+
+Clone
+    (Noun) An entire or partial copy of a repository. The partial
+    clone must be in the form of a revision and its ancestors.
+
+    Example: "Is your clone up to date?"
+
+    (Verb) The process of creating a clone, using :hg:`clone`.
+
+    Example: "I'm going to clone the repository."
+
+Closed branch head
+    See 'Head, closed branch'.
+
+Commit
+    (Noun) A synonym for changeset.
+
+    Example: "Is the bug fixed in your recent commit?"
+
+    (Verb) The act of recording changes to a repository. When files
+    are committed in a working directory, Mercurial finds the
+    differences between the committed files and their parent
+    changeset, creating a new changeset in the repository.
+
+    Example: "You should commit those changes now."
+
+Cset
+    A common abbreviation of the term changeset.
+
+DAG
+    The repository of changesets of a distributed version control
+    system (DVCS) can be described as a directed acyclic graph (DAG),
+    consisting of nodes and edges, where nodes correspond to
+    changesets and edges imply a parent -> child relation. This graph
+    can be visualized by graphical tools such as :hg:`log --graph`. In
+    Mercurial, the DAG is limited by the requirement for children to
+    have at most two parents.
+
+Deprecated
+    Feature removed from documentation, but not scheduled for removal.
+
+Default branch
+    See 'Branch, default'.
+
+Descendant
+    Any changeset that can be reached by a chain of child changesets
+    from a given changeset. More precisely, the descendants of a
+    changeset can be defined by two properties: the child of a
+    changeset is a descendant, and the child of a descendant is a
+    descendant. See also: 'Ancestor'.
+
+Diff
+    (Noun) The difference between the contents and attributes of files
+    in two changesets or a changeset and the current working
+    directory. The difference is usually represented in a standard
+    form called a "diff" or "patch". The "git diff" format is used
+    when the changes include copies, renames, or changes to file
+    attributes, none of which can be represented/handled by classic
+    "diff" and "patch".
+
+    Example: "Did you see my correction in the diff?"
+
+    (Verb) Diffing two changesets is the action of creating a diff or
+    patch.
+
+    Example: "If you diff with changeset X, you will see what I mean."
+
+Directory, working
+    The working directory represents the state of the files tracked by
+    Mercurial, that will be recorded in the next commit. The working
+    directory initially corresponds to the snapshot at an existing
+    changeset, known as the parent of the working directory. See
+    'Parent, working directory'. The state may be modified by changes
+    to the files introduced manually or by a merge. The repository
+    metadata exists in the .hg directory inside the working directory.
+
+Draft
+    Changesets in the draft phase have not been shared with publishing
+    repositories and may thus be safely changed by history-modifying
+    extensions. See :hg:`help phases`.
+
+Experimental
+    Feature that may change or be removed at a later date.
+
+Graph
+    See DAG and :hg:`log --graph`.
+
+Head
+    The term 'head' may be used to refer to both a branch head or a
+    repository head, depending on the context. See 'Head, branch' and
+    'Head, repository' for specific definitions.
+
+    Heads are where development generally takes place and are the
+    usual targets for update and merge operations.
+
+Head, branch
+    A changeset with no descendants on the same named branch.
+
+Head, closed branch
+    A changeset that marks a head as no longer interesting. The closed
+    head is no longer listed by :hg:`heads`. A branch is considered
+    closed when all its heads are closed and consequently is not
+    listed by :hg:`branches`.
+
+    Closed heads can be re-opened by committing new changeset as the
+    child of the changeset that marks a head as closed.
+
+Head, repository
+    A topological head which has not been closed.
+
+Head, topological
+    A changeset with no children in the repository.
+
+History, immutable
+    Once committed, changesets cannot be altered.  Extensions which
+    appear to change history actually create new changesets that
+    replace existing ones, and then destroy the old changesets. Doing
+    so in public repositories can result in old changesets being
+    reintroduced to the repository.
+
+History, rewriting
+    The changesets in a repository are immutable. However, extensions
+    to Mercurial can be used to alter the repository, usually in such
+    a way as to preserve changeset contents.
+
+Immutable history
+    See 'History, immutable'.
+
+Merge changeset
+    See 'Changeset, merge'.
+
+Manifest
+    Each changeset has a manifest, which is the list of files that are
+    tracked by the changeset.
+
+Merge
+    Used to bring together divergent branches of work. When you update
+    to a changeset and then merge another changeset, you bring the
+    history of the latter changeset into your working directory. Once
+    conflicts are resolved (and marked), this merge may be committed
+    as a merge changeset, bringing two branches together in the DAG.
+
+Named branch
+    See 'Branch, named'.
+
+Null changeset
+    The empty changeset. It is the parent state of newly-initialized
+    repositories and repositories with no checked out revision. It is
+    thus the parent of root changesets and the effective ancestor when
+    merging unrelated changesets. Can be specified by the alias 'null'
+    or by the changeset ID '000000000000'.
+
+Parent
+    See 'Changeset, parent'.
+
+Parent changeset
+    See 'Changeset, parent'.
+
+Parent, working directory
+    The working directory parent reflects a virtual revision which is
+    the child of the changeset (or two changesets with an uncommitted
+    merge) shown by :hg:`parents`. This is changed with
+    :hg:`update`. Other commands to see the working directory parent
+    are :hg:`summary` and :hg:`id`. Can be specified by the alias ".".
+
+Patch
+    (Noun) The product of a diff operation.
+
+    Example: "I've sent you my patch."
+
+    (Verb) The process of using a patch file to transform one
+    changeset into another.
+
+    Example: "You will need to patch that revision."
+
+Phase
+    A per-changeset state tracking how the changeset has been or
+    should be shared. See :hg:`help phases`.
+
+Public
+    Changesets in the public phase have been shared with publishing
+    repositories and are therefore considered immutable. See :hg:`help
+    phases`.
+
+Pull
+    An operation in which changesets in a remote repository which are
+    not in the local repository are brought into the local
+    repository. Note that this operation without special arguments
+    only updates the repository, it does not update the files in the
+    working directory. See :hg:`help pull`.
+
+Push
+    An operation in which changesets in a local repository which are
+    not in a remote repository are sent to the remote repository. Note
+    that this operation only adds changesets which have been committed
+    locally to the remote repository. Uncommitted changes are not
+    sent. See :hg:`help push`.
+
+Repository
+    The metadata describing all recorded states of a collection of
+    files. Each recorded state is represented by a changeset. A
+    repository is usually (but not always) found in the ``.hg``
+    subdirectory of a working directory. Any recorded state can be
+    recreated by "updating" a working directory to a specific
+    changeset.
+
+Repository head
+    See 'Head, repository'.
+
+Revision
+    A state of the repository at some point in time. Earlier revisions
+    can be updated to by using :hg:`update`.  See also 'Revision
+    number'; See also 'Changeset'.
+
+Revision number
+    This integer uniquely identifies a changeset in a specific
+    repository. It represents the order in which changesets were added
+    to a repository, starting with revision number 0. Note that the
+    revision number may be different in each clone of a repository. To
+    identify changesets uniquely between different clones, see
+    'Changeset id'.
+
+Revlog
+    History storage mechanism used by Mercurial. It is a form of delta
+    encoding, with occasional full revision of data followed by delta
+    of each successive revision. It includes data and an index
+    pointing to the data.
+
+Rewriting history
+    See 'History, rewriting'.
+
+Root
+    A changeset that has only the null changeset as its parent. Most
+    repositories have only a single root changeset.
+
+Secret
+    Changesets in the secret phase may not be shared via push, pull,
+    or clone. See :hg:`help phases`.
+
+Tag
+    An alternative name given to a changeset. Tags can be used in all
+    places where Mercurial expects a changeset ID, e.g., with
+    :hg:`update`. The creation of a tag is stored in the history and
+    will thus automatically be shared with other using push and pull.
+
+Tip
+    The changeset with the highest revision number. It is the changeset
+    most recently added in a repository.
+
+Tip, branch
+    The head of a given branch with the highest revision number. When
+    a branch name is used as a revision identifier, it refers to the
+    branch tip. See also 'Branch, head'. Note that because revision
+    numbers may be different in different repository clones, the
+    branch tip may be different in different cloned repositories.
+
+Update
+    (Noun) Another synonym of changeset.
+
+    Example: "I've pushed an update."
+
+    (Verb) This term is usually used to describe updating the state of
+    the working directory to that of a specific changeset. See
+    :hg:`help update`.
+
+    Example: "You should update."
+
+Working directory
+    See 'Directory, working'.
+
+Working directory parent
+    See 'Parent, working directory'.
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mercurial/helptext/hg-ssh.8.txt	Fri Nov 22 21:42:04 2019 +0900
@@ -0,0 +1,71 @@
+========
+ hg-ssh
+========
+
+----------------------------------------
+restricted ssh login shell for Mercurial
+----------------------------------------
+
+:Author:         Thomas Arendsen Hein <thomas@intevation.de>
+:Organization:   Mercurial
+:Manual section: 8
+:Manual group:   Mercurial Manual
+
+.. contents::
+   :backlinks: top
+   :class: htmlonly
+   :depth: 1
+
+Synopsis
+""""""""
+**hg-ssh** repositories...
+
+Description
+"""""""""""
+**hg-ssh** is a wrapper for ssh access to a limited set of mercurial repos.
+
+To be used in ~/.ssh/authorized_keys with the "command" option, see sshd(8):
+command="hg-ssh path/to/repo1 /path/to/repo2 ~/repo3 ~user/repo4" ssh-dss ...
+(probably together with these other useful options:
+no-port-forwarding,no-X11-forwarding,no-agent-forwarding)
+
+This allows pull/push over ssh from/to the repositories given as arguments.
+
+If all your repositories are subdirectories of a common directory, you can
+allow shorter paths with:
+command="cd path/to/my/repositories && hg-ssh repo1 subdir/repo2"
+
+You can use pattern matching of your normal shell, e.g.:
+command="cd repos && hg-ssh user/thomas/* projects/{mercurial,foo}"
+
+You can also add a --read-only flag to allow read-only access to a key, e.g.:
+command="hg-ssh --read-only repos/\*"
+
+Bugs
+""""
+Probably lots, please post them to the mailing list (see Resources_
+below) when you find them.
+
+See Also
+""""""""
+|hg(1)|_
+
+Author
+""""""
+Written by Matt Mackall <mpm@selenic.com>
+
+Resources
+"""""""""
+Main Web Site: https://mercurial-scm.org/
+
+Source code repository: https://www.mercurial-scm.org/repo/hg
+
+Mailing list: https://www.mercurial-scm.org/mailman/listinfo/mercurial/
+
+Copying
+"""""""
+Copyright (C) 2005-2016 Matt Mackall.
+Free use of this software is granted under the terms of the GNU General
+Public License version 2 or any later version.
+
+.. include:: common.txt
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mercurial/helptext/hg.1.txt	Fri Nov 22 21:42:04 2019 +0900
@@ -0,0 +1,119 @@
+====
+ hg
+====
+
+---------------------------------------
+Mercurial source code management system
+---------------------------------------
+
+:Author:         Matt Mackall <mpm@selenic.com>
+:Organization:   Mercurial
+:Manual section: 1
+:Manual group:   Mercurial Manual
+
+.. contents::
+   :backlinks: top
+   :class: htmlonly
+   :depth: 1
+
+
+Synopsis
+""""""""
+**hg** *command* [*option*]... [*argument*]...
+
+Description
+"""""""""""
+The **hg** command provides a command line interface to the Mercurial
+system.
+
+Command Elements
+""""""""""""""""
+
+files...
+    indicates one or more filename or relative path filenames; see
+    `File Name Patterns`_ for information on pattern matching
+
+path
+    indicates a path on the local machine
+
+revision
+    indicates a changeset which can be specified as a changeset
+    revision number, a tag, or a unique substring of the changeset
+    hash value
+
+repository path
+    either the pathname of a local repository or the URI of a remote
+    repository.
+
+.. include:: hg.1.gendoc.txt
+
+Files
+"""""
+
+``/etc/mercurial/hgrc``, ``$HOME/.hgrc``, ``.hg/hgrc``
+    This file contains defaults and configuration. Values in
+    ``.hg/hgrc`` override those in ``$HOME/.hgrc``, and these override
+    settings made in the global ``/etc/mercurial/hgrc`` configuration.
+    See |hgrc(5)|_ for details of the contents and format of these
+    files.
+
+``.hgignore``
+    This file contains regular expressions (one per line) that
+    describe file names that should be ignored by **hg**. For details,
+    see |hgignore(5)|_.
+
+``.hgsub``
+    This file defines the locations of all subrepositories, and
+    tells where the subrepository checkouts came from. For details, see
+    :hg:`help subrepos`.
+
+``.hgsubstate``
+    This file is where Mercurial stores all nested repository states. *NB: This
+    file should not be edited manually.*
+
+``.hgtags``
+    This file contains changeset hash values and text tag names (one
+    of each separated by spaces) that correspond to tagged versions of
+    the repository contents. The file content is encoded using UTF-8.
+
+``.hg/last-message.txt``
+    This file is used by :hg:`commit` to store a backup of the commit message
+    in case the commit fails.
+
+``.hg/localtags``
+    This file can be used to define local tags which are not shared among
+    repositories. The file format is the same as for ``.hgtags``, but it is
+    encoded using the local system encoding.
+
+Some commands (e.g. revert) produce backup files ending in ``.orig``,
+if the ``.orig`` file already exists and is not tracked by Mercurial,
+it will be overwritten.
+
+Bugs
+""""
+Probably lots, please post them to the mailing list (see Resources_
+below) when you find them.
+
+See Also
+""""""""
+|hgignore(5)|_, |hgrc(5)|_
+
+Author
+""""""
+Written by Matt Mackall <mpm@selenic.com>
+
+Resources
+"""""""""
+Main Web Site: https://mercurial-scm.org/
+
+Source code repository: https://www.mercurial-scm.org/repo/hg
+
+Mailing list: https://www.mercurial-scm.org/mailman/listinfo/mercurial/
+
+Copying
+"""""""
+Copyright (C) 2005-2019 Matt Mackall.
+Free use of this software is granted under the terms of the GNU General
+Public License version 2 or any later version.
+
+.. include:: common.txt
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mercurial/helptext/hgignore.5.txt	Fri Nov 22 21:42:04 2019 +0900
@@ -0,0 +1,34 @@
+==========
+ hgignore
+==========
+
+---------------------------------
+syntax for Mercurial ignore files
+---------------------------------
+
+:Author:         Vadim Gelfer <vadim.gelfer@gmail.com>
+:Organization:   Mercurial
+:Manual section: 5
+:Manual group:   Mercurial Manual
+
+.. include:: hgignore.5.gendoc.txt
+
+Author
+======
+Vadim Gelfer <vadim.gelfer@gmail.com>
+
+Mercurial was written by Matt Mackall <mpm@selenic.com>.
+
+See Also
+========
+|hg(1)|_, |hgrc(5)|_
+
+Copying
+=======
+This manual page is copyright 2006 Vadim Gelfer.
+Mercurial is copyright 2005-2019 Matt Mackall.
+Free use of this software is granted under the terms of the GNU General
+Public License version 2 or any later version.
+
+.. include:: common.txt
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mercurial/helptext/hgignore.txt	Fri Nov 22 21:42:04 2019 +0900
@@ -0,0 +1,97 @@
+Synopsis
+========
+
+The Mercurial system uses a file called ``.hgignore`` in the root
+directory of a repository to control its behavior when it searches
+for files that it is not currently tracking.
+
+Description
+===========
+
+The working directory of a Mercurial repository will often contain
+files that should not be tracked by Mercurial. These include backup
+files created by editors and build products created by compilers.
+These files can be ignored by listing them in a ``.hgignore`` file in
+the root of the working directory. The ``.hgignore`` file must be
+created manually. It is typically put under version control, so that
+the settings will propagate to other repositories with push and pull.
+
+An untracked file is ignored if its path relative to the repository
+root directory, or any prefix path of that path, is matched against
+any pattern in ``.hgignore``.
+
+For example, say we have an untracked file, ``file.c``, at
+``a/b/file.c`` inside our repository. Mercurial will ignore ``file.c``
+if any pattern in ``.hgignore`` matches ``a/b/file.c``, ``a/b`` or ``a``.
+
+In addition, a Mercurial configuration file can reference a set of
+per-user or global ignore files. See the ``ignore`` configuration
+key on the ``[ui]`` section of :hg:`help config` for details of how to
+configure these files.
+
+To control Mercurial's handling of files that it manages, many
+commands support the ``-I`` and ``-X`` options; see
+:hg:`help <command>` and :hg:`help patterns` for details.
+
+Files that are already tracked are not affected by .hgignore, even
+if they appear in .hgignore. An untracked file X can be explicitly
+added with :hg:`add X`, even if X would be excluded by a pattern
+in .hgignore.
+
+Syntax
+======
+
+An ignore file is a plain text file consisting of a list of patterns,
+with one pattern per line. Empty lines are skipped. The ``#``
+character is treated as a comment character, and the ``\`` character
+is treated as an escape character.
+
+Mercurial supports several pattern syntaxes. The default syntax used
+is Python/Perl-style regular expressions.
+
+To change the syntax used, use a line of the following form::
+
+  syntax: NAME
+
+where ``NAME`` is one of the following:
+
+``regexp``
+  Regular expression, Python/Perl syntax.
+``glob``
+  Shell-style glob.
+``rootglob``
+  A variant of ``glob`` that is rooted (see below).
+
+The chosen syntax stays in effect when parsing all patterns that
+follow, until another syntax is selected.
+
+Neither ``glob`` nor regexp patterns are rooted. A glob-syntax
+pattern of the form ``*.c`` will match a file ending in ``.c`` in any
+directory, and a regexp pattern of the form ``\.c$`` will do the
+same. To root a regexp pattern, start it with ``^``. To get the same
+effect with glob-syntax, you have to use ``rootglob``.
+
+Subdirectories can have their own .hgignore settings by adding
+``subinclude:path/to/subdir/.hgignore`` to the root ``.hgignore``. See
+:hg:`help patterns` for details on ``subinclude:`` and ``include:``.
+
+.. note::
+
+  Patterns specified in other than ``.hgignore`` are always rooted.
+  Please see :hg:`help patterns` for details.
+
+Example
+=======
+
+Here is an example ignore file. ::
+
+  # use glob syntax.
+  syntax: glob
+
+  *.elc
+  *.pyc
+  *~
+
+  # switch to regexp syntax.
+  syntax: regexp
+  ^\.pc/
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mercurial/helptext/hgrc.5.txt	Fri Nov 22 21:42:04 2019 +0900
@@ -0,0 +1,41 @@
+======
+ hgrc
+======
+
+---------------------------------
+configuration files for Mercurial
+---------------------------------
+
+:Author:         Bryan O'Sullivan <bos@serpentine.com>
+:Organization:   Mercurial
+:Manual section: 5
+:Manual group:   Mercurial Manual
+
+.. contents::
+   :backlinks: top
+   :class: htmlonly
+
+
+Description
+===========
+
+.. include:: hgrc.5.gendoc.txt
+
+Author
+======
+Bryan O'Sullivan <bos@serpentine.com>.
+
+Mercurial was written by Matt Mackall <mpm@selenic.com>.
+
+See Also
+========
+|hg(1)|_, |hgignore(5)|_
+
+Copying
+=======
+This manual page is copyright 2005 Bryan O'Sullivan.
+Mercurial is copyright 2005-2019 Matt Mackall.
+Free use of this software is granted under the terms of the GNU General
+Public License version 2 or any later version.
+
+.. include:: common.txt
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mercurial/helptext/hgweb.txt	Fri Nov 22 21:42:04 2019 +0900
@@ -0,0 +1,86 @@
+Mercurial's internal web server, hgweb, can serve either a single
+repository, or a tree of repositories. In the second case, repository
+paths and global options can be defined using a dedicated
+configuration file common to :hg:`serve`, ``hgweb.wsgi``,
+``hgweb.cgi`` and ``hgweb.fcgi``.
+
+This file uses the same syntax as other Mercurial configuration files
+but recognizes only the following sections:
+
+  - web
+  - paths
+  - collections
+
+The ``web`` options are thoroughly described in :hg:`help config`.
+
+The ``paths`` section maps URL paths to paths of repositories in the
+filesystem. hgweb will not expose the filesystem directly - only
+Mercurial repositories can be published and only according to the
+configuration.
+
+The left hand side is the path in the URL. Note that hgweb reserves
+subpaths like ``rev`` or ``file``, try using different names for
+nested repositories to avoid confusing effects.
+
+The right hand side is the path in the filesystem. If the specified
+path ends with ``*`` or ``**`` the filesystem will be searched
+recursively for repositories below that point.
+With ``*`` it will not recurse into the repositories it finds (except for
+``.hg/patches``).
+With ``**`` it will also search inside repository working directories
+and possibly find subrepositories.
+
+In this example::
+
+  [paths]
+  /projects/a = /srv/tmprepos/a
+  /projects/b = c:/repos/b
+  / = /srv/repos/*
+  /user/bob = /home/bob/repos/**
+
+- The first two entries make two repositories in different directories
+  appear under the same directory in the web interface
+- The third entry will publish every Mercurial repository found in
+  ``/srv/repos/``, for instance the repository ``/srv/repos/quux/``
+  will appear as ``http://server/quux/``
+- The fourth entry will publish both ``http://server/user/bob/quux/``
+  and ``http://server/user/bob/quux/testsubrepo/``
+
+The ``collections`` section is deprecated and has been superseded by
+``paths``.
+
+URLs and Common Arguments
+=========================
+
+URLs under each repository have the form ``/{command}[/{arguments}]``
+where ``{command}`` represents the name of a command or handler and
+``{arguments}`` represents any number of additional URL parameters
+to that command.
+
+The web server has a default style associated with it. Styles map to
+a collection of named templates. Each template is used to render a
+specific piece of data, such as a changeset or diff.
+
+The style for the current request can be overwritten two ways. First,
+if ``{command}`` contains a hyphen (``-``), the text before the hyphen
+defines the style. For example, ``/atom-log`` will render the ``log``
+command handler with the ``atom`` style. The second way to set the
+style is with the ``style`` query string argument. For example,
+``/log?style=atom``. The hyphenated URL parameter is preferred.
+
+Not all templates are available for all styles. Attempting to use
+a style that doesn't have all templates defined may result in an error
+rendering the page.
+
+Many commands take a ``{revision}`` URL parameter. This defines the
+changeset to operate on. This is commonly specified as the short,
+12 digit hexadecimal abbreviation for the full 40 character unique
+revision identifier. However, any value described by
+:hg:`help revisions` typically works.
+
+Commands and URLs
+=================
+
+The following web commands and their URLs are available:
+
+  .. webcommandsmarker
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mercurial/helptext/internals/bundle2.txt	Fri Nov 22 21:42:04 2019 +0900
@@ -0,0 +1,677 @@
+Bundle2 refers to a data format that is used for both on-disk storage
+and over-the-wire transfer of repository data and state.
+
+The data format allows the capture of multiple components of
+repository data. Contrast with the initial bundle format, which
+only captured *changegroup* data (and couldn't store bookmarks,
+phases, etc).
+
+Bundle2 is used for:
+
+* Transferring data from a repository (e.g. as part of an ``hg clone``
+  or ``hg pull`` operation).
+* Transferring data to a repository (e.g. as part of an ``hg push``
+  operation).
+* Storing data on disk (e.g. the result of an ``hg bundle``
+  operation).
+* Transferring the results of a repository operation (e.g. the
+  reply to an ``hg push`` operation).
+
+At its highest level, a bundle2 payload is a stream that begins
+with some metadata and consists of a series of *parts*, with each
+part describing repository data or state or the result of an
+operation. New bundle2 parts are introduced over time when there is
+a need to capture a new form of data. A *capabilities* mechanism
+exists to allow peers to understand which bundle2 parts the other
+understands.
+
+Stream Format
+=============
+
+A bundle2 payload consists of a magic string (``HG20``) followed by
+stream level parameters, followed by any number of payload *parts*.
+
+It may help to think of the stream level parameters as *headers* and the
+payload parts as the *body*.
+
+Stream Level Parameters
+-----------------------
+
+Following the magic string is data that defines parameters applicable to the
+entire payload.
+
+Stream level parameters begin with a 32-bit unsigned big-endian integer.
+The value of this integer defines the number of bytes of stream level
+parameters that follow.
+
+The *N* bytes of raw data contains a space separated list of parameters.
+Each parameter consists of a required name and an optional value.
+
+Parameters have the form ``<name>`` or ``<name>=<value>``.
+
+Both the parameter name and value are URL quoted.
+
+Names MUST start with a letter. If the first letter is lower case, the
+parameter is advisory and can safely be ignored. If the first letter
+is upper case, the parameter is mandatory and the handler MUST stop if
+it is unable to process it.
+
+Stream level parameters apply to the entire bundle2 payload. Lower-level
+options should go into a bundle2 part instead.
+
+The following stream level parameters are defined:
+
+Compression
+   Compression format of payload data. ``GZ`` denotes zlib. ``BZ``
+   denotes bzip2. ``ZS`` denotes zstandard.
+
+   When defined, all bytes after the stream level parameters are
+   compressed using the compression format defined by this parameter.
+
+   If this parameter isn't present, data is raw/uncompressed.
+
+   This parameter MUST be mandatory because attempting to consume
+   streams without knowing how to decode the underlying bytes will
+   result in errors.
+
+Payload Part
+------------
+
+Following the stream level parameters are 0 or more payload parts. Each
+payload part consists of a header and a body.
+
+The payload part header consists of a 32-bit unsigned big-endian integer
+defining the number of bytes in the header that follow. The special
+value ``0`` indicates the end of the bundle2 stream.
+
+The binary format of the part header is as follows:
+
+* 8-bit unsigned size of the part name
+* N-bytes alphanumeric part name
+* 32-bit unsigned big-endian part ID
+* N bytes part parameter data
+
+The *part name* identifies the type of the part. A part name with an
+UPPERCASE letter is mandatory. Otherwise, the part is advisory. A
+consumer should abort if it encounters a mandatory part it doesn't know
+how to process. See the sections below for each defined part type.
+
+The *part ID* is a unique identifier within the bundle used to refer to a
+specific part. It should be unique within the bundle2 payload.
+
+Part parameter data consists of:
+
+* 1 byte number of mandatory parameters
+* 1 byte number of advisory parameters
+* 2 * N bytes of sizes of parameter key and values
+* N * M blobs of values for parameter key and values
+
+Following the 2 bytes of mandatory and advisory parameter counts are
+2-tuples of bytes of the sizes of each parameter. e.g.
+(<key size>, <value size>).
+
+Following that are the raw values, without padding. Mandatory parameters
+come first, followed by advisory parameters.
+
+Each parameter's key MUST be unique within the part.
+
+Following the part parameter data is the part payload. The part payload
+consists of a series of framed chunks. The frame header is a 32-bit
+big-endian integer defining the size of the chunk. The N bytes of raw
+payload data follows.
+
+The part payload consists of 0 or more chunks.
+
+A chunk with size ``0`` denotes the end of the part payload. Therefore,
+there will always be at least 1 32-bit integer following the payload
+part header.
+
+A chunk size of ``-1`` is used to signal an *interrupt*. If such a chunk
+size is seen, the stream processor should process the next bytes as a new
+payload part. After this payload part, processing of the original,
+interrupted part should resume.
+
+Capabilities
+============
+
+Bundle2 is a dynamic format that can evolve over time. For example,
+when a new repository data concept is invented, a new bundle2 part
+is typically invented to hold that data. In addition, parts performing
+similar functionality may come into existence if there is a better
+mechanism for performing certain functionality.
+
+Because the bundle2 format evolves over time, peers need to understand
+what bundle2 features the other can understand. The *capabilities*
+mechanism is how those features are expressed.
+
+Bundle2 capabilities are logically expressed as a dictionary of
+string key-value pairs where the keys are strings and the values
+are lists of strings.
+
+Capabilities are encoded for exchange between peers. The encoded
+capabilities blob consists of a newline (``\n``) delimited list of
+entries. Each entry has the form ``<key>`` or ``<key>=<value>``,
+depending if the capability has a value.
+
+The capability name is URL quoted (``%XX`` encoding of URL unsafe
+characters).
+
+The value, if present, is formed by URL quoting each value in
+the capability list and concatenating the result with a comma (``,``).
+
+For example, the capabilities ``novaluekey`` and ``listvaluekey``
+with values ``value 1`` and ``value 2``. This would be encoded as:
+
+   listvaluekey=value%201,value%202\nnovaluekey
+
+The sections below detail the defined bundle2 capabilities.
+
+HG20
+----
+
+Denotes that the peer supports the bundle2 data format.
+
+bookmarks
+---------
+
+Denotes that the peer supports the ``bookmarks`` part.
+
+Peers should not issue mandatory ``bookmarks`` parts unless this
+capability is present.
+
+changegroup
+-----------
+
+Denotes which versions of the *changegroup* format the peer can
+receive. Values include ``01``, ``02``, and ``03``.
+
+The peer should not generate changegroup data for a version not
+specified by this capability.
+
+checkheads
+----------
+
+Denotes which forms of heads checking the peer supports.
+
+If ``related`` is in the value, then the peer supports the ``check:heads``
+part and the peer is capable of detecting race conditions when applying
+changelog data.
+
+digests
+-------
+
+Denotes which hashing formats the peer supports.
+
+Values are names of hashing function. Values include ``md5``, ``sha1``,
+and ``sha512``.
+
+error
+-----
+
+Denotes which ``error:`` parts the peer supports.
+
+Value is a list of strings of ``error:`` part names. Valid values
+include ``abort``, ``unsupportecontent``, ``pushraced``, and ``pushkey``.
+
+Peers should not issue an ``error:`` part unless the type of that
+part is listed as supported by this capability.
+
+listkeys
+--------
+
+Denotes that the peer supports the ``listkeys`` part.
+
+hgtagsfnodes
+------------
+
+Denotes that the peer supports the ``hgtagsfnodes`` part.
+
+obsmarkers
+----------
+
+Denotes that the peer supports the ``obsmarker`` part and which versions
+of the obsolescence data format it can receive. Values are strings like
+``V<N>``. e.g. ``V1``.
+
+phases
+------
+
+Denotes that the peer supports the ``phases`` part.
+
+pushback
+--------
+
+Denotes that the peer supports sending/receiving bundle2 data in response
+to a bundle2 request.
+
+This capability is typically used by servers that employ server-side
+rewriting of pushed repository data. For example, a server may wish to
+automatically rebase pushed changesets. When this capability is present,
+the server can send a bundle2 response containing the rewritten changeset
+data and the client will apply it.
+
+pushkey
+-------
+
+Denotes that the peer supports the ``puskey`` part.
+
+remote-changegroup
+------------------
+
+Denotes that the peer supports the ``remote-changegroup`` part and
+which protocols it can use to fetch remote changegroup data.
+
+Values are protocol names. e.g. ``http`` and ``https``.
+
+stream
+------
+
+Denotes that the peer supports ``stream*`` parts in order to support
+*stream clone*.
+
+Values are which ``stream*`` parts the peer supports. ``v2`` denotes
+support for the ``stream2`` part.
+
+Bundle2 Part Types
+==================
+
+The sections below detail the various bundle2 part types.
+
+bookmarks
+---------
+
+The ``bookmarks`` part holds bookmarks information.
+
+This part has no parameters.
+
+The payload consists of entries defining bookmarks. Each entry consists of:
+
+* 20 bytes binary changeset node.
+* 2 bytes big endian short defining bookmark name length.
+* N bytes defining bookmark name.
+
+Receivers typically update bookmarks to match the state specified in
+this part.
+
+changegroup
+-----------
+
+The ``changegroup`` part contains *changegroup* data (changelog, manifestlog,
+and filelog revision data).
+
+The following part parameters are defined for this part.
+
+version
+   Changegroup version string. e.g. ``01``, ``02``, and ``03``. This parameter
+   determines how to interpret the changegroup data within the part.
+
+nbchanges
+   The number of changesets in this changegroup. This parameter can be used
+   to aid in the display of progress bars, etc during part application.
+
+treemanifest
+   Whether the changegroup contains tree manifests.
+
+targetphase
+   The target phase of changesets in this part. Value is an integer of
+   the target phase.
+
+The payload of this part is raw changegroup data. See
+:hg:`help internals.changegroups` for the format of changegroup data.
+
+check:bookmarks
+---------------
+
+The ``check:bookmarks`` part is inserted into a bundle as a means for the
+receiver to validate that the sender's known state of bookmarks matches
+the receiver's.
+
+This part has no parameters.
+
+The payload is a binary stream of bookmark data. Each entry in the stream
+consists of:
+
+* 20 bytes binary node that bookmark is associated with
+* 2 bytes unsigned short defining length of bookmark name
+* N bytes containing the bookmark name
+
+If all bits in the node value are ``1``, then this signifies a missing
+bookmark.
+
+When the receiver encounters this part, for each bookmark in the part
+payload, it should validate that the current bookmark state matches
+the specified state. If it doesn't, then the receiver should take
+appropriate action. (In the case of pushes, this mismatch signifies
+a race condition and the receiver should consider rejecting the push.)
+
+check:heads
+-----------
+
+The ``check:heads`` part is a means to validate that the sender's state
+of DAG heads matches the receiver's.
+
+This part has no parameters.
+
+The body of this part is an array of 20 byte binary nodes representing
+changeset heads.
+
+Receivers should compare the set of heads defined in this part to the
+current set of repo heads and take action if there is a mismatch in that
+set.
+
+Note that this part applies to *all* heads in the repo.
+
+check:phases
+------------
+
+The ``check:phases`` part validates that the sender's state of phase
+boundaries matches the receiver's.
+
+This part has no parameters.
+
+The payload consists of an array of 24 byte entries. Each entry is
+a big endian 32-bit integer defining the phase integer and 20 byte
+binary node value.
+
+For each changeset defined in this part, the receiver should validate
+that its current phase matches the phase defined in this part. The
+receiver should take appropriate action if a mismatch occurs.
+
+check:updated-heads
+-------------------
+
+The ``check:updated-heads`` part validates that the sender's state of
+DAG heads updated by this bundle matches the receiver's.
+
+This type is nearly identical to ``check:heads`` except the heads
+in the payload are only a subset of heads in the repository. The
+receiver should validate that all nodes specified by the sender are
+branch heads and take appropriate action if not.
+
+error:abort
+-----------
+
+The ``error:abort`` part conveys a fatal error.
+
+The following part parameters are defined:
+
+message
+   The string content of the error message.
+
+hint
+   Supplemental string giving a hint on how to fix the problem.
+
+error:pushkey
+-------------
+
+The ``error:pushkey`` part conveys an error in the *pushkey* protocol.
+
+The following part parameters are defined:
+
+namespace
+   The pushkey domain that exhibited the error.
+
+key
+   The key whose update failed.
+
+new
+   The value we tried to set the key to.
+
+old
+   The old value of the key (as supplied by the client).
+
+ret
+   The integer result code for the pushkey request.
+
+in-reply-to
+   Part ID that triggered this error.
+
+This part is generated if there was an error applying *pushkey* data.
+Pushkey data includes bookmarks, phases, and obsolescence markers.
+
+error:pushraced
+---------------
+
+The ``error:pushraced`` part conveys that an error occurred and
+the likely cause is losing a race with another pusher.
+
+The following part parameters are defined:
+
+message
+   String error message.
+
+This part is typically emitted when a receiver examining ``check:*``
+parts encountered inconsistency between incoming state and local state.
+The likely cause of that inconsistency is another repository change
+operation (often another client performing an ``hg push``).
+
+error:unsupportedcontent
+------------------------
+
+The ``error:unsupportedcontent`` part conveys that a bundle2 receiver
+encountered a part or content it was not able to handle.
+
+The following part parameters are defined:
+
+parttype
+   The name of the part that triggered this error.
+
+params
+   ``\0`` delimited list of parameters.
+
+hgtagsfnodes
+------------
+
+The ``hgtagsfnodes`` type defines file nodes for the ``.hgtags`` file
+for various changesets.
+
+This part has no parameters.
+
+The payload is an array of pairs of 20 byte binary nodes. The first node
+is a changeset node. The second node is the ``.hgtags`` file node.
+
+Resolving tags requires resolving the ``.hgtags`` file node for changesets.
+On large repositories, this can be expensive. Repositories cache the
+mapping of changeset to ``.hgtags`` file node on disk as a performance
+optimization. This part allows that cached data to be transferred alongside
+changeset data.
+
+Receivers should update their ``.hgtags`` cache file node mappings with
+the incoming data.
+
+listkeys
+--------
+
+The ``listkeys`` part holds content for a *pushkey* namespace.
+
+The following part parameters are defined:
+
+namespace
+   The pushkey domain this data belongs to.
+
+The part payload contains a newline (``\n``) delimited list of
+tab (``\t``) delimited key-value pairs defining entries in this pushkey
+namespace.
+
+obsmarkers
+----------
+
+The ``obsmarkers`` part defines obsolescence markers.
+
+This part has no parameters.
+
+The payload consists of obsolescence markers using the on-disk markers
+format. The first byte defines the version format.
+
+The receiver should apply the obsolescence markers defined in this
+part. A ``reply:obsmarkers`` part should be sent to the sender, if possible.
+
+output
+------
+
+The ``output`` part is used to display output on the receiver.
+
+This part has no parameters.
+
+The payload consists of raw data to be printed on the receiver.
+
+phase-heads
+-----------
+
+The ``phase-heads`` part defines phase boundaries.
+
+This part has no parameters.
+
+The payload consists of an array of 24 byte entries. Each entry is
+a big endian 32-bit integer defining the phase integer and 20 byte
+binary node value.
+
+pushkey
+-------
+
+The ``pushkey`` part communicates an intent to perform a ``pushkey``
+request.
+
+The following part parameters are defined:
+
+namespace
+   The pushkey domain to operate on.
+
+key
+   The key within the pushkey namespace that is being changed.
+
+old
+   The old value for the key being changed.
+
+new
+   The new value for the key being changed.
+
+This part has no payload.
+
+The receiver should perform a pushkey operation as described by this
+part's parameters.
+
+If the pushey operation fails, a ``reply:pushkey`` part should be sent
+back to the sender, if possible. The ``in-reply-to`` part parameter
+should reference the source part.
+
+pushvars
+--------
+
+The ``pushvars`` part defines environment variables that should be
+set when processing this bundle2 payload.
+
+The part's advisory parameters define environment variables.
+
+There is no part payload.
+
+When received, part parameters are prefixed with ``USERVAR_`` and the
+resulting variables are defined in the hooks context for the current
+bundle2 application. This part provides a mechanism for senders to
+inject extra state into the hook execution environment on the receiver.
+
+remote-changegroup
+------------------
+
+The ``remote-changegroup`` part defines an external location of a bundle
+to apply. This part can be used by servers to serve pre-generated bundles
+hosted at arbitrary URLs.
+
+The following part parameters are defined:
+
+url
+   The URL of the remote bundle.
+
+size
+   The size in bytes of the remote bundle.
+
+digests
+   A space separated list of the digest types provided in additional
+   part parameters.
+
+digest:<type>
+   The hexadecimal representation of the digest (hash) of the remote bundle.
+
+There is no payload for this part type.
+
+When encountered, clients should attempt to fetch the URL being advertised
+and read and apply it as a bundle.
+
+The ``size`` and ``digest:<type>`` parameters should be used to validate
+that the downloaded bundle matches what was advertised. If a mismatch occurs,
+the client should abort.
+
+reply:changegroup
+-----------------
+
+The ``reply:changegroup`` part conveys the results of application of a
+``changegroup`` part.
+
+The following part parameters are defined:
+
+return
+   Integer return code from changegroup application.
+
+in-reply-to
+   Part ID of part this reply is in response to.
+
+reply:obsmarkers
+----------------
+
+The ``reply:obsmarkers`` part conveys the results of applying an
+``obsmarkers`` part.
+
+The following part parameters are defined:
+
+new
+   The integer number of new markers that were applied.
+
+in-reply-to
+   The part ID that this part is in reply to.
+
+reply:pushkey
+-------------
+
+The ``reply:pushkey`` part conveys the result of a *pushkey* operation.
+
+The following part parameters are defined:
+
+return
+   Integer result code from pushkey operation.
+
+in-reply-to
+   Part ID that triggered this pushkey operation.
+
+This part has no payload.
+
+replycaps
+---------
+
+The ``replycaps`` part notifies the receiver that a reply bundle should
+be created.
+
+This part has no parameters.
+
+The payload consists of a bundle2 capabilities blob.
+
+stream2
+-------
+
+The ``stream2`` part contains *streaming clone* version 2 data.
+
+The following part parameters are defined:
+
+requirements
+   URL quoted repository requirements string. Requirements are delimited by a
+   command (``,``).
+
+filecount
+   The total number of files being transferred in the payload.
+
+bytecount
+   The total size of file content being transferred in the payload.
+
+The payload consists of raw stream clone version 2 data.
+
+The ``filecount`` and ``bytecount`` parameters can be used for progress and
+reporting purposes. The values may not be exact.
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mercurial/helptext/internals/bundles.txt	Fri Nov 22 21:42:04 2019 +0900
@@ -0,0 +1,93 @@
+A bundle is a container for repository data.
+
+Bundles are used as standalone files as well as the interchange format
+over the wire protocol used when two Mercurial peers communicate with
+each other.
+
+Headers
+=======
+
+Bundles produced since Mercurial 0.7 (September 2005) have a 4 byte
+header identifying the major bundle type. The header always begins with
+``HG`` and the follow 2 bytes indicate the bundle type/version. Some
+bundle types have additional data after this 4 byte header.
+
+The following sections describe each bundle header/type.
+
+HG10
+----
+
+``HG10`` headers indicate a *changegroup bundle*. This is the original
+bundle format, so it is sometimes referred to as *bundle1*. It has been
+present since version 0.7 (released September 2005).
+
+This header is followed by 2 bytes indicating the compression algorithm
+used for data that follows. All subsequent data following this
+compression identifier is compressed according to the algorithm/method
+specified.
+
+Supported algorithms include the following.
+
+``BZ``
+   *bzip2* compression.
+
+   Bzip2 compressors emit a leading ``BZ`` header. Mercurial uses this
+   leading ``BZ`` as part of the bundle header. Therefore consumers
+   of bzip2 bundles need to *seed* the bzip2 decompressor with ``BZ`` or
+   seek the input stream back to the beginning of the algorithm component
+   of the bundle header so that decompressor input is valid. This behavior
+   is unique among supported compression algorithms.
+
+   Supported since version 0.7 (released December 2006).
+
+``GZ``
+  *zlib* compression.
+
+   Supported since version 0.9.2 (released December 2006).
+
+``UN``
+  *Uncompressed* or no compression. Unmodified changegroup data follows.
+
+  Supported since version 0.9.2 (released December 2006).
+
+3rd party extensions may implement their own compression. However, no
+authority reserves values for their compression algorithm identifiers.
+
+HG2X
+----
+
+``HG2X`` headers (where ``X`` is any value) denote a *bundle2* bundle.
+Bundle2 bundles are a container format for various kinds of repository
+data and capabilities, beyond changegroup data (which was the only data
+supported by ``HG10`` bundles.
+
+``HG20`` is currently the only defined bundle2 version.
+
+The ``HG20`` format is documented at :hg:`help internals.bundle2`.
+
+Initial ``HG20`` support was added in Mercurial 3.0 (released May
+2014). However, bundle2 bundles were hidden behind an experimental flag
+until version 3.5 (released August 2015), when they were enabled in the
+wire protocol. Various commands (including ``hg bundle``) did not
+support generating bundle2 files until Mercurial 3.6 (released November
+2015).
+
+HGS1
+----
+
+*Experimental*
+
+A ``HGS1`` header indicates a *streaming clone bundle*. This is a bundle
+that contains raw revlog data from a repository store. (Typically revlog
+data is exchanged in the form of changegroups.)
+
+The purpose of *streaming clone bundles* are to *clone* repository data
+very efficiently.
+
+The ``HGS1`` header is always followed by 2 bytes indicating a
+compression algorithm of the data that follows. Only ``UN``
+(uncompressed data) is currently allowed.
+
+``HGS1UN`` support was added as an experimental feature in version 3.6
+(released November 2015) as part of the initial offering of the *clone
+bundles* feature.
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mercurial/helptext/internals/cbor.txt	Fri Nov 22 21:42:04 2019 +0900
@@ -0,0 +1,130 @@
+Mercurial uses Concise Binary Object Representation (CBOR)
+(RFC 7049) for various data formats.
+
+This document describes the subset of CBOR that Mercurial uses and
+gives recommendations for appropriate use of CBOR within Mercurial.
+
+Type Limitations
+================
+
+Major types 0 and 1 (unsigned integers and negative integers) MUST be
+fully supported.
+
+Major type 2 (byte strings) MUST be fully supported. However, there
+are limitations around the use of indefinite-length byte strings.
+(See below.)
+
+Major type 3 (text strings) are NOT supported.
+
+Major type 4 (arrays) MUST be supported. However, values are limited
+to the set of types described in the "Container Types" section below.
+And indefinite-length arrays are NOT supported.
+
+Major type 5 (maps) MUST be supported. However, key values are limited
+to the set of types described in the "Container Types" section below.
+And indefinite-length maps are NOT supported.
+
+Major type 6 (semantic tagging of major types) can be used with the
+following semantic tag values:
+
+258
+   Mathematical finite set. Suitable for representing Python's
+   ``set`` type.
+
+All other semantic tag values are not allowed.
+
+Major type 7 (simple data types) can be used with the following
+type values:
+
+20
+   False
+21
+   True
+22
+   Null
+31
+   Break stop code (for indefinite-length items).
+
+All other simple data type values (including every value requiring the
+1 byte extension) are disallowed.
+
+Indefinite-Length Byte Strings
+==============================
+
+Indefinite-length byte strings (major type 2) are allowed. However,
+they MUST NOT occur inside a container type (such as an array or map).
+i.e. they can only occur as the "top-most" element in a stream of
+values.
+
+Encoders and decoders SHOULD *stream* indefinite-length byte strings.
+i.e. an encoder or decoder SHOULD NOT buffer the entirety of a long
+byte string value when indefinite-length byte strings are being used
+if it can be avoided. Mercurial MAY use extremely long indefinite-length
+byte strings and buffering the source or destination value COULD lead to
+memory exhaustion.
+
+Chunks in an indefinite-length byte string SHOULD NOT exceed 2^20
+bytes.
+
+Container Types
+===============
+
+Mercurial may use the array (major type 4), map (major type 5), and
+set (semantic tag 258 plus major type 4 array) container types.
+
+An array may contain any supported type as values.
+
+A map MUST only use the following types as keys:
+
+* unsigned integers (major type 0)
+* negative integers (major type 1)
+* byte strings (major type 2) (but not indefinite-length byte strings)
+* false (simple type 20)
+* true (simple type 21)
+* null (simple type 22)
+
+A map MUST only use the following types as values:
+
+* all types supported as map keys
+* arrays
+* maps
+* sets
+
+A set may only use the following types as values:
+
+* all types supported as map keys
+
+It is recommended that keys in maps and values in sets and arrays all
+be of a uniform type.
+
+Avoiding Large Byte Strings
+===========================
+
+The use of large byte strings is discouraged, especially in scenarios where
+the total size of the byte string may by unbound for some inputs (e.g. when
+representing the content of a tracked file). It is highly recommended to use
+indefinite-length byte strings for these purposes.
+
+Since indefinite-length byte strings cannot be nested within an outer
+container (such as an array or map), to associate a large byte string
+with another data structure, it is recommended to use an array or
+map followed immediately by an indefinite-length byte string. For example,
+instead of the following map::
+
+   {
+      "key1": "value1",
+      "key2": "value2",
+      "long_value": "some very large value...",
+   }
+
+Use a map followed by a byte string:
+
+   {
+      "key1": "value1",
+      "key2": "value2",
+      "value_follows": True,
+   }
+   <BEGIN INDEFINITE-LENGTH BYTE STRING>
+   "some very large value"
+   "..."
+   <END INDEFINITE-LENGTH BYTE STRING>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mercurial/helptext/internals/censor.txt	Fri Nov 22 21:42:04 2019 +0900
@@ -0,0 +1,22 @@
+The censor system allows retroactively removing content from
+files. Actually censoring a node requires using the censor extension,
+but the functionality for handling censored nodes is partially in core.
+
+Censored nodes in a filelog have the flag ``REVIDX_ISCENSORED`` set,
+and the contents of the censored node are replaced with a censor
+tombstone. For historical reasons, the tombstone is packed in the
+filelog metadata field ``censored``. This allows censored nodes to be
+(mostly) safely transmitted through old formats like changegroup
+versions 1 and 2. When using changegroup formats older than 3, the
+receiver is required to re-add the ``REVIDX_ISCENSORED`` flag when
+storing the revision. This depends on the ``censored`` metadata key
+never being used for anything other than censoring revisions, which is
+true as of January 2017. Note that the revlog flag is the
+authoritative marker of a censored node: the tombstone should only be
+consulted when looking for a reason a node was censored or when revlog
+flags are unavailable as mentioned above.
+
+The tombstone data is a free-form string. It's expected that users of
+censor will want to record the reason for censoring a node in the
+tombstone. Censored nodes must be able to fit in the size of the
+content being censored.
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mercurial/helptext/internals/changegroups.txt	Fri Nov 22 21:42:04 2019 +0900
@@ -0,0 +1,207 @@
+Changegroups are representations of repository revlog data, specifically
+the changelog data, root/flat manifest data, treemanifest data, and
+filelogs.
+
+There are 3 versions of changegroups: ``1``, ``2``, and ``3``. From a
+high-level, versions ``1`` and ``2`` are almost exactly the same, with the
+only difference being an additional item in the *delta header*. Version
+``3`` adds support for storage flags in the *delta header* and optionally
+exchanging treemanifests (enabled by setting an option on the
+``changegroup`` part in the bundle2).
+
+Changegroups when not exchanging treemanifests consist of 3 logical
+segments::
+
+   +---------------------------------+
+   |           |          |          |
+   | changeset | manifest | filelogs |
+   |           |          |          |
+   |           |          |          |
+   +---------------------------------+
+
+When exchanging treemanifests, there are 4 logical segments::
+
+   +-------------------------------------------------+
+   |           |          |               |          |
+   | changeset |   root   | treemanifests | filelogs |
+   |           | manifest |               |          |
+   |           |          |               |          |
+   +-------------------------------------------------+
+
+The principle building block of each segment is a *chunk*. A *chunk*
+is a framed piece of data::
+
+   +---------------------------------------+
+   |           |                           |
+   |  length   |           data            |
+   | (4 bytes) |   (<length - 4> bytes)    |
+   |           |                           |
+   +---------------------------------------+
+
+All integers are big-endian signed integers. Each chunk starts with a 32-bit
+integer indicating the length of the entire chunk (including the length field
+itself).
+
+There is a special case chunk that has a value of 0 for the length
+(``0x00000000``). We call this an *empty chunk*.
+
+Delta Groups
+============
+
+A *delta group* expresses the content of a revlog as a series of deltas,
+or patches against previous revisions.
+
+Delta groups consist of 0 or more *chunks* followed by the *empty chunk*
+to signal the end of the delta group::
+
+  +------------------------------------------------------------------------+
+  |                |             |               |             |           |
+  | chunk0 length  | chunk0 data | chunk1 length | chunk1 data |    0x0    |
+  |   (4 bytes)    |  (various)  |   (4 bytes)   |  (various)  | (4 bytes) |
+  |                |             |               |             |           |
+  +------------------------------------------------------------------------+
+
+Each *chunk*'s data consists of the following::
+
+  +---------------------------------------+
+  |                        |              |
+  |     delta header       |  delta data  |
+  |  (various by version)  |  (various)   |
+  |                        |              |
+  +---------------------------------------+
+
+The *delta data* is a series of *delta*s that describe a diff from an existing
+entry (either that the recipient already has, or previously specified in the
+bundle/changegroup).
+
+The *delta header* is different between versions ``1``, ``2``, and
+``3`` of the changegroup format.
+
+Version 1 (headerlen=80)::
+
+   +------------------------------------------------------+
+   |            |             |             |             |
+   |    node    |   p1 node   |   p2 node   |  link node  |
+   | (20 bytes) |  (20 bytes) |  (20 bytes) |  (20 bytes) |
+   |            |             |             |             |
+   +------------------------------------------------------+
+
+Version 2 (headerlen=100)::
+
+   +------------------------------------------------------------------+
+   |            |             |             |            |            |
+   |    node    |   p1 node   |   p2 node   | base node  | link node  |
+   | (20 bytes) |  (20 bytes) |  (20 bytes) | (20 bytes) | (20 bytes) |
+   |            |             |             |            |            |
+   +------------------------------------------------------------------+
+
+Version 3 (headerlen=102)::
+
+   +------------------------------------------------------------------------------+
+   |            |             |             |            |            |           |
+   |    node    |   p1 node   |   p2 node   | base node  | link node  |   flags   |
+   | (20 bytes) |  (20 bytes) |  (20 bytes) | (20 bytes) | (20 bytes) | (2 bytes) |
+   |            |             |             |            |            |           |
+   +------------------------------------------------------------------------------+
+
+The *delta data* consists of ``chunklen - 4 - headerlen`` bytes, which contain a
+series of *delta*s, densely packed (no separators). These deltas describe a diff
+from an existing entry (either that the recipient already has, or previously
+specified in the bundle/changegroup). The format is described more fully in
+``hg help internals.bdiff``, but briefly::
+
+   +---------------------------------------------------------------+
+   |              |            |            |                      |
+   | start offset | end offset | new length |        content       |
+   |  (4 bytes)   |  (4 bytes) |  (4 bytes) | (<new length> bytes) |
+   |              |            |            |                      |
+   +---------------------------------------------------------------+
+
+Please note that the length field in the delta data does *not* include itself.
+
+In version 1, the delta is always applied against the previous node from
+the changegroup or the first parent if this is the first entry in the
+changegroup.
+
+In version 2 and up, the delta base node is encoded in the entry in the
+changegroup. This allows the delta to be expressed against any parent,
+which can result in smaller deltas and more efficient encoding of data.
+
+The *flags* field holds bitwise flags affecting the processing of revision
+data. The following flags are defined:
+
+32768
+   Censored revision. The revision's fulltext has been replaced by censor
+   metadata. May only occur on file revisions.
+16384
+   Ellipsis revision. Revision hash does not match data (likely due to rewritten
+   parents).
+8192
+   Externally stored. The revision fulltext contains ``key:value`` ``\n``
+   delimited metadata defining an object stored elsewhere. Used by the LFS
+   extension.
+
+For historical reasons, the integer values are identical to revlog version 1
+per-revision storage flags and correspond to bits being set in this 2-byte
+field. Bits were allocated starting from the most-significant bit, hence the
+reverse ordering and allocation of these flags.
+
+Changeset Segment
+=================
+
+The *changeset segment* consists of a single *delta group* holding
+changelog data. The *empty chunk* at the end of the *delta group* denotes
+the boundary to the *manifest segment*.
+
+Manifest Segment
+================
+
+The *manifest segment* consists of a single *delta group* holding manifest
+data. If treemanifests are in use, it contains only the manifest for the
+root directory of the repository. Otherwise, it contains the entire
+manifest data. The *empty chunk* at the end of the *delta group* denotes
+the boundary to the next segment (either the *treemanifests segment* or the
+*filelogs segment*, depending on version and the request options).
+
+Treemanifests Segment
+---------------------
+
+The *treemanifests segment* only exists in changegroup version ``3``, and
+only if the 'treemanifest' param is part of the bundle2 changegroup part
+(it is not possible to use changegroup version 3 outside of bundle2).
+Aside from the filenames in the *treemanifests segment* containing a
+trailing ``/`` character, it behaves identically to the *filelogs segment*
+(see below). The final sub-segment is followed by an *empty chunk* (logically,
+a sub-segment with filename size 0). This denotes the boundary to the
+*filelogs segment*.
+
+Filelogs Segment
+================
+
+The *filelogs segment* consists of multiple sub-segments, each
+corresponding to an individual file whose data is being described::
+
+   +--------------------------------------------------+
+   |          |          |          |     |           |
+   | filelog0 | filelog1 | filelog2 | ... |    0x0    |
+   |          |          |          |     | (4 bytes) |
+   |          |          |          |     |           |
+   +--------------------------------------------------+
+
+The final filelog sub-segment is followed by an *empty chunk* (logically,
+a sub-segment with filename size 0). This denotes the end of the segment
+and of the overall changegroup.
+
+Each filelog sub-segment consists of the following::
+
+   +------------------------------------------------------+
+   |                 |                      |             |
+   | filename length |       filename       | delta group |
+   |    (4 bytes)    | (<length - 4> bytes) |  (various)  |
+   |                 |                      |             |
+   +------------------------------------------------------+
+
+That is, a *chunk* consisting of the filename (not terminated or padded)
+followed by N chunks constituting the *delta group* for this file. The
+*empty chunk* at the end of each *delta group* denotes the boundary to the
+next filelog sub-segment.
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mercurial/helptext/internals/config.txt	Fri Nov 22 21:42:04 2019 +0900
@@ -0,0 +1,109 @@
+All config options used within Mercurial should be registered.
+
+Config Option in Core
+=====================
+
+Config options used by Mercurial core are registered in the
+``mercurial.configitems`` module.
+
+Simple entry
+------------
+
+A registration entry typically looks like::
+
+    coreconfigitem('section', 'option',
+        default=MyDefaultValue,
+    )
+
+Once registered, Mercurial will know that ``section.option`` is a legitimate
+config option and that ``MyDefaultValue`` should be used if no other values are
+defined in configuration files.
+
+Complex default value
+---------------------
+
+If the default provided is a callable, it is called to retrieve the default
+value when accessing the config option. This is useful for default values that
+are mutable like the empty list::
+
+    coreconfigitem('pager', 'ignore',
+        default=list,
+    )
+
+In addition, there are cases where the default is not fixed, but computed from
+other properties. In this case, use the ``dynamicdefault`` object as the value
+for the ``default`` parameter. A default value is then explicitly required when
+reading the option::
+
+    # registration
+    coreconfigitem('web', 'name',
+        default=dynamicdefault,
+    )
+
+    # usage
+    ui.config('web', 'name', dirname)
+
+Free form options
+-----------------
+
+Some config sections use free form options (e.g. ``paths``). You can register
+them using the ``generic`` parameters::
+
+    coreconfigitem('paths', '.*',
+        default=None,
+        generic=True,
+    )
+
+When ``generic=True`` is set, the option name is matched as a regular expression
+(rooted to string start). It can be used to select specific sub parameters::
+
+    coreconfigitem('merge-tools', br'.*\.args$',
+        default="$local $base $other",
+        generic=True,
+        priority=-1,
+    )
+
+The ``priority`` parameter controls the order used to match the generic pattern
+(lower first).
+
+Config Option in Extensions
+===========================
+
+General case
+------------
+
+Extensions should register config items through the ``registrar`` API (also used
+for commands and others)::
+
+    configtable = {}
+    configitem = registrar.configitem(configtable)
+
+    configitem('blackbox', 'dirty',
+        default=False,
+    )
+
+The ``dynamicdefault`` object is then available as
+``configitem.dynamicdefault``.
+
+Supporting older versions
+-------------------------
+
+The registrar was introduced in Mercurial 4.3, and the ``generic`` parameter was
+introduced in 4.4. Starting with Mercurial 4.4, all core options were registered
+and developer warnings are emitted when accessing unregistered option.
+
+Extensions supporting versions older than Mercurial 4.3 cannot rely on the
+default value being registered. The simplest way to register an option while
+still supporting an older version is to use ``dynamicdefault`` for options
+requiring a default value. The existing code passing an explicit default can
+then stay in use until compatibility with Mercurial 4.2 is dropped.
+
+As reminder, here are the default values for each config type:
+
+    - config:      None
+    - configbool:  False
+    - configbytes: 0
+    - configdate:  None
+    - configint:   None
+    - configlist:  []
+    - configpath:  None
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mercurial/helptext/internals/extensions.txt	Fri Nov 22 21:42:04 2019 +0900
@@ -0,0 +1,367 @@
+Extensions allow the creation of new features and using them directly from
+the main hg command line as if they were built-in commands. The extensions
+have full access to the *internal* API.
+
+Use of Mercurial's internal API very likely makes your code subject to
+Mercurial's license. Before going any further, read the License page.
+
+There are NO guarantees that third-party code calling into Mercurial's
+internals won't break from release to release. If you do use Mercurial's API
+for published third-party code, we expect you to test your code before each
+major Mercurial release. This will prevent various bug reports from your users
+when they upgrade their copy of Mercurial.
+
+File Layout
+===========
+
+Extensions are usually written as simple python modules. Larger ones are
+better split into multiple modules of a single package (see the convert
+extension). The package root module gives its name to the extension and
+implements the ``cmdtable`` and optional callbacks described below.
+
+Command table
+=============
+
+To write your own extension, your python module can provide an optional dict
+named ``cmdtable`` with entries describing each command. A command should be
+registered to the ``cmdtable`` by ``@command`` decorator.
+
+Example using ``@command`` decorator (requires Mercurial 1.9)::
+
+    from mercurial.i18n import _
+
+    cmdtable = {}
+    try:
+        from mercurial import registrar
+        command = registrar.command(cmdtable)
+    except (AttributeError, ImportError):
+        # Fallback to hg < 4.3 support
+        from mercurial import cmdutil
+        command = cmdutil.command(cmdtable)
+
+    @command('print-parents',
+        [('s', 'short', None, _('print short form')),
+         ('l', 'long', None, _('print long form'))],
+        _('[options] node'))
+    def printparents(ui, repo, node, **opts):
+        ...
+
+The cmdtable dictionary
+-----------------------
+
+The ``cmdtable`` dictionary uses as key the new command names, and, as value,
+a tuple containing:
+
+1. the function to be called when the command is used.
+2. a list of options the command can take.
+3. a command line synopsis for the command (the function docstring is used for
+   the full help).
+
+List of options
+---------------
+
+All the command flag options are documented in the mercurial/fancyopts.py
+sources.
+
+The options list is a list of tuples containing:
+
+1. the short option letter, or ``''`` if no short option is available
+   (for example, ``o`` for a ``-o`` option).
+2. the long option name (for example, ``option`` for a ``--option`` option).
+3. a default value for the option.
+4. a help string for the option (it's possible to omit the "hg newcommand"
+   part and only the options and parameter substring is needed).
+
+Command function signatures
+---------------------------
+
+Functions that implement new commands always receive a ``ui`` and usually
+a ``repo`` parameter. The rest of parameters are taken from the command line
+items that don't start with a dash and are passed in the same order they were
+written. If no default value is given in the parameter list they are required.
+
+If there is no repo to be associated with the command and consequently no
+``repo`` passed, then ``norepo=True`` should be passed to the ``@command``
+decorator::
+
+    @command('mycommand', [], norepo=True)
+    def mycommand(ui, **opts):
+        ...
+
+For examples of ``norepo``, see the convert extension.
+
+Command function docstrings
+===========================
+
+The docstring of your function is used as the main help text, shown by
+``hg help mycommand``. The docstring should be formatted using a simple
+subset of reStructuredText markup. The supported constructs include:
+
+Paragraphs::
+
+    This is a paragraph.
+
+    Paragraphs are separated
+    by blank lines.
+
+A verbatim block is introduced with a double colon followed by an indented
+block. The double colon is turned into a single colon on display::
+
+    Some text::
+
+      verbatim
+        text
+         !!
+
+We have field lists::
+
+    :key1: value1
+    :key2: value2
+
+Bullet lists::
+
+    - foo
+    - bar
+
+Enumerated lists::
+
+    1. foo
+    2. bar
+
+Inline markup::
+
+    ``*bold*``, ``monospace``, :hg:`command`
+
+Mark Mercurial commands with ``:hg:`` to make a nice link to the corresponding
+documentation. We'll expand the support if new constructs can be parsed
+without too much trouble.
+
+Communicating with the user
+===========================
+
+Besides the ``ui`` methods, like ``ui.write(*msg)`` or
+``ui.prompt(msg, default="y")``, an extension can add help text for each
+of its commands and the extension itself.
+
+The module docstring will be used as help string when ``hg help extensionname``
+is used and, similarly, the help string for a command and the docstring
+belonging to the function that's wrapped by the command will be shown when
+``hg help command`` is invoked.
+
+Setup Callbacks
+===============
+
+Extensions are loaded in phases. All extensions are processed in a given phase
+before the next phase begins. In the first phase, all extension modules are
+loaded and registered with Mercurial. This means that you can find all enabled
+extensions with ``extensions.find`` in the following phases.
+
+Extension setup
+---------------
+
+There are two callbacks to be called when extensions are loaded, named
+``uisetup`` and ``extsetup``. ``uisetup`` is called first for each extension,
+then ``extsetup`` is called. This means ``extsetup`` can be useful in case
+one extension optionally depends on another extension.
+
+Both ``uisetup`` and ``extsetup`` receive a ui object with the local
+repository configuration::
+
+    def uisetup(ui):
+        # ...
+
+    def extsetup(ui):
+        # ...
+
+Be aware that ``uisetup`` in NOT the function to configure a ``ui`` instance.
+It's called only once per process, not per ``ui`` instance. Also, any changes
+to the ``ui`` may be discarded because the ``ui`` here temporarily loaded
+local configuration. So, it's generally wrong to do `ui.setconfig()` in
+these callbacks. Notable exception is setting ``pre/post-<command>`` hooks
+and extending ``ui.__class__``.
+
+In Mercurial 1.3.1 or earlier, ``extsetup`` takes no argument.
+
+Command table setup
+-------------------
+
+After ``extsetup``, the ``cmdtable`` is copied into the global command table
+in Mercurial.
+
+Ui instance setup
+-----------------
+
+The optional ``uipopulate`` is called for each ``ui`` instance after
+configuration is loaded, where extensions can set up additional ui members,
+update configuration by ``ui.setconfig()``, and extend the class dynamically.
+
+Typically there are three ``ui`` instances involved in command execution:
+
+``req.ui`` (or ``repo.baseui``)
+    Only system and user configurations are loaded into it.
+``lui``
+    Local repository configuration is loaded as well. This will be used at
+    early dispatching stage where a repository isn't available.
+``repo.ui``
+    The fully-loaded ``ui`` used after a repository is instantiated. This
+    will be created from the ``req.ui`` per repository.
+
+In command server and hgweb, this may be called more than once for the same
+``ui`` instance.
+
+(New in Mercurial 4.9)
+
+Repository setup
+----------------
+
+Extensions can implement an optional callback named ``reposetup``. It is
+called after the main Mercurial repository initialization, and can be used
+to setup any local state the extension might need.
+
+As other command functions it receives an ``ui`` object and a ``repo`` object
+(no additional parameters for this, though)::
+
+    def reposetup(ui, repo):
+        #do initialization here.
+
+It is important to take into account that the ``ui`` object that is received
+by the ``reposetup`` function is not the same as the one received by the
+``uisetup`` and ``extsetup`` functions. This is particularly important when
+setting up hooks as described in the following section, since not all hooks
+use the same ``ui`` object and hence different hooks must be configured in
+different setup functions.
+
+Wrapping methods on the ui and repo classes
+-------------------------------------------
+
+Because extensions can be loaded *per repository*, you should avoid using
+``extensions.wrapfunction()`` on methods of the ``ui`` and ``repo`` objects.
+Instead, create a subclass of the specific class of the instance passed into
+the ``*setup()`` hook; e.g. use ``ui.__class__`` as the base class, then
+reassign your new class to ``ui.__class__`` again. Mercurial will then use
+your updated ``ui`` or ``repo`` instance only for repositories where your
+extension is enabled (or copies thereof, reusing your new class).
+
+For example::
+
+    def uisetup(ui):
+        class echologui(ui.__class__):
+            def log(self, service, *msg, **opts):
+                if msg:
+                    self.write('%s: %s\n' % (service, msg[0] % msg[1:]))
+                super(echologui, self).log(service, *msg, **opts)
+
+        ui.__class__ = echologui
+
+Configuring Hooks
+=================
+
+Some extensions must use hooks to do their work. These required hooks can
+be configured manually by the user by modifying the ``[hook]`` section of
+their hgrc, but they can also be configured automatically by calling the
+``ui.setconfig('hooks', ...)`` function in one of the setup functions
+described above.
+
+The main difference between manually modifying the hooks section in the hgrc
+and using ``ui.setconfig()`` is that when using ``ui.setconfig()`` you have
+access to the actual hook function object, which you can pass directly to
+``ui.setconfig()``, while when you use the hooks section of the hgrc file
+you must refer to the hook function by using the
+``python:modulename.functioname`` idiom (e.g. ``python:hgext.notify.hook``).
+
+For example::
+
+    # Define hooks -- note that the actual function name it irrelevant.
+    def preupdatehook(ui, repo, **kwargs):
+        ui.write("Pre-update hook triggered\n")
+
+    def updatehook(ui, repo, **kwargs):
+        ui.write("Update hook triggered\n")
+
+    def uisetup(ui):
+        # When pre-<cmd> and post-<cmd> hooks are configured by means of
+        # the ui.setconfig() function, you must use the ui object passed
+        # to uisetup or extsetup.
+        ui.setconfig("hooks", "pre-update.myextension", preupdatehook)
+
+    def reposetup(ui, repo):
+        # Repository-specific hooks can be configured here. These include
+        # the update hook.
+        ui.setconfig("hooks", "update.myextension", updatehook)
+
+Note how different hooks may need to be configured in different setup
+functions. In the example you can see that the ``update`` hook must be
+configured in the ``reposetup`` function, while the ``pre-update`` hook
+must be configured on the ``uisetup`` or the ``extsetup`` functions.
+
+Marking compatible versions
+===========================
+
+Every extension should use the ``testedwith`` variable to specify Mercurial
+releases it's known to be compatible with. This helps us and users diagnose
+where problems are coming from::
+
+    testedwith = '2.0 2.0.1 2.1 2.1.1 2.1.2'
+
+Do not use the ``internal`` marker in third-party extensions; we will
+immediately drop all bug reports mentioning your extension if we catch you
+doing this.
+
+Similarly, an extension can use the ``buglink`` variable to specify how users
+should report issues with the extension.  This link will be included in the
+error message if the extension produces errors::
+
+    buglink = 'https://bitbucket.org/USER/REPO/issues'
+
+If an extension requires a minimum version of Mercurial, it can be declared
+with the ``minimumhgversion`` variable::
+
+    minimumhgversion = '4.6'
+
+Older clients will print a warning that the extension requires a new version,
+instead of attempting to load it.
+
+Wrap up: what belongs where?
+============================
+
+You will find here a list of most common tasks, based on setups from the
+extensions included in Mercurial core.
+
+uisetup
+-------
+
+* Changes to ``ui.__class__`` . The ``ui`` object that will be used to run
+  the command has not yet been created. Changes made here will affect ``ui``
+  objects created after this, and in particular the ``ui`` that will be passed
+  to ``runcommand``
+* Command wraps (``extensions.wrapcommand``)
+* Changes that need to be visible by other extensions: because initialization
+  occurs in phases (all extensions run ``uisetup``, then all run ``extsetup``),
+  a change made here will be visible by other extensions during ``extsetup``.
+* Monkeypatches or function wraps (``extensions.wrapfunction``) of ``dispatch``
+  module members
+* Set up ``pre-*`` and ``post-*`` hooks. (DEPRECATED. ``uipopulate`` is
+  preferred on Mercurial 4.9 and later.)
+* ``pushkey`` setup
+
+extsetup
+--------
+
+* Changes depending on the status of other extensions. (``if extensions.find('mq')``)
+* Add a global option to all commands
+* Extend revsets
+
+uipopulate
+----------
+
+* Modify ``ui`` instance attributes and configuration variables.
+* Changes to ``ui.__class__`` per instance.
+* Set up all hooks per scoped configuration.
+
+reposetup
+---------
+
+* Set up all hooks but ``pre-*`` and ``post-*``. (DEPRECATED. ``uipopulate`` is
+  preferred on Mercurial 4.9 and later.)
+* Modify configuration variables
+* Changes to ``repo.__class__``, ``repo.dirstate.__class__``
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mercurial/helptext/internals/linelog.txt	Fri Nov 22 21:42:04 2019 +0900
@@ -0,0 +1,302 @@
+linelog is a storage format inspired by the "Interleaved deltas" idea. See
+https://en.wikipedia.org/wiki/Interleaved_deltas for its introduction.
+
+0. SCCS Weave
+
+  To understand what linelog is, first we have a quick look at a simplified
+  (with header removed) SCCS weave format, which is an implementation of the
+  "Interleaved deltas" idea.
+
+0.1 Basic SCCS Weave File Format
+
+  A SCCS weave file consists of plain text lines. Each line is either a
+  special instruction starting with "^A" or part of the content of the real
+  file the weave tracks. There are 3 important operations, where REV denotes
+  the revision number:
+
+    ^AI REV, marking the beginning of an insertion block introduced by REV
+    ^AD REV, marking the beginning of a deletion block introduced by REV
+    ^AE REV, marking the end of the block started by "^AI REV" or "^AD REV"
+
+  Note on revision numbers: For any two different revision numbers, one must
+  be an ancestor of the other to make them comparable. This enforces linear
+  history. Besides, the comparison functions (">=", "<") should be efficient.
+  This means, if revisions are strings like git or hg, an external map is
+  required to convert them into integers.
+
+  For example, to represent the following changes:
+
+    REV 1 | REV 2 | REV 3
+    ------+-------+-------
+    a     | a     | a
+    b     | b     | 2
+    c     | 1     | c
+          | 2     |
+          | c     |
+
+  A possible weave file looks like:
+
+    ^AI 1
+    a
+    ^AD 3
+    b
+    ^AI 2
+    1
+    ^AE 3
+    2
+    ^AE 2
+    c
+    ^AE 1
+
+  An "^AE" does not always match its nearest operation ("^AI" or "^AD"). In
+  the above example, "^AE 3" does not match the nearest "^AI 2" but "^AD 3".
+  Therefore we need some extra information for "^AE". The SCCS weave uses a
+  revision number. It could also be a boolean value about whether it is an
+  insertion or a deletion (see section 0.4).
+
+0.2 Checkout
+
+  The "checkout" operation is to retrieve file content at a given revision,
+  say X. It's doable by going through the file line by line and:
+
+    - If meet ^AI rev, and rev > X, find the corresponding ^AE and jump there
+    - If meet ^AD rev, and rev <= X, find the corresponding ^AE and jump there
+    - Ignore ^AE
+    - For normal lines, just output them
+
+0.3 Annotate
+
+  The "annotate" operation is to show extra metadata like the revision number
+  and the original line number a line comes from.
+
+  It's basically just a "Checkout". For the extra metadata, they can be stored
+  side by side with the line contents. Alternatively, we can infer the
+  revision number from "^AI"s.
+
+  Some SCM tools have to calculate diffs on the fly and thus are much slower
+  on this operation.
+
+0.4 Tree Structure
+
+  The word "interleaved" is used because "^AI" .. "^AE" and "^AD" .. "^AE"
+  blocks can be interleaved.
+
+  If we consider insertions and deletions separately, they can form tree
+  structures, respectively.
+
+    +--- ^AI 1        +--- ^AD 3
+    | +- ^AI 2        | +- ^AD 2
+    | |               | |
+    | +- ^AE 2        | +- ^AE 2
+    |                 |
+    +--- ^AE 1        +--- ^AE 3
+
+  More specifically, it's possible to build a tree for all insertions, where
+  the tree node has the structure "(rev, startline, endline)". "startline" is
+  the line number of "^AI" and "endline" is the line number of the matched
+  "^AE".  The tree will have these properties:
+
+    1. child.rev > parent.rev
+    2. child.startline > parent.startline
+    3. child.endline < parent.endline
+
+  A similar tree for all deletions can also be built with the first property
+  changed to:
+
+    1. child.rev < parent.rev
+
+0.5 Malformed Cases
+
+  The following cases are considered malformed in our implementation:
+
+    1. Interleaved insertions, or interleaved deletions.
+       It can be rewritten to a non-interleaved tree structure.
+
+       Take insertions as example, deletions are similar:
+
+       ^AI x         ^AI x
+       a             a
+       ^AI x + 1  -> ^AI x + 1
+       b             b
+       ^AE x         ^AE x + 1
+       c             ^AE x
+       ^AE x + 1     ^AI x + 1
+                     c
+                     ^AE x + 1
+
+    2. Nested insertions, where the inner one has a smaller revision number.
+       Or nested deletions, where the inner one has a larger revision number.
+       It can be rewritten to a non-nested form.
+
+       Take insertions as example, deletions are similar:
+
+       ^AI x + 1     ^AI x + 1
+       a             a
+       ^AI x      -> ^AE x + 1
+       b             ^AI x
+       ^AE x         b
+       c             ^AE x
+       ^AE x + 1     ^AI x + 1
+                     c
+                     ^AE x + 1
+
+    3. Insertion inside deletion with a smaller revision number.
+
+       Rewrite by duplicating the content inserted:
+
+       ^AD x          ^AD x
+       a              a
+       ^AI x + 1  ->  b
+       b              c
+       ^AE x + 1      ^AE x
+       c              ^AI x + 1
+       ^AE x          b
+                      ^AE x + 1
+
+       Note: If "annotate" purely depends on "^AI" information, then the
+       duplication content will lose track of where "b" is originally from.
+
+  Some of them may be valid in other implementations for special purposes. For
+  example, to "revive" a previously deleted block in a newer revision.
+
+0.6 Cases Can Be Optimized
+
+  It's always better to get things nested. For example, the left is more
+  efficient than the right while they represent the same content:
+
+    +--- ^AD 2          +- ^AD 1
+    | +- ^AD 1          |   LINE A
+    | |   LINE A        +- ^AE 1
+    | +- ^AE 1          +- ^AD 2
+    |     LINE B        |   LINE B
+    +--- ^AE 2          +- ^AE 2
+
+  Our implementation sometimes generates the less efficient data. To always
+  get the optimal form, it requires extra code complexity that seems unworthy.
+
+0.7 Inefficiency
+
+  The file format can be slow because:
+
+  - Inserting a new line at position P requires rewriting all data after P.
+  - Finding "^AE" requires walking through the content (O(N), where N is the
+    number of lines between "^AI/D" and "^AE").
+
+1. Linelog
+
+  The linelog is a binary format that dedicates to speed up mercurial (or
+  git)'s "annotate" operation. It's designed to avoid issues mentioned in
+  section 0.7.
+
+1.1 Content Stored
+
+  Linelog is not another storage for file contents. It only stores line
+  numbers and corresponding revision numbers, instead of actual line content.
+  This is okay for the "annotate" operation because usually the external
+  source is fast to checkout the content of a file at a specific revision.
+
+  A typical SCCS weave is also fast on the "grep" operation, which needs
+  random accesses to line contents from different revisions of a file. This
+  can be slow with linelog's no-line-content design. However we could use
+  an extra map ((rev, line num) -> line content) to speed it up.
+
+  Note the revision numbers in linelog should be independent from mercurial
+  integer revision numbers. There should be some mapping between linelog rev
+  and hg hash stored side by side, to make the files reusable after being
+  copied to another machine.
+
+1.2 Basic Format
+
+  A linelog file consists of "instruction"s. An "instruction" can be either:
+
+    - JGE  REV ADDR     # jump to ADDR if rev >= REV
+    - JL   REV ADDR     # jump to ADDR if rev < REV
+    - LINE REV LINENUM  # append the (LINENUM+1)-th line in revision REV
+
+  For example, here is the example linelog representing the same file with
+  3 revisions mentioned in section 0.1:
+
+    SCCS  |    Linelog
+    Weave | Addr : Instruction
+    ------+------+-------------
+    ^AI 1 |    0 : JL   1 8
+    a     |    1 : LINE 1 0
+    ^AD 3 |    2 : JGE  3 6
+    b     |    3 : LINE 1 1
+    ^AI 2 |    4 : JL   2 7
+    1     |    5 : LINE 2 2
+    ^AE 3 |
+    2     |    6 : LINE 2 3
+    ^AE 2 |
+    c     |    7 : LINE 1 2
+    ^AE 1 |
+          |    8 : END
+
+  This way, "find ^AE" is O(1) because we just jump there. And we can insert
+  new lines without rewriting most part of the file by appending new lines and
+  changing a single instruction to jump to them.
+
+  The current implementation uses 64 bits for an instruction: The opcode (JGE,
+  JL or LINE) takes 2 bits, REV takes 30 bits and ADDR or LINENUM takes 32
+  bits. It also stores the max revision number and buffer size at the first
+  64 bits for quick access to these values.
+
+1.3 Comparing with Mercurial's revlog format
+
+  Apparently, linelog is very different from revlog: linelog stores rev and
+  line numbers, while revlog has line contents and other metadata (like
+  parents, flags). However, the revlog format could also be used to store rev
+  and line numbers. For example, to speed up the annotate operation, we could
+  also pre-calculate annotate results and just store them using the revlog
+  format.
+
+  Therefore, linelog is actually somehow similar to revlog, with the important
+  trade-off that it only supports linear history (mentioned in section 0.1).
+  Essentially, the differences are:
+
+    a) Linelog is full of deltas, while revlog could contain full file
+       contents sometimes. So linelog is smaller. Revlog could trade
+       reconstruction speed for file size - best case, revlog is as small as
+       linelog.
+    b) The interleaved delta structure allows skipping large portion of
+       uninteresting deltas so linelog's content reconstruction is faster than
+       the delta-only version of revlog (however it's possible to construct
+       a case where interleaved deltas degrade to plain deltas, so linelog
+       worst case would be delta-only revlog). Revlog could trade file size
+       for reconstruction speed.
+    c) Linelog implicitly maintains the order of all lines it stores. So it
+       could dump all the lines from all revisions, with a reasonable order.
+       While revlog could also dump all line additions, it requires extra
+       computation to figure out the order putting those lines - that's some
+       kind of "merge".
+
+  "c" makes "hg absorb" easier to implement and makes it possible to do
+  "annotate --deleted".
+
+1.4 Malformed Cases Handling
+
+  The following "case 1", "case 2", and "case 3" refer to cases mentioned
+  in section 0.5.
+
+  Using the exposed API (replacelines), case 1 is impossible to generate,
+  although it's possible to generate it by constructing rawdata and load that
+  via linelog.fromdata.
+
+  Doing annotate(maxrev) before replacelines (aka. a1, a2 passed to
+  replacelines are related to the latest revision) eliminates the possibility
+  of case 3. That makes sense since usually you'd like to make edits on top of
+  the latest revision. Practically, both absorb and fastannotate do this.
+
+  Doing annotate(maxrev), plus replacelines(rev, ...) where rev >= maxrev
+  eliminates the possibility of case 2. That makes sense since usually the
+  edits belong to "new revisions", not "old revisions". Practically,
+  fastannotate does this. Absorb calls replacelines with rev < maxrev to edit
+  past revisions. So it needs some extra care to not generate case 2.
+
+  If case 1 occurs, that probably means linelog file corruption (assuming
+  linelog is edited via public APIs) the checkout or annotate result could
+  be less meaningful or even error out, but linelog wouldn't enter an infinite
+  loop.
+
+  If either case 2 or 3 occurs, linelog works as if the inner "^AI/D" and "^AE"
+  operations on the left side are silently ignored.
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mercurial/helptext/internals/mergestate.txt	Fri Nov 22 21:42:04 2019 +0900
@@ -0,0 +1,80 @@
+The active mergestate is stored in ``.hg/merge`` when a merge is triggered
+by commands like ``hg merge``, ``hg rebase``, etc. until the merge is
+completed or aborted to track the 3-way merge state of individual files.
+
+The contents of the directory are:
+
+Conflicting files
+-----------------
+
+The local version of the conflicting files are stored with their
+filenames as the hash of their paths.
+
+state
+-----
+
+This mergestate file record is used by hg version prior to 2.9.1
+and contains less data than ``state2``. If there is no contradiction
+with ``state2``, we can assume that both are written at the same time.
+In this case, data from ``state2`` is used. Otherwise, we use ``state``.
+We read/write both ``state`` and ``state2`` records to ensure backward
+compatibility.
+
+state2
+------
+
+This record stores a superset of data in ``state``, including new kinds
+of records in the future.
+
+Each record can contain arbitrary content and has an associated type. This
+`type` should be a letter. If `type` is uppercase, the record is mandatory:
+versions of Mercurial that don't support it should abort. If `type` is
+lowercase, the record can be safely ignored.
+
+Currently known records:
+
+| * L: the node of the "local" part of the merge (hexified version)
+| * O: the node of the "other" part of the merge (hexified version)
+| * F: a file to be merged entry
+| * C: a change/delete or delete/change conflict
+| * D: a file that the external merge driver will merge internally
+|      (experimental)
+| * P: a path conflict (file vs directory)
+| * m: the external merge driver defined for this merge plus its run state
+|      (experimental)
+| * f: a (filename, dictionary) tuple of optional values for a given file
+| * X: unsupported mandatory record type (used in tests)
+| * x: unsupported advisory record type (used in tests)
+| * l: the labels for the parts of the merge.
+
+Merge driver run states (experimental):
+
+| * u: driver-resolved files unmarked -- needs to be run next time we're
+|      about to resolve or commit
+| * m: driver-resolved files marked -- only needs to be run before commit
+| * s: success/skipped -- does not need to be run any more
+
+Merge record states (indexed by filename):
+
+| * u: unresolved conflict
+| * r: resolved conflict
+| * pu: unresolved path conflict (file conflicts with directory)
+| * pr: resolved path conflict
+| * d: driver-resolved conflict
+
+The resolve command transitions between 'u' and 'r' for conflicts and
+'pu' and 'pr' for path conflicts.
+
+This format is a list of arbitrary records of the form:
+
+[type][length][content]
+
+`type` is a single character, `length` is a 4 byte integer, and
+`content` is an arbitrary byte sequence of length `length`.
+
+Mercurial versions prior to 3.7 have a bug where if there are
+unsupported mandatory merge records, attempting to clear out the merge
+state with hg update --clean or similar aborts. The 't' record type
+works around that by writing out what those versions treat as an
+advisory record, but later versions interpret as special: the first
+character is the 'real' record type and everything onwards is the data.
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mercurial/helptext/internals/requirements.txt	Fri Nov 22 21:42:04 2019 +0900
@@ -0,0 +1,144 @@
+Repositories contain a file (``.hg/requires``) containing a list of
+features/capabilities that are *required* for clients to interface
+with the repository. This file has been present in Mercurial since
+version 0.9.2 (released December 2006).
+
+One of the first things clients do when opening a repository is read
+``.hg/requires`` and verify that all listed requirements are supported,
+aborting if not. Requirements are therefore a strong mechanism to
+prevent incompatible clients from reading from unknown repository
+formats or even corrupting them by writing to them.
+
+Extensions may add requirements. When they do this, clients not running
+an extension will be unable to read from repositories.
+
+The following sections describe the requirements defined by the
+Mercurial core distribution.
+
+revlogv1
+========
+
+When present, revlogs are version 1 (RevlogNG). RevlogNG was introduced
+in 2006. The ``revlogv1`` requirement has been enabled by default
+since the ``requires`` file was introduced in Mercurial 0.9.2.
+
+If this requirement is not present, version 0 revlogs are assumed.
+
+store
+=====
+
+The *store* repository layout should be used.
+
+This requirement has been enabled by default since the ``requires`` file
+was introduced in Mercurial 0.9.2.
+
+fncache
+=======
+
+The *fncache* repository layout should be used.
+
+The *fncache* layout hash encodes filenames with long paths and
+encodes reserved filenames.
+
+This requirement is enabled by default when the *store* requirement is
+enabled (which is the default behavior). It was introduced in Mercurial
+1.1 (released December 2008).
+
+shared
+======
+
+Denotes that the store for a repository is shared from another location
+(defined by the ``.hg/sharedpath`` file).
+
+This requirement is set when a repository is created via :hg:`share`.
+
+The requirement was added in Mercurial 1.3 (released July 2009).
+
+relshared
+=========
+
+Derivative of ``shared``; the location of the store is relative to the
+store of this repository.
+
+This requirement is set when a repository is created via :hg:`share`
+using the ``--relative`` option.
+
+The requirement was added in Mercurial 4.2 (released May 2017).
+
+dotencode
+=========
+
+The *dotencode* repository layout should be used.
+
+The *dotencode* layout encodes the first period or space in filenames
+to prevent issues on OS X and Windows.
+
+This requirement is enabled by default when the *store* requirement
+is enabled (which is the default behavior). It was introduced in
+Mercurial 1.7 (released November 2010).
+
+parentdelta
+===========
+
+Denotes a revlog delta encoding format that was experimental and
+replaced by *generaldelta*. It should not be seen in the wild because
+it was never enabled by default.
+
+This requirement was added in Mercurial 1.7 and removed in Mercurial
+1.9.
+
+generaldelta
+============
+
+Revlogs should be created with the *generaldelta* flag enabled. The
+generaldelta flag will cause deltas to be encoded against a parent
+revision instead of the previous revision in the revlog.
+
+Support for this requirement was added in Mercurial 1.9 (released
+July 2011). The requirement was disabled on new repositories by
+default until Mercurial 3.7 (released February 2016).
+
+manifestv2
+==========
+
+Denotes that version 2 of manifests are being used.
+
+Support for this requirement was added in Mercurial 3.4 (released
+May 2015). The new format failed to meet expectations and support
+for the format and requirement were removed in Mercurial 4.6
+(released May 2018) since the feature never graduated frome experiment
+status.
+
+treemanifest
+============
+
+Denotes that tree manifests are being used. Tree manifests are
+one manifest per directory (as opposed to a single flat manifest).
+
+Support for this requirement was added in Mercurial 3.4 (released
+August 2015). The requirement is currently experimental and is
+disabled by default.
+
+exp-sparse
+==========
+
+The working directory is sparse (only contains a subset of files).
+
+Support for this requirement was added in Mercurial 4.3 (released
+August 2017). This requirement and feature are experimental and may
+disappear in a future Mercurial release. The requirement will only
+be present on repositories that have opted in to a sparse working
+directory.
+
+bookmarksinstore
+==================
+
+Bookmarks are stored in ``.hg/store/`` instead of directly in ``.hg/``
+where they used to be stored. The active bookmark is still stored
+directly in ``.hg/``. This makes them always shared by ``hg share``,
+whether or not ``-B`` was passed.
+
+Support for this requirement was added in Mercurial 5.1 (released
+August 2019). The requirement will only be present on repositories
+that have opted in to this format (by having
+``format.bookmarks-in-store=true`` set when they were created).
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mercurial/helptext/internals/revlogs.txt	Fri Nov 22 21:42:04 2019 +0900
@@ -0,0 +1,239 @@
+Revision logs - or *revlogs* - are an append only data structure for
+storing discrete entries, or *revisions*. They are the primary storage
+mechanism of repository data.
+
+Revlogs effectively model a directed acyclic graph (DAG). Each node
+has edges to 1 or 2 *parent* nodes. Each node contains metadata and
+the raw value for that node.
+
+Revlogs consist of entries which have metadata and revision data.
+Metadata includes the hash of the revision's content, sizes, and
+links to its *parent* entries. The collective metadata is referred
+to as the *index* and the revision data is the *data*.
+
+Revision data is stored as a series of compressed deltas against
+ancestor revisions.
+
+Revlogs are written in an append-only fashion. We never need to rewrite
+a file to insert nor do we need to remove data. Rolling back in-progress
+writes can be performed by truncating files. Read locks can be avoided
+using simple techniques. This means that references to other data in
+the same revlog *always* refer to a previous entry.
+
+Revlogs can be modeled as 0-indexed arrays. The first revision is
+revision #0 and the second is revision #1. The revision -1 is typically
+used to mean *does not exist* or *not defined*.
+
+File Format
+===========
+
+A revlog begins with a 32-bit big endian integer holding version info
+and feature flags. This integer overlaps with the first four bytes of
+the first revision entry.
+
+This integer is logically divided into 2 16-bit shorts. The least
+significant half of the integer is the format/version short. The other
+short holds feature flags that dictate behavior of the revlog.
+
+The following values for the format/version short are defined:
+
+0
+   The original revlog version.
+1
+   RevlogNG (*next generation*). It replaced version 0 when it was
+   implemented in 2006.
+2
+   In-development version incorporating accumulated knowledge and
+   missing features from 10+ years of revlog version 1.
+57005 (0xdead)
+   Reserved for internal testing of new versions. No defined format
+   beyond 32-bit header.
+
+The feature flags short consists of bit flags. Where 0 is the least
+significant bit. The bit flags vary by revlog version.
+
+Version 0 revlogs have no defined flags and the presence of a flag
+is considered an error.
+
+Version 1 revlogs have the following flags at the specified bit offsets:
+
+0
+   Store revision data inline.
+1
+   Generaldelta encoding.
+
+Version 2 revlogs have the following flags at the specified bit offsets:
+
+0
+   Store revision data inline.
+
+The following header values are common:
+
+00 00 00 01
+   v1
+00 01 00 01
+   v1 + inline
+00 02 00 01
+   v1 + generaldelta
+00 03 00 01
+   v1 + inline + generaldelta
+
+Following the 32-bit header is the remaining 60 bytes of the first index
+entry. Following that are additional *index* entries. Inlined revision
+data is possibly located between index entries. More on this inlined
+layout is described below.
+
+Version 1 Format
+================
+
+Version 1 (RevlogNG) begins with an index describing the revisions in
+the revlog. If the ``inline`` flag is set, revision data is stored inline,
+or between index entries (as opposed to in a separate container).
+
+Each index entry is 64 bytes. The byte layout of each entry is as
+follows, with byte 0 being the first byte (all data stored as big endian):
+
+0-3 (4 bytes) (rev 0 only)
+   Revlog header
+
+0-5 (6 bytes)
+   Absolute offset of revision data from beginning of revlog.
+
+6-7 (2 bytes)
+   Bit flags impacting revision behavior. The following bit offsets define:
+
+   0: REVIDX_ISCENSORED revision has censor metadata, must be verified.
+
+   1: REVIDX_ELLIPSIS revision hash does not match its data. Used by
+   narrowhg
+
+   2: REVIDX_EXTSTORED revision data is stored externally.
+
+8-11 (4 bytes)
+   Compressed length of revision data / chunk as stored in revlog.
+
+12-15 (4 bytes)
+   Uncompressed length of revision data. This is the size of the full
+   revision data, not the size of the chunk post decompression.
+
+16-19 (4 bytes)
+   Base or previous revision this revision's delta was produced against.
+   This revision holds full text (as opposed to a delta) if it points to
+   itself. For generaldelta repos, this is the previous revision in the
+   delta chain. For non-generaldelta repos, this is the base or first
+   revision in the delta chain.
+
+20-23 (4 bytes)
+   A revision this revision is *linked* to. This allows a revision in
+   one revlog to be forever associated with a revision in another
+   revlog. For example, a file's revlog may point to the changelog
+   revision that introduced it.
+
+24-27 (4 bytes)
+   Revision of 1st parent. -1 indicates no parent.
+
+28-31 (4 bytes)
+   Revision of 2nd parent. -1 indicates no 2nd parent.
+
+32-63 (32 bytes)
+   Hash of revision's full text. Currently, SHA-1 is used and only
+   the first 20 bytes of this field are used. The rest of the bytes
+   are ignored and should be stored as \0.
+
+If inline revision data is being stored, the compressed revision data
+(of length from bytes offset 8-11 from the index entry) immediately
+follows the index entry. There is no header on the revision data. There
+is no padding between it and the index entries before and after.
+
+If revision data is not inline, then raw revision data is stored in a
+separate byte container. The offsets from bytes 0-5 and the compressed
+length from bytes 8-11 define how to access this data.
+
+The 6 byte absolute offset field from the first revlog entry overlaps
+with the revlog header. That is, the first 6 bytes of the first revlog
+entry can be split into four bytes containing the header for the revlog
+file and an additional two bytes containing the offset for the first
+entry. Since this is the offset from the beginning of the file for the
+first revision entry, the two bytes will always be set to zero.
+
+Version 2 Format
+================
+
+(In development. Format not finalized or stable.)
+
+Version 2 is identical to version 2 with the following differences.
+
+There is no dedicated *generaldelta* revlog format flag. Instead,
+the feature is implied enabled by default.
+
+Delta Chains
+============
+
+Revision data is encoded as a chain of *chunks*. Each chain begins with
+the compressed original full text for that revision. Each subsequent
+*chunk* is a *delta* against the previous revision. We therefore call
+these chains of chunks/deltas *delta chains*.
+
+The full text for a revision is reconstructed by loading the original
+full text for the base revision of a *delta chain* and then applying
+*deltas* until the target revision is reconstructed.
+
+*Delta chains* are limited in length so lookup time is bound. They are
+limited to ~2x the length of the revision's data. The linear distance
+between the base chunk and the final chunk is also limited so the
+amount of read I/O to load all chunks in the delta chain is bound.
+
+Deltas and delta chains are either computed against the previous
+revision in the revlog or another revision (almost certainly one of
+the parents of the revision). Historically, deltas were computed against
+the previous revision. The *generaldelta* revlog feature flag (enabled
+by default in Mercurial 3.7) activates the mode where deltas are
+computed against an arbitrary revision (almost certainly a parent revision).
+
+File Storage
+============
+
+Revlogs logically consist of an index (metadata of entries) and
+revision data. This data may be stored together in a single file or in
+separate files. The mechanism used is indicated by the ``inline`` feature
+flag on the revlog.
+
+Mercurial's behavior is to use inline storage until a revlog reaches a
+certain size, at which point it will be converted to non-inline. The
+reason there is a size limit on inline storage is to establish an upper
+bound on how much data must be read to load the index. It would be a waste
+to read tens or hundreds of extra megabytes of data just to access the
+index data.
+
+The actual layout of revlog files on disk is governed by the repository's
+*store format*. Typically, a ``.i`` file represents the index revlog
+(possibly containing inline data) and a ``.d`` file holds the revision data.
+
+Revision Entries
+================
+
+Revision entries consist of an optional 1 byte header followed by an
+encoding of the revision data. The headers are as follows:
+
+\0 (0x00)
+   Revision data is the entirety of the entry, including this header.
+u (0x75)
+   Raw revision data follows.
+x (0x78)
+   zlib (RFC 1950) data.
+
+   The 0x78 value is actually the first byte of the zlib header (CMF byte).
+
+Hash Computation
+================
+
+The hash of the revision is stored in the index and is used both as a primary
+key and for data integrity verification.
+
+Currently, SHA-1 is the only supported hashing algorithm. To obtain the SHA-1
+hash of a revision:
+
+1. Hash the parent nodes
+2. Hash the fulltext of the revision
+
+The 20 byte node ids of the parents are fed into the hasher in ascending order.
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mercurial/helptext/internals/wireprotocol.txt	Fri Nov 22 21:42:04 2019 +0900
@@ -0,0 +1,1277 @@
+The Mercurial wire protocol is a request-response based protocol
+with multiple wire representations.
+
+Each request is modeled as a command name, a dictionary of arguments, and
+optional raw input. Command arguments and their types are intrinsic
+properties of commands. So is the response type of the command. This means
+clients can't always send arbitrary arguments to servers and servers can't
+return multiple response types.
+
+The protocol is synchronous and does not support multiplexing (concurrent
+commands).
+
+Handshake
+=========
+
+It is required or common for clients to perform a *handshake* when connecting
+to a server. The handshake serves the following purposes:
+
+* Negotiating protocol/transport level options
+* Allows the client to learn about server capabilities to influence
+  future requests
+* Ensures the underlying transport channel is in a *clean* state
+
+An important goal of the handshake is to allow clients to use more modern
+wire protocol features. By default, clients must assume they are talking
+to an old version of Mercurial server (possibly even the very first
+implementation). So, clients should not attempt to call or utilize modern
+wire protocol features until they have confirmation that the server
+supports them. The handshake implementation is designed to allow both
+ends to utilize the latest set of features and capabilities with as
+few round trips as possible.
+
+The handshake mechanism varies by transport and protocol and is documented
+in the sections below.
+
+HTTP Protocol
+=============
+
+Handshake
+---------
+
+The client sends a ``capabilities`` command request (``?cmd=capabilities``)
+as soon as HTTP requests may be issued.
+
+By default, the server responds with a version 1 capabilities string, which
+the client parses to learn about the server's abilities. The ``Content-Type``
+for this response is ``application/mercurial-0.1`` or
+``application/mercurial-0.2`` depending on whether the client advertised
+support for version ``0.2`` in its request. (Clients aren't supposed to
+advertise support for ``0.2`` until the capabilities response indicates
+the server's support for that media type. However, a client could
+conceivably cache this metadata and issue the capabilities request in such
+a way to elicit an ``application/mercurial-0.2`` response.)
+
+Clients wishing to switch to a newer API service may send an
+``X-HgUpgrade-<X>`` header containing a space-delimited list of API service
+names the client is capable of speaking. The request MUST also include an
+``X-HgProto-<X>`` header advertising a known serialization format for the
+response. ``cbor`` is currently the only defined serialization format.
+
+If the request contains these headers, the response ``Content-Type`` MAY
+be for a different media type. e.g. ``application/mercurial-cbor`` if the
+client advertises support for CBOR.
+
+The response MUST be deserializable to a map with the following keys:
+
+apibase
+   URL path to API services, relative to the repository root. e.g. ``api/``.
+
+apis
+   A map of API service names to API descriptors. An API descriptor contains
+   more details about that API. In the case of the HTTP Version 2 Transport,
+   it will be the normal response to a ``capabilities`` command.
+
+   Only the services advertised by the client that are also available on
+   the server are advertised.
+
+v1capabilities
+   The capabilities string that would be returned by a version 1 response.
+
+The client can then inspect the server-advertised APIs and decide which
+API to use, including continuing to use the HTTP Version 1 Transport.
+
+HTTP Version 1 Transport
+------------------------
+
+Commands are issued as HTTP/1.0 or HTTP/1.1 requests. Commands are
+sent to the base URL of the repository with the command name sent in
+the ``cmd`` query string parameter. e.g.
+``https://example.com/repo?cmd=capabilities``. The HTTP method is ``GET``
+or ``POST`` depending on the command and whether there is a request
+body.
+
+Command arguments can be sent multiple ways.
+
+The simplest is part of the URL query string using ``x-www-form-urlencoded``
+encoding (see Python's ``urllib.urlencode()``. However, many servers impose
+length limitations on the URL. So this mechanism is typically only used if
+the server doesn't support other mechanisms.
+
+If the server supports the ``httpheader`` capability, command arguments can
+be sent in HTTP request headers named ``X-HgArg-<N>`` where ``<N>`` is an
+integer starting at 1. A ``x-www-form-urlencoded`` representation of the
+arguments is obtained. This full string is then split into chunks and sent
+in numbered ``X-HgArg-<N>`` headers. The maximum length of each HTTP header
+is defined by the server in the ``httpheader`` capability value, which defaults
+to ``1024``. The server reassembles the encoded arguments string by
+concatenating the ``X-HgArg-<N>`` headers then URL decodes them into a
+dictionary.
+
+The list of ``X-HgArg-<N>`` headers should be added to the ``Vary`` request
+header to instruct caches to take these headers into consideration when caching
+requests.
+
+If the server supports the ``httppostargs`` capability, the client
+may send command arguments in the HTTP request body as part of an
+HTTP POST request. The command arguments will be URL encoded just like
+they would for sending them via HTTP headers. However, no splitting is
+performed: the raw arguments are included in the HTTP request body.
+
+The client sends a ``X-HgArgs-Post`` header with the string length of the
+encoded arguments data. Additional data may be included in the HTTP
+request body immediately following the argument data. The offset of the
+non-argument data is defined by the ``X-HgArgs-Post`` header. The
+``X-HgArgs-Post`` header is not required if there is no argument data.
+
+Additional command data can be sent as part of the HTTP request body. The
+default ``Content-Type`` when sending data is ``application/mercurial-0.1``.
+A ``Content-Length`` header is currently always sent.
+
+Example HTTP requests::
+
+    GET /repo?cmd=capabilities
+    X-HgArg-1: foo=bar&baz=hello%20world
+
+The request media type should be chosen based on server support. If the
+``httpmediatype`` server capability is present, the client should send
+the newest mutually supported media type. If this capability is absent,
+the client must assume the server only supports the
+``application/mercurial-0.1`` media type.
+
+The ``Content-Type`` HTTP response header identifies the response as coming
+from Mercurial and can also be used to signal an error has occurred.
+
+The ``application/mercurial-*`` media types indicate a generic Mercurial
+data type.
+
+The ``application/mercurial-0.1`` media type is raw Mercurial data. It is the
+predecessor of the format below.
+
+The ``application/mercurial-0.2`` media type is compression framed Mercurial
+data. The first byte of the payload indicates the length of the compression
+format identifier that follows. Next are N bytes indicating the compression
+format. e.g. ``zlib``. The remaining bytes are compressed according to that
+compression format. The decompressed data behaves the same as with
+``application/mercurial-0.1``.
+
+The ``application/hg-error`` media type indicates a generic error occurred.
+The content of the HTTP response body typically holds text describing the
+error.
+
+The ``application/mercurial-cbor`` media type indicates a CBOR payload
+and should be interpreted as identical to ``application/cbor``.
+
+Behavior of media types is further described in the ``Content Negotiation``
+section below.
+
+Clients should issue a ``User-Agent`` request header that identifies the client.
+The server should not use the ``User-Agent`` for feature detection.
+
+A command returning a ``string`` response issues a
+``application/mercurial-0.*`` media type and the HTTP response body contains
+the raw string value (after compression decoding, if used). A
+``Content-Length`` header is typically issued, but not required.
+
+A command returning a ``stream`` response issues a
+``application/mercurial-0.*`` media type and the HTTP response is typically
+using *chunked transfer* (``Transfer-Encoding: chunked``).
+
+HTTP Version 2 Transport
+------------------------
+
+**Experimental - feature under active development**
+
+Version 2 of the HTTP protocol is exposed under the ``/api/*`` URL space.
+It's final API name is not yet formalized.
+
+Commands are triggered by sending HTTP POST requests against URLs of the
+form ``<permission>/<command>``, where ``<permission>`` is ``ro`` or
+``rw``, meaning read-only and read-write, respectively and ``<command>``
+is a named wire protocol command.
+
+Non-POST request methods MUST be rejected by the server with an HTTP
+405 response.
+
+Commands that modify repository state in meaningful ways MUST NOT be
+exposed under the ``ro`` URL prefix. All available commands MUST be
+available under the ``rw`` URL prefix.
+
+Server adminstrators MAY implement blanket HTTP authentication keyed
+off the URL prefix. For example, a server may require authentication
+for all ``rw/*`` URLs and let unauthenticated requests to ``ro/*``
+URL proceed. A server MAY issue an HTTP 401, 403, or 407 response
+in accordance with RFC 7235. Clients SHOULD recognize the HTTP Basic
+(RFC 7617) and Digest (RFC 7616) authentication schemes. Clients SHOULD
+make an attempt to recognize unknown schemes using the
+``WWW-Authenticate`` response header on a 401 response, as defined by
+RFC 7235.
+
+Read-only commands are accessible under ``rw/*`` URLs so clients can
+signal the intent of the operation very early in the connection
+lifecycle. For example, a ``push`` operation - which consists of
+various read-only commands mixed with at least one read-write command -
+can perform all commands against ``rw/*`` URLs so that any server-side
+authentication requirements are discovered upon attempting the first
+command - not potentially several commands into the exchange. This
+allows clients to fail faster or prompt for credentials as soon as the
+exchange takes place. This provides a better end-user experience.
+
+Requests to unknown commands or URLS result in an HTTP 404.
+TODO formally define response type, how error is communicated, etc.
+
+HTTP request and response bodies use the ``hgrpc`` protocol for media
+exchange.` (See :hg:`help internals.wireprotocolrpc` for details of
+the protocol.) The entirety of the HTTP message body is 0 or more frames
+as defined by this protocol.
+
+Clients and servers MUST advertise the ``TBD`` media type via the
+``Content-Type`` request and response headers. In addition, clients MUST
+advertise this media type value in their ``Accept`` request header in all
+requests.
+TODO finalize the media type. For now, it is defined in wireprotoserver.py.
+
+Servers receiving requests without an ``Accept`` header SHOULD respond with
+an HTTP 406.
+
+Servers receiving requests with an invalid ``Content-Type`` header SHOULD
+respond with an HTTP 415.
+
+The command to run is specified in the POST payload as defined by ``hgrpc``.
+This is redundant with data already encoded in the URL. This is by design,
+so server operators can have better understanding about server activity from
+looking merely at HTTP access logs.
+
+In most circumstances, the command specified in the URL MUST match
+the command specified in the frame-based payload or the server will
+respond with an error. The exception to this is the special
+``multirequest`` URL. (See below.) In addition, HTTP requests
+are limited to one command invocation. The exception is the special
+``multirequest`` URL.
+
+The ``multirequest`` command endpoints (``ro/multirequest`` and
+``rw/multirequest``) are special in that they allow the execution of
+*any* command and allow the execution of multiple commands. If the
+HTTP request issues multiple commands across multiple frames, all
+issued commands will be processed by the server. Per the defined
+behavior of ``hgrpc```, commands may be issued interleaved and responses
+may come back in a different order than they were issued. Clients MUST
+be able to deal with this.
+
+SSH Protocol
+============
+
+Handshake
+---------
+
+For all clients, the handshake consists of the client sending 1 or more
+commands to the server using version 1 of the transport. Servers respond
+to commands they know how to respond to and send an empty response (``0\n``)
+for unknown commands (per standard behavior of version 1 of the transport).
+Clients then typically look for a response to the newest sent command to
+determine which transport version to use and what the available features for
+the connection and server are.
+
+Preceding any response from client-issued commands, the server may print
+non-protocol output. It is common for SSH servers to print banners, message
+of the day announcements, etc when clients connect. It is assumed that any
+such *banner* output will precede any Mercurial server output. So clients
+must be prepared to handle server output on initial connect that isn't
+in response to any client-issued command and doesn't conform to Mercurial's
+wire protocol. This *banner* output should only be on stdout. However,
+some servers may send output on stderr.
+
+Pre 0.9.1 clients issue a ``between`` command with the ``pairs`` argument
+having the value
+``0000000000000000000000000000000000000000-0000000000000000000000000000000000000000``.
+
+The ``between`` command has been supported since the original Mercurial
+SSH server. Requesting the empty range will return a ``\n`` string response,
+which will be encoded as ``1\n\n`` (value length of ``1`` followed by a newline
+followed by the value, which happens to be a newline).
+
+For pre 0.9.1 clients and all servers, the exchange looks like::
+
+   c: between\n
+   c: pairs 81\n
+   c: 0000000000000000000000000000000000000000-0000000000000000000000000000000000000000
+   s: 1\n
+   s: \n
+
+0.9.1+ clients send a ``hello`` command (with no arguments) before the
+``between`` command. The response to this command allows clients to
+discover server capabilities and settings.
+
+An example exchange between 0.9.1+ clients and a ``hello`` aware server looks
+like::
+
+   c: hello\n
+   c: between\n
+   c: pairs 81\n
+   c: 0000000000000000000000000000000000000000-0000000000000000000000000000000000000000
+   s: 324\n
+   s: capabilities: lookup changegroupsubset branchmap pushkey known getbundle ...\n
+   s: 1\n
+   s: \n
+
+And a similar scenario but with servers sending a banner on connect::
+
+   c: hello\n
+   c: between\n
+   c: pairs 81\n
+   c: 0000000000000000000000000000000000000000-0000000000000000000000000000000000000000
+   s: welcome to the server\n
+   s: if you find any issues, email someone@somewhere.com\n
+   s: 324\n
+   s: capabilities: lookup changegroupsubset branchmap pushkey known getbundle ...\n
+   s: 1\n
+   s: \n
+
+Note that output from the ``hello`` command is terminated by a ``\n``. This is
+part of the response payload and not part of the wire protocol adding a newline
+after responses. In other words, the length of the response contains the
+trailing ``\n``.
+
+Clients supporting version 2 of the SSH transport send a line beginning
+with ``upgrade`` before the ``hello`` and ``between`` commands. The line
+(which isn't a well-formed command line because it doesn't consist of a
+single command name) serves to both communicate the client's intent to
+switch to transport version 2 (transports are version 1 by default) as
+well as to advertise the client's transport-level capabilities so the
+server may satisfy that request immediately.
+
+The upgrade line has the form:
+
+    upgrade <token> <transport capabilities>
+
+That is the literal string ``upgrade`` followed by a space, followed by
+a randomly generated string, followed by a space, followed by a string
+denoting the client's transport capabilities.
+
+The token can be anything. However, a random UUID is recommended. (Use
+of version 4 UUIDs is recommended because version 1 UUIDs can leak the
+client's MAC address.)
+
+The transport capabilities string is a URL/percent encoded string
+containing key-value pairs defining the client's transport-level
+capabilities. The following capabilities are defined:
+
+proto
+   A comma-delimited list of transport protocol versions the client
+   supports. e.g. ``ssh-v2``.
+
+If the server does not recognize the ``upgrade`` line, it should issue
+an empty response and continue processing the ``hello`` and ``between``
+commands. Here is an example handshake between a version 2 aware client
+and a non version 2 aware server:
+
+   c: upgrade 2e82ab3f-9ce3-4b4e-8f8c-6fd1c0e9e23a proto=ssh-v2
+   c: hello\n
+   c: between\n
+   c: pairs 81\n
+   c: 0000000000000000000000000000000000000000-0000000000000000000000000000000000000000
+   s: 0\n
+   s: 324\n
+   s: capabilities: lookup changegroupsubset branchmap pushkey known getbundle ...\n
+   s: 1\n
+   s: \n
+
+(The initial ``0\n`` line from the server indicates an empty response to
+the unknown ``upgrade ..`` command/line.)
+
+If the server recognizes the ``upgrade`` line and is willing to satisfy that
+upgrade request, it replies to with a payload of the following form:
+
+   upgraded <token> <transport name>\n
+
+This line is the literal string ``upgraded``, a space, the token that was
+specified by the client in its ``upgrade ...`` request line, a space, and the
+name of the transport protocol that was chosen by the server. The transport
+name MUST match one of the names the client specified in the ``proto`` field
+of its ``upgrade ...`` request line.
+
+If a server issues an ``upgraded`` response, it MUST also read and ignore
+the lines associated with the ``hello`` and ``between`` command requests
+that were issued by the server. It is assumed that the negotiated transport
+will respond with equivalent requested information following the transport
+handshake.
+
+All data following the ``\n`` terminating the ``upgraded`` line is the
+domain of the negotiated transport. It is common for the data immediately
+following to contain additional metadata about the state of the transport and
+the server. However, this isn't strictly speaking part of the transport
+handshake and isn't covered by this section.
+
+Here is an example handshake between a version 2 aware client and a version
+2 aware server:
+
+   c:  upgrade 2e82ab3f-9ce3-4b4e-8f8c-6fd1c0e9e23a proto=ssh-v2
+   c:  hello\n
+   c:  between\n
+   c:  pairs 81\n
+   c:  0000000000000000000000000000000000000000-0000000000000000000000000000000000000000
+   s: upgraded 2e82ab3f-9ce3-4b4e-8f8c-6fd1c0e9e23a ssh-v2\n
+   s: <additional transport specific data>
+
+The client-issued token that is echoed in the response provides a more
+resilient mechanism for differentiating *banner* output from Mercurial
+output. In version 1, properly formatted banner output could get confused
+for Mercurial server output. By submitting a randomly generated token
+that is then present in the response, the client can look for that token
+in response lines and have reasonable certainty that the line did not
+originate from a *banner* message.
+
+SSH Version 1 Transport
+-----------------------
+
+The SSH transport (version 1) is a custom text-based protocol suitable for
+use over any bi-directional stream transport. It is most commonly used with
+SSH.
+
+A SSH transport server can be started with ``hg serve --stdio``. The stdin,
+stderr, and stdout file descriptors of the started process are used to exchange
+data. When Mercurial connects to a remote server over SSH, it actually starts
+a ``hg serve --stdio`` process on the remote server.
+
+Commands are issued by sending the command name followed by a trailing newline
+``\n`` to the server. e.g. ``capabilities\n``.
+
+Command arguments are sent in the following format::
+
+    <argument> <length>\n<value>
+
+That is, the argument string name followed by a space followed by the
+integer length of the value (expressed as a string) followed by a newline
+(``\n``) followed by the raw argument value.
+
+Dictionary arguments are encoded differently::
+
+    <argument> <# elements>\n
+    <key1> <length1>\n<value1>
+    <key2> <length2>\n<value2>
+    ...
+
+Non-argument data is sent immediately after the final argument value. It is
+encoded in chunks::
+
+    <length>\n<data>
+
+Each command declares a list of supported arguments and their types. If a
+client sends an unknown argument to the server, the server should abort
+immediately. The special argument ``*`` in a command's definition indicates
+that all argument names are allowed.
+
+The definition of supported arguments and types is initially made when a
+new command is implemented. The client and server must initially independently
+agree on the arguments and their types. This initial set of arguments can be
+supplemented through the presence of *capabilities* advertised by the server.
+
+Each command has a defined expected response type.
+
+A ``string`` response type is a length framed value. The response consists of
+the string encoded integer length of a value followed by a newline (``\n``)
+followed by the value. Empty values are allowed (and are represented as
+``0\n``).
+
+A ``stream`` response type consists of raw bytes of data. There is no framing.
+
+A generic error response type is also supported. It consists of a an error
+message written to ``stderr`` followed by ``\n-\n``. In addition, ``\n`` is
+written to ``stdout``.
+
+If the server receives an unknown command, it will send an empty ``string``
+response.
+
+The server terminates if it receives an empty command (a ``\n`` character).
+
+If the server announces support for the ``protocaps`` capability, the client
+should issue a ``protocaps`` command after the initial handshake to annonunce
+its own capabilities. The client capabilities are persistent.
+
+SSH Version 2 Transport
+-----------------------
+
+**Experimental and under development**
+
+Version 2 of the SSH transport behaves identically to version 1 of the SSH
+transport with the exception of handshake semantics. See above for how
+version 2 of the SSH transport is negotiated.
+
+Immediately following the ``upgraded`` line signaling a switch to version
+2 of the SSH protocol, the server automatically sends additional details
+about the capabilities of the remote server. This has the form:
+
+   <integer length of value>\n
+   capabilities: ...\n
+
+e.g.
+
+   s: upgraded 2e82ab3f-9ce3-4b4e-8f8c-6fd1c0e9e23a ssh-v2\n
+   s: 240\n
+   s: capabilities: known getbundle batch ...\n
+
+Following capabilities advertisement, the peers communicate using version
+1 of the SSH transport.
+
+Capabilities
+============
+
+Servers advertise supported wire protocol features. This allows clients to
+probe for server features before blindly calling a command or passing a
+specific argument.
+
+The server's features are exposed via a *capabilities* string. This is a
+space-delimited string of tokens/features. Some features are single words
+like ``lookup`` or ``batch``. Others are complicated key-value pairs
+advertising sub-features. e.g. ``httpheader=2048``. When complex, non-word
+values are used, each feature name can define its own encoding of sub-values.
+Comma-delimited and ``x-www-form-urlencoded`` values are common.
+
+The following document capabilities defined by the canonical Mercurial server
+implementation.
+
+batch
+-----
+
+Whether the server supports the ``batch`` command.
+
+This capability/command was introduced in Mercurial 1.9 (released July 2011).
+
+branchmap
+---------
+
+Whether the server supports the ``branchmap`` command.
+
+This capability/command was introduced in Mercurial 1.3 (released July 2009).
+
+bundle2-exp
+-----------
+
+Precursor to ``bundle2`` capability that was used before bundle2 was a
+stable feature.
+
+This capability was introduced in Mercurial 3.0 behind an experimental
+flag. This capability should not be observed in the wild.
+
+bundle2
+-------
+
+Indicates whether the server supports the ``bundle2`` data exchange format.
+
+The value of the capability is a URL quoted, newline (``\n``) delimited
+list of keys or key-value pairs.
+
+A key is simply a URL encoded string.
+
+A key-value pair is a URL encoded key separated from a URL encoded value by
+an ``=``. If the value is a list, elements are delimited by a ``,`` after
+URL encoding.
+
+For example, say we have the values::
+
+  {'HG20': [], 'changegroup': ['01', '02'], 'digests': ['sha1', 'sha512']}
+
+We would first construct a string::
+
+  HG20\nchangegroup=01,02\ndigests=sha1,sha512
+
+We would then URL quote this string::
+
+  HG20%0Achangegroup%3D01%2C02%0Adigests%3Dsha1%2Csha512
+
+This capability was introduced in Mercurial 3.4 (released May 2015).
+
+changegroupsubset
+-----------------
+
+Whether the server supports the ``changegroupsubset`` command.
+
+This capability was introduced in Mercurial 0.9.2 (released December
+2006).
+
+This capability was introduced at the same time as the ``lookup``
+capability/command.
+
+compression
+-----------
+
+Declares support for negotiating compression formats.
+
+Presence of this capability indicates the server supports dynamic selection
+of compression formats based on the client request.
+
+Servers advertising this capability are required to support the
+``application/mercurial-0.2`` media type in response to commands returning
+streams. Servers may support this media type on any command.
+
+The value of the capability is a comma-delimited list of strings declaring
+supported compression formats. The order of the compression formats is in
+server-preferred order, most preferred first.
+
+The identifiers used by the official Mercurial distribution are:
+
+bzip2
+   bzip2
+none
+   uncompressed / raw data
+zlib
+   zlib (no gzip header)
+zstd
+   zstd
+
+This capability was introduced in Mercurial 4.1 (released February 2017).
+
+getbundle
+---------
+
+Whether the server supports the ``getbundle`` command.
+
+This capability was introduced in Mercurial 1.9 (released July 2011).
+
+httpheader
+----------
+
+Whether the server supports receiving command arguments via HTTP request
+headers.
+
+The value of the capability is an integer describing the max header
+length that clients should send. Clients should ignore any content after a
+comma in the value, as this is reserved for future use.
+
+This capability was introduced in Mercurial 1.9 (released July 2011).
+
+httpmediatype
+-------------
+
+Indicates which HTTP media types (``Content-Type`` header) the server is
+capable of receiving and sending.
+
+The value of the capability is a comma-delimited list of strings identifying
+support for media type and transmission direction. The following strings may
+be present:
+
+0.1rx
+   Indicates server support for receiving ``application/mercurial-0.1`` media
+   types.
+
+0.1tx
+   Indicates server support for sending ``application/mercurial-0.1`` media
+   types.
+
+0.2rx
+   Indicates server support for receiving ``application/mercurial-0.2`` media
+   types.
+
+0.2tx
+   Indicates server support for sending ``application/mercurial-0.2`` media
+   types.
+
+minrx=X
+   Minimum media type version the server is capable of receiving. Value is a
+   string like ``0.2``.
+
+   This capability can be used by servers to limit connections from legacy
+   clients not using the latest supported media type. However, only clients
+   with knowledge of this capability will know to consult this value. This
+   capability is present so the client may issue a more user-friendly error
+   when the server has locked out a legacy client.
+
+mintx=X
+   Minimum media type version the server is capable of sending. Value is a
+   string like ``0.1``.
+
+Servers advertising support for the ``application/mercurial-0.2`` media type
+should also advertise the ``compression`` capability.
+
+This capability was introduced in Mercurial 4.1 (released February 2017).
+
+httppostargs
+------------
+
+**Experimental**
+
+Indicates that the server supports and prefers clients send command arguments
+via a HTTP POST request as part of the request body.
+
+This capability was introduced in Mercurial 3.8 (released May 2016).
+
+known
+-----
+
+Whether the server supports the ``known`` command.
+
+This capability/command was introduced in Mercurial 1.9 (released July 2011).
+
+lfs
+---
+
+Indicates that the LFS extension is enabled on the server.  It makes no claims
+about the repository actually having LFS blobs committed to it.
+
+This capability was introduced by the LFS extension in Mercurial 4.5 (released
+Feb 2018).
+
+lfs-serve
+---------
+
+Indicates that the LFS extension is enabled on the server, and LFS blobs are
+committed to the remote repository.  (Specifically, it indicates that the 'lfs'
+requirement is present in the remote repository.)
+
+This capability was introduced by the LFS extension in Mercurial 4.8 (released
+Nov 2018).
+
+lookup
+------
+
+Whether the server supports the ``lookup`` command.
+
+This capability was introduced in Mercurial 0.9.2 (released December
+2006).
+
+This capability was introduced at the same time as the ``changegroupsubset``
+capability/command.
+
+partial-pull
+------------
+
+Indicates that the client can deal with partial answers to pull requests
+by repeating the request.
+
+If this parameter is not advertised, the server will not send pull bundles.
+
+This client capability was introduced in Mercurial 4.6.
+
+protocaps
+---------
+
+Whether the server supports the ``protocaps`` command for SSH V1 transport.
+
+This capability was introduced in Mercurial 4.6.
+
+pushkey
+-------
+
+Whether the server supports the ``pushkey`` and ``listkeys`` commands.
+
+This capability was introduced in Mercurial 1.6 (released July 2010).
+
+standardbundle
+--------------
+
+**Unsupported**
+
+This capability was introduced during the Mercurial 0.9.2 development cycle in
+2006. It was never present in a release, as it was replaced by the ``unbundle``
+capability. This capability should not be encountered in the wild.
+
+stream-preferred
+----------------
+
+If present the server prefers that clients clone using the streaming clone
+protocol (``hg clone --stream``) rather than the standard
+changegroup/bundle based protocol.
+
+This capability was introduced in Mercurial 2.2 (released May 2012).
+
+streamreqs
+----------
+
+Indicates whether the server supports *streaming clones* and the *requirements*
+that clients must support to receive it.
+
+If present, the server supports the ``stream_out`` command, which transmits
+raw revlogs from the repository instead of changegroups. This provides a faster
+cloning mechanism at the expense of more bandwidth used.
+
+The value of this capability is a comma-delimited list of repo format
+*requirements*. These are requirements that impact the reading of data in
+the ``.hg/store`` directory. An example value is
+``streamreqs=generaldelta,revlogv1`` indicating the server repo requires
+the ``revlogv1`` and ``generaldelta`` requirements.
+
+If the only format requirement is ``revlogv1``, the server may expose the
+``stream`` capability instead of the ``streamreqs`` capability.
+
+This capability was introduced in Mercurial 1.7 (released November 2010).
+
+stream
+------
+
+Whether the server supports *streaming clones* from ``revlogv1`` repos.
+
+If present, the server supports the ``stream_out`` command, which transmits
+raw revlogs from the repository instead of changegroups. This provides a faster
+cloning mechanism at the expense of more bandwidth used.
+
+This capability was introduced in Mercurial 0.9.1 (released July 2006).
+
+When initially introduced, the value of the capability was the numeric
+revlog revision. e.g. ``stream=1``. This indicates the changegroup is using
+``revlogv1``. This simple integer value wasn't powerful enough, so the
+``streamreqs`` capability was invented to handle cases where the repo
+requirements have more than just ``revlogv1``. Newer servers omit the
+``=1`` since it was the only value supported and the value of ``1`` can
+be implied by clients.
+
+unbundlehash
+------------
+
+Whether the ``unbundle`` commands supports receiving a hash of all the
+heads instead of a list.
+
+For more, see the documentation for the ``unbundle`` command.
+
+This capability was introduced in Mercurial 1.9 (released July 2011).
+
+unbundle
+--------
+
+Whether the server supports pushing via the ``unbundle`` command.
+
+This capability/command has been present since Mercurial 0.9.1 (released
+July 2006).
+
+Mercurial 0.9.2 (released December 2006) added values to the capability
+indicating which bundle types the server supports receiving. This value is a
+comma-delimited list. e.g. ``HG10GZ,HG10BZ,HG10UN``. The order of values
+reflects the priority/preference of that type, where the first value is the
+most preferred type.
+
+Content Negotiation
+===================
+
+The wire protocol has some mechanisms to help peers determine what content
+types and encoding the other side will accept. Historically, these mechanisms
+have been built into commands themselves because most commands only send a
+well-defined response type and only certain commands needed to support
+functionality like compression.
+
+Currently, only the HTTP version 1 transport supports content negotiation
+at the protocol layer.
+
+HTTP requests advertise supported response formats via the ``X-HgProto-<N>``
+request header, where ``<N>`` is an integer starting at 1 allowing the logical
+value to span multiple headers. This value consists of a list of
+space-delimited parameters. Each parameter denotes a feature or capability.
+
+The following parameters are defined:
+
+0.1
+   Indicates the client supports receiving ``application/mercurial-0.1``
+   responses.
+
+0.2
+   Indicates the client supports receiving ``application/mercurial-0.2``
+   responses.
+
+cbor
+   Indicates the client supports receiving ``application/mercurial-cbor``
+   responses.
+
+   (Only intended to be used with version 2 transports.)
+
+comp
+   Indicates compression formats the client can decode. Value is a list of
+   comma delimited strings identifying compression formats ordered from
+   most preferential to least preferential. e.g. ``comp=zstd,zlib,none``.
+
+   This parameter does not have an effect if only the ``0.1`` parameter
+   is defined, as support for ``application/mercurial-0.2`` or greater is
+   required to use arbitrary compression formats.
+
+   If this parameter is not advertised, the server interprets this as
+   equivalent to ``zlib,none``.
+
+Clients may choose to only send this header if the ``httpmediatype``
+server capability is present, as currently all server-side features
+consulting this header require the client to opt in to new protocol features
+advertised via the ``httpmediatype`` capability.
+
+A server that doesn't receive an ``X-HgProto-<N>`` header should infer a
+value of ``0.1``. This is compatible with legacy clients.
+
+A server receiving a request indicating support for multiple media type
+versions may respond with any of the supported media types. Not all servers
+may support all media types on all commands.
+
+Commands
+========
+
+This section contains a list of all wire protocol commands implemented by
+the canonical Mercurial server.
+
+See :hg:`help internals.wireprotocolv2` for information on commands exposed
+to the frame-based protocol.
+
+batch
+-----
+
+Issue multiple commands while sending a single command request. The purpose
+of this command is to allow a client to issue multiple commands while avoiding
+multiple round trips to the server therefore enabling commands to complete
+quicker.
+
+The command accepts a ``cmds`` argument that contains a list of commands to
+execute.
+
+The value of ``cmds`` is a ``;`` delimited list of strings. Each string has the
+form ``<command> <arguments>``. That is, the command name followed by a space
+followed by an argument string.
+
+The argument string is a ``,`` delimited list of ``<key>=<value>`` values
+corresponding to command arguments. Both the argument name and value are
+escaped using a special substitution map::
+
+   : -> :c
+   , -> :o
+   ; -> :s
+   = -> :e
+
+The response type for this command is ``string``. The value contains a
+``;`` delimited list of responses for each requested command. Each value
+in this list is escaped using the same substitution map used for arguments.
+
+If an error occurs, the generic error response may be sent.
+
+between
+-------
+
+(Legacy command used for discovery in old clients)
+
+Obtain nodes between pairs of nodes.
+
+The ``pairs`` arguments contains a space-delimited list of ``-`` delimited
+hex node pairs. e.g.::
+
+   a072279d3f7fd3a4aa7ffa1a5af8efc573e1c896-6dc58916e7c070f678682bfe404d2e2d68291a18
+
+Return type is a ``string``. Value consists of lines corresponding to each
+requested range. Each line contains a space-delimited list of hex nodes.
+A newline ``\n`` terminates each line, including the last one.
+
+branchmap
+---------
+
+Obtain heads in named branches.
+
+Accepts no arguments. Return type is a ``string``.
+
+Return value contains lines with URL encoded branch names followed by a space
+followed by a space-delimited list of hex nodes of heads on that branch.
+e.g.::
+
+    default a072279d3f7fd3a4aa7ffa1a5af8efc573e1c896 6dc58916e7c070f678682bfe404d2e2d68291a18
+    stable baae3bf31522f41dd5e6d7377d0edd8d1cf3fccc
+
+There is no trailing newline.
+
+branches
+--------
+
+(Legacy command used for discovery in old clients. Clients with ``getbundle``
+use the ``known`` and ``heads`` commands instead.)
+
+Obtain ancestor changesets of specific nodes back to a branch point.
+
+Despite the name, this command has nothing to do with Mercurial named branches.
+Instead, it is related to DAG branches.
+
+The command accepts a ``nodes`` argument, which is a string of space-delimited
+hex nodes.
+
+For each node requested, the server will find the first ancestor node that is
+a DAG root or is a merge.
+
+Return type is a ``string``. Return value contains lines with result data for
+each requested node. Each line contains space-delimited nodes followed by a
+newline (``\n``). The 4 nodes reported on each line correspond to the requested
+node, the ancestor node found, and its 2 parent nodes (which may be the null
+node).
+
+capabilities
+------------
+
+Obtain the capabilities string for the repo.
+
+Unlike the ``hello`` command, the capabilities string is not prefixed.
+There is no trailing newline.
+
+This command does not accept any arguments. Return type is a ``string``.
+
+This command was introduced in Mercurial 0.9.1 (released July 2006).
+
+changegroup
+-----------
+
+(Legacy command: use ``getbundle`` instead)
+
+Obtain a changegroup version 1 with data for changesets that are
+descendants of client-specified changesets.
+
+The ``roots`` arguments contains a list of space-delimited hex nodes.
+
+The server responds with a changegroup version 1 containing all
+changesets between the requested root/base nodes and the repo's head nodes
+at the time of the request.
+
+The return type is a ``stream``.
+
+changegroupsubset
+-----------------
+
+(Legacy command: use ``getbundle`` instead)
+
+Obtain a changegroup version 1 with data for changesetsets between
+client specified base and head nodes.
+
+The ``bases`` argument contains a list of space-delimited hex nodes.
+The ``heads`` argument contains a list of space-delimited hex nodes.
+
+The server responds with a changegroup version 1 containing all
+changesets between the requested base and head nodes at the time of the
+request.
+
+The return type is a ``stream``.
+
+clonebundles
+------------
+
+Obtains a manifest of bundle URLs available to seed clones.
+
+Each returned line contains a URL followed by metadata. See the
+documentation in the ``clonebundles`` extension for more.
+
+The return type is a ``string``.
+
+getbundle
+---------
+
+Obtain a bundle containing repository data.
+
+This command accepts the following arguments:
+
+heads
+   List of space-delimited hex nodes of heads to retrieve.
+common
+   List of space-delimited hex nodes that the client has in common with the
+   server.
+obsmarkers
+   Boolean indicating whether to include obsolescence markers as part
+   of the response. Only works with bundle2.
+bundlecaps
+   Comma-delimited set of strings defining client bundle capabilities.
+listkeys
+   Comma-delimited list of strings of ``pushkey`` namespaces. For each
+   namespace listed, a bundle2 part will be included with the content of
+   that namespace.
+cg
+   Boolean indicating whether changegroup data is requested.
+cbattempted
+   Boolean indicating whether the client attempted to use the *clone bundles*
+   feature before performing this request.
+bookmarks
+   Boolean indicating whether bookmark data is requested.
+phases
+   Boolean indicating whether phases data is requested.
+
+The return type on success is a ``stream`` where the value is bundle.
+On the HTTP version 1 transport, the response is zlib compressed.
+
+If an error occurs, a generic error response can be sent.
+
+Unless the client sends a false value for the ``cg`` argument, the returned
+bundle contains a changegroup with the nodes between the specified ``common``
+and ``heads`` nodes. Depending on the command arguments, the type and content
+of the returned bundle can vary significantly.
+
+The default behavior is for the server to send a raw changegroup version
+``01`` response.
+
+If the ``bundlecaps`` provided by the client contain a value beginning
+with ``HG2``, a bundle2 will be returned. The bundle2 data may contain
+additional repository data, such as ``pushkey`` namespace values.
+
+heads
+-----
+
+Returns a list of space-delimited hex nodes of repository heads followed
+by a newline. e.g.
+``a9eeb3adc7ddb5006c088e9eda61791c777cbf7c 31f91a3da534dc849f0d6bfc00a395a97cf218a1\n``
+
+This command does not accept any arguments. The return type is a ``string``.
+
+hello
+-----
+
+Returns lines describing interesting things about the server in an RFC-822
+like format.
+
+Currently, the only line defines the server capabilities. It has the form::
+
+    capabilities: <value>
+
+See above for more about the capabilities string.
+
+SSH clients typically issue this command as soon as a connection is
+established.
+
+This command does not accept any arguments. The return type is a ``string``.
+
+This command was introduced in Mercurial 0.9.1 (released July 2006).
+
+listkeys
+--------
+
+List values in a specified ``pushkey`` namespace.
+
+The ``namespace`` argument defines the pushkey namespace to operate on.
+
+The return type is a ``string``. The value is an encoded dictionary of keys.
+
+Key-value pairs are delimited by newlines (``\n``). Within each line, keys and
+values are separated by a tab (``\t``). Keys and values are both strings.
+
+lookup
+------
+
+Try to resolve a value to a known repository revision.
+
+The ``key`` argument is converted from bytes to an
+``encoding.localstr`` instance then passed into
+``localrepository.__getitem__`` in an attempt to resolve it.
+
+The return type is a ``string``.
+
+Upon successful resolution, returns ``1 <hex node>\n``. On failure,
+returns ``0 <error string>\n``. e.g.::
+
+   1 273ce12ad8f155317b2c078ec75a4eba507f1fba\n
+
+   0 unknown revision 'foo'\n
+
+known
+-----
+
+Determine whether multiple nodes are known.
+
+The ``nodes`` argument is a list of space-delimited hex nodes to check
+for existence.
+
+The return type is ``string``.
+
+Returns a string consisting of ``0``s and ``1``s indicating whether nodes
+are known. If the Nth node specified in the ``nodes`` argument is known,
+a ``1`` will be returned at byte offset N. If the node isn't known, ``0``
+will be present at byte offset N.
+
+There is no trailing newline.
+
+protocaps
+---------
+
+Notify the server about the client capabilities in the SSH V1 transport
+protocol.
+
+The ``caps`` argument is a space-delimited list of capabilities.
+
+The server will reply with the string ``OK``.
+
+pushkey
+-------
+
+Set a value using the ``pushkey`` protocol.
+
+Accepts arguments ``namespace``, ``key``, ``old``, and ``new``, which
+correspond to the pushkey namespace to operate on, the key within that
+namespace to change, the old value (which may be empty), and the new value.
+All arguments are string types.
+
+The return type is a ``string``. The value depends on the transport protocol.
+
+The SSH version 1 transport sends a string encoded integer followed by a
+newline (``\n``) which indicates operation result. The server may send
+additional output on the ``stderr`` stream that should be displayed to the
+user.
+
+The HTTP version 1 transport sends a string encoded integer followed by a
+newline followed by additional server output that should be displayed to
+the user. This may include output from hooks, etc.
+
+The integer result varies by namespace. ``0`` means an error has occurred
+and there should be additional output to display to the user.
+
+stream_out
+----------
+
+Obtain *streaming clone* data.
+
+The return type is either a ``string`` or a ``stream``, depending on
+whether the request was fulfilled properly.
+
+A return value of ``1\n`` indicates the server is not configured to serve
+this data. If this is seen by the client, they may not have verified the
+``stream`` capability is set before making the request.
+
+A return value of ``2\n`` indicates the server was unable to lock the
+repository to generate data.
+
+All other responses are a ``stream`` of bytes. The first line of this data
+contains 2 space-delimited integers corresponding to the path count and
+payload size, respectively::
+
+    <path count> <payload size>\n
+
+The ``<payload size>`` is the total size of path data: it does not include
+the size of the per-path header lines.
+
+Following that header are ``<path count>`` entries. Each entry consists of a
+line with metadata followed by raw revlog data. The line consists of::
+
+    <store path>\0<size>\n
+
+The ``<store path>`` is the encoded store path of the data that follows.
+``<size>`` is the amount of data for this store path/revlog that follows the
+newline.
+
+There is no trailer to indicate end of data. Instead, the client should stop
+reading after ``<path count>`` entries are consumed.
+
+unbundle
+--------
+
+Send a bundle containing data (usually changegroup data) to the server.
+
+Accepts the argument ``heads``, which is a space-delimited list of hex nodes
+corresponding to server repository heads observed by the client. This is used
+to detect race conditions and abort push operations before a server performs
+too much work or a client transfers too much data.
+
+The request payload consists of a bundle to be applied to the repository,
+similarly to as if :hg:`unbundle` were called.
+
+In most scenarios, a special ``push response`` type is returned. This type
+contains an integer describing the change in heads as a result of the
+operation. A value of ``0`` indicates nothing changed. ``1`` means the number
+of heads remained the same. Values ``2`` and larger indicate the number of
+added heads minus 1. e.g. ``3`` means 2 heads were added. Negative values
+indicate the number of fewer heads, also off by 1. e.g. ``-2`` means there
+is 1 fewer head.
+
+The encoding of the ``push response`` type varies by transport.
+
+For the SSH version 1 transport, this type is composed of 2 ``string``
+responses: an empty response (``0\n``) followed by the integer result value.
+e.g. ``1\n2``. So the full response might be ``0\n1\n2``.
+
+For the HTTP version 1 transport, the response is a ``string`` type composed
+of an integer result value followed by a newline (``\n``) followed by string
+content holding server output that should be displayed on the client (output
+hooks, etc).
+
+In some cases, the server may respond with a ``bundle2`` bundle. In this
+case, the response type is ``stream``. For the HTTP version 1 transport, the
+response is zlib compressed.
+
+The server may also respond with a generic error type, which contains a string
+indicating the failure.
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mercurial/helptext/internals/wireprotocolrpc.txt	Fri Nov 22 21:42:04 2019 +0900
@@ -0,0 +1,740 @@
+**Experimental and under development**
+
+This document describe's Mercurial's transport-agnostic remote procedure
+call (RPC) protocol which is used to perform interactions with remote
+servers. This protocol is also referred to as ``hgrpc``.
+
+The protocol has the following high-level features:
+
+* Concurrent request and response support (multiple commands can be issued
+  simultaneously and responses can be streamed simultaneously).
+* Supports half-duplex and full-duplex connections.
+* All data is transmitted within *frames*, which have a well-defined
+  header and encode their length.
+* Side-channels for sending progress updates and printing output. Text
+  output from the remote can be localized locally.
+* Support for simultaneous and long-lived compression streams, even across
+  requests.
+* Uses CBOR for data exchange.
+
+The protocol is not specific to Mercurial and could be used by other
+applications.
+
+High-level Overview
+===================
+
+To operate the protocol, a bi-directional, half-duplex pipe supporting
+ordered sends and receives is required. That is, each peer has one pipe
+for sending data and another for receiving. Full-duplex pipes are also
+supported.
+
+All data is read and written in atomic units called *frames*. These
+are conceptually similar to TCP packets. Higher-level functionality
+is built on the exchange and processing of frames.
+
+All frames are associated with a *stream*. A *stream* provides a
+unidirectional grouping of frames. Streams facilitate two goals:
+content encoding and parallelism. There is a dedicated section on
+streams below.
+
+The protocol is request-response based: the client issues requests to
+the server, which issues replies to those requests. Server-initiated
+messaging is not currently supported, but this specification carves
+out room to implement it.
+
+All frames are associated with a numbered request. Frames can thus
+be logically grouped by their request ID.
+
+Frames
+======
+
+Frames begin with an 8 octet header followed by a variable length
+payload::
+
+    +------------------------------------------------+
+    |                 Length (24)                    |
+    +--------------------------------+---------------+
+    |         Request ID (16)        | Stream ID (8) |
+    +------------------+-------------+---------------+
+    | Stream Flags (8) |
+    +-----------+------+
+    | Type (4)  |
+    +-----------+
+    | Flags (4) |
+    +===========+===================================================|
+    |                     Frame Payload (0...)                    ...
+    +---------------------------------------------------------------+
+
+The length of the frame payload is expressed as an unsigned 24 bit
+little endian integer. Values larger than 65535 MUST NOT be used unless
+given permission by the server as part of the negotiated capabilities
+during the handshake. The frame header is not part of the advertised
+frame length. The payload length is the over-the-wire length. If there
+is content encoding applied to the payload as part of the frame's stream,
+the length is the output of that content encoding, not the input.
+
+The 16-bit ``Request ID`` field denotes the integer request identifier,
+stored as an unsigned little endian integer. Odd numbered requests are
+client-initiated. Even numbered requests are server-initiated. This
+refers to where the *request* was initiated - not where the *frame* was
+initiated, so servers will send frames with odd ``Request ID`` in
+response to client-initiated requests. Implementations are advised to
+start ordering request identifiers at ``1`` and ``0``, increment by
+``2``, and wrap around if all available numbers have been exhausted.
+
+The 8-bit ``Stream ID`` field denotes the stream that the frame is
+associated with. Frames belonging to a stream may have content
+encoding applied and the receiver may need to decode the raw frame
+payload to obtain the original data. Odd numbered IDs are
+client-initiated. Even numbered IDs are server-initiated.
+
+The 8-bit ``Stream Flags`` field defines stream processing semantics.
+See the section on streams below.
+
+The 4-bit ``Type`` field denotes the type of frame being sent.
+
+The 4-bit ``Flags`` field defines special, per-type attributes for
+the frame.
+
+The sections below define the frame types and their behavior.
+
+Command Request (``0x01``)
+--------------------------
+
+This frame contains a request to run a command.
+
+The payload consists of a CBOR map defining the command request. The
+bytestring keys of that map are:
+
+name
+   Name of the command that should be executed (bytestring).
+args
+   Map of bytestring keys to various value types containing the named
+   arguments to this command.
+
+   Each command defines its own set of argument names and their expected
+   types.
+
+redirect (optional)
+   (map) Advertises client support for following response *redirects*.
+
+   This map has the following bytestring keys:
+
+   targets
+      (array of bytestring) List of named redirect targets supported by
+      this client. The names come from the targets advertised by the
+      server's *capabilities* message.
+
+   hashes
+      (array of bytestring) List of preferred hashing algorithms that can
+      be used for content integrity verification.
+
+   See the *Content Redirects* section below for more on content redirects.
+
+This frame type MUST ONLY be sent from clients to servers: it is illegal
+for a server to send this frame to a client.
+
+The following flag values are defined for this type:
+
+0x01
+   New command request. When set, this frame represents the beginning
+   of a new request to run a command. The ``Request ID`` attached to this
+   frame MUST NOT be active.
+0x02
+   Command request continuation. When set, this frame is a continuation
+   from a previous command request frame for its ``Request ID``. This
+   flag is set when the CBOR data for a command request does not fit
+   in a single frame.
+0x04
+   Additional frames expected. When set, the command request didn't fit
+   into a single frame and additional CBOR data follows in a subsequent
+   frame.
+0x08
+   Command data frames expected. When set, command data frames are
+   expected to follow the final command request frame for this request.
+
+``0x01`` MUST be set on the initial command request frame for a
+``Request ID``.
+
+``0x01`` or ``0x02`` MUST be set to indicate this frame's role in
+a series of command request frames.
+
+If command data frames are to be sent, ``0x08`` MUST be set on ALL
+command request frames.
+
+Command Data (``0x02``)
+-----------------------
+
+This frame contains raw data for a command.
+
+Most commands can be executed by specifying arguments. However,
+arguments have an upper bound to their length. For commands that
+accept data that is beyond this length or whose length isn't known
+when the command is initially sent, they will need to stream
+arbitrary data to the server. This frame type facilitates the sending
+of this data.
+
+The payload of this frame type consists of a stream of raw data to be
+consumed by the command handler on the server. The format of the data
+is command specific.
+
+The following flag values are defined for this type:
+
+0x01
+   Command data continuation. When set, the data for this command
+   continues into a subsequent frame.
+
+0x02
+   End of data. When set, command data has been fully sent to the
+   server. The command has been fully issued and no new data for this
+   command will be sent. The next frame will belong to a new command.
+
+Command Response Data (``0x03``)
+--------------------------------
+
+This frame contains response data to an issued command.
+
+Response data ALWAYS consists of a series of 1 or more CBOR encoded
+values. A CBOR value may be using indefinite length encoding. And the
+bytes constituting the value may span several frames.
+
+The following flag values are defined for this type:
+
+0x01
+   Data continuation. When set, an additional frame containing response data
+   will follow.
+0x02
+   End of data. When set, the response data has been fully sent and
+   no additional frames for this response will be sent.
+
+The ``0x01`` flag is mutually exclusive with the ``0x02`` flag.
+
+Error Occurred (``0x05``)
+-------------------------
+
+Some kind of error occurred.
+
+There are 3 general kinds of failures that can occur:
+
+* Command error encountered before any response issued
+* Command error encountered after a response was issued
+* Protocol or stream level error
+
+This frame type is used to capture the latter cases. (The general
+command error case is handled by the leading CBOR map in
+``Command Response`` frames.)
+
+The payload of this frame contains a CBOR map detailing the error. That
+map has the following bytestring keys:
+
+type
+   (bytestring) The overall type of error encountered. Can be one of the
+   following values:
+
+   protocol
+      A protocol-level error occurred. This typically means someone
+      is violating the framing protocol semantics and the server is
+      refusing to proceed.
+
+   server
+      A server-level error occurred. This typically indicates some kind of
+      logic error on the server, likely the fault of the server.
+
+   command
+      A command-level error, likely the fault of the client.
+
+message
+   (array of maps) A richly formatted message that is intended for
+   human consumption. See the ``Human Output Side-Channel`` frame
+   section for a description of the format of this data structure.
+
+Human Output Side-Channel (``0x06``)
+------------------------------------
+
+This frame contains a message that is intended to be displayed to
+people. Whereas most frames communicate machine readable data, this
+frame communicates textual data that is intended to be shown to
+humans.
+
+The frame consists of a series of *formatting requests*. Each formatting
+request consists of a formatting string, arguments for that formatting
+string, and labels to apply to that formatting string.
+
+A formatting string is a printf()-like string that allows variable
+substitution within the string. Labels allow the rendered text to be
+*decorated*. Assuming use of the canonical Mercurial code base, a
+formatting string can be the input to the ``i18n._`` function. This
+allows messages emitted from the server to be localized. So even if
+the server has different i18n settings, people could see messages in
+their *native* settings. Similarly, the use of labels allows
+decorations like coloring and underlining to be applied using the
+client's configured rendering settings.
+
+Formatting strings are similar to ``printf()`` strings or how
+Python's ``%`` operator works. The only supported formatting sequences
+are ``%s`` and ``%%``. ``%s`` will be replaced by whatever the string
+at that position resolves to. ``%%`` will be replaced by ``%``. All
+other 2-byte sequences beginning with ``%`` represent a literal
+``%`` followed by that character. However, future versions of the
+wire protocol reserve the right to allow clients to opt in to receiving
+formatting strings with additional formatters, hence why ``%%`` is
+required to represent the literal ``%``.
+
+The frame payload consists of a CBOR array of CBOR maps. Each map
+defines an *atom* of text data to print. Each *atom* has the following
+bytestring keys:
+
+msg
+   (bytestring) The formatting string. Content MUST be ASCII.
+args (optional)
+   Array of bytestrings defining arguments to the formatting string.
+labels (optional)
+   Array of bytestrings defining labels to apply to this atom.
+
+All data to be printed MUST be encoded into a single frame: this frame
+does not support spanning data across multiple frames.
+
+All textual data encoded in these frames is assumed to be line delimited.
+The last atom in the frame SHOULD end with a newline (``\n``). If it
+doesn't, clients MAY add a newline to facilitate immediate printing.
+
+Progress Update (``0x07``)
+--------------------------
+
+This frame holds the progress of an operation on the peer. Consumption
+of these frames allows clients to display progress bars, estimated
+completion times, etc.
+
+Each frame defines the progress of a single operation on the peer. The
+payload consists of a CBOR map with the following bytestring keys:
+
+topic
+   Topic name (string)
+pos
+   Current numeric position within the topic (integer)
+total
+   Total/end numeric position of this topic (unsigned integer)
+label (optional)
+   Unit label (string)
+item (optional)
+   Item name (string)
+
+Progress state is created when a frame is received referencing a
+*topic* that isn't currently tracked. Progress tracking for that
+*topic* is finished when a frame is received reporting the current
+position of that topic as ``-1``.
+
+Multiple *topics* may be active at any given time.
+
+Rendering of progress information is not mandated or governed by this
+specification: implementations MAY render progress information however
+they see fit, including not at all.
+
+The string data describing the topic SHOULD be static strings to
+facilitate receivers localizing that string data. The emitter
+MUST normalize all string data to valid UTF-8 and receivers SHOULD
+validate that received data conforms to UTF-8. The topic name
+SHOULD be ASCII.
+
+Sender Protocol Settings (``0x08``)
+-----------------------------------
+
+This frame type advertises the sender's support for various protocol and
+stream level features. The data advertised in this frame is used to influence
+subsequent behavior of the current frame exchange channel.
+
+The frame payload consists of a CBOR map. It may contain the following
+bytestring keys:
+
+contentencodings
+   (array of bytestring) A list of content encodings supported by the
+   sender, in order of most to least preferred.
+
+   Peers are allowed to encode stream data using any of the listed
+   encodings.
+
+   See the ``Content Encoding Profiles`` section for an enumeration
+   of supported content encodings.
+
+   If not defined, the value is assumed to be a list with the single value
+   ``identity``, meaning only the no-op encoding is supported.
+
+   Senders MAY filter the set of advertised encodings against what it
+   knows the receiver supports (e.g. if the receiver advertised encodings
+   via the capabilities descriptor). However, doing so will prevent
+   servers from gaining an understanding of the aggregate capabilities
+   of clients. So clients are discouraged from doing so.
+
+When this frame is not sent/received, the receiver assumes default values
+for all keys.
+
+If encountered, this frame type MUST be sent before any other frame type
+in a channel.
+
+The following flag values are defined for this frame type:
+
+0x01
+   Data continuation. When set, an additional frame containing more protocol
+   settings immediately follows.
+0x02
+   End of data. When set, the protocol settings data has been completely
+   sent.
+
+The ``0x01`` flag is mutually exclusive with the ``0x02`` flag.
+
+Stream Encoding Settings (``0x09``)
+-----------------------------------
+
+This frame type holds information defining the content encoding
+settings for a *stream*.
+
+This frame type is likely consumed by the protocol layer and is not
+passed on to applications.
+
+This frame type MUST ONLY occur on frames having the *Beginning of Stream*
+``Stream Flag`` set.
+
+The payload of this frame defines what content encoding has (possibly)
+been applied to the payloads of subsequent frames in this stream.
+
+The payload consists of a series of CBOR values. The first value is a
+bytestring denoting the content encoding profile of the data in this
+stream. Subsequent CBOR values supplement this simple value in a
+profile-specific manner. See the ``Content Encoding Profiles`` section
+for more.
+
+In the absence of this frame on a stream, it is assumed the stream is
+using the ``identity`` content encoding.
+
+The following flag values are defined for this frame type:
+
+0x01
+   Data continuation. When set, an additional frame containing more encoding
+   settings immediately follows.
+0x02
+   End of data. When set, the encoding settings data has been completely
+   sent.
+
+The ``0x01`` flag is mutually exclusive with the ``0x02`` flag.
+
+Stream States and Flags
+=======================
+
+Streams can be in two states: *open* and *closed*. An *open* stream
+is active and frames attached to that stream could arrive at any time.
+A *closed* stream is not active. If a frame attached to a *closed*
+stream arrives, that frame MUST have an appropriate stream flag
+set indicating beginning of stream. All streams are in the *closed*
+state by default.
+
+The ``Stream Flags`` field denotes a set of bit flags for defining
+the relationship of this frame within a stream. The following flags
+are defined:
+
+0x01
+   Beginning of stream. The first frame in the stream MUST set this
+   flag. When received, the ``Stream ID`` this frame is attached to
+   becomes ``open``.
+
+0x02
+   End of stream. The last frame in a stream MUST set this flag. When
+   received, the ``Stream ID`` this frame is attached to becomes
+   ``closed``. Any content encoding context associated with this stream
+   can be destroyed after processing the payload of this frame.
+
+0x04
+   Apply content encoding. When set, any content encoding settings
+   defined by the stream should be applied when attempting to read
+   the frame. When not set, the frame payload isn't encoded.
+
+TODO consider making stream opening and closing communicated via
+explicit frame types (e.g. a "stream state change" frame) rather than
+flags on all frames. This would make stream state changes more explicit,
+as they could only occur on specific frame types.
+
+Streams
+=======
+
+Streams - along with ``Request IDs`` - facilitate grouping of frames.
+But the purpose of each is quite different and the groupings they
+constitute are independent.
+
+A ``Request ID`` is essentially a tag. It tells you which logical
+request a frame is associated with.
+
+A *stream* is a sequence of frames grouped for the express purpose
+of applying a stateful encoding or for denoting sub-groups of frames.
+
+Unlike ``Request ID``s which span the request and response, a stream
+is unidirectional and stream IDs are independent from client to
+server.
+
+There is no strict hierarchical relationship between ``Request IDs``
+and *streams*. A stream can contain frames having multiple
+``Request IDs``. Frames belonging to the same ``Request ID`` can
+span multiple streams.
+
+One goal of streams is to facilitate content encoding. A stream can
+define an encoding to be applied to frame payloads. For example, the
+payload transmitted over the wire may contain output from a
+zstandard compression operation and the receiving end may decompress
+that payload to obtain the original data.
+
+The other goal of streams is to facilitate concurrent execution. For
+example, a server could spawn 4 threads to service a request that can
+be easily parallelized. Each of those 4 threads could write into its
+own stream. Those streams could then in turn be delivered to 4 threads
+on the receiving end, with each thread consuming its stream in near
+isolation. The *main* thread on both ends merely does I/O and
+encodes/decodes frame headers: the bulk of the work is done by worker
+threads.
+
+In addition, since content encoding is defined per stream, each
+*worker thread* could perform potentially CPU bound work concurrently
+with other threads. This approach of applying encoding at the
+sub-protocol / stream level eliminates a potential resource constraint
+on the protocol stream as a whole (it is common for the throughput of
+a compression engine to be smaller than the throughput of a network).
+
+Having multiple streams - each with their own encoding settings - also
+facilitates the use of advanced data compression techniques. For
+example, a transmitter could see that it is generating data faster
+and slower than the receiving end is consuming it and adjust its
+compression settings to trade CPU for compression ratio accordingly.
+
+While streams can define a content encoding, not all frames within
+that stream must use that content encoding. This can be useful when
+data is being served from caches and being derived dynamically. A
+cache could pre-compressed data so the server doesn't have to
+recompress it. The ability to pick and choose which frames are
+compressed allows servers to easily send data to the wire without
+involving potentially expensive encoding overhead.
+
+Content Encoding Profiles
+=========================
+
+Streams can have named content encoding *profiles* associated with
+them. A profile defines a shared understanding of content encoding
+settings and behavior.
+
+Profiles are described in the following sections.
+
+identity
+--------
+
+The ``identity`` profile is a no-op encoding: the encoded bytes are
+exactly the input bytes.
+
+This profile MUST be supported by all peers.
+
+In the absence of an identified profile, the ``identity`` profile is
+assumed.
+
+zstd-8mb
+--------
+
+Zstandard encoding (RFC 8478). Zstandard is a fast and effective lossless
+compression format.
+
+This profile allows decompressor window sizes of up to 8 MB.
+
+zlib
+----
+
+zlib compressed data (RFC 1950). zlib is a widely-used and supported
+lossless compression format.
+
+It isn't as fast as zstandard and it is recommended to use zstandard instead,
+if possible.
+
+Command Protocol
+================
+
+A client can request that a remote run a command by sending it
+frames defining that command. This logical stream is composed of
+1 or more ``Command Request`` frames and and 0 or more ``Command Data``
+frames.
+
+All frames composing a single command request MUST be associated with
+the same ``Request ID``.
+
+Clients MAY send additional command requests without waiting on the
+response to a previous command request. If they do so, they MUST ensure
+that the ``Request ID`` field of outbound frames does not conflict
+with that of an active ``Request ID`` whose response has not yet been
+fully received.
+
+Servers MAY respond to commands in a different order than they were
+sent over the wire. Clients MUST be prepared to deal with this. Servers
+also MAY start executing commands in a different order than they were
+received, or MAY execute multiple commands concurrently.
+
+If there is a dependency between commands or a race condition between
+commands executing (e.g. a read-only command that depends on the results
+of a command that mutates the repository), then clients MUST NOT send
+frames issuing a command until a response to all dependent commands has
+been received.
+TODO think about whether we should express dependencies between commands
+to avoid roundtrip latency.
+
+A command is defined by a command name, 0 or more command arguments,
+and optional command data.
+
+Arguments are the recommended mechanism for transferring fixed sets of
+parameters to a command. Data is appropriate for transferring variable
+data. Thinking in terms of HTTP, arguments would be headers and data
+would be the message body.
+
+It is recommended for servers to delay the dispatch of a command
+until all argument have been received. Servers MAY impose limits on the
+maximum argument size.
+TODO define failure mechanism.
+
+Servers MAY dispatch to commands immediately once argument data
+is available or delay until command data is received in full.
+
+Once a ``Command Request`` frame is sent, a client must be prepared to
+receive any of the following frames associated with that request:
+``Command Response``, ``Error Response``, ``Human Output Side-Channel``,
+``Progress Update``.
+
+The *main* response for a command will be in ``Command Response`` frames.
+The payloads of these frames consist of 1 or more CBOR encoded values.
+The first CBOR value on the first ``Command Response`` frame is special
+and denotes the overall status of the command. This CBOR map contains
+the following bytestring keys:
+
+status
+   (bytestring) A well-defined message containing the overall status of
+   this command request. The following values are defined:
+
+   ok
+      The command was received successfully and its response follows.
+   error
+      There was an error processing the command. More details about the
+      error are encoded in the ``error`` key.
+   redirect
+      The response for this command is available elsewhere. Details on
+      where are in the ``location`` key.
+
+error (optional)
+   A map containing information about an encountered error. The map has the
+   following keys:
+
+   message
+      (array of maps) A message describing the error. The message uses the
+      same format as those in the ``Human Output Side-Channel`` frame.
+
+location (optional)
+   (map) Presence indicates that a *content redirect* has occurred. The map
+   provides the external location of the content.
+
+   This map contains the following bytestring keys:
+
+   url
+      (bytestring) URL from which this content may be requested.
+
+   mediatype
+      (bytestring) The media type for the fetched content. e.g.
+      ``application/mercurial-*``.
+
+      In some transports, this value is also advertised by the transport.
+      e.g. as the ``Content-Type`` HTTP header.
+
+   size (optional)
+      (unsigned integer) Total size of remote object in bytes. This is
+      the raw size of the entity that will be fetched, minus any
+      non-Mercurial protocol encoding (e.g. HTTP content or transfer
+      encoding.)
+
+   fullhashes (optional)
+      (array of arrays) Content hashes for the entire payload. Each entry
+      is an array of bytestrings containing the hash name and the hash value.
+
+   fullhashseed (optional)
+      (bytestring) Optional seed value to feed into hasher for full content
+      hash verification.
+
+   serverdercerts (optional)
+      (array of bytestring) DER encoded x509 certificates for the server. When
+      defined, clients MAY validate that the x509 certificate on the target
+      server exactly matches the certificate used here.
+
+   servercadercerts (optional)
+      (array of bytestring) DER encoded x509 certificates for the certificate
+      authority of the target server. When defined, clients MAY validate that
+      the x509 on the target server was signed by CA certificate in this set.
+
+   # TODO support for giving client an x509 certificate pair to be used as a
+   # client certificate.
+
+   # TODO support common authentication mechanisms (e.g. HTTP basic/digest
+   # auth).
+
+   # TODO support custom authentication mechanisms. This likely requires
+   # server to advertise required auth mechanism so client can filter.
+
+   # TODO support chained hashes. e.g. hash for each 1MB segment so client
+   # can iteratively validate data without having to consume all of it first.
+
+TODO formalize when error frames can be seen and how errors can be
+recognized midway through a command response.
+
+Content Redirects
+=================
+
+Servers have the ability to respond to ANY command request with a
+*redirect* to another location. Such a response is referred to as a *redirect
+response*. (This feature is conceptually similar to HTTP redirects, but is
+more powerful.)
+
+A *redirect response* MUST ONLY be issued if the client advertises support
+for a redirect *target*.
+
+A *redirect response* MUST NOT be issued unless the client advertises support
+for one.
+
+Clients advertise support for *redirect responses* after looking at the server's
+*capabilities* data, which is fetched during initial server connection
+handshake. The server's capabilities data advertises named *targets* for
+potential redirects.
+
+Each target is described by a protocol name, connection and protocol features,
+etc. The server also advertises target-agnostic redirect settings, such as
+which hash algorithms are supported for content integrity checking. (See
+the documentation for the *capabilities* command for more.)
+
+Clients examine the set of advertised redirect targets for compatibility.
+When sending a command request, the client advertises the set of redirect
+target names it is willing to follow, along with some other settings influencing
+behavior.
+
+For example, say the server is advertising a ``cdn`` redirect target that
+requires SNI and TLS 1.2. If the client supports those features, it will
+send command requests stating that the ``cdn`` target is acceptable to use.
+But if the client doesn't support SNI or TLS 1.2 (or maybe it encountered an
+error using this target from a previous request), then it omits this target
+name.
+
+If the client advertises support for a redirect target, the server MAY
+substitute the normal, inline response data for a *redirect response* -
+one where the initial CBOR map has a ``status`` key with value ``redirect``.
+
+The *redirect response* at a minimum advertises the URL where the response
+can be retrieved.
+
+The *redirect response* MAY also advertise additional details about that
+content and how to retrieve it. Notably, the response may contain the
+x509 public certificates for the server being redirected to or the
+certificate authority that signed that server's certificate. Unless the
+client has existing settings that offer stronger trust validation than what
+the server advertises, the client SHOULD use the server-provided certificates
+when validating the connection to the remote server in place of any default
+connection verification checks. This is because certificates coming from
+the server SHOULD establish a stronger chain of trust than what the default
+certification validation mechanism in most environments provides. (By default,
+certificate validation ensures the signer of the cert chains up to a set of
+trusted root certificates. And if an explicit certificate or CA certificate
+is presented, that greadly reduces the set of certificates that will be
+recognized as valid, thus reducing the potential for a "bad" certificate
+to be used and trusted.)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mercurial/helptext/internals/wireprotocolv2.txt	Fri Nov 22 21:42:04 2019 +0900
@@ -0,0 +1,724 @@
+**Experimental and under active development**
+
+This section documents the wire protocol commands exposed to transports
+using the frame-based protocol. The set of commands exposed through
+these transports is distinct from the set of commands exposed to legacy
+transports.
+
+The frame-based protocol uses CBOR to encode command execution requests.
+All command arguments must be mapped to a specific or set of CBOR data
+types.
+
+The response to many commands is also CBOR. There is no common response
+format: each command defines its own response format.
+
+TODOs
+=====
+
+* Add "node namespace" support to each command. In order to support
+  SHA-1 hash transition, we want servers to be able to expose different
+  "node namespaces" for the same data. Every command operating on nodes
+  should specify which "node namespace" it is operating on and responses
+  should encode the "node namespace" accordingly.
+
+Commands
+========
+
+The sections below detail all commands available to wire protocol version
+2.
+
+branchmap
+---------
+
+Obtain heads in named branches.
+
+Receives no arguments.
+
+The response is a map with bytestring keys defining the branch name.
+Values are arrays of bytestring defining raw changeset nodes.
+
+capabilities
+------------
+
+Obtain the server's capabilities.
+
+Receives no arguments.
+
+This command is typically called only as part of the handshake during
+initial connection establishment.
+
+The response is a map with bytestring keys defining server information.
+
+The defined keys are:
+
+commands
+   A map defining available wire protocol commands on this server.
+
+   Keys in the map are the names of commands that can be invoked. Values
+   are maps defining information about that command. The bytestring keys
+   are:
+
+      args
+         (map) Describes arguments accepted by the command.
+
+         Keys are bytestrings denoting the argument name.
+
+         Values are maps describing the argument. The map has the following
+         bytestring keys:
+
+         default
+            (varied) The default value for this argument if not specified. Only
+            present if ``required`` is not true.
+
+         required
+            (boolean) Whether the argument must be specified. Failure to send
+            required arguments will result in an error executing the command.
+
+         type
+            (bytestring) The type of the argument. e.g. ``bytes`` or ``bool``.
+
+         validvalues
+            (set) Values that are recognized for this argument. Some arguments
+            only allow a fixed set of values to be specified. These arguments
+            may advertise that set in this key. If this set is advertised and
+            a value not in this set is specified, the command should result
+            in error.
+
+      permissions
+         An array of permissions required to execute this command.
+
+      *
+         (various) Individual commands may define extra keys that supplement
+         generic command metadata. See the command definition for more.
+
+framingmediatypes
+   An array of bytestrings defining the supported framing protocol
+   media types. Servers will not accept media types not in this list.
+
+pathfilterprefixes
+   (set of bytestring) Matcher prefixes that are recognized when performing
+   path filtering. Specifying a path filter whose type/prefix does not
+   match one in this set will likely be rejected by the server.
+
+rawrepoformats
+   An array of storage formats the repository is using. This set of
+   requirements can be used to determine whether a client can read a
+   *raw* copy of file data available.
+
+redirect
+   A map declaring potential *content redirects* that may be used by this
+   server. Contains the following bytestring keys:
+
+   targets
+      (array of maps) Potential redirect targets. Values are maps describing
+      this target in more detail. Each map has the following bytestring keys:
+
+      name
+         (bytestring) Identifier for this target. The identifier will be used
+         by clients to uniquely identify this target.
+
+      protocol
+         (bytestring) High-level network protocol. Values can be
+         ``http``, ```https``, ``ssh``, etc.
+
+      uris
+          (array of bytestrings) Representative URIs for this target.
+
+      snirequired (optional)
+          (boolean) Indicates whether Server Name Indication is required
+          to use this target. Defaults to False.
+
+      tlsversions (optional)
+          (array of bytestring) Indicates which TLS versions are supported by
+          this target. Values are ``1.1``, ``1.2``, ``1.3``, etc.
+
+   hashes
+      (array of bytestring) Indicates support for hashing algorithms that are
+      used to ensure content integrity. Values include ``sha1``, ``sha256``,
+      etc.
+
+changesetdata
+-------------
+
+Obtain various data related to changesets.
+
+The command accepts the following arguments:
+
+revisions
+   (array of maps) Specifies revisions whose data is being requested. Each
+   value in the array is a map describing revisions. See the
+   *Revisions Specifiers* section below for the format of this map.
+
+   Data will be sent for the union of all revisions resolved by all
+   revision specifiers.
+
+   Only revision specifiers operating on changeset revisions are allowed.
+
+fields
+   (set of bytestring) Which data associated with changelog revisions to
+   fetch. The following values are recognized:
+
+   bookmarks
+      Bookmarks associated with a revision.
+
+   parents
+      Parent revisions.
+
+   phase
+      The phase state of a revision.
+
+   revision
+      The raw, revision data for the changelog entry. The hash of this data
+      will match the revision's node value.
+
+The response bytestream starts with a CBOR map describing the data that follows.
+This map has the following bytestring keys:
+
+totalitems
+   (unsigned integer) Total number of changelog revisions whose data is being
+   transferred. This maps to the set of revisions in the requested node
+   range, not the total number of records that follow (see below for why).
+
+Following the map header is a series of 0 or more CBOR values. If values
+are present, the first value will always be a map describing a single changeset
+revision.
+
+If the ``fieldsfollowing`` key is present, the map will immediately be followed
+by N CBOR bytestring values, where N is the number of elements in
+``fieldsfollowing``. Each bytestring value corresponds to a field denoted
+by ``fieldsfollowing``.
+
+Following the optional bytestring field values is the next revision descriptor
+map, or end of stream.
+
+Each revision descriptor map has the following bytestring keys:
+
+node
+   (bytestring) The node value for this revision. This is the SHA-1 hash of
+   the raw revision data.
+
+bookmarks (optional)
+   (array of bytestrings) Bookmarks attached to this revision. Only present
+   if ``bookmarks`` data is being requested and the revision has bookmarks
+   attached.
+
+fieldsfollowing (optional)
+   (array of 2-array) Denotes what fields immediately follow this map. Each
+   value is an array with 2 elements: the bytestring field name and an unsigned
+   integer describing the length of the data, in bytes.
+
+   If this key isn't present, no special fields will follow this map.
+
+   The following fields may be present:
+
+   revision
+      Raw, revision data for the changelog entry. Contains a serialized form
+      of the changeset data, including the author, date, commit message, set
+      of changed files, manifest node, and other metadata.
+
+      Only present if the ``revision`` field was requested.
+
+parents (optional)
+   (array of bytestrings) The nodes representing the parent revisions of this
+   revision. Only present if ``parents`` data is being requested.
+
+phase (optional)
+   (bytestring) The phase that a revision is in. Recognized values are
+   ``secret``, ``draft``, and ``public``. Only present if ``phase`` data
+   is being requested.
+
+The set of changeset revisions emitted may not match the exact set of
+changesets requested. Furthermore, the set of keys present on each
+map may vary. This is to facilitate emitting changeset updates as well
+as new revisions.
+
+For example, if the request wants ``phase`` and ``revision`` data,
+the response may contain entries for each changeset in the common nodes
+set with the ``phase`` key and without the ``revision`` key in order
+to reflect a phase-only update.
+
+TODO support different revision selection mechanisms (e.g. non-public, specific
+revisions)
+TODO support different hash "namespaces" for revisions (e.g. sha-1 versus other)
+TODO support emitting obsolescence data
+TODO support filtering based on relevant paths (narrow clone)
+TODO support hgtagsfnodes cache / tags data
+TODO support branch heads cache
+TODO consider unify query mechanism. e.g. as an array of "query descriptors"
+rather than a set of top-level arguments that have semantics when combined.
+
+filedata
+--------
+
+Obtain various data related to an individual tracked file.
+
+The command accepts the following arguments:
+
+fields
+   (set of bytestring) Which data associated with a file to fetch.
+   The following values are recognized:
+
+   linknode
+      The changeset node introducing this revision.
+
+   parents
+      Parent nodes for the revision.
+
+   revision
+      The raw revision data for a file.
+
+haveparents
+   (bool) Whether the client has the parent revisions of all requested
+   nodes. If set, the server may emit revision data as deltas against
+   any parent revision. If not set, the server MUST only emit deltas for
+   revisions previously emitted by this command.
+
+   False is assumed in the absence of any value.
+
+nodes
+   (array of bytestrings) File nodes whose data to retrieve.
+
+path
+   (bytestring) Path of the tracked file whose data to retrieve.
+
+TODO allow specifying revisions via alternate means (such as from
+changeset revisions or ranges)
+
+The response bytestream starts with a CBOR map describing the data that
+follows. It has the following bytestream keys:
+
+totalitems
+   (unsigned integer) Total number of file revisions whose data is
+   being returned.
+
+Following the map header is a series of 0 or more CBOR values. If values
+are present, the first value will always be a map describing a single changeset
+revision.
+
+If the ``fieldsfollowing`` key is present, the map will immediately be followed
+by N CBOR bytestring values, where N is the number of elements in
+``fieldsfollowing``. Each bytestring value corresponds to a field denoted
+by ``fieldsfollowing``.
+
+Following the optional bytestring field values is the next revision descriptor
+map, or end of stream.
+
+Each revision descriptor map has the following bytestring keys:
+
+Each map has the following bytestring keys:
+
+node
+   (bytestring) The node of the file revision whose data is represented.
+
+deltabasenode
+   (bytestring) Node of the file revision the following delta is against.
+
+   Only present if the ``revision`` field is requested and delta data
+   follows this map.
+
+fieldsfollowing
+   (array of 2-array) Denotes extra bytestring fields that following this map.
+   See the documentation for ``changesetdata`` for semantics.
+
+   The following named fields may be present:
+
+   ``delta``
+      The delta data to use to construct the fulltext revision.
+
+      Only present if the ``revision`` field is requested and a delta is
+      being emitted. The ``deltabasenode`` top-level key will also be
+      present if this field is being emitted.
+
+   ``revision``
+      The fulltext revision data for this manifest. Only present if the
+      ``revision`` field is requested and a fulltext revision is being emitted.
+
+parents
+   (array of bytestring) The nodes of the parents of this file revision.
+
+   Only present if the ``parents`` field is requested.
+
+When ``revision`` data is requested, the server chooses to emit either fulltext
+revision data or a delta. What the server decides can be inferred by looking
+for the presence of the ``delta`` or ``revision`` keys in the
+``fieldsfollowing`` array.
+
+filesdata
+---------
+
+Obtain various data related to multiple tracked files for specific changesets.
+
+This command is similar to ``filedata`` with the main difference being that
+individual requests operate on multiple file paths. This allows clients to
+request data for multiple paths by issuing a single command.
+
+The command accepts the following arguments:
+
+fields
+   (set of bytestring) Which data associated with a file to fetch.
+   The following values are recognized:
+
+   linknode
+      The changeset node introducing this revision.
+
+   parents
+      Parent nodes for the revision.
+
+   revision
+      The raw revision data for a file.
+
+haveparents
+   (bool) Whether the client has the parent revisions of all requested
+   nodes.
+
+pathfilter
+   (map) Defines a filter that determines what file paths are relevant.
+
+   See the *Path Filters* section for more.
+
+   If the argument is omitted, it is assumed that all paths are relevant.
+
+revisions
+   (array of maps) Specifies revisions whose data is being requested. Each value
+   in the array is a map describing revisions. See the *Revisions Specifiers*
+   section below for the format of this map.
+
+   Data will be sent for the union of all revisions resolved by all revision
+   specifiers.
+
+   Only revision specifiers operating on changeset revisions are allowed.
+
+The response bytestream starts with a CBOR map describing the data that
+follows. This map has the following bytestring keys:
+
+totalpaths
+   (unsigned integer) Total number of paths whose data is being transferred.
+
+totalitems
+   (unsigned integer) Total number of file revisions whose data is being
+   transferred.
+
+Following the map header are 0 or more sequences of CBOR values. Each sequence
+represents data for a specific tracked path. Each sequence begins with a CBOR
+map describing the file data that follows. Following that map is N CBOR values
+describing file revision data. The format of this data is identical to that
+returned by the ``filedata`` command.
+
+Each sequence's map header has the following bytestring keys:
+
+path
+   (bytestring) The tracked file path whose data follows.
+
+totalitems
+   (unsigned integer) Total number of file revisions whose data is being
+   transferred.
+
+The ``haveparents`` argument has significant implications on the data
+transferred.
+
+When ``haveparents`` is true, the command MAY only emit data for file
+revisions introduced by the set of changeset revisions whose data is being
+requested. In other words, the command may assume that all file revisions
+for all relevant paths for ancestors of the requested changeset revisions
+are present on the receiver.
+
+When ``haveparents`` is false, the command MUST assume that the receiver
+has no file revisions data. This means that all referenced file revisions
+in the queried set of changeset revisions will be sent.
+
+TODO we want a more complicated mechanism for the client to specify which
+ancestor revisions are known. This is needed so intelligent deltas can be
+emitted and so updated linknodes can be sent if the client needs to adjust
+its linknodes for existing file nodes to older changeset revisions.
+TODO we may want to make linknodes an array so multiple changesets can be
+marked as introducing a file revision, since this can occur with e.g. hidden
+changesets.
+
+heads
+-----
+
+Obtain DAG heads in the repository.
+
+The command accepts the following arguments:
+
+publiconly (optional)
+   (boolean) If set, operate on the DAG for public phase changesets only.
+   Non-public (i.e. draft) phase DAG heads will not be returned.
+
+The response is a CBOR array of bytestrings defining changeset nodes
+of DAG heads. The array can be empty if the repository is empty or no
+changesets satisfied the request.
+
+TODO consider exposing phase of heads in response
+
+known
+-----
+
+Determine whether a series of changeset nodes is known to the server.
+
+The command accepts the following arguments:
+
+nodes
+   (array of bytestrings) List of changeset nodes whose presence to
+   query.
+
+The response is a bytestring where each byte contains a 0 or 1 for the
+corresponding requested node at the same index.
+
+TODO use a bit array for even more compact response
+
+listkeys
+--------
+
+List values in a specified ``pushkey`` namespace.
+
+The command receives the following arguments:
+
+namespace
+   (bytestring) Pushkey namespace to query.
+
+The response is a map with bytestring keys and values.
+
+TODO consider using binary to represent nodes in certain pushkey namespaces.
+
+lookup
+------
+
+Try to resolve a value to a changeset revision.
+
+Unlike ``known`` which operates on changeset nodes, lookup operates on
+node fragments and other names that a user may use.
+
+The command receives the following arguments:
+
+key
+   (bytestring) Value to try to resolve.
+
+On success, returns a bytestring containing the resolved node.
+
+manifestdata
+------------
+
+Obtain various data related to manifests (which are lists of files in
+a revision).
+
+The command accepts the following arguments:
+
+fields
+   (set of bytestring) Which data associated with manifests to fetch.
+   The following values are recognized:
+
+   parents
+      Parent nodes for the manifest.
+
+   revision
+      The raw revision data for the manifest.
+
+haveparents
+   (bool) Whether the client has the parent revisions of all requested
+   nodes. If set, the server may emit revision data as deltas against
+   any parent revision. If not set, the server MUST only emit deltas for
+   revisions previously emitted by this command.
+
+   False is assumed in the absence of any value.
+
+nodes
+   (array of bytestring) Manifest nodes whose data to retrieve.
+
+tree
+   (bytestring) Path to manifest to retrieve. The empty bytestring represents
+   the root manifest. All other values represent directories/trees within
+   the repository.
+
+TODO allow specifying revisions via alternate means (such as from changeset
+revisions or ranges)
+TODO consider recursive expansion of manifests (with path filtering for
+narrow use cases)
+
+The response bytestream starts with a CBOR map describing the data that
+follows. It has the following bytestring keys:
+
+totalitems
+   (unsigned integer) Total number of manifest revisions whose data is
+   being returned.
+
+Following the map header is a series of 0 or more CBOR values. If values
+are present, the first value will always be a map describing a single manifest
+revision.
+
+If the ``fieldsfollowing`` key is present, the map will immediately be followed
+by N CBOR bytestring values, where N is the number of elements in
+``fieldsfollowing``. Each bytestring value corresponds to a field denoted
+by ``fieldsfollowing``.
+
+Following the optional bytestring field values is the next revision descriptor
+map, or end of stream.
+
+Each revision descriptor map has the following bytestring keys:
+
+node
+   (bytestring) The node of the manifest revision whose data is represented.
+
+deltabasenode
+   (bytestring) The node that the delta representation of this revision is
+   computed against. Only present if the ``revision`` field is requested and
+   a delta is being emitted.
+
+fieldsfollowing
+   (array of 2-array) Denotes extra bytestring fields that following this map.
+   See the documentation for ``changesetdata`` for semantics.
+
+   The following named fields may be present:
+
+   ``delta``
+      The delta data to use to construct the fulltext revision.
+
+      Only present if the ``revision`` field is requested and a delta is
+      being emitted. The ``deltabasenode`` top-level key will also be
+      present if this field is being emitted.
+
+   ``revision``
+      The fulltext revision data for this manifest. Only present if the
+      ``revision`` field is requested and a fulltext revision is being emitted.
+
+parents
+   (array of bytestring) The nodes of the parents of this manifest revision.
+   Only present if the ``parents`` field is requested.
+
+When ``revision`` data is requested, the server chooses to emit either fulltext
+revision data or a delta. What the server decides can be inferred by looking
+for the presence of ``delta`` or ``revision`` in the ``fieldsfollowing`` array.
+
+Servers MAY advertise the following extra fields in the capabilities
+descriptor for this command:
+
+recommendedbatchsize
+   (unsigned integer) Number of revisions the server recommends as a batch
+   query size. If defined, clients needing to issue multiple ``manifestdata``
+   commands to obtain needed data SHOULD construct their commands to have
+   this many revisions per request.
+
+pushkey
+-------
+
+Set a value using the ``pushkey`` protocol.
+
+The command receives the following arguments:
+
+namespace
+   (bytestring) Pushkey namespace to operate on.
+key
+   (bytestring) The pushkey key to set.
+old
+   (bytestring) Old value for this key.
+new
+   (bytestring) New value for this key.
+
+TODO consider using binary to represent nodes is certain pushkey namespaces.
+TODO better define response type and meaning.
+
+rawstorefiledata
+----------------
+
+Allows retrieving raw files used to store repository data.
+
+The command accepts the following arguments:
+
+files
+   (array of bytestring) Describes the files that should be retrieved.
+
+   The meaning of values in this array is dependent on the storage backend used
+   by the server.
+
+The response bytestream starts with a CBOR map describing the data that follows.
+This map has the following bytestring keys:
+
+filecount
+   (unsigned integer) Total number of files whose data is being transferred.
+
+totalsize
+   (unsigned integer) Total size in bytes of files data that will be
+   transferred. This is file on-disk size and not wire size.
+
+Following the map header are N file segments. Each file segment consists of a
+CBOR map followed by an indefinite length bytestring. Each map has the following
+bytestring keys:
+
+location
+   (bytestring) Denotes the location in the repository where the file should be
+   written. Values map to vfs instances to use for the writing.
+
+path
+   (bytestring) Path of file being transferred. Path is the raw store
+   path and can be any sequence of bytes that can be tracked in a Mercurial
+   manifest.
+
+size
+   (unsigned integer) Size of file data. This will be the final written
+   file size. The total size of the data that follows the CBOR map
+   will be greater due to encoding overhead of CBOR.
+
+TODO this command is woefully incomplete. If we are to move forward with a
+stream clone analog, it needs a lot more metadata around how to describe what
+files are available to retrieve, other semantics.
+
+Revision Specifiers
+===================
+
+A *revision specifier* is a map that evaluates to a set of revisions.
+
+A *revision specifier* has a ``type`` key that defines the revision
+selection type to perform. Other keys in the map are used in a
+type-specific manner.
+
+The following types are defined:
+
+changesetexplicit
+   An explicit set of enumerated changeset revisions.
+
+   The ``nodes`` key MUST contain an array of full binary nodes, expressed
+   as bytestrings.
+
+changesetexplicitdepth
+   Like ``changesetexplicit``, but contains a ``depth`` key defining the
+   unsigned integer number of ancestor revisions to also resolve. For each
+   value in ``nodes``, DAG ancestors will be walked until up to N total
+   revisions from that ancestry walk are present in the final resolved set.
+
+changesetdagrange
+   Defines revisions via a DAG range of changesets on the changelog.
+
+   The ``roots`` key MUST contain an array of full, binary node values
+   representing the *root* revisions.
+
+   The ``heads`` key MUST contain an array of full, binary nodes values
+   representing the *head* revisions.
+
+   The DAG range between ``roots`` and ``heads`` will be resolved and all
+   revisions between will be used. Nodes in ``roots`` are not part of the
+   resolved set. Nodes in ``heads`` are. The ``roots`` array may be empty.
+   The ``heads`` array MUST be defined.
+
+Path Filters
+============
+
+Various commands accept a *path filter* argument that defines the set of file
+paths relevant to the request.
+
+A *path filter* is defined as a map with the bytestring keys ``include`` and
+``exclude``. Each is an array of bytestring values. Each value defines a pattern
+rule (see :hg:`help patterns`) that is used to match file paths.
+
+A path matches the path filter if it is matched by a rule in the ``include``
+set but doesn't match a rule in the ``exclude`` set. In other words, a path
+matcher takes the union of all ``include`` patterns and then substracts the
+union of all ``exclude`` patterns.
+
+Patterns MUST be prefixed with their pattern type. Only the following pattern
+types are allowed: ``path:``, ``rootfilesin:``.
+
+If the ``include`` key is omitted, it is assumed that all paths are
+relevant. The patterns from ``exclude`` will still be used, if defined.
+
+An example value is ``path:tests/foo``, which would match a file named
+``tests/foo`` or a directory ``tests/foo`` and all files under it.
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mercurial/helptext/merge-tools.txt	Fri Nov 22 21:42:04 2019 +0900
@@ -0,0 +1,109 @@
+To merge files Mercurial uses merge tools.
+
+A merge tool combines two different versions of a file into a merged
+file. Merge tools are given the two files and the greatest common
+ancestor of the two file versions, so they can determine the changes
+made on both branches.
+
+Merge tools are used both for :hg:`resolve`, :hg:`merge`, :hg:`update`,
+:hg:`backout` and in several extensions.
+
+Usually, the merge tool tries to automatically reconcile the files by
+combining all non-overlapping changes that occurred separately in
+the two different evolutions of the same initial base file. Furthermore, some
+interactive merge programs make it easier to manually resolve
+conflicting merges, either in a graphical way, or by inserting some
+conflict markers. Mercurial does not include any interactive merge
+programs but relies on external tools for that.
+
+Available merge tools
+=====================
+
+External merge tools and their properties are configured in the
+merge-tools configuration section - see hgrc(5) - but they can often just
+be named by their executable.
+
+A merge tool is generally usable if its executable can be found on the
+system and if it can handle the merge. The executable is found if it
+is an absolute or relative executable path or the name of an
+application in the executable search path. The tool is assumed to be
+able to handle the merge if it can handle symlinks if the file is a
+symlink, if it can handle binary files if the file is binary, and if a
+GUI is available if the tool requires a GUI.
+
+There are some internal merge tools which can be used. The internal
+merge tools are:
+
+.. internaltoolsmarker
+
+Internal tools are always available and do not require a GUI but will
+by default not handle symlinks or binary files. See next section for
+detail about "actual capabilities" described above.
+
+Choosing a merge tool
+=====================
+
+Mercurial uses these rules when deciding which merge tool to use:
+
+1. If a tool has been specified with the --tool option to merge or resolve, it
+   is used.  If it is the name of a tool in the merge-tools configuration, its
+   configuration is used. Otherwise the specified tool must be executable by
+   the shell.
+
+2. If the ``HGMERGE`` environment variable is present, its value is used and
+   must be executable by the shell.
+
+3. If the filename of the file to be merged matches any of the patterns in the
+   merge-patterns configuration section, the first usable merge tool
+   corresponding to a matching pattern is used.
+
+4. If ui.merge is set it will be considered next. If the value is not the name
+   of a configured tool, the specified value is used and must be executable by
+   the shell. Otherwise the named tool is used if it is usable.
+
+5. If any usable merge tools are present in the merge-tools configuration
+   section, the one with the highest priority is used.
+
+6. If a program named ``hgmerge`` can be found on the system, it is used - but
+   it will by default not be used for symlinks and binary files.
+
+7. If the file to be merged is not binary and is not a symlink, then
+   internal ``:merge`` is used.
+
+8. Otherwise, ``:prompt`` is used.
+
+For historical reason, Mercurial treats merge tools as below while
+examining rules above.
+
+==== =============== ====== =======
+step specified via   binary symlink
+==== =============== ====== =======
+1.   --tool          o/o    o/o
+2.   HGMERGE         o/o    o/o
+3.   merge-patterns  o/o(*) x/?(*)
+4.   ui.merge        x/?(*) x/?(*)
+==== =============== ====== =======
+
+Each capability column indicates Mercurial behavior for
+internal/external merge tools at examining each rule.
+
+- "o": "assume that a tool has capability"
+- "x": "assume that a tool does not have capability"
+- "?": "check actual capability of a tool"
+
+If ``merge.strict-capability-check`` configuration is true, Mercurial
+checks capabilities of merge tools strictly in (*) cases above (= each
+capability column becomes "?/?"). It is false by default for backward
+compatibility.
+
+.. note::
+
+   After selecting a merge program, Mercurial will by default attempt
+   to merge the files using a simple merge algorithm first. Only if it doesn't
+   succeed because of conflicting changes will Mercurial actually execute the
+   merge program. Whether to use the simple merge algorithm first can be
+   controlled by the premerge setting of the merge tool. Premerge is enabled by
+   default unless the file is binary or a symlink.
+
+See the merge-tools and ui sections of hgrc(5) for details on the
+configuration of merge tools.
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mercurial/helptext/pager.txt	Fri Nov 22 21:42:04 2019 +0900
@@ -0,0 +1,43 @@
+Some Mercurial commands can produce a lot of output, and Mercurial will
+attempt to use a pager to make those commands more pleasant.
+
+To set the pager that should be used, set the application variable::
+
+  [pager]
+  pager = less -FRX
+
+If no pager is set in the user or repository configuration, Mercurial uses the
+environment variable $PAGER. If $PAGER is not set, pager.pager from the default
+or system configuration is used. If none of these are set, a default pager will
+be used, typically `less` on Unix and `more` on Windows.
+
+.. container:: windows
+
+  On Windows, `more` is not color aware, so using it effectively disables color.
+  MSYS and Cygwin shells provide `less` as a pager, which can be configured to
+  support ANSI color codes.  See :hg:`help config.color.pagermode` to configure
+  the color mode when invoking a pager.
+
+You can disable the pager for certain commands by adding them to the
+pager.ignore list::
+
+  [pager]
+  ignore = version, help, update
+
+To ignore global commands like :hg:`version` or :hg:`help`, you have
+to specify them in your user configuration file.
+
+To control whether the pager is used at all for an individual command,
+you can use --pager=<value>:
+
+  - use as needed: `auto`.
+  - require the pager: `yes` or `on`.
+  - suppress the pager: `no` or `off` (any unrecognized value
+    will also work).
+
+To globally turn off all attempts to use a pager, set::
+
+  [ui]
+  paginate = never
+
+which will prevent the pager from running.
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mercurial/helptext/patterns.txt	Fri Nov 22 21:42:04 2019 +0900
@@ -0,0 +1,86 @@
+Mercurial accepts several notations for identifying one or more files
+at a time.
+
+By default, Mercurial treats filenames as shell-style extended glob
+patterns.
+
+Alternate pattern notations must be specified explicitly.
+
+.. note::
+
+  Patterns specified in ``.hgignore`` are not rooted.
+  Please see :hg:`help hgignore` for details.
+
+To use a plain path name without any pattern matching, start it with
+``path:``. These path names must completely match starting at the
+current repository root, and when the path points to a directory, it is matched
+recursively. To match all files in a directory non-recursively (not including
+any files in subdirectories), ``rootfilesin:`` can be used, specifying an
+absolute path (relative to the repository root).
+
+To use an extended glob, start a name with ``glob:``. Globs are rooted
+at the current directory; a glob such as ``*.c`` will only match files
+in the current directory ending with ``.c``. ``rootglob:`` can be used
+instead of ``glob:`` for a glob that is rooted at the root of the
+repository.
+
+The supported glob syntax extensions are ``**`` to match any string
+across path separators and ``{a,b}`` to mean "a or b".
+
+To use a Perl/Python regular expression, start a name with ``re:``.
+Regexp pattern matching is anchored at the root of the repository.
+
+To read name patterns from a file, use ``listfile:`` or ``listfile0:``.
+The latter expects null delimited patterns while the former expects line
+feeds. Each string read from the file is itself treated as a file
+pattern.
+
+To read a set of patterns from a file, use ``include:`` or ``subinclude:``.
+``include:`` will use all the patterns from the given file and treat them as if
+they had been passed in manually.  ``subinclude:`` will only apply the patterns
+against files that are under the subinclude file's directory. See :hg:`help
+hgignore` for details on the format of these files.
+
+All patterns, except for ``glob:`` specified in command line (not for
+``-I`` or ``-X`` options), can match also against directories: files
+under matched directories are treated as matched.
+For ``-I`` and ``-X`` options, ``glob:`` will match directories recursively.
+
+Plain examples::
+
+  path:foo/bar        a name bar in a directory named foo in the root
+                      of the repository
+  path:path:name      a file or directory named "path:name"
+  rootfilesin:foo/bar the files in a directory called foo/bar, but not any files
+                      in its subdirectories and not a file bar in directory foo
+
+Glob examples::
+
+  glob:*.c       any name ending in ".c" in the current directory
+  *.c            any name ending in ".c" in the current directory
+  **.c           any name ending in ".c" in any subdirectory of the
+                 current directory including itself.
+  foo/*          any file in directory foo
+  foo/**         any file in directory foo plus all its subdirectories,
+                 recursively
+  foo/*.c        any name ending in ".c" in the directory foo
+  foo/**.c       any name ending in ".c" in any subdirectory of foo
+                 including itself.
+  rootglob:*.c   any name ending in ".c" in the root of the repository
+
+Regexp examples::
+
+  re:.*\.c$      any name ending in ".c", anywhere in the repository
+
+File examples::
+
+  listfile:list.txt  read list from list.txt with one file pattern per line
+  listfile0:list.txt read list from list.txt with null byte delimiters
+
+See also :hg:`help filesets`.
+
+Include examples::
+
+  include:path/to/mypatternfile    reads patterns to be applied to all paths
+  subinclude:path/to/subignorefile reads patterns specifically for paths in the
+                                   subdirectory
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mercurial/helptext/phases.txt	Fri Nov 22 21:42:04 2019 +0900
@@ -0,0 +1,100 @@
+What are phases?
+================
+
+Phases are a system for tracking which changesets have been or should
+be shared. This helps prevent common mistakes when modifying history
+(for instance, with the mq or rebase extensions).
+
+Each changeset in a repository is in one of the following phases:
+
+ - public : changeset is visible on a public server
+ - draft : changeset is not yet published
+ - secret : changeset should not be pushed, pulled, or cloned
+
+These phases are ordered (public < draft < secret) and no changeset
+can be in a lower phase than its ancestors. For instance, if a
+changeset is public, all its ancestors are also public. Lastly,
+changeset phases should only be changed towards the public phase.
+
+How are phases managed?
+=======================
+
+For the most part, phases should work transparently. By default, a
+changeset is created in the draft phase and is moved into the public
+phase when it is pushed to another repository.
+
+Once changesets become public, extensions like mq and rebase will
+refuse to operate on them to prevent creating duplicate changesets.
+Phases can also be manually manipulated with the :hg:`phase` command
+if needed. See :hg:`help -v phase` for examples.
+
+To make your commits secret by default, put this in your
+configuration file::
+
+  [phases]
+  new-commit = secret
+
+Phases and servers
+==================
+
+Normally, all servers are ``publishing`` by default. This means::
+
+ - all draft changesets that are pulled or cloned appear in phase
+ public on the client
+
+ - all draft changesets that are pushed appear as public on both
+ client and server
+
+ - secret changesets are neither pushed, pulled, or cloned
+
+.. note::
+
+  Pulling a draft changeset from a publishing server does not mark it
+  as public on the server side due to the read-only nature of pull.
+
+Sometimes it may be desirable to push and pull changesets in the draft
+phase to share unfinished work. This can be done by setting a
+repository to disable publishing in its configuration file::
+
+  [phases]
+  publish = False
+
+See :hg:`help config` for more information on configuration files.
+
+.. note::
+
+  Servers running older versions of Mercurial are treated as
+  publishing.
+
+.. note::
+
+   Changesets in secret phase are not exchanged with the server. This
+   applies to their content: file names, file contents, and changeset
+   metadata. For technical reasons, the identifier (e.g. d825e4025e39)
+   of the secret changeset may be communicated to the server.
+
+
+Examples
+========
+
+ - list changesets in draft or secret phase::
+
+     hg log -r "not public()"
+
+ - change all secret changesets to draft::
+
+     hg phase --draft "secret()"
+
+ - forcibly move the current changeset and descendants from public to draft::
+
+     hg phase --force --draft .
+
+ - show a list of changeset revisions and each corresponding phase::
+
+     hg log --template "{rev} {phase}\n"
+
+ - resynchronize draft changesets relative to a remote repository::
+
+     hg phase -fd "outgoing(URL)"
+
+See :hg:`help phase` for more information on manually manipulating phases.
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mercurial/helptext/revisions.txt	Fri Nov 22 21:42:04 2019 +0900
@@ -0,0 +1,223 @@
+Mercurial supports several ways to specify revisions.
+
+Specifying single revisions
+===========================
+
+A plain integer is treated as a revision number. Negative integers are
+treated as sequential offsets from the tip, with -1 denoting the tip,
+-2 denoting the revision prior to the tip, and so forth.
+
+A 40-digit hexadecimal string is treated as a unique revision identifier.
+A hexadecimal string less than 40 characters long is treated as a
+unique revision identifier and is referred to as a short-form
+identifier. A short-form identifier is only valid if it is the prefix
+of exactly one full-length identifier.
+
+Any other string is treated as a bookmark, tag, or branch name. A
+bookmark is a movable pointer to a revision. A tag is a permanent name
+associated with a revision. A branch name denotes the tipmost open branch head
+of that branch - or if they are all closed, the tipmost closed head of the
+branch. Bookmark, tag, and branch names must not contain the ":" character.
+
+The reserved name "tip" always identifies the most recent revision.
+
+The reserved name "null" indicates the null revision. This is the
+revision of an empty repository, and the parent of revision 0.
+
+The reserved name "." indicates the working directory parent. If no
+working directory is checked out, it is equivalent to null. If an
+uncommitted merge is in progress, "." is the revision of the first
+parent.
+
+Finally, commands that expect a single revision (like ``hg update``) also
+accept revsets (see below for details). When given a revset, they use the
+last revision of the revset. A few commands accept two single revisions
+(like ``hg diff``). When given a revset, they use the first and the last
+revisions of the revset.
+
+Specifying multiple revisions
+=============================
+
+Mercurial supports a functional language for selecting a set of
+revisions. Expressions in this language are called revsets.
+
+The language supports a number of predicates which are joined by infix
+operators. Parenthesis can be used for grouping.
+
+Identifiers such as branch names may need quoting with single or
+double quotes if they contain characters like ``-`` or if they match
+one of the predefined predicates.
+
+Special characters can be used in quoted identifiers by escaping them,
+e.g., ``\n`` is interpreted as a newline. To prevent them from being
+interpreted, strings can be prefixed with ``r``, e.g. ``r'...'``.
+
+Operators
+=========
+
+There is a single prefix operator:
+
+``not x``
+  Changesets not in x. Short form is ``! x``.
+
+These are the supported infix operators:
+
+``x::y``
+  A DAG range, meaning all changesets that are descendants of x and
+  ancestors of y, including x and y themselves. If the first endpoint
+  is left out, this is equivalent to ``ancestors(y)``, if the second
+  is left out it is equivalent to ``descendants(x)``.
+
+  An alternative syntax is ``x..y``.
+
+``x:y``
+  All changesets with revision numbers between x and y, both
+  inclusive. Either endpoint can be left out, they default to 0 and
+  tip.
+
+``x and y``
+  The intersection of changesets in x and y. Short form is ``x & y``.
+
+``x or y``
+  The union of changesets in x and y. There are two alternative short
+  forms: ``x | y`` and ``x + y``.
+
+``x - y``
+  Changesets in x but not in y.
+
+``x % y``
+  Changesets that are ancestors of x but not ancestors of y (i.e. ::x - ::y).
+  This is shorthand notation for ``only(x, y)`` (see below). The second
+  argument is optional and, if left out, is equivalent to ``only(x)``.
+
+``x^n``
+  The nth parent of x, n == 0, 1, or 2.
+  For n == 0, x; for n == 1, the first parent of each changeset in x;
+  for n == 2, the second parent of changeset in x.
+
+``x~n``
+  The nth first ancestor of x; ``x~0`` is x; ``x~3`` is ``x^^^``.
+  For n < 0, the nth unambiguous descendent of x.
+
+``x ## y``
+  Concatenate strings and identifiers into one string.
+
+  All other prefix, infix and postfix operators have lower priority than
+  ``##``. For example, ``a1 ## a2~2`` is equivalent to ``(a1 ## a2)~2``.
+
+  For example::
+
+    [revsetalias]
+    issue(a1) = grep(r'\bissue[ :]?' ## a1 ## r'\b|\bbug\(' ## a1 ## r'\)')
+
+  ``issue(1234)`` is equivalent to
+  ``grep(r'\bissue[ :]?1234\b|\bbug\(1234\)')``
+  in this case. This matches against all of "issue 1234", "issue:1234",
+  "issue1234" and "bug(1234)".
+
+There is a single postfix operator:
+
+``x^``
+  Equivalent to ``x^1``, the first parent of each changeset in x.
+
+Patterns
+========
+
+Where noted, predicates that perform string matching can accept a pattern
+string. The pattern may be either a literal, or a regular expression. If the
+pattern starts with ``re:``, the remainder of the pattern is treated as a
+regular expression. Otherwise, it is treated as a literal. To match a pattern
+that actually starts with ``re:``, use the prefix ``literal:``.
+
+Matching is case-sensitive, unless otherwise noted.  To perform a case-
+insensitive match on a case-sensitive predicate, use a regular expression,
+prefixed with ``(?i)``.
+
+For example, ``tag(r're:(?i)release')`` matches "release" or "RELEASE"
+or "Release", etc.
+
+Predicates
+==========
+
+The following predicates are supported:
+
+.. predicatesmarker
+
+Aliases
+=======
+
+New predicates (known as "aliases") can be defined, using any combination of
+existing predicates or other aliases. An alias definition looks like::
+
+  <alias> = <definition>
+
+in the ``revsetalias`` section of a Mercurial configuration file. Arguments
+of the form `a1`, `a2`, etc. are substituted from the alias into the
+definition.
+
+For example,
+
+::
+
+  [revsetalias]
+  h = heads()
+  d(s) = sort(s, date)
+  rs(s, k) = reverse(sort(s, k))
+
+defines three aliases, ``h``, ``d``, and ``rs``. ``rs(0:tip, author)`` is
+exactly equivalent to ``reverse(sort(0:tip, author))``.
+
+Equivalents
+===========
+
+Command line equivalents for :hg:`log`::
+
+  -f    ->  ::.
+  -d x  ->  date(x)
+  -k x  ->  keyword(x)
+  -m    ->  merge()
+  -u x  ->  user(x)
+  -b x  ->  branch(x)
+  -P x  ->  !::x
+  -l x  ->  limit(expr, x)
+
+Examples
+========
+
+Some sample queries:
+
+- Changesets on the default branch::
+
+    hg log -r "branch(default)"
+
+- Changesets on the default branch since tag 1.5 (excluding merges)::
+
+    hg log -r "branch(default) and 1.5:: and not merge()"
+
+- Open branch heads::
+
+    hg log -r "head() and not closed()"
+
+- Changesets between tags 1.3 and 1.5 mentioning "bug" that affect
+  ``hgext/*``::
+
+    hg log -r "1.3::1.5 and keyword(bug) and file('hgext/*')"
+
+- Changesets committed in May 2008, sorted by user::
+
+    hg log -r "sort(date('May 2008'), user)"
+
+- Changesets mentioning "bug" or "issue" that are not in a tagged
+  release::
+
+    hg log -r "(keyword(bug) or keyword(issue)) and not ancestors(tag())"
+
+- Update to the commit that bookmark @ is pointing to, without activating the
+  bookmark (this works because the last revision of the revset is used)::
+
+    hg update :@
+
+- Show diff between tags 1.3 and 1.5 (this works because the first and the
+  last revisions of the revset are used)::
+
+    hg diff -r 1.3::1.5
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mercurial/helptext/scripting.txt	Fri Nov 22 21:42:04 2019 +0900
@@ -0,0 +1,202 @@
+It is common for machines (as opposed to humans) to consume Mercurial.
+This help topic describes some of the considerations for interfacing
+machines with Mercurial.
+
+Choosing an Interface
+=====================
+
+Machines have a choice of several methods to interface with Mercurial.
+These include:
+
+- Executing the ``hg`` process
+- Querying a HTTP server
+- Calling out to a command server
+
+Executing ``hg`` processes is very similar to how humans interact with
+Mercurial in the shell. It should already be familiar to you.
+
+:hg:`serve` can be used to start a server. By default, this will start
+a "hgweb" HTTP server. This HTTP server has support for machine-readable
+output, such as JSON. For more, see :hg:`help hgweb`.
+
+:hg:`serve` can also start a "command server." Clients can connect
+to this server and issue Mercurial commands over a special protocol.
+For more details on the command server, including links to client
+libraries, see https://www.mercurial-scm.org/wiki/CommandServer.
+
+:hg:`serve` based interfaces (the hgweb and command servers) have the
+advantage over simple ``hg`` process invocations in that they are
+likely more efficient. This is because there is significant overhead
+to spawn new Python processes.
+
+.. tip::
+
+   If you need to invoke several ``hg`` processes in short order and/or
+   performance is important to you, use of a server-based interface
+   is highly recommended.
+
+Environment Variables
+=====================
+
+As documented in :hg:`help environment`, various environment variables
+influence the operation of Mercurial. The following are particularly
+relevant for machines consuming Mercurial:
+
+HGPLAIN
+    If not set, Mercurial's output could be influenced by configuration
+    settings that impact its encoding, verbose mode, localization, etc.
+
+    It is highly recommended for machines to set this variable when
+    invoking ``hg`` processes.
+
+HGENCODING
+    If not set, the locale used by Mercurial will be detected from the
+    environment. If the determined locale does not support display of
+    certain characters, Mercurial may render these character sequences
+    incorrectly (often by using "?" as a placeholder for invalid
+    characters in the current locale).
+
+    Explicitly setting this environment variable is a good practice to
+    guarantee consistent results. "utf-8" is a good choice on UNIX-like
+    environments.
+
+HGRCPATH
+    If not set, Mercurial will inherit config options from config files
+    using the process described in :hg:`help config`. This includes
+    inheriting user or system-wide config files.
+
+    When utmost control over the Mercurial configuration is desired, the
+    value of ``HGRCPATH`` can be set to an explicit file with known good
+    configs. In rare cases, the value can be set to an empty file or the
+    null device (often ``/dev/null``) to bypass loading of any user or
+    system config files. Note that these approaches can have unintended
+    consequences, as the user and system config files often define things
+    like the username and extensions that may be required to interface
+    with a repository.
+
+Command-line Flags
+==================
+
+Mercurial's default command-line parser is designed for humans, and is not
+robust against malicious input. For instance, you can start a debugger by
+passing ``--debugger`` as an option value::
+
+    $ REV=--debugger sh -c 'hg log -r "$REV"'
+
+This happens because several command-line flags need to be scanned without
+using a concrete command table, which may be modified while loading repository
+settings and extensions.
+
+Since Mercurial 4.4.2, the parsing of such flags may be restricted by setting
+``HGPLAIN=+strictflags``. When this feature is enabled, all early options
+(e.g. ``-R/--repository``, ``--cwd``, ``--config``) must be specified first
+amongst the other global options, and cannot be injected to an arbitrary
+location::
+
+    $ HGPLAIN=+strictflags hg -R "$REPO" log -r "$REV"
+
+In earlier Mercurial versions where ``+strictflags`` isn't available, you
+can mitigate the issue by concatenating an option value with its flag::
+
+    $ hg log -r"$REV" --keyword="$KEYWORD"
+
+Consuming Command Output
+========================
+
+It is common for machines to need to parse the output of Mercurial
+commands for relevant data. This section describes the various
+techniques for doing so.
+
+Parsing Raw Command Output
+--------------------------
+
+Likely the simplest and most effective solution for consuming command
+output is to simply invoke ``hg`` commands as you would as a user and
+parse their output.
+
+The output of many commands can easily be parsed with tools like
+``grep``, ``sed``, and ``awk``.
+
+A potential downside with parsing command output is that the output
+of commands can change when Mercurial is upgraded. While Mercurial
+does generally strive for strong backwards compatibility, command
+output does occasionally change. Having tests for your automated
+interactions with ``hg`` commands is generally recommended, but is
+even more important when raw command output parsing is involved.
+
+Using Templates to Control Output
+---------------------------------
+
+Many ``hg`` commands support templatized output via the
+``-T/--template`` argument. For more, see :hg:`help templates`.
+
+Templates are useful for explicitly controlling output so that
+you get exactly the data you want formatted how you want it. For
+example, ``log -T {node}\n`` can be used to print a newline
+delimited list of changeset nodes instead of a human-tailored
+output containing authors, dates, descriptions, etc.
+
+.. tip::
+
+   If parsing raw command output is too complicated, consider
+   using templates to make your life easier.
+
+The ``-T/--template`` argument allows specifying pre-defined styles.
+Mercurial ships with the machine-readable styles ``cbor``, ``json``,
+and ``xml``, which provide CBOR, JSON, and XML output, respectively.
+These are useful for producing output that is machine readable as-is.
+
+(Mercurial 5.0 is required for CBOR style.)
+
+.. important::
+
+   The ``json`` and ``xml`` styles are considered experimental. While
+   they may be attractive to use for easily obtaining machine-readable
+   output, their behavior may change in subsequent versions.
+
+   These styles may also exhibit unexpected results when dealing with
+   certain encodings. Mercurial treats things like filenames as a
+   series of bytes and normalizing certain byte sequences to JSON
+   or XML with certain encoding settings can lead to surprises.
+
+Command Server Output
+---------------------
+
+If using the command server to interact with Mercurial, you are likely
+using an existing library/API that abstracts implementation details of
+the command server. If so, this interface layer may perform parsing for
+you, saving you the work of implementing it yourself.
+
+Output Verbosity
+----------------
+
+Commands often have varying output verbosity, even when machine
+readable styles are being used (e.g. ``-T json``). Adding
+``-v/--verbose`` and ``--debug`` to the command's arguments can
+increase the amount of data exposed by Mercurial.
+
+An alternate way to get the data you need is by explicitly specifying
+a template.
+
+Other Topics
+============
+
+revsets
+   Revisions sets is a functional query language for selecting a set
+   of revisions. Think of it as SQL for Mercurial repositories. Revsets
+   are useful for querying repositories for specific data.
+
+   See :hg:`help revsets` for more.
+
+share extension
+   The ``share`` extension provides functionality for sharing
+   repository data across several working copies. It can even
+   automatically "pool" storage for logically related repositories when
+   cloning.
+
+   Configuring the ``share`` extension can lead to significant resource
+   utilization reduction, particularly around disk space and the
+   network. This is especially true for continuous integration (CI)
+   environments.
+
+   See :hg:`help -e share` for more.
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mercurial/helptext/subrepos.txt	Fri Nov 22 21:42:04 2019 +0900
@@ -0,0 +1,171 @@
+Subrepositories let you nest external repositories or projects into a
+parent Mercurial repository, and make commands operate on them as a
+group.
+
+Mercurial currently supports Mercurial, Git, and Subversion
+subrepositories.
+
+Subrepositories are made of three components:
+
+1. Nested repository checkouts. They can appear anywhere in the
+   parent working directory.
+
+2. Nested repository references. They are defined in ``.hgsub``, which
+   should be placed in the root of working directory, and
+   tell where the subrepository checkouts come from. Mercurial
+   subrepositories are referenced like::
+
+     path/to/nested = https://example.com/nested/repo/path
+
+   Git and Subversion subrepos are also supported::
+
+     path/to/nested = [git]git://example.com/nested/repo/path
+     path/to/nested = [svn]https://example.com/nested/trunk/path
+
+   where ``path/to/nested`` is the checkout location relatively to the
+   parent Mercurial root, and ``https://example.com/nested/repo/path``
+   is the source repository path. The source can also reference a
+   filesystem path.
+
+   Note that ``.hgsub`` does not exist by default in Mercurial
+   repositories, you have to create and add it to the parent
+   repository before using subrepositories.
+
+3. Nested repository states. They are defined in ``.hgsubstate``, which
+   is placed in the root of working directory, and
+   capture whatever information is required to restore the
+   subrepositories to the state they were committed in a parent
+   repository changeset. Mercurial automatically record the nested
+   repositories states when committing in the parent repository.
+
+   .. note::
+
+      The ``.hgsubstate`` file should not be edited manually.
+
+
+Adding a Subrepository
+======================
+
+If ``.hgsub`` does not exist, create it and add it to the parent
+repository. Clone or checkout the external projects where you want it
+to live in the parent repository. Edit ``.hgsub`` and add the
+subrepository entry as described above. At this point, the
+subrepository is tracked and the next commit will record its state in
+``.hgsubstate`` and bind it to the committed changeset.
+
+Synchronizing a Subrepository
+=============================
+
+Subrepos do not automatically track the latest changeset of their
+sources. Instead, they are updated to the changeset that corresponds
+with the changeset checked out in the top-level changeset. This is so
+developers always get a consistent set of compatible code and
+libraries when they update.
+
+Thus, updating subrepos is a manual process. Simply check out target
+subrepo at the desired revision, test in the top-level repo, then
+commit in the parent repository to record the new combination.
+
+Deleting a Subrepository
+========================
+
+To remove a subrepository from the parent repository, delete its
+reference from ``.hgsub``, then remove its files.
+
+Interaction with Mercurial Commands
+===================================
+
+:add: add does not recurse in subrepos unless -S/--subrepos is
+    specified.  However, if you specify the full path of a file in a
+    subrepo, it will be added even without -S/--subrepos specified.
+    Subversion subrepositories are currently silently
+    ignored.
+
+:addremove: addremove does not recurse into subrepos unless
+    -S/--subrepos is specified.  However, if you specify the full
+    path of a directory in a subrepo, addremove will be performed on
+    it even without -S/--subrepos being specified.  Git and
+    Subversion subrepositories will print a warning and continue.
+
+:archive: archive does not recurse in subrepositories unless
+    -S/--subrepos is specified.
+
+:cat: Git subrepositories only support exact file matches.
+    Subversion subrepositories are currently ignored.
+
+:commit: commit creates a consistent snapshot of the state of the
+    entire project and its subrepositories. If any subrepositories
+    have been modified, Mercurial will abort.  Mercurial can be made
+    to instead commit all modified subrepositories by specifying
+    -S/--subrepos, or setting "ui.commitsubrepos=True" in a
+    configuration file (see :hg:`help config`).  After there are no
+    longer any modified subrepositories, it records their state and
+    finally commits it in the parent repository.  The --addremove
+    option also honors the -S/--subrepos option.  However, Git and
+    Subversion subrepositories will print a warning and abort.
+
+:diff: diff does not recurse in subrepos unless -S/--subrepos is
+    specified.  However, if you specify the full path of a file or
+    directory in a subrepo, it will be diffed even without
+    -S/--subrepos being specified.  Subversion subrepositories are
+    currently silently ignored.
+
+:files: files does not recurse into subrepos unless -S/--subrepos is
+    specified.  However, if you specify the full path of a file or
+    directory in a subrepo, it will be displayed even without
+    -S/--subrepos being specified.  Git and Subversion subrepositories
+    are currently silently ignored.
+
+:forget: forget currently only handles exact file matches in subrepos.
+    Git and Subversion subrepositories are currently silently ignored.
+
+:incoming: incoming does not recurse in subrepos unless -S/--subrepos
+    is specified. Git and Subversion subrepositories are currently
+    silently ignored.
+
+:outgoing: outgoing does not recurse in subrepos unless -S/--subrepos
+    is specified. Git and Subversion subrepositories are currently
+    silently ignored.
+
+:pull: pull is not recursive since it is not clear what to pull prior
+    to running :hg:`update`. Listing and retrieving all
+    subrepositories changes referenced by the parent repository pulled
+    changesets is expensive at best, impossible in the Subversion
+    case.
+
+:push: Mercurial will automatically push all subrepositories first
+    when the parent repository is being pushed. This ensures new
+    subrepository changes are available when referenced by top-level
+    repositories.  Push is a no-op for Subversion subrepositories.
+
+:serve: serve does not recurse into subrepositories unless
+    -S/--subrepos is specified.  Git and Subversion subrepositories
+    are currently silently ignored.
+
+:status: status does not recurse into subrepositories unless
+    -S/--subrepos is specified. Subrepository changes are displayed as
+    regular Mercurial changes on the subrepository
+    elements. Subversion subrepositories are currently silently
+    ignored.
+
+:remove: remove does not recurse into subrepositories unless
+    -S/--subrepos is specified.  However, if you specify a file or
+    directory path in a subrepo, it will be removed even without
+    -S/--subrepos.  Git and Subversion subrepositories are currently
+    silently ignored.
+
+:update: update restores the subrepos in the state they were
+    originally committed in target changeset. If the recorded
+    changeset is not available in the current subrepository, Mercurial
+    will pull it in first before updating.  This means that updating
+    can require network access when using subrepositories.
+
+Remapping Subrepositories Sources
+=================================
+
+A subrepository source location may change during a project life,
+invalidating references stored in the parent repository history. To
+fix this, rewriting rules can be defined in parent repository ``hgrc``
+file or in Mercurial configuration. See the ``[subpaths]`` section in
+hgrc(5) for more details.
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mercurial/helptext/templates.txt	Fri Nov 22 21:42:04 2019 +0900
@@ -0,0 +1,215 @@
+Mercurial allows you to customize output of commands through
+templates. You can either pass in a template or select an existing
+template-style from the command line, via the --template option.
+
+You can customize output for any "log-like" command: log,
+outgoing, incoming, tip, parents, and heads.
+
+Some built-in styles are packaged with Mercurial. These can be listed
+with :hg:`log --template list`. Example usage::
+
+    $ hg log -r1.0::1.1 --template changelog
+
+A template is a piece of text, with markup to invoke variable
+expansion::
+
+    $ hg log -r1 --template "{node}\n"
+    b56ce7b07c52de7d5fd79fb89701ea538af65746
+
+Keywords
+========
+
+Strings in curly braces are called keywords. The availability of
+keywords depends on the exact context of the templater. These
+keywords are usually available for templating a log-like command:
+
+.. keywordsmarker
+
+The "date" keyword does not produce human-readable output. If you
+want to use a date in your output, you can use a filter to process
+it. Filters are functions which return a string based on the input
+variable. Be sure to use the stringify filter first when you're
+applying a string-input filter to a list-like input variable.
+You can also use a chain of filters to get the desired output::
+
+   $ hg tip --template "{date|isodate}\n"
+   2008-08-21 18:22 +0000
+
+Filters
+=======
+
+List of filters:
+
+.. filtersmarker
+
+Note that a filter is nothing more than a function call, i.e.
+``expr|filter`` is equivalent to ``filter(expr)``.
+
+Functions
+=========
+
+In addition to filters, there are some basic built-in functions:
+
+.. functionsmarker
+
+Operators
+=========
+
+We provide a limited set of infix arithmetic operations on integers::
+
+  + for addition
+  - for subtraction
+  * for multiplication
+  / for floor division (division rounded to integer nearest -infinity)
+
+Division fulfills the law x = x / y + mod(x, y).
+
+Also, for any expression that returns a list, there is a list operator::
+
+    expr % "{template}"
+
+As seen in the above example, ``{template}`` is interpreted as a template.
+To prevent it from being interpreted, you can use an escape character ``\{``
+or a raw string prefix, ``r'...'``.
+
+The dot operator can be used as a shorthand for accessing a sub item:
+
+- ``expr.member`` is roughly equivalent to ``expr % '{member}'`` if ``expr``
+  returns a non-list/dict. The returned value is not stringified.
+- ``dict.key`` is identical to ``get(dict, 'key')``.
+
+Aliases
+=======
+
+New keywords and functions can be defined in the ``templatealias`` section of
+a Mercurial configuration file::
+
+  <alias> = <definition>
+
+Arguments of the form `a1`, `a2`, etc. are substituted from the alias into
+the definition.
+
+For example,
+
+::
+
+  [templatealias]
+  r = rev
+  rn = "{r}:{node|short}"
+  leftpad(s, w) = pad(s, w, ' ', True)
+
+defines two symbol aliases, ``r`` and ``rn``, and a function alias
+``leftpad()``.
+
+It's also possible to specify complete template strings, using the
+``templates`` section. The syntax used is the general template string syntax.
+
+For example,
+
+::
+
+  [templates]
+  nodedate = "{node|short}: {date(date, "%Y-%m-%d")}\n"
+
+defines a template, ``nodedate``, which can be called like::
+
+  $ hg log -r . -Tnodedate
+
+A template defined in ``templates`` section can also be referenced from
+another template::
+
+  $ hg log -r . -T "{rev} {nodedate}"
+
+but be aware that the keywords cannot be overridden by templates. For example,
+a template defined as ``templates.rev`` cannot be referenced as ``{rev}``.
+
+A template defined in ``templates`` section may have sub templates which
+are inserted before/after/between items::
+
+  [templates]
+  myjson = ' {dict(rev, node|short)|json}'
+  myjson:docheader = '\{\n'
+  myjson:docfooter = '\n}\n'
+  myjson:separator = ',\n'
+
+Examples
+========
+
+Some sample command line templates:
+
+- Format lists, e.g. files::
+
+   $ hg log -r 0 --template "files:\n{files % '  {file}\n'}"
+
+- Join the list of files with a ", "::
+
+   $ hg log -r 0 --template "files: {join(files, ', ')}\n"
+
+- Join the list of files ending with ".py" with a ", "::
+
+   $ hg log -r 0 --template "pythonfiles: {join(files('**.py'), ', ')}\n"
+
+- Separate non-empty arguments by a " "::
+
+   $ hg log -r 0 --template "{separate(' ', node, bookmarks, tags}\n"
+
+- Modify each line of a commit description::
+
+   $ hg log --template "{splitlines(desc) % '**** {line}\n'}"
+
+- Format date::
+
+   $ hg log -r 0 --template "{date(date, '%Y')}\n"
+
+- Display date in UTC::
+
+   $ hg log -r 0 --template "{localdate(date, 'UTC')|date}\n"
+
+- Output the description set to a fill-width of 30::
+
+   $ hg log -r 0 --template "{fill(desc, 30)}"
+
+- Use a conditional to test for the default branch::
+
+   $ hg log -r 0 --template "{ifeq(branch, 'default', 'on the main branch',
+   'on branch {branch}')}\n"
+
+- Append a newline if not empty::
+
+   $ hg tip --template "{if(author, '{author}\n')}"
+
+- Label the output for use with the color extension::
+
+   $ hg log -r 0 --template "{label('changeset.{phase}', node|short)}\n"
+
+- Invert the firstline filter, i.e. everything but the first line::
+
+   $ hg log -r 0 --template "{sub(r'^.*\n?\n?', '', desc)}\n"
+
+- Display the contents of the 'extra' field, one per line::
+
+   $ hg log -r 0 --template "{join(extras, '\n')}\n"
+
+- Mark the active bookmark with '*'::
+
+   $ hg log --template "{bookmarks % '{bookmark}{ifeq(bookmark, active, '*')} '}\n"
+
+- Find the previous release candidate tag, the distance and changes since the tag::
+
+   $ hg log -r . --template "{latesttag('re:^.*-rc$') % '{tag}, {changes}, {distance}'}\n"
+
+- Mark the working copy parent with '@'::
+
+   $ hg log --template "{ifcontains(rev, revset('.'), '@')}\n"
+
+- Show details of parent revisions::
+
+   $ hg log --template "{revset('parents(%d)', rev) % '{desc|firstline}\n'}"
+
+- Show only commit descriptions that start with "template"::
+
+   $ hg log --template "{startswith('template', firstline(desc))}\n"
+
+- Print the first word of each line of a commit message::
+
+   $ hg log --template "{word(0, desc)}\n"
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mercurial/helptext/urls.txt	Fri Nov 22 21:42:04 2019 +0900
@@ -0,0 +1,66 @@
+Valid URLs are of the form::
+
+  local/filesystem/path[#revision]
+  file://local/filesystem/path[#revision]
+  http://[user[:pass]@]host[:port]/[path][#revision]
+  https://[user[:pass]@]host[:port]/[path][#revision]
+  ssh://[user@]host[:port]/[path][#revision]
+
+Paths in the local filesystem can either point to Mercurial
+repositories or to bundle files (as created by :hg:`bundle` or
+:hg:`incoming --bundle`). See also :hg:`help paths`.
+
+An optional identifier after # indicates a particular branch, tag, or
+changeset to use from the remote repository. See also :hg:`help
+revisions`.
+
+Some features, such as pushing to http:// and https:// URLs are only
+possible if the feature is explicitly enabled on the remote Mercurial
+server.
+
+Note that the security of HTTPS URLs depends on proper configuration of
+web.cacerts.
+
+Some notes about using SSH with Mercurial:
+
+- SSH requires an accessible shell account on the destination machine
+  and a copy of hg in the remote path or specified with remotecmd.
+- path is relative to the remote user's home directory by default. Use
+  an extra slash at the start of a path to specify an absolute path::
+
+    ssh://example.com//tmp/repository
+
+- Mercurial doesn't use its own compression via SSH; the right thing
+  to do is to configure it in your ~/.ssh/config, e.g.::
+
+    Host *.mylocalnetwork.example.com
+      Compression no
+    Host *
+      Compression yes
+
+  Alternatively specify "ssh -C" as your ssh command in your
+  configuration file or with the --ssh command line option.
+
+These URLs can all be stored in your configuration file with path
+aliases under the [paths] section like so::
+
+  [paths]
+  alias1 = URL1
+  alias2 = URL2
+  ...
+
+You can then use the alias for any command that uses a URL (for
+example :hg:`pull alias1` will be treated as :hg:`pull URL1`).
+
+Two path aliases are special because they are used as defaults when
+you do not provide the URL to a command:
+
+default:
+  When you create a repository with hg clone, the clone command saves
+  the location of the source repository as the new repository's
+  'default' path. This is then used when you omit path from push- and
+  pull-like commands (including incoming and outgoing).
+
+default-push:
+  The push command will look for a path named 'default-push', and
+  prefer it over 'default' if both are defined.
--- a/mercurial/hgweb/__init__.py	Wed Nov 20 19:07:02 2019 +0100
+++ b/mercurial/hgweb/__init__.py	Fri Nov 22 21:42:04 2019 +0900
@@ -77,19 +77,19 @@
         else:
             prefix = b''
 
-        port = r':%d' % self.httpd.port
-        if port == r':80':
-            port = r''
+        port = ':%d' % self.httpd.port
+        if port == ':80':
+            port = ''
 
         bindaddr = self.httpd.addr
-        if bindaddr == r'0.0.0.0':
-            bindaddr = r'*'
-        elif r':' in bindaddr:  # IPv6
-            bindaddr = r'[%s]' % bindaddr
+        if bindaddr == '0.0.0.0':
+            bindaddr = '*'
+        elif ':' in bindaddr:  # IPv6
+            bindaddr = '[%s]' % bindaddr
 
         fqaddr = self.httpd.fqaddr
-        if r':' in fqaddr:
-            fqaddr = r'[%s]' % fqaddr
+        if ':' in fqaddr:
+            fqaddr = '[%s]' % fqaddr
 
         url = b'http://%s%s/%s' % (
             pycompat.sysbytes(fqaddr),
--- a/mercurial/hgweb/common.py	Wed Nov 20 19:07:02 2019 +0100
+++ b/mercurial/hgweb/common.py	Fri Nov 22 21:42:04 2019 +0900
@@ -143,9 +143,7 @@
 
 def _statusmessage(code):
     responses = httpserver.basehttprequesthandler.responses
-    return pycompat.bytesurl(
-        responses.get(code, (r'Error', r'Unknown error'))[0]
-    )
+    return pycompat.bytesurl(responses.get(code, ('Error', 'Unknown error'))[0])
 
 
 def statusmessage(code, message=None):
--- a/mercurial/hgweb/hgwebdir_mod.py	Wed Nov 20 19:07:02 2019 +0100
+++ b/mercurial/hgweb/hgwebdir_mod.py	Fri Nov 22 21:42:04 2019 +0900
@@ -32,6 +32,7 @@
     error,
     extensions,
     hg,
+    pathutil,
     profiling,
     pycompat,
     registrar,
@@ -436,7 +437,7 @@
             def _virtualdirs():
                 # Check the full virtual path, and each parent
                 yield virtual
-                for p in util.finddirs(virtual):
+                for p in pathutil.finddirs(virtual):
                     yield p
 
             for virtualrepo in _virtualdirs():
--- a/mercurial/hgweb/server.py	Wed Nov 20 19:07:02 2019 +0100
+++ b/mercurial/hgweb/server.py	Fri Nov 22 21:42:04 2019 +0900
@@ -43,8 +43,8 @@
     Just like CGI environment, the path is unquoted, the query is
     not.
     """
-    if r'?' in uri:
-        path, query = uri.split(r'?', 1)
+    if '?' in uri:
+        path, query = uri.split('?', 1)
     else:
         path, query = uri, r''
     return urlreq.unquote(path), query
@@ -62,7 +62,7 @@
 
     def writelines(self, seq):
         for msg in seq:
-            self.handler.log_error(r"HG error:  %s", encoding.strfromlocal(msg))
+            self.handler.log_error("HG error:  %s", encoding.strfromlocal(msg))
 
 
 class _httprequesthandler(httpservermod.basehttprequesthandler):
@@ -97,18 +97,18 @@
     def log_message(self, format, *args):
         self._log_any(self.server.accesslog, format, *args)
 
-    def log_request(self, code=r'-', size=r'-'):
+    def log_request(self, code='-', size='-'):
         xheaders = []
         if util.safehasattr(self, b'headers'):
             xheaders = [
-                h for h in self.headers.items() if h[0].startswith(r'x-')
+                h for h in self.headers.items() if h[0].startswith('x-')
             ]
         self.log_message(
-            r'"%s" %s %s%s',
+            '"%s" %s %s%s',
             self.requestline,
             str(code),
             str(size),
-            r''.join([r' %s:%s' % h for h in sorted(xheaders)]),
+            ''.join([' %s:%s' % h for h in sorted(xheaders)]),
         )
 
     def do_write(self):
@@ -128,20 +128,20 @@
                 isinstance(e, (OSError, socket.error))
                 and e.errno == errno.ECONNRESET
             ):
-                tb = r"".join(traceback.format_exception(*sys.exc_info()))
+                tb = "".join(traceback.format_exception(*sys.exc_info()))
                 # We need a native-string newline to poke in the log
                 # message, because we won't get a newline when using an
                 # r-string. This is the easy way out.
                 newline = chr(10)
                 self.log_error(
                     r"Exception happened during processing "
-                    r"request '%s':%s%s",
+                    "request '%s':%s%s",
                     self.path,
                     newline,
                     tb,
                 )
 
-            self._start_response(r"500 Internal Server Error", [])
+            self._start_response("500 Internal Server Error", [])
             self._write(b"Internal Server Error")
             self._done()
 
@@ -160,72 +160,72 @@
             self.server.prefix + b'/'
         ):
             self._start_response(pycompat.strurl(common.statusmessage(404)), [])
-            if self.command == r'POST':
+            if self.command == 'POST':
                 # Paranoia: tell the client we're going to close the
                 # socket so they don't try and reuse a socket that
                 # might have a POST body waiting to confuse us. We do
                 # this by directly munging self.saved_headers because
                 # self._start_response ignores Connection headers.
-                self.saved_headers = [(r'Connection', r'Close')]
+                self.saved_headers = [('Connection', 'Close')]
             self._write(b"Not Found")
             self._done()
             return
 
         env = {}
-        env[r'GATEWAY_INTERFACE'] = r'CGI/1.1'
-        env[r'REQUEST_METHOD'] = self.command
-        env[r'SERVER_NAME'] = self.server.server_name
-        env[r'SERVER_PORT'] = str(self.server.server_port)
-        env[r'REQUEST_URI'] = self.path
-        env[r'SCRIPT_NAME'] = pycompat.sysstr(self.server.prefix)
-        env[r'PATH_INFO'] = pycompat.sysstr(path[len(self.server.prefix) :])
-        env[r'REMOTE_HOST'] = self.client_address[0]
-        env[r'REMOTE_ADDR'] = self.client_address[0]
-        env[r'QUERY_STRING'] = query or r''
+        env['GATEWAY_INTERFACE'] = 'CGI/1.1'
+        env['REQUEST_METHOD'] = self.command
+        env['SERVER_NAME'] = self.server.server_name
+        env['SERVER_PORT'] = str(self.server.server_port)
+        env['REQUEST_URI'] = self.path
+        env['SCRIPT_NAME'] = pycompat.sysstr(self.server.prefix)
+        env['PATH_INFO'] = pycompat.sysstr(path[len(self.server.prefix) :])
+        env['REMOTE_HOST'] = self.client_address[0]
+        env['REMOTE_ADDR'] = self.client_address[0]
+        env['QUERY_STRING'] = query or ''
 
         if pycompat.ispy3:
             if self.headers.get_content_type() is None:
-                env[r'CONTENT_TYPE'] = self.headers.get_default_type()
+                env['CONTENT_TYPE'] = self.headers.get_default_type()
             else:
-                env[r'CONTENT_TYPE'] = self.headers.get_content_type()
-            length = self.headers.get(r'content-length')
+                env['CONTENT_TYPE'] = self.headers.get_content_type()
+            length = self.headers.get('content-length')
         else:
             if self.headers.typeheader is None:
-                env[r'CONTENT_TYPE'] = self.headers.type
+                env['CONTENT_TYPE'] = self.headers.type
             else:
-                env[r'CONTENT_TYPE'] = self.headers.typeheader
-            length = self.headers.getheader(r'content-length')
+                env['CONTENT_TYPE'] = self.headers.typeheader
+            length = self.headers.getheader('content-length')
         if length:
-            env[r'CONTENT_LENGTH'] = length
+            env['CONTENT_LENGTH'] = length
         for header in [
             h
             for h in self.headers.keys()
-            if h.lower() not in (r'content-type', r'content-length')
+            if h.lower() not in ('content-type', 'content-length')
         ]:
-            hkey = r'HTTP_' + header.replace(r'-', r'_').upper()
+            hkey = 'HTTP_' + header.replace('-', '_').upper()
             hval = self.headers.get(header)
-            hval = hval.replace(r'\n', r'').strip()
+            hval = hval.replace('\n', '').strip()
             if hval:
                 env[hkey] = hval
-        env[r'SERVER_PROTOCOL'] = self.request_version
-        env[r'wsgi.version'] = (1, 0)
-        env[r'wsgi.url_scheme'] = pycompat.sysstr(self.url_scheme)
-        if env.get(r'HTTP_EXPECT', b'').lower() == b'100-continue':
+        env['SERVER_PROTOCOL'] = self.request_version
+        env['wsgi.version'] = (1, 0)
+        env['wsgi.url_scheme'] = pycompat.sysstr(self.url_scheme)
+        if env.get('HTTP_EXPECT', b'').lower() == b'100-continue':
             self.rfile = common.continuereader(self.rfile, self.wfile.write)
 
-        env[r'wsgi.input'] = self.rfile
-        env[r'wsgi.errors'] = _error_logger(self)
-        env[r'wsgi.multithread'] = isinstance(
+        env['wsgi.input'] = self.rfile
+        env['wsgi.errors'] = _error_logger(self)
+        env['wsgi.multithread'] = isinstance(
             self.server, socketserver.ThreadingMixIn
         )
         if util.safehasattr(socketserver, b'ForkingMixIn'):
-            env[r'wsgi.multiprocess'] = isinstance(
+            env['wsgi.multiprocess'] = isinstance(
                 self.server, socketserver.ForkingMixIn
             )
         else:
-            env[r'wsgi.multiprocess'] = False
+            env['wsgi.multiprocess'] = False
 
-        env[r'wsgi.run_once'] = 0
+        env['wsgi.run_once'] = 0
 
         wsgiref.validate.check_environ(env)
 
@@ -251,17 +251,16 @@
         self._chunked = False
         for h in self.saved_headers:
             self.send_header(*h)
-            if h[0].lower() == r'content-length':
+            if h[0].lower() == 'content-length':
                 self.length = int(h[1])
         if self.length is None and saved_status[0] != common.HTTP_NOT_MODIFIED:
             self._chunked = (
-                not self.close_connection
-                and self.request_version == r'HTTP/1.1'
+                not self.close_connection and self.request_version == 'HTTP/1.1'
             )
             if self._chunked:
-                self.send_header(r'Transfer-Encoding', r'chunked')
+                self.send_header('Transfer-Encoding', 'chunked')
             else:
-                self.send_header(r'Connection', r'close')
+                self.send_header('Connection', 'close')
         self.end_headers()
         self.sent_headers = True
 
@@ -270,7 +269,7 @@
         code, msg = http_status.split(None, 1)
         code = int(code)
         self.saved_status = http_status
-        bad_headers = (r'connection', r'transfer-encoding')
+        bad_headers = ('connection', 'transfer-encoding')
         self.saved_headers = [
             h for h in headers if h[0].lower() not in bad_headers
         ]
@@ -335,8 +334,8 @@
 
     def setup(self):
         self.connection = self.request
-        self.rfile = self.request.makefile(r"rb", self.rbufsize)
-        self.wfile = self.request.makefile(r"wb", self.wbufsize)
+        self.rfile = self.request.makefile("rb", self.rbufsize)
+        self.wfile = self.request.makefile("wb", self.wbufsize)
 
 
 try:
--- a/mercurial/hgweb/webutil.py	Wed Nov 20 19:07:02 2019 +0100
+++ b/mercurial/hgweb/webutil.py	Fri Nov 22 21:42:04 2019 +0900
@@ -541,8 +541,15 @@
 
 def _listfilesgen(context, ctx, stripecount):
     parity = paritygen(stripecount)
+    filesadded = ctx.filesadded()
     for blockno, f in enumerate(ctx.files()):
-        template = b'filenodelink' if f in ctx else b'filenolink'
+        if f not in ctx:
+            status = b'removed'
+        elif f in filesadded:
+            status = b'added'
+        else:
+            status = b'modified'
+        template = b'filenolink' if status == b'removed' else b'filenodelink'
         yield context.process(
             template,
             {
@@ -550,6 +557,7 @@
                 b'file': f,
                 b'blockno': blockno + 1,
                 b'parity': next(parity),
+                b'status': status,
             },
         )
 
--- a/mercurial/hgweb/wsgicgi.py	Wed Nov 20 19:07:02 2019 +0100
+++ b/mercurial/hgweb/wsgicgi.py	Fri Nov 22 21:42:04 2019 +0900
@@ -25,28 +25,28 @@
     procutil.setbinary(procutil.stdout)
 
     environ = dict(pycompat.iteritems(os.environ))  # re-exports
-    environ.setdefault(r'PATH_INFO', b'')
-    if environ.get(r'SERVER_SOFTWARE', r'').startswith(r'Microsoft-IIS'):
+    environ.setdefault('PATH_INFO', b'')
+    if environ.get('SERVER_SOFTWARE', '').startswith('Microsoft-IIS'):
         # IIS includes script_name in PATH_INFO
-        scriptname = environ[r'SCRIPT_NAME']
-        if environ[r'PATH_INFO'].startswith(scriptname):
-            environ[r'PATH_INFO'] = environ[r'PATH_INFO'][len(scriptname) :]
+        scriptname = environ['SCRIPT_NAME']
+        if environ['PATH_INFO'].startswith(scriptname):
+            environ['PATH_INFO'] = environ['PATH_INFO'][len(scriptname) :]
 
     stdin = procutil.stdin
-    if environ.get(r'HTTP_EXPECT', r'').lower() == r'100-continue':
+    if environ.get('HTTP_EXPECT', '').lower() == '100-continue':
         stdin = common.continuereader(stdin, procutil.stdout.write)
 
-    environ[r'wsgi.input'] = stdin
-    environ[r'wsgi.errors'] = procutil.stderr
-    environ[r'wsgi.version'] = (1, 0)
-    environ[r'wsgi.multithread'] = False
-    environ[r'wsgi.multiprocess'] = True
-    environ[r'wsgi.run_once'] = True
+    environ['wsgi.input'] = stdin
+    environ['wsgi.errors'] = procutil.stderr
+    environ['wsgi.version'] = (1, 0)
+    environ['wsgi.multithread'] = False
+    environ['wsgi.multiprocess'] = True
+    environ['wsgi.run_once'] = True
 
-    if environ.get(r'HTTPS', r'off').lower() in (r'on', r'1', r'yes'):
-        environ[r'wsgi.url_scheme'] = r'https'
+    if environ.get('HTTPS', 'off').lower() in ('on', '1', 'yes'):
+        environ['wsgi.url_scheme'] = 'https'
     else:
-        environ[r'wsgi.url_scheme'] = r'http'
+        environ['wsgi.url_scheme'] = 'http'
 
     headers_set = []
     headers_sent = []
--- a/mercurial/hgweb/wsgiheaders.py	Wed Nov 20 19:07:02 2019 +0100
+++ b/mercurial/hgweb/wsgiheaders.py	Fri Nov 22 21:42:04 2019 +0900
@@ -129,7 +129,7 @@
         return self._headers[:]
 
     def __repr__(self):
-        return r"%s(%r)" % (self.__class__.__name__, self._headers)
+        return "%s(%r)" % (self.__class__.__name__, self._headers)
 
     def __str__(self):
         """str() returns the formatted headers, complete with end line,
--- a/mercurial/hook.py	Wed Nov 20 19:07:02 2019 +0100
+++ b/mercurial/hook.py	Fri Nov 22 21:42:04 2019 +0900
@@ -22,6 +22,7 @@
 )
 from .utils import (
     procutil,
+    resourceutil,
     stringutil,
 )
 
@@ -38,7 +39,7 @@
 
     if callable(funcname):
         obj = funcname
-        funcname = pycompat.sysbytes(obj.__module__ + r"." + obj.__name__)
+        funcname = pycompat.sysbytes(obj.__module__ + "." + obj.__name__)
     else:
         d = funcname.rfind(b'.')
         if d == -1:
@@ -48,7 +49,7 @@
             )
         modname = funcname[:d]
         oldpaths = sys.path
-        if procutil.mainfrozen():
+        if resourceutil.mainfrozen():
             # binary installs require sys.path manipulation
             modpath, modfile = os.path.split(modname)
             if modpath and modfile:
@@ -61,7 +62,7 @@
                 e1 = sys.exc_info()
                 try:
                     # extensions are loaded with hgext_ prefix
-                    obj = __import__(r"hgext_%s" % pycompat.sysstr(modname))
+                    obj = __import__("hgext_%s" % pycompat.sysstr(modname))
                 except (ImportError, SyntaxError):
                     e2 = sys.exc_info()
                     if ui.tracebackflag:
--- a/mercurial/httppeer.py	Wed Nov 20 19:07:02 2019 +0100
+++ b/mercurial/httppeer.py	Fri Nov 22 21:42:04 2019 +0900
@@ -63,7 +63,7 @@
     # and using an r-string to make it portable between Python 2 and 3
     # doesn't work because then the \r is a literal backslash-r
     # instead of a carriage return.
-    valuelen = limit - len(fmt % r'000') - len(b': \r\n')
+    valuelen = limit - len(fmt % '000') - len(b': \r\n')
     result = []
 
     n = 0
@@ -158,7 +158,7 @@
             argsio = io.BytesIO(strargs)
             argsio.length = len(strargs)
             data = _multifile(argsio, data)
-        headers[r'X-HgArgs-Post'] = len(strargs)
+        headers['X-HgArgs-Post'] = len(strargs)
     elif args:
         # Calling self.capable() can infinite loop if we are calling
         # "capabilities". But that command should never accept wire
@@ -187,8 +187,8 @@
         size = data.length
     elif data is not None:
         size = len(data)
-    if data is not None and r'Content-Type' not in headers:
-        headers[r'Content-Type'] = r'application/mercurial-0.1'
+    if data is not None and 'Content-Type' not in headers:
+        headers['Content-Type'] = 'application/mercurial-0.1'
 
     # Tell the server we accept application/mercurial-0.2 and multiple
     # compression formats if the server is capable of emitting those
@@ -228,17 +228,17 @@
 
     varyheaders = []
     for header in headers:
-        if header.lower().startswith(r'x-hg'):
+        if header.lower().startswith('x-hg'):
             varyheaders.append(header)
 
     if varyheaders:
-        headers[r'Vary'] = r','.join(sorted(varyheaders))
+        headers['Vary'] = ','.join(sorted(varyheaders))
 
     req = requestbuilder(pycompat.strurl(cu), data, headers)
 
     if data is not None:
         ui.debug(b"sending %d bytes\n" % size)
-        req.add_unredirected_header(r'Content-Length', r'%d' % size)
+        req.add_unredirected_header('Content-Length', '%d' % size)
 
     return req, cu, qs
 
@@ -348,9 +348,9 @@
             ui.warn(_(b'real URL is %s\n') % respurl)
 
     try:
-        proto = pycompat.bytesurl(resp.getheader(r'content-type', r''))
+        proto = pycompat.bytesurl(resp.getheader('content-type', ''))
     except AttributeError:
-        proto = pycompat.bytesurl(resp.headers.get(r'content-type', r''))
+        proto = pycompat.bytesurl(resp.headers.get('content-type', ''))
 
     safeurl = util.hidepassword(baseurl)
     if proto.startswith(b'application/hg-error'):
@@ -517,7 +517,7 @@
 
         tempname = bundle2.writebundle(self.ui, cg, None, type)
         fp = httpconnection.httpsendfile(self.ui, tempname, b"rb")
-        headers = {r'Content-Type': r'application/mercurial-0.1'}
+        headers = {'Content-Type': 'application/mercurial-0.1'}
 
         try:
             r = self._call(cmd, data=fp, headers=headers, **args)
@@ -543,14 +543,14 @@
         try:
             # dump bundle to disk
             fd, filename = pycompat.mkstemp(prefix=b"hg-bundle-", suffix=b".hg")
-            with os.fdopen(fd, r"wb") as fh:
+            with os.fdopen(fd, "wb") as fh:
                 d = fp.read(4096)
                 while d:
                     fh.write(d)
                     d = fp.read(4096)
             # start http push
             with httpconnection.httpsendfile(self.ui, filename, b"rb") as fp_:
-                headers = {r'Content-Type': r'application/mercurial-0.1'}
+                headers = {'Content-Type': 'application/mercurial-0.1'}
                 return self._callstream(cmd, data=fp_, headers=headers, **args)
         finally:
             if filename is not None:
@@ -621,12 +621,12 @@
 
     # TODO modify user-agent to reflect v2
     headers = {
-        r'Accept': wireprotov2server.FRAMINGTYPE,
-        r'Content-Type': wireprotov2server.FRAMINGTYPE,
+        'Accept': wireprotov2server.FRAMINGTYPE,
+        'Content-Type': wireprotov2server.FRAMINGTYPE,
     }
 
     req = requestbuilder(pycompat.strurl(url), body, headers)
-    req.add_unredirected_header(r'Content-Length', r'%d' % len(body))
+    req.add_unredirected_header('Content-Length', '%d' % len(body))
 
     try:
         res = opener.open(req)
@@ -965,7 +965,7 @@
 
     if advertisev2:
         args[b'headers'] = {
-            r'X-HgProto-1': r'cbor',
+            'X-HgProto-1': 'cbor',
         }
 
         args[b'headers'].update(
--- a/mercurial/i18n.py	Wed Nov 20 19:07:02 2019 +0100
+++ b/mercurial/i18n.py	Fri Nov 22 21:42:04 2019 +0900
@@ -13,6 +13,7 @@
 import sys
 
 from .pycompat import getattr
+from .utils import resourceutil
 from . import (
     encoding,
     pycompat,
@@ -45,18 +46,14 @@
         # ctypes not found or unknown langid
         pass
 
-_ugettext = None
 
-
-def setdatapath(datapath):
-    datapath = pycompat.fsdecode(datapath)
-    localedir = os.path.join(datapath, r'locale')
-    t = gettextmod.translation(r'hg', localedir, _languages, fallback=True)
-    global _ugettext
-    try:
-        _ugettext = t.ugettext
-    except AttributeError:
-        _ugettext = t.gettext
+datapath = pycompat.fsdecode(resourceutil.datapath)
+localedir = os.path.join(datapath, 'locale')
+t = gettextmod.translation('hg', localedir, _languages, fallback=True)
+try:
+    _ugettext = t.ugettext
+except AttributeError:
+    _ugettext = t.gettext
 
 
 _msgcache = {}  # encoding: {message: translation}
--- a/mercurial/interfaces/repository.py	Wed Nov 20 19:07:02 2019 +0100
+++ b/mercurial/interfaces/repository.py	Fri Nov 22 21:42:04 2019 +0900
@@ -1746,7 +1746,7 @@
     def currentwlock():
         """Return the wlock if it's held or None."""
 
-    def checkcommitpatterns(wctx, vdirs, match, status, fail):
+    def checkcommitpatterns(wctx, match, status, fail):
         pass
 
     def commit(
--- a/mercurial/keepalive.py	Wed Nov 20 19:07:02 2019 +0100
+++ b/mercurial/keepalive.py	Fri Nov 22 21:42:04 2019 +0900
@@ -331,9 +331,9 @@
         headers.update(sorted(req.unredirected_hdrs.items()))
         headers = util.sortdict((n.lower(), v) for n, v in headers.items())
         skipheaders = {}
-        for n in (r'host', r'accept-encoding'):
+        for n in ('host', 'accept-encoding'):
             if n in headers:
-                skipheaders[r'skip_' + n.replace(r'-', r'_')] = 1
+                skipheaders['skip_' + n.replace('-', '_')] = 1
         try:
             if urllibcompat.hasdata(req):
                 data = urllibcompat.getdata(req)
@@ -342,12 +342,12 @@
                     urllibcompat.getselector(req),
                     **skipheaders
                 )
-                if r'content-type' not in headers:
+                if 'content-type' not in headers:
                     h.putheader(
-                        r'Content-type', r'application/x-www-form-urlencoded'
+                        'Content-type', 'application/x-www-form-urlencoded'
                     )
-                if r'content-length' not in headers:
-                    h.putheader(r'Content-length', r'%d' % len(data))
+                if 'content-length' not in headers:
+                    h.putheader('Content-length', '%d' % len(data))
             else:
                 h.putrequest(
                     req.get_method(),
@@ -401,8 +401,8 @@
     def __init__(self, sock, debuglevel=0, strict=0, method=None):
         extrakw = {}
         if not pycompat.ispy3:
-            extrakw[r'strict'] = True
-            extrakw[r'buffering'] = True
+            extrakw['strict'] = True
+            extrakw['buffering'] = True
         httplib.HTTPResponse.__init__(
             self, sock, debuglevel=debuglevel, method=method, **extrakw
         )
--- a/mercurial/linelog.py	Wed Nov 20 19:07:02 2019 +0100
+++ b/mercurial/linelog.py	Fri Nov 22 21:42:04 2019 +0900
@@ -53,7 +53,7 @@
         return iter(self.lines)
 
 
-class _llinstruction(object):
+class _llinstruction(object):  # pytype: disable=ignored-metaclass
 
     __metaclass__ = abc.ABCMeta
 
@@ -99,7 +99,7 @@
         self._target = op2
 
     def __str__(self):
-        return r'JGE %d %d' % (self._cmprev, self._target)
+        return 'JGE %d %d' % (self._cmprev, self._target)
 
     def __eq__(self, other):
         return (
@@ -126,7 +126,7 @@
         self._target = op2
 
     def __str__(self):
-        return r'JUMP %d' % (self._target)
+        return 'JUMP %d' % (self._target)
 
     def __eq__(self, other):
         return type(self) == type(other) and self._target == other._target
@@ -168,7 +168,7 @@
         self._target = op2
 
     def __str__(self):
-        return r'JL %d %d' % (self._cmprev, self._target)
+        return 'JL %d %d' % (self._cmprev, self._target)
 
     def __eq__(self, other):
         return (
@@ -196,7 +196,7 @@
         self._origlineno = op2
 
     def __str__(self):
-        return r'LINE %d %d' % (self._rev, self._origlineno)
+        return 'LINE %d %d' % (self._rev, self._origlineno)
 
     def __eq__(self, other):
         return (
@@ -262,7 +262,7 @@
         )
 
     def debugstr(self):
-        fmt = r'%%%dd %%s' % len(str(len(self._program)))
+        fmt = '%%%dd %%s' % len(str(len(self._program)))
         return pycompat.sysstr(b'\n').join(
             fmt % (idx, i) for idx, i in enumerate(self._program[1:], 1)
         )
@@ -278,8 +278,14 @@
         fakejge = _decodeone(buf, 0)
         if isinstance(fakejge, _jump):
             maxrev = 0
+        elif isinstance(fakejge, (_jge, _jl)):
+            maxrev = fakejge._cmprev
         else:
-            maxrev = fakejge._cmprev
+            raise LineLogError(
+                'Expected one of _jump, _jge, or _jl. Got %s.'
+                % type(fakejge).__name__
+            )
+        assert isinstance(fakejge, (_jump, _jge, _jl))  # help pytype
         numentries = fakejge._target
         if expected != numentries:
             raise LineLogError(
--- a/mercurial/localrepo.py	Wed Nov 20 19:07:02 2019 +0100
+++ b/mercurial/localrepo.py	Fri Nov 22 21:42:04 2019 +0900
@@ -1823,11 +1823,11 @@
 
     def known(self, nodes):
         cl = self.changelog
-        nm = cl.nodemap
+        get_rev = cl.index.get_rev
         filtered = cl.filteredrevs
         result = []
         for n in nodes:
-            r = nm.get(n)
+            r = get_rev(n)
             resp = not (r is None or r in filtered)
             result.append(resp)
         return result
@@ -2350,7 +2350,8 @@
             self.svfs.rename(b'undo.phaseroots', b'phaseroots', checkambig=True)
         self.invalidate()
 
-        parentgone = any(p not in self.changelog.nodemap for p in parents)
+        has_node = self.changelog.index.has_node
+        parentgone = any(not has_node(p) for p in parents)
         if parentgone:
             # prevent dirstateguard from overwriting already restored one
             dsguard.close()
@@ -2458,9 +2459,9 @@
 
     def invalidatecaches(self):
 
-        if r'_tagscache' in vars(self):
+        if '_tagscache' in vars(self):
             # can't use delattr on proxy
-            del self.__dict__[r'_tagscache']
+            del self.__dict__['_tagscache']
 
         self._branchcaches.clear()
         self.invalidatevolatilesets()
@@ -2479,13 +2480,13 @@
         rereads the dirstate. Use dirstate.invalidate() if you want to
         explicitly read the dirstate again (i.e. restoring it to a previous
         known good state).'''
-        if hasunfilteredcache(self, r'dirstate'):
+        if hasunfilteredcache(self, 'dirstate'):
             for k in self.dirstate._filecache:
                 try:
                     delattr(self.dirstate, k)
                 except AttributeError:
                     pass
-            delattr(self.unfiltered(), r'dirstate')
+            delattr(self.unfiltered(), 'dirstate')
 
     def invalidate(self, clearfilecache=False):
         '''Invalidates both store and non-store parts other than dirstate
@@ -2535,7 +2536,7 @@
         """Reload stats of cached files so that they are flagged as valid"""
         for k, ce in self._filecache.items():
             k = pycompat.sysstr(k)
-            if k == r'dirstate' or k not in self.__dict__:
+            if k == 'dirstate' or k not in self.__dict__:
                 continue
             ce.refresh()
 
@@ -2787,7 +2788,7 @@
 
         return fparent1
 
-    def checkcommitpatterns(self, wctx, vdirs, match, status, fail):
+    def checkcommitpatterns(self, wctx, match, status, fail):
         """check for commit arguments that aren't committable"""
         if match.isexact() or match.prefix():
             matched = set(status.modified + status.added + status.removed)
@@ -2798,7 +2799,8 @@
                     continue
                 if f in status.deleted:
                     fail(f, _(b'file not found!'))
-                if f in vdirs:  # visited directory
+                # Is it a directory that exists or used to exist?
+                if self.wvfs.isdir(f) or wctx.p1().hasdir(f):
                     d = f + b'/'
                     for mf in matched:
                         if mf.startswith(d):
@@ -2835,8 +2837,6 @@
             match = matchmod.always()
 
         if not force:
-            vdirs = []
-            match.explicitdir = vdirs.append
             match.bad = fail
 
         # lock() for recent changelog (see issue4368)
@@ -2865,7 +2865,7 @@
 
             # make sure all explicit patterns are matched
             if not force:
-                self.checkcommitpatterns(wctx, vdirs, match, status, fail)
+                self.checkcommitpatterns(wctx, match, status, fail)
 
             cctx = context.workingcommitctx(
                 self, status, text, user, date, extra
@@ -3362,10 +3362,10 @@
             if tr is not None:
                 hookargs.update(tr.hookargs)
             hookargs = pycompat.strkwargs(hookargs)
-            hookargs[r'namespace'] = namespace
-            hookargs[r'key'] = key
-            hookargs[r'old'] = old
-            hookargs[r'new'] = new
+            hookargs['namespace'] = namespace
+            hookargs['key'] = key
+            hookargs['old'] = old
+            hookargs['new'] = new
             self.hook(b'prepushkey', throw=True, **hookargs)
         except error.HookAbort as exc:
             self.ui.write_err(_(b"pushkey-abort: %s\n") % exc)
@@ -3705,7 +3705,7 @@
     # of repos call close() on repo references.
     class poisonedrepository(object):
         def __getattribute__(self, item):
-            if item == r'close':
+            if item == 'close':
                 return object.__getattribute__(self, item)
 
             raise error.ProgrammingError(
@@ -3717,4 +3717,4 @@
 
     # We may have a repoview, which intercepts __setattr__. So be sure
     # we operate at the lowest level possible.
-    object.__setattr__(repo, r'__class__', poisonedrepository)
+    object.__setattr__(repo, '__class__', poisonedrepository)
--- a/mercurial/lock.py	Wed Nov 20 19:07:02 2019 +0100
+++ b/mercurial/lock.py	Fri Nov 22 21:42:04 2019 +0900
@@ -238,7 +238,7 @@
     def __del__(self):
         if self.held:
             warnings.warn(
-                r"use lock.release instead of del lock",
+                "use lock.release instead of del lock",
                 category=DeprecationWarning,
                 stacklevel=2,
             )
@@ -330,27 +330,35 @@
                 return None
             raise
 
-    def _testlock(self, locker):
+    def _lockshouldbebroken(self, locker):
         if locker is None:
-            return None
+            return False
         try:
             host, pid = locker.split(b":", 1)
         except ValueError:
-            return locker
+            return False
         if host != lock._host:
-            return locker
+            return False
         try:
             pid = int(pid)
         except ValueError:
-            return locker
+            return False
         if procutil.testpid(pid):
+            return False
+        return True
+
+    def _testlock(self, locker):
+        if not self._lockshouldbebroken(locker):
             return locker
+
         # if locker dead, break lock.  must do this with another lock
         # held, or can race and break valid lock.
         try:
-            l = lock(self.vfs, self.f + b'.break', timeout=0)
-            self.vfs.unlink(self.f)
-            l.release()
+            with lock(self.vfs, self.f + b'.break', timeout=0):
+                locker = self._readlock()
+                if not self._lockshouldbebroken(locker):
+                    return locker
+                self.vfs.unlink(self.f)
         except error.LockError:
             return locker
 
--- a/mercurial/logcmdutil.py	Wed Nov 20 19:07:02 2019 +0100
+++ b/mercurial/logcmdutil.py	Fri Nov 22 21:42:04 2019 +0900
@@ -42,6 +42,16 @@
 )
 
 
+if not globals():
+    from typing import (
+        Any,
+        Tuple,
+    )
+
+    for t in (Any, Tuple):
+        assert t
+
+
 def getlimit(opts):
     """get the log limit according to option -l/--limit"""
     limit = opts.get(b'limit')
@@ -339,8 +349,11 @@
         self._exthook(ctx)
 
         if self.ui.debugflag:
-            files = ctx.p1().status(ctx)[:3]
-            for key, value in zip([b'files', b'files+', b'files-'], files):
+            files = ctx.p1().status(ctx)
+            for key, value in zip(
+                [b'files', b'files+', b'files-'],
+                [files.modified, files.added, files.removed],
+            ):
                 if value:
                     self.ui.write(
                         columns[key] % b" ".join(value),
@@ -470,9 +483,9 @@
         ):
             files = ctx.p1().status(ctx)
             fm.data(
-                modified=fm.formatlist(files[0], name=b'file'),
-                added=fm.formatlist(files[1], name=b'file'),
-                removed=fm.formatlist(files[2], name=b'file'),
+                modified=fm.formatlist(files.modified, name=b'file'),
+                added=fm.formatlist(files.added, name=b'file'),
+                removed=fm.formatlist(files.removed, name=b'file'),
             )
 
         verbose = not self.ui.debugflag and self.ui.verbose
@@ -840,6 +853,7 @@
 
 
 def getrevs(repo, pats, opts):
+    # type: (Any, Any, Any) -> Tuple[smartset.BaseSet, changesetdiffer]
     """Return (revs, differ) where revs is a smartset
 
     differ is a changesetdiffer with pre-configured file matcher.
@@ -968,7 +982,7 @@
     differ = changesetdiffer()
     differ._makefilematcher = filematcher
     differ._makehunksfilter = hunksfilter
-    return revs, differ
+    return smartset.baseset(revs), differ
 
 
 def _graphnodeformatter(ui, displayer):
--- a/mercurial/lsprof.py	Wed Nov 20 19:07:02 2019 +0100
+++ b/mercurial/lsprof.py	Fri Nov 22 21:42:04 2019 +0900
@@ -31,7 +31,7 @@
     def __init__(self, data):
         self.data = data
 
-    def sort(self, crit=r"inlinetime"):
+    def sort(self, crit="inlinetime"):
         """XXX docstring"""
         # profiler_entries isn't defined when running under PyPy.
         if profiler_entry:
@@ -135,9 +135,9 @@
                 mname = _fn2mod[code.co_filename] = k
                 break
         else:
-            mname = _fn2mod[code.co_filename] = r'<%s>' % code.co_filename
+            mname = _fn2mod[code.co_filename] = '<%s>' % code.co_filename
 
-    res = r'%s:%d(%s)' % (mname, code.co_firstlineno, code.co_name)
+    res = '%s:%d(%s)' % (mname, code.co_firstlineno, code.co_name)
 
     if sys.version_info.major >= 3:
         res = res.encode('latin-1')
--- a/mercurial/mail.py	Wed Nov 20 19:07:02 2019 +0100
+++ b/mercurial/mail.py	Fri Nov 22 21:42:04 2019 +0900
@@ -36,6 +36,12 @@
     stringutil,
 )
 
+if not globals():  # hide this from non-pytype users
+    from typing import Any, List, Tuple, Union
+
+    # keep pyflakes happy
+    assert all((Any, List, Tuple, Union))
+
 
 class STARTTLS(smtplib.SMTP):
     '''Derived class to verify the peer certificate for STARTTLS.
@@ -94,11 +100,12 @@
             ui=self._ui,
             serverhostname=self._host,
         )
-        self.file = new_socket.makefile(r'rb')
+        self.file = new_socket.makefile('rb')
         return new_socket
 
 
 def _pyhastls():
+    # type: () -> bool
     """Returns true iff Python has TLS support, false otherwise."""
     try:
         import ssl
@@ -201,7 +208,7 @@
     fp = open(mbox, b'ab+')
     # Should be time.asctime(), but Windows prints 2-characters day
     # of month instead of one. Make them print the same thing.
-    date = time.strftime(r'%a %b %d %H:%M:%S %Y', time.localtime())
+    date = time.strftime('%a %b %d %H:%M:%S %Y', time.localtime())
     fp.write(
         b'From %s %s\n'
         % (encoding.strtolocal(sender), encoding.strtolocal(date))
@@ -246,42 +253,50 @@
 
 
 def codec2iana(cs):
+    # type: (str) -> str
     ''''''
-    cs = pycompat.sysbytes(email.charset.Charset(cs).input_charset.lower())
+    cs = email.charset.Charset(cs).input_charset.lower()
 
     # "latin1" normalizes to "iso8859-1", standard calls for "iso-8859-1"
-    if cs.startswith(b"iso") and not cs.startswith(b"iso-"):
-        return b"iso-" + cs[3:]
+    if cs.startswith("iso") and not cs.startswith("iso-"):
+        return "iso-" + cs[3:]
     return cs
 
 
-def mimetextpatch(s, subtype=b'plain', display=False):
+def mimetextpatch(s, subtype='plain', display=False):
+    # type: (bytes, str, bool) -> email.message.Message
     '''Return MIME message suitable for a patch.
     Charset will be detected by first trying to decode as us-ascii, then utf-8,
     and finally the global encodings. If all those fail, fall back to
     ISO-8859-1, an encoding with that allows all byte sequences.
     Transfer encodings will be used if necessary.'''
 
-    cs = [b'us-ascii', b'utf-8', encoding.encoding, encoding.fallbackencoding]
+    cs = [
+        'us-ascii',
+        'utf-8',
+        pycompat.sysstr(encoding.encoding),
+        pycompat.sysstr(encoding.fallbackencoding),
+    ]
     if display:
-        cs = [b'us-ascii']
+        cs = ['us-ascii']
     for charset in cs:
         try:
-            s.decode(pycompat.sysstr(charset))
+            s.decode(charset)
             return mimetextqp(s, subtype, codec2iana(charset))
         except UnicodeDecodeError:
             pass
 
-    return mimetextqp(s, subtype, b"iso-8859-1")
+    return mimetextqp(s, subtype, "iso-8859-1")
 
 
 def mimetextqp(body, subtype, charset):
+    # type: (bytes, str, str) -> email.message.Message
     '''Return MIME message.
     Quoted-printable transfer encoding will be used if necessary.
     '''
     cs = email.charset.Charset(charset)
     msg = email.message.Message()
-    msg.set_type(pycompat.sysstr(b'text/' + subtype))
+    msg.set_type('text/' + subtype)
 
     for line in body.splitlines():
         if len(line) > 950:
@@ -301,20 +316,25 @@
 
 
 def _charsets(ui):
+    # type: (Any) -> List[str]
     '''Obtains charsets to send mail parts not containing patches.'''
-    charsets = [cs.lower() for cs in ui.configlist(b'email', b'charsets')]
+    charsets = [
+        pycompat.sysstr(cs.lower())
+        for cs in ui.configlist(b'email', b'charsets')
+    ]
     fallbacks = [
-        encoding.fallbackencoding.lower(),
-        encoding.encoding.lower(),
-        b'utf-8',
+        pycompat.sysstr(encoding.fallbackencoding.lower()),
+        pycompat.sysstr(encoding.encoding.lower()),
+        'utf-8',
     ]
     for cs in fallbacks:  # find unique charsets while keeping order
         if cs not in charsets:
             charsets.append(cs)
-    return [cs for cs in charsets if not cs.endswith(b'ascii')]
+    return [cs for cs in charsets if not cs.endswith('ascii')]
 
 
 def _encode(ui, s, charsets):
+    # type: (Any, bytes, List[str]) -> Tuple[bytes, str]
     '''Returns (converted) string, charset tuple.
     Finds out best charset by cycling through sendcharsets in descending
     order. Tries both encoding and fallbackencoding for input. Only as
@@ -327,14 +347,17 @@
         # wants, and fall back to garbage-in-ascii.
         for ocs in sendcharsets:
             try:
-                return s.encode(pycompat.sysstr(ocs)), ocs
+                return s.encode(ocs), ocs
             except UnicodeEncodeError:
                 pass
             except LookupError:
-                ui.warn(_(b'ignoring invalid sendcharset: %s\n') % ocs)
+                ui.warn(
+                    _(b'ignoring invalid sendcharset: %s\n')
+                    % pycompat.sysbytes(ocs)
+                )
         else:
             # Everything failed, ascii-armor what we've got and send it.
-            return s.encode('ascii', 'backslashreplace')
+            return s.encode('ascii', 'backslashreplace'), 'us-ascii'
     # We have a bytes of unknown encoding. We'll try and guess a valid
     # encoding, falling back to pretending we had ascii even though we
     # know that's wrong.
@@ -349,27 +372,32 @@
                 continue
             for ocs in sendcharsets:
                 try:
-                    return u.encode(pycompat.sysstr(ocs)), ocs
+                    return u.encode(ocs), ocs
                 except UnicodeEncodeError:
                     pass
                 except LookupError:
-                    ui.warn(_(b'ignoring invalid sendcharset: %s\n') % ocs)
+                    ui.warn(
+                        _(b'ignoring invalid sendcharset: %s\n')
+                        % pycompat.sysbytes(ocs)
+                    )
     # if ascii, or all conversion attempts fail, send (broken) ascii
-    return s, b'us-ascii'
+    return s, 'us-ascii'
 
 
 def headencode(ui, s, charsets=None, display=False):
+    # type: (Any, Union[bytes, str], List[str], bool) -> str
     '''Returns RFC-2047 compliant header from given string.'''
     if not display:
         # split into words?
         s, cs = _encode(ui, s, charsets)
-        return encoding.strtolocal(email.header.Header(s, cs).encode())
-    return s
+        return email.header.Header(s, cs).encode()
+    return encoding.strfromlocal(s)
 
 
 def _addressencode(ui, name, addr, charsets=None):
-    assert isinstance(addr, bytes)
-    name = encoding.strfromlocal(headencode(ui, name, charsets))
+    # type: (Any, str, str, List[str]) -> str
+    addr = encoding.strtolocal(addr)
+    name = headencode(ui, name, charsets)
     try:
         acc, dom = addr.split(b'@')
         acc.decode('ascii')
@@ -383,45 +411,46 @@
             addr.decode('ascii')
         except UnicodeDecodeError:
             raise error.Abort(_(b'invalid local address: %s') % addr)
-    return pycompat.bytesurl(
-        email.utils.formataddr((name, encoding.strfromlocal(addr)))
-    )
+    return email.utils.formataddr((name, encoding.strfromlocal(addr)))
 
 
 def addressencode(ui, address, charsets=None, display=False):
+    # type: (Any, bytes, List[str], bool) -> str
     '''Turns address into RFC-2047 compliant header.'''
     if display or not address:
-        return address or b''
+        return encoding.strfromlocal(address or b'')
     name, addr = email.utils.parseaddr(encoding.strfromlocal(address))
-    return _addressencode(ui, name, encoding.strtolocal(addr), charsets)
+    return _addressencode(ui, name, addr, charsets)
 
 
 def addrlistencode(ui, addrs, charsets=None, display=False):
+    # type: (Any, List[bytes], List[str], bool) -> List[str]
     '''Turns a list of addresses into a list of RFC-2047 compliant headers.
     A single element of input list may contain multiple addresses, but output
     always has one address per item'''
+    straddrs = []
     for a in addrs:
-        assert isinstance(a, bytes), r'%r unexpectedly not a bytestr' % a
+        assert isinstance(a, bytes), '%r unexpectedly not a bytestr' % a
+        straddrs.append(encoding.strfromlocal(a))
     if display:
-        return [a.strip() for a in addrs if a.strip()]
+        return [a.strip() for a in straddrs if a.strip()]
 
     result = []
-    for name, addr in email.utils.getaddresses(
-        [encoding.strfromlocal(a) for a in addrs]
-    ):
+    for name, addr in email.utils.getaddresses(straddrs):
         if name or addr:
-            r = _addressencode(ui, name, encoding.strtolocal(addr), charsets)
+            r = _addressencode(ui, name, addr, charsets)
             result.append(r)
     return result
 
 
 def mimeencode(ui, s, charsets=None, display=False):
+    # type: (Any, bytes, List[str], bool) -> email.message.Message
     '''creates mime text object, encodes it if needed, and sets
     charset and transfer-encoding accordingly.'''
-    cs = b'us-ascii'
+    cs = 'us-ascii'
     if not display:
         s, cs = _encode(ui, s, charsets)
-    return mimetextqp(s, b'plain', cs)
+    return mimetextqp(s, 'plain', cs)
 
 
 if pycompat.ispy3:
@@ -429,12 +458,13 @@
     Generator = email.generator.BytesGenerator
 
     def parse(fp):
+        # type: (Any) -> email.message.Message
         ep = email.parser.Parser()
         # disable the "universal newlines" mode, which isn't binary safe.
         # I have no idea if ascii/surrogateescape is correct, but that's
         # what the standard Python email parser does.
         fp = io.TextIOWrapper(
-            fp, encoding=r'ascii', errors=r'surrogateescape', newline=chr(10)
+            fp, encoding='ascii', errors='surrogateescape', newline=chr(10)
         )
         try:
             return ep.parse(fp)
@@ -442,6 +472,7 @@
             fp.detach()
 
     def parsebytes(data):
+        # type: (bytes) -> email.message.Message
         ep = email.parser.BytesParser()
         return ep.parsebytes(data)
 
@@ -451,15 +482,18 @@
     Generator = email.generator.Generator
 
     def parse(fp):
+        # type: (Any) -> email.message.Message
         ep = email.parser.Parser()
         return ep.parse(fp)
 
     def parsebytes(data):
+        # type: (str) -> email.message.Message
         ep = email.parser.Parser()
         return ep.parsestr(data)
 
 
 def headdecode(s):
+    # type: (Union[email.header.Header, bytes]) -> bytes
     '''Decodes RFC-2047 header'''
     uparts = []
     for part, charset in email.header.decode_header(s):
--- a/mercurial/manifest.py	Wed Nov 20 19:07:02 2019 +0100
+++ b/mercurial/manifest.py	Fri Nov 22 21:42:04 2019 +0900
@@ -23,6 +23,7 @@
 from . import (
     error,
     mdiff,
+    pathutil,
     policy,
     pycompat,
     revlog,
@@ -33,7 +34,7 @@
     util as interfaceutil,
 )
 
-parsers = policy.importmod(r'parsers')
+parsers = policy.importmod('parsers')
 propertycache = util.propertycache
 
 # Allow tests to more easily test the alternate path in manifestdict.fastdelta()
@@ -494,7 +495,7 @@
 
     @propertycache
     def _dirs(self):
-        return util.dirs(self)
+        return pathutil.dirs(self)
 
     def dirs(self):
         return self._dirs
@@ -1104,7 +1105,7 @@
 
     @propertycache
     def _alldirs(self):
-        return util.dirs(self)
+        return pathutil.dirs(self)
 
     def dirs(self):
         return self._alldirs
--- a/mercurial/match.py	Wed Nov 20 19:07:02 2019 +0100
+++ b/mercurial/match.py	Fri Nov 22 21:42:04 2019 +0900
@@ -24,7 +24,7 @@
 )
 from .utils import stringutil
 
-rustmod = policy.importrust(r'filepatterns')
+rustmod = policy.importrust('filepatterns')
 
 allpatternkinds = (
     b're',
@@ -345,7 +345,10 @@
                 ):
                     kindpats.append((k, p, source or pat))
             except error.Abort as inst:
-                raise error.Abort(b'%s: %s' % (pat, inst[0]))
+                raise error.Abort(
+                    b'%s: %s'
+                    % (pat, inst[0])  # pytype: disable=unsupported-operands
+                )
             except IOError as inst:
                 if warn:
                     warn(
@@ -372,10 +375,6 @@
         '''Callback from dirstate.walk for each explicit file that can't be
         found/accessed, with an error message.'''
 
-    # If an explicitdir is set, it will be called when an explicitly listed
-    # directory is visited.
-    explicitdir = None
-
     # If an traversedir is set, it will be called when a directory discovered
     # by recursive traversal is visited.
     traversedir = None
@@ -543,16 +542,6 @@
         return b'<predicatenmatcher pred=%s>' % s
 
 
-def normalizerootdir(dir, funcname):
-    if dir == b'.':
-        util.nouideprecwarn(
-            b"match.%s() no longer accepts '.', use '' instead." % funcname,
-            b'5.1',
-        )
-        return b''
-    return dir
-
-
 class patternmatcher(basematcher):
     r"""Matches a set of (kind, pat, source) against a 'root' directory.
 
@@ -595,17 +584,17 @@
 
     @propertycache
     def _dirs(self):
-        return set(util.dirs(self._fileset))
+        return set(pathutil.dirs(self._fileset))
 
     def visitdir(self, dir):
-        dir = normalizerootdir(dir, b'visitdir')
         if self._prefix and dir in self._fileset:
             return b'all'
         return (
             dir in self._fileset
             or dir in self._dirs
             or any(
-                parentdir in self._fileset for parentdir in util.finddirs(dir)
+                parentdir in self._fileset
+                for parentdir in pathutil.finddirs(dir)
             )
         )
 
@@ -626,9 +615,9 @@
         return b'<patternmatcher patterns=%r>' % pycompat.bytestr(self._pats)
 
 
-# This is basically a reimplementation of util.dirs that stores the children
-# instead of just a count of them, plus a small optional optimization to avoid
-# some directories we don't need.
+# This is basically a reimplementation of pathutil.dirs that stores the
+# children instead of just a count of them, plus a small optional optimization
+# to avoid some directories we don't need.
 class _dirchildren(object):
     def __init__(self, paths, onlyinclude=None):
         self._dirs = {}
@@ -650,7 +639,7 @@
     @staticmethod
     def _findsplitdirs(path):
         # yields (dirname, basename) tuples, walking back to the root.  This is
-        # very similar to util.finddirs, except:
+        # very similar to pathutil.finddirs, except:
         #  - produces a (dirname, basename) tuple, not just 'dirname'
         # Unlike manifest._splittopdir, this does not suffix `dirname` with a
         # slash.
@@ -682,14 +671,15 @@
         self._parents = parents
 
     def visitdir(self, dir):
-        dir = normalizerootdir(dir, b'visitdir')
         if self._prefix and dir in self._roots:
             return b'all'
         return (
             dir in self._roots
             or dir in self._dirs
             or dir in self._parents
-            or any(parentdir in self._roots for parentdir in util.finddirs(dir))
+            or any(
+                parentdir in self._roots for parentdir in pathutil.finddirs(dir)
+            )
         )
 
     @propertycache
@@ -714,7 +704,9 @@
             b'' in self._roots
             or dir in self._roots
             or dir in self._dirs
-            or any(parentdir in self._roots for parentdir in util.finddirs(dir))
+            or any(
+                parentdir in self._roots for parentdir in pathutil.finddirs(dir)
+            )
         ):
             return b'this'
 
@@ -760,15 +752,12 @@
 
     @propertycache
     def _dirs(self):
-        return set(util.dirs(self._fileset))
+        return set(pathutil.dirs(self._fileset))
 
     def visitdir(self, dir):
-        dir = normalizerootdir(dir, b'visitdir')
         return dir in self._dirs
 
     def visitchildrenset(self, dir):
-        dir = normalizerootdir(dir, b'visitchildrenset')
-
         if not self._fileset or dir not in self._dirs:
             return set()
 
@@ -799,8 +788,7 @@
     '''Composes two matchers by matching if the first matches and the second
     does not.
 
-    The second matcher's non-matching-attributes (bad, explicitdir,
-    traversedir) are ignored.
+    The second matcher's non-matching-attributes (bad, traversedir) are ignored.
     '''
 
     def __init__(self, m1, m2):
@@ -808,7 +796,6 @@
         self._m1 = m1
         self._m2 = m2
         self.bad = m1.bad
-        self.explicitdir = m1.explicitdir
         self.traversedir = m1.traversedir
 
     def matchfn(self, f):
@@ -869,8 +856,7 @@
 def intersectmatchers(m1, m2):
     '''Composes two matchers by matching if both of them match.
 
-    The second matcher's non-matching-attributes (bad, explicitdir,
-    traversedir) are ignored.
+    The second matcher's non-matching-attributes (bad, traversedir) are ignored.
     '''
     if m1 is None or m2 is None:
         return m1 or m2
@@ -879,7 +865,6 @@
         # TODO: Consider encapsulating these things in a class so there's only
         # one thing to copy from m1.
         m.bad = m1.bad
-        m.explicitdir = m1.explicitdir
         m.traversedir = m1.traversedir
         return m
     if m2.always():
@@ -894,7 +879,6 @@
         self._m1 = m1
         self._m2 = m2
         self.bad = m1.bad
-        self.explicitdir = m1.explicitdir
         self.traversedir = m1.traversedir
 
     @propertycache
@@ -1005,7 +989,6 @@
         return self._matcher.matchfn(self._path + b"/" + f)
 
     def visitdir(self, dir):
-        dir = normalizerootdir(dir, b'visitdir')
         if dir == b'':
             dir = self._path
         else:
@@ -1013,7 +996,6 @@
         return self._matcher.visitdir(dir)
 
     def visitchildrenset(self, dir):
-        dir = normalizerootdir(dir, b'visitchildrenset')
         if dir == b'':
             dir = self._path
         else:
@@ -1037,8 +1019,7 @@
 class prefixdirmatcher(basematcher):
     """Adapt a matcher to work on a parent directory.
 
-    The matcher's non-matching-attributes (bad, explicitdir, traversedir) are
-    ignored.
+    The matcher's non-matching-attributes (bad, traversedir) are ignored.
 
     The prefix path should usually be the relative path from the root of
     this matcher to the root of the wrapped matcher.
@@ -1086,7 +1067,7 @@
 
     @propertycache
     def _pathdirs(self):
-        return set(util.finddirs(self._path))
+        return set(pathutil.finddirs(self._path))
 
     def visitdir(self, dir):
         if dir == self._path:
@@ -1121,14 +1102,13 @@
 class unionmatcher(basematcher):
     """A matcher that is the union of several matchers.
 
-    The non-matching-attributes (bad, explicitdir, traversedir) are taken from
-    the first matcher.
+    The non-matching-attributes (bad, traversedir) are taken from the first
+    matcher.
     """
 
     def __init__(self, matchers):
         m1 = matchers[0]
         super(unionmatcher, self).__init__()
-        self.explicitdir = m1.explicitdir
         self.traversedir = m1.traversedir
         self._matchers = matchers
 
@@ -1507,8 +1487,8 @@
     p = set()
     # Add the parents as non-recursive/exact directories, since they must be
     # scanned to get to either the roots or the other exact directories.
-    p.update(util.dirs(d))
-    p.update(util.dirs(r))
+    p.update(pathutil.dirs(d))
+    p.update(pathutil.dirs(r))
 
     # FIXME: all uses of this function convert these to sets, do so before
     # returning.
--- a/mercurial/mdiff.py	Wed Nov 20 19:07:02 2019 +0100
+++ b/mercurial/mdiff.py	Fri Nov 22 21:42:04 2019 +0900
@@ -27,8 +27,8 @@
 
 _missing_newline_marker = b"\\ No newline at end of file\n"
 
-bdiff = policy.importmod(r'bdiff')
-mpatch = policy.importmod(r'mpatch')
+bdiff = policy.importmod('bdiff')
+mpatch = policy.importmod('mpatch')
 
 blocks = bdiff.blocks
 fixws = bdiff.fixws
@@ -38,6 +38,7 @@
 splitnewlines = bdiff.splitnewlines
 
 
+# TODO: this looks like it could be an attrs, which might help pytype
 class diffopts(object):
     '''context is the number of context lines
     text treats all files as text
@@ -52,6 +53,8 @@
     upgrade generates git diffs to avoid data loss
     '''
 
+    _HAS_DYNAMIC_ATTRIBUTES = True
+
     defaults = {
         b'context': 3,
         b'text': False,
--- a/mercurial/merge.py	Wed Nov 20 19:07:02 2019 +0100
+++ b/mercurial/merge.py	Fri Nov 22 21:42:04 2019 +0900
@@ -32,6 +32,7 @@
     filemerge,
     match as matchmod,
     obsutil,
+    pathutil,
     pycompat,
     scmutil,
     subrepoutil,
@@ -813,7 +814,7 @@
             return False
 
         # Check for path prefixes that exist as unknown files.
-        for p in reversed(list(util.finddirs(f))):
+        for p in reversed(list(pathutil.finddirs(f))):
             if p in self._missingdircache:
                 return
             if p in self._unknowndircache:
@@ -947,7 +948,7 @@
             backup = (
                 f in fileconflicts
                 or f in pathconflicts
-                or any(p in pathconflicts for p in util.finddirs(f))
+                or any(p in pathconflicts for p in pathutil.finddirs(f))
             )
             (flags,) = args
             actions[f] = (ACTION_GET, (flags, backup), msg)
@@ -1077,7 +1078,7 @@
     in.
     """
     for f in manifest:
-        for p in util.finddirs(f):
+        for p in pathutil.finddirs(f):
             if p in dirs:
                 yield f, p
                 break
@@ -1116,7 +1117,7 @@
             ACTION_CREATED_MERGE,
         ):
             # This action may create a new local file.
-            createdfiledirs.update(util.finddirs(f))
+            createdfiledirs.update(pathutil.finddirs(f))
             if mf.hasdir(f):
                 # The file aliases a local directory.  This might be ok if all
                 # the files in the local directory are being deleted.  This
@@ -1710,7 +1711,7 @@
                 # with a directory this file is in, and if so, back that up.
                 conflicting = f
                 if not repo.wvfs.lexists(f):
-                    for p in util.finddirs(f):
+                    for p in pathutil.finddirs(f):
                         if repo.wvfs.isfileorlink(p):
                             conflicting = p
                             break
@@ -2675,7 +2676,6 @@
 
     # There's no API to copy a matcher. So mutate the passed matcher and
     # restore it when we're done.
-    oldexplicitdir = matcher.explicitdir
     oldtraversedir = matcher.traversedir
 
     res = []
@@ -2683,7 +2683,7 @@
     try:
         if removeemptydirs:
             directories = []
-            matcher.explicitdir = matcher.traversedir = directories.append
+            matcher.traversedir = directories.append
 
         status = repo.status(match=matcher, ignored=ignored, unknown=True)
 
@@ -2705,5 +2705,4 @@
         return res
 
     finally:
-        matcher.explicitdir = oldexplicitdir
         matcher.traversedir = oldtraversedir
--- a/mercurial/obsolete.py	Wed Nov 20 19:07:02 2019 +0100
+++ b/mercurial/obsolete.py	Fri Nov 22 21:42:04 2019 +0900
@@ -87,7 +87,7 @@
 )
 from .utils import dateutil
 
-parsers = policy.importmod(r'parsers')
+parsers = policy.importmod('parsers')
 
 _pack = struct.pack
 _unpack = struct.unpack
@@ -580,7 +580,7 @@
         return len(self._all)
 
     def __nonzero__(self):
-        if not self._cached(r'_all'):
+        if not self._cached('_all'):
             try:
                 return self.svfs.stat(b'obsstore').st_size > 1
             except OSError as inst:
@@ -641,7 +641,7 @@
                 raise ValueError(succ)
         if prec in succs:
             raise ValueError(
-                r'in-marker cycle with %s' % pycompat.sysstr(node.hex(prec))
+                'in-marker cycle with %s' % pycompat.sysstr(node.hex(prec))
             )
 
         metadata = tuple(sorted(pycompat.iteritems(metadata)))
@@ -752,11 +752,11 @@
         markers = list(markers)  # to allow repeated iteration
         self._data = self._data + rawdata
         self._all.extend(markers)
-        if self._cached(r'successors'):
+        if self._cached('successors'):
             _addsuccessors(self.successors, markers)
-        if self._cached(r'predecessors'):
+        if self._cached('predecessors'):
             _addpredecessors(self.predecessors, markers)
-        if self._cached(r'children'):
+        if self._cached('children'):
             _addchildren(self.children, markers)
         _checkinvalidmarkers(markers)
 
@@ -802,7 +802,7 @@
     # rely on obsstore class default when possible.
     kwargs = {}
     if defaultformat is not None:
-        kwargs[r'defaultformat'] = defaultformat
+        kwargs['defaultformat'] = defaultformat
     readonly = not isenabled(repo, createmarkersopt)
     store = obsstore(repo.svfs, readonly=readonly, **kwargs)
     if store and readonly:
@@ -980,7 +980,7 @@
     phase = repo._phasecache.phase  # would be faster to grab the full list
     public = phases.public
     cl = repo.changelog
-    torev = cl.nodemap.get
+    torev = cl.index.get_rev
     tonode = cl.node
     obsstore = repo.obsstore
     for rev in repo.revs(b'(not public()) and (not obsolete())'):
--- a/mercurial/obsutil.py	Wed Nov 20 19:07:02 2019 +0100
+++ b/mercurial/obsutil.py	Fri Nov 22 21:42:04 2019 +0900
@@ -254,7 +254,7 @@
     unfi = repo.unfiltered()
 
     # shortcut to various useful item
-    nm = unfi.changelog.nodemap
+    has_node = unfi.changelog.index.has_node
     precursorsmarkers = unfi.obsstore.predecessors
     successormarkers = unfi.obsstore.successors
     childrenmarkers = unfi.obsstore.children
@@ -302,7 +302,7 @@
                 continue
 
             # is this a locally known node ?
-            known = prec in nm
+            known = has_node(prec)
             # if locally-known and not in the <nodes> set the traversal
             # stop here.
             if known and prec not in nodes:
@@ -333,7 +333,7 @@
     if repo.obsstore:
         # We only need this complicated logic if there is obsolescence
         # XXX will probably deserve an optimised revset.
-        nm = repo.changelog.nodemap
+        has_node = repo.changelog.index.has_node
         plen = -1
         # compute the whole set of successors or descendants
         while len(foreground) != plen:
@@ -341,7 +341,7 @@
             succs = set(c.node() for c in foreground)
             mutable = [c.node() for c in foreground if c.mutable()]
             succs.update(allsuccessors(repo.obsstore, mutable))
-            known = (n for n in succs if n in nm)
+            known = (n for n in succs if has_node(n))
             foreground = set(repo.set(b'%ln::', known))
     return set(c.node() for c in foreground)
 
@@ -483,7 +483,7 @@
 
 def getobsoleted(repo, tr):
     """return the set of pre-existing revisions obsoleted by a transaction"""
-    torev = repo.unfiltered().changelog.nodemap.get
+    torev = repo.unfiltered().changelog.index.get_rev
     phase = repo._phasecache.phase
     succsmarkers = repo.obsstore.successors.get
     public = phases.public
--- a/mercurial/patch.py	Wed Nov 20 19:07:02 2019 +0100
+++ b/mercurial/patch.py	Fri Nov 22 21:42:04 2019 +0900
@@ -217,7 +217,7 @@
     fileobj did not contain a patch. Caller must unlink filename when done.'''
 
     fd, tmpname = pycompat.mkstemp(prefix=b'hg-patch-')
-    tmpfp = os.fdopen(fd, r'wb')
+    tmpfp = os.fdopen(fd, 'wb')
     try:
         yield _extract(ui, fileobj, tmpname, tmpfp)
     finally:
@@ -241,8 +241,8 @@
 
     msg = mail.parse(fileobj)
 
-    subject = msg[r'Subject'] and mail.headdecode(msg[r'Subject'])
-    data[b'user'] = msg[r'From'] and mail.headdecode(msg[r'From'])
+    subject = msg['Subject'] and mail.headdecode(msg['Subject'])
+    data[b'user'] = msg['From'] and mail.headdecode(msg['From'])
     if not subject and not data[b'user']:
         # Not an email, restore parsed headers if any
         subject = (
@@ -255,7 +255,7 @@
     # should try to parse msg['Date']
     parents = []
 
-    nodeid = msg[r'X-Mercurial-Node']
+    nodeid = msg['X-Mercurial-Node']
     if nodeid:
         data[b'nodeid'] = nodeid = mail.headdecode(nodeid)
         ui.debug(b'Node ID: %s\n' % nodeid)
@@ -383,7 +383,7 @@
         return self._ispatchinga(afile) and self._ispatchingb(bfile)
 
     def __repr__(self):
-        return r"<patchmeta %s %r>" % (self.op, self.path)
+        return "<patchmeta %s %r>" % (self.op, self.path)
 
 
 def readgitpatch(lr):
@@ -1225,7 +1225,7 @@
                 ncpatchfp = None
                 try:
                     # Write the initial patch
-                    f = util.nativeeolwriter(os.fdopen(patchfd, r'wb'))
+                    f = util.nativeeolwriter(os.fdopen(patchfd, 'wb'))
                     chunk.header.write(f)
                     chunk.write(f)
                     f.write(
@@ -1245,7 +1245,7 @@
                         ui.warn(_(b"editor exited with exit code %d\n") % ret)
                         continue
                     # Remove comment lines
-                    patchfp = open(patchfn, r'rb')
+                    patchfp = open(patchfn, 'rb')
                     ncpatchfp = stringio()
                     for line in util.iterfile(patchfp):
                         line = util.fromnativeeol(line)
@@ -2605,7 +2605,14 @@
 
     if not changes:
         changes = ctx1.status(ctx2, match=match)
-    modified, added, removed = changes[:3]
+    if isinstance(changes, list):
+        modified, added, removed = changes[:3]
+    else:
+        modified, added, removed = (
+            changes.modified,
+            changes.added,
+            changes.removed,
+        )
 
     if not modified and not added and not removed:
         return []
@@ -2788,7 +2795,7 @@
 
 def difflabel(func, *args, **kw):
     '''yields 2-tuples of (output, label) based on the output of func()'''
-    if kw.get(r'opts') and kw[r'opts'].worddiff:
+    if kw.get('opts') and kw['opts'].worddiff:
         dodiffhunk = diffsinglehunkinline
     else:
         dodiffhunk = diffsinglehunk
--- a/mercurial/pathutil.py	Wed Nov 20 19:07:02 2019 +0100
+++ b/mercurial/pathutil.py	Fri Nov 22 21:42:04 2019 +0900
@@ -9,10 +9,14 @@
 from . import (
     encoding,
     error,
+    policy,
     pycompat,
     util,
 )
 
+rustdirs = policy.importrust('dirstate', 'Dirs')
+parsers = policy.importmod('parsers')
+
 
 def _lowerclean(s):
     return encoding.hfsignoreclean(s.lower())
@@ -271,6 +275,66 @@
         return path
 
 
+def finddirs(path):
+    pos = path.rfind(b'/')
+    while pos != -1:
+        yield path[:pos]
+        pos = path.rfind(b'/', 0, pos)
+    yield b''
+
+
+class dirs(object):
+    '''a multiset of directory names from a set of file paths'''
+
+    def __init__(self, map, skip=None):
+        self._dirs = {}
+        addpath = self.addpath
+        if isinstance(map, dict) and skip is not None:
+            for f, s in pycompat.iteritems(map):
+                if s[0] != skip:
+                    addpath(f)
+        elif skip is not None:
+            raise error.ProgrammingError(
+                b"skip character is only supported with a dict source"
+            )
+        else:
+            for f in map:
+                addpath(f)
+
+    def addpath(self, path):
+        dirs = self._dirs
+        for base in finddirs(path):
+            if base.endswith(b'/'):
+                raise ValueError(
+                    "found invalid consecutive slashes in path: %r" % base
+                )
+            if base in dirs:
+                dirs[base] += 1
+                return
+            dirs[base] = 1
+
+    def delpath(self, path):
+        dirs = self._dirs
+        for base in finddirs(path):
+            if dirs[base] > 1:
+                dirs[base] -= 1
+                return
+            del dirs[base]
+
+    def __iter__(self):
+        return iter(self._dirs)
+
+    def __contains__(self, d):
+        return d in self._dirs
+
+
+if util.safehasattr(parsers, 'dirs'):
+    dirs = parsers.dirs
+
+if rustdirs is not None:
+    dirs = rustdirs
+
+
 # forward two methods from posixpath that do what we need, but we'd
 # rather not let our internals know that we're thinking in posix terms
 # - instead we'll let them be oblivious.
--- a/mercurial/phases.py	Wed Nov 20 19:07:02 2019 +0100
+++ b/mercurial/phases.py	Fri Nov 22 21:42:04 2019 +0900
@@ -134,7 +134,7 @@
 public, draft, secret = range(3)
 internal = INTERNAL_FLAG | HIDEABLE_FLAG
 archived = HIDEABLE_FLAG
-allphases = range(internal + 1)
+allphases = list(range(internal + 1))
 trackedphases = allphases[1:]
 # record phase names
 cmdphasenames = [b'public', b'draft', b'secret']  # known to `hg phase` command
@@ -512,9 +512,9 @@
         Nothing is lost as unknown nodes only hold data for their descendants.
         """
         filtered = False
-        nodemap = repo.changelog.nodemap  # to filter unknown nodes
+        has_node = repo.changelog.index.has_node  # to filter unknown nodes
         for phase, nodes in enumerate(self.phaseroots):
-            missing = sorted(node for node in nodes if node not in nodemap)
+            missing = sorted(node for node in nodes if not has_node(node))
             if missing:
                 for mnode in missing:
                     repo.ui.debug(
@@ -672,7 +672,7 @@
     repo = repo.unfiltered()
     # build list from dictionary
     draftroots = []
-    nodemap = repo.changelog.nodemap  # to filter unknown nodes
+    has_node = repo.changelog.index.has_node  # to filter unknown nodes
     for nhex, phase in pycompat.iteritems(roots):
         if nhex == b'publishing':  # ignore data related to publish option
             continue
@@ -688,7 +688,7 @@
                     % nhex
                 )
         elif phase == draft:
-            if node in nodemap:
+            if has_node(node):
                 draftroots.append(node)
         else:
             repo.ui.warn(
@@ -733,7 +733,7 @@
 
     repo = repo.unfiltered()
     cl = repo.changelog
-    rev = cl.nodemap.get
+    rev = cl.index.get_rev
     if not roots:
         return heads
     if not heads or heads == [nullid]:
--- a/mercurial/policy.py	Wed Nov 20 19:07:02 2019 +0100
+++ b/mercurial/policy.py	Fri Nov 22 21:42:04 2019 +0900
@@ -29,14 +29,14 @@
 policy = b'allow'
 _packageprefs = {
     # policy: (versioned package, pure package)
-    b'c': (r'cext', None),
-    b'allow': (r'cext', r'pure'),
-    b'cffi': (r'cffi', None),
-    b'cffi-allow': (r'cffi', r'pure'),
-    b'py': (None, r'pure'),
+    b'c': ('cext', None),
+    b'allow': ('cext', 'pure'),
+    b'cffi': ('cffi', None),
+    b'cffi-allow': ('cffi', 'pure'),
+    b'py': (None, 'pure'),
     # For now, rust policies impact importrust only
-    b'rust+c': (r'cext', None),
-    b'rust+c-allow': (r'cext', r'pure'),
+    b'rust+c': ('cext', None),
+    b'rust+c-allow': ('cext', 'pure'),
 }
 
 try:
@@ -50,15 +50,15 @@
 #
 # The canonical way to do this is to test platform.python_implementation().
 # But we don't import platform and don't bloat for it here.
-if r'__pypy__' in sys.builtin_module_names:
+if '__pypy__' in sys.builtin_module_names:
     policy = b'cffi'
 
 # Environment variable can always force settings.
 if sys.version_info[0] >= 3:
-    if r'HGMODULEPOLICY' in os.environ:
-        policy = os.environ[r'HGMODULEPOLICY'].encode(r'utf-8')
+    if 'HGMODULEPOLICY' in os.environ:
+        policy = os.environ['HGMODULEPOLICY'].encode('utf-8')
 else:
-    policy = os.environ.get(r'HGMODULEPOLICY', policy)
+    policy = os.environ.get('HGMODULEPOLICY', policy)
 
 
 def _importfrom(pkgname, modname):
@@ -68,7 +68,7 @@
     try:
         fakelocals[modname] = mod = getattr(pkg, modname)
     except AttributeError:
-        raise ImportError(r'cannot import name %s' % modname)
+        raise ImportError('cannot import name %s' % modname)
     # force import; fakelocals[modname] may be replaced with the real module
     getattr(mod, '__doc__', None)
     return fakelocals[modname]
@@ -76,19 +76,19 @@
 
 # keep in sync with "version" in C modules
 _cextversions = {
-    (r'cext', r'base85'): 1,
-    (r'cext', r'bdiff'): 3,
-    (r'cext', r'mpatch'): 1,
-    (r'cext', r'osutil'): 4,
-    (r'cext', r'parsers'): 13,
+    ('cext', 'base85'): 1,
+    ('cext', 'bdiff'): 3,
+    ('cext', 'mpatch'): 1,
+    ('cext', 'osutil'): 4,
+    ('cext', 'parsers'): 16,
 }
 
 # map import request to other package or module
 _modredirects = {
-    (r'cext', r'charencode'): (r'cext', r'parsers'),
-    (r'cffi', r'base85'): (r'pure', r'base85'),
-    (r'cffi', r'charencode'): (r'pure', r'charencode'),
-    (r'cffi', r'parsers'): (r'pure', r'parsers'),
+    ('cext', 'charencode'): ('cext', 'parsers'),
+    ('cffi', 'base85'): ('pure', 'base85'),
+    ('cffi', 'charencode'): ('pure', 'charencode'),
+    ('cffi', 'parsers'): ('pure', 'parsers'),
 }
 
 
@@ -97,8 +97,8 @@
     actual = getattr(mod, 'version', None)
     if actual != expected:
         raise ImportError(
-            r'cannot import module %s.%s '
-            r'(expected version: %d, actual: %r)'
+            'cannot import module %s.%s '
+            '(expected version: %d, actual: %r)'
             % (pkgname, modname, expected, actual)
         )
 
@@ -108,7 +108,7 @@
     try:
         verpkg, purepkg = _packageprefs[policy]
     except KeyError:
-        raise ImportError(r'invalid HGMODULEPOLICY %r' % policy)
+        raise ImportError('invalid HGMODULEPOLICY %r' % policy)
     assert verpkg or purepkg
     if verpkg:
         pn, mn = _modredirects.get((verpkg, modname), (verpkg, modname))
@@ -141,7 +141,7 @@
         return default
 
     try:
-        mod = _importfrom(r'rustext', modname)
+        mod = _importfrom('rustext', modname)
     except ImportError:
         if _isrustpermissive():
             return default
@@ -154,4 +154,4 @@
     except AttributeError:
         if _isrustpermissive():
             return default
-        raise ImportError(r"Cannot import name %s" % member)
+        raise ImportError("Cannot import name %s" % member)
--- a/mercurial/posix.py	Wed Nov 20 19:07:02 2019 +0100
+++ b/mercurial/posix.py	Fri Nov 22 21:42:04 2019 +0900
@@ -32,7 +32,7 @@
     pycompat,
 )
 
-osutil = policy.importmod(r'osutil')
+osutil = policy.importmod('osutil')
 
 normpath = os.path.normpath
 samestat = os.path.samestat
@@ -60,11 +60,11 @@
 
 if not pycompat.ispy3:
 
-    def posixfile(name, mode=r'r', buffering=-1):
+    def posixfile(name, mode='r', buffering=-1):
         fp = open(name, mode=mode, buffering=buffering)
         # The position when opening in append mode is implementation defined, so
         # make it consistent by always seeking to the end.
-        if r'a' in mode:
+        if 'a' in mode:
             fp.seek(0, os.SEEK_END)
         return fp
 
@@ -323,7 +323,10 @@
                     fullpath = os.path.join(cachedir, target)
                     open(fullpath, b'w').close()
                 except IOError as inst:
-                    if inst[0] == errno.EACCES:
+                    if (
+                        inst[0]  # pytype: disable=unsupported-operands
+                        == errno.EACCES
+                    ):
                         # If we can't write to cachedir, just pretend
                         # that the fs is readonly and by association
                         # that the fs won't support symlinks. This
@@ -463,7 +466,7 @@
             u = s.decode('utf-8')
 
         # Decompose then lowercase (HFS+ technote specifies lower)
-        enc = unicodedata.normalize(r'NFD', u).lower().encode('utf-8')
+        enc = unicodedata.normalize('NFD', u).lower().encode('utf-8')
         # drop HFS+ ignored characters
         return encoding.hfsignoreclean(enc)
 
--- a/mercurial/profiling.py	Wed Nov 20 19:07:02 2019 +0100
+++ b/mercurial/profiling.py	Fri Nov 22 21:42:04 2019 +0900
@@ -77,7 +77,7 @@
 @contextlib.contextmanager
 def flameprofile(ui, fp):
     try:
-        from flamegraph import flamegraph
+        from flamegraph import flamegraph  # pytype: disable=import-error
     except ImportError:
         raise error.Abort(
             _(
@@ -167,9 +167,9 @@
         elif profformat == b'hotpath':
             # inconsistent config: profiling.showmin
             limit = ui.configwith(fraction, b'profiling', b'showmin', 0.05)
-            kwargs[r'limit'] = limit
+            kwargs['limit'] = limit
             showtime = ui.configbool(b'profiling', b'showtime')
-            kwargs[r'showtime'] = showtime
+            kwargs['showtime'] = showtime
 
         statprof.display(fp, data=data, format=displayformat, **kwargs)
 
@@ -204,7 +204,7 @@
 
         If the profiler was already started, this has no effect."""
         if not self._entered:
-            raise error.ProgrammingError()
+            raise error.ProgrammingError(b'use a context manager to start')
         if self._started:
             return
         self._started = True
--- a/mercurial/pure/charencode.py	Wed Nov 20 19:07:02 2019 +0100
+++ b/mercurial/pure/charencode.py	Fri Nov 22 21:42:04 2019 +0900
@@ -85,6 +85,6 @@
         jm = _jsonmap
     # non-BMP char is represented as UTF-16 surrogate pair
     u16b = u8chars.decode('utf-8', _utf8strict).encode('utf-16', _utf8strict)
-    u16codes = array.array(r'H', u16b)
+    u16codes = array.array('H', u16b)
     u16codes.pop(0)  # drop BOM
     return b''.join(jm[x] if x < 128 else b'\\u%04x' % x for x in u16codes)
--- a/mercurial/pure/osutil.py	Wed Nov 20 19:07:02 2019 +0100
+++ b/mercurial/pure/osutil.py	Fri Nov 22 21:42:04 2019 +0900
@@ -218,7 +218,7 @@
     def _raiseioerror(name):
         err = ctypes.WinError()
         raise IOError(
-            err.errno, r'%s: %s' % (encoding.strfromlocal(name), err.strerror)
+            err.errno, '%s: %s' % (encoding.strfromlocal(name), err.strerror)
         )
 
     class posixfile(object):
@@ -257,7 +257,7 @@
                 creation = _OPEN_ALWAYS
                 flags |= _O_APPEND
             else:
-                raise ValueError(r"invalid mode: %s" % pycompat.sysstr(mode))
+                raise ValueError("invalid mode: %s" % pycompat.sysstr(mode))
 
             fh = _kernel32.CreateFileA(
                 name,
@@ -280,8 +280,8 @@
             # unfortunately, f.name is '<fdopen>' at this point -- so we store
             # the name on this wrapper. We cannot just assign to f.name,
             # because that attribute is read-only.
-            object.__setattr__(self, r'name', name)
-            object.__setattr__(self, r'_file', f)
+            object.__setattr__(self, 'name', name)
+            object.__setattr__(self, '_file', f)
 
         def __iter__(self):
             return self._file
--- a/mercurial/pure/parsers.py	Wed Nov 20 19:07:02 2019 +0100
+++ b/mercurial/pure/parsers.py	Fri Nov 22 21:42:04 2019 +0900
@@ -10,8 +10,12 @@
 import struct
 import zlib
 
-from ..node import nullid
-from .. import pycompat
+from ..node import nullid, nullrev
+from .. import (
+    pycompat,
+    revlogutils,
+    util,
+)
 
 stringio = pycompat.bytesio
 
@@ -43,10 +47,51 @@
 
 
 class BaseIndexObject(object):
+    @property
+    def nodemap(self):
+        msg = b"index.nodemap is deprecated, use index.[has_node|rev|get_rev]"
+        util.nouideprecwarn(msg, b'5.3', stacklevel=2)
+        return self._nodemap
+
+    @util.propertycache
+    def _nodemap(self):
+        nodemap = revlogutils.NodeMap({nullid: nullrev})
+        for r in range(0, len(self)):
+            n = self[r][7]
+            nodemap[n] = r
+        return nodemap
+
+    def has_node(self, node):
+        """return True if the node exist in the index"""
+        return node in self._nodemap
+
+    def rev(self, node):
+        """return a revision for a node
+
+        If the node is unknown, raise a RevlogError"""
+        return self._nodemap[node]
+
+    def get_rev(self, node):
+        """return a revision for a node
+
+        If the node is unknown, return None"""
+        return self._nodemap.get(node)
+
+    def _stripnodes(self, start):
+        if '_nodemap' in vars(self):
+            for r in range(start, len(self)):
+                n = self[r][7]
+                del self._nodemap[n]
+
+    def clearcaches(self):
+        self.__dict__.pop('_nodemap', None)
+
     def __len__(self):
         return self._lgt + len(self._extra)
 
     def append(self, tup):
+        if '_nodemap' in vars(self):
+            self._nodemap[tup[7]] = len(self)
         self._extra.append(tup)
 
     def _check_index(self, i):
@@ -86,6 +131,7 @@
             raise ValueError(b"deleting slices only supports a:-1 with step 1")
         i = i.start
         self._check_index(i)
+        self._stripnodes(i)
         if i < self._lgt:
             self._data = self._data[: i * indexsize]
             self._lgt = i
@@ -123,6 +169,7 @@
             raise ValueError(b"deleting slices only supports a:-1 with step 1")
         i = i.start
         self._check_index(i)
+        self._stripnodes(i)
         if i < self._lgt:
             self._offsets = self._offsets[:i]
             self._lgt = i
--- a/mercurial/pvec.py	Wed Nov 20 19:07:02 2019 +0100
+++ b/mercurial/pvec.py	Fri Nov 22 21:42:04 2019 +0900
@@ -48,7 +48,7 @@
   different branches
 '''
 
-from __future__ import absolute_import
+from __future__ import absolute_import, division
 
 from .node import nullrev
 from . import (
@@ -57,12 +57,12 @@
 )
 
 _size = 448  # 70 chars b85-encoded
-_bytes = _size / 8
+_bytes = _size // 8
 _depthbits = 24
-_depthbytes = _depthbits / 8
+_depthbytes = _depthbits // 8
 _vecbytes = _bytes - _depthbytes
 _vecbits = _vecbytes * 8
-_radius = (_vecbits - 30) / 2  # high probability vectors are related
+_radius = (_vecbits - 30) // 2  # high probability vectors are related
 
 
 def _bin(bs):
@@ -74,9 +74,10 @@
 
 
 def _str(v, l):
+    # type: (int, int) -> bytes
     bs = b""
     for p in pycompat.xrange(l):
-        bs = chr(v & 255) + bs
+        bs = pycompat.bytechr(v & 255) + bs
         v >>= 8
     return bs
 
@@ -131,7 +132,7 @@
     if hdist > ddist:
         # if delta = 10 and hdist = 100, then we need to go up 55 steps
         # to the ancestor and down 45
-        changes = (hdist - ddist + 1) / 2
+        changes = (hdist - ddist + 1) // 2
     else:
         # must make at least one change
         changes = 1
--- a/mercurial/pycompat.py	Wed Nov 20 19:07:02 2019 +0100
+++ b/mercurial/pycompat.py	Fri Nov 22 21:42:04 2019 +0900
@@ -19,7 +19,7 @@
 import tempfile
 
 ispy3 = sys.version_info[0] >= 3
-ispypy = r'__pypy__' in sys.builtin_module_names
+ispypy = '__pypy__' in sys.builtin_module_names
 
 if not ispy3:
     import cookielib
@@ -94,6 +94,13 @@
     import io
     import struct
 
+    if os.name == r'nt' and sys.version_info >= (3, 6):
+        # MBCS (or ANSI) filesystem encoding must be used as before.
+        # Otherwise non-ASCII filenames in existing repositories would be
+        # corrupted.
+        # This must be set once prior to any fsencode/fsdecode calls.
+        sys._enablelegacywindowsfsencoding()
+
     fsencode = os.fsencode
     fsdecode = os.fsdecode
     oscurdir = os.curdir.encode('ascii')
@@ -139,12 +146,12 @@
     #
     # https://hg.python.org/cpython/file/v3.5.1/Programs/python.c#l55
     #
-    # TODO: On Windows, the native argv is wchar_t, so we'll need a different
-    # workaround to simulate the Python 2 (i.e. ANSI Win32 API) behavior.
+    # On Windows, the native argv is unicode and is converted to MBCS bytes
+    # since we do enable the legacy filesystem encoding.
     if getattr(sys, 'argv', None) is not None:
         sysargv = list(map(os.fsencode, sys.argv))
 
-    bytechr = struct.Struct(r'>B').pack
+    bytechr = struct.Struct('>B').pack
     byterepr = b'%r'.__mod__
 
     class bytestr(bytes):
@@ -416,7 +423,7 @@
         if isinstance(filename, str):
             return filename
         else:
-            raise TypeError(r"expect str, not %s" % type(filename).__name__)
+            raise TypeError("expect str, not %s" % type(filename).__name__)
 
     # In Python 2, fsdecode() has a very chance to receive bytes. So it's
     # better not to touch Python 2 part as it's already working fine.
@@ -493,7 +500,7 @@
     mode=b'w+b', bufsize=-1, suffix=b'', prefix=b'tmp', dir=None, delete=True
 ):
     mode = sysstr(mode)
-    assert r'b' in mode
+    assert 'b' in mode
     return tempfile.NamedTemporaryFile(
         mode, bufsize, suffix=suffix, prefix=prefix, dir=dir, delete=delete
     )
--- a/mercurial/rcutil.py	Wed Nov 20 19:07:02 2019 +0100
+++ b/mercurial/rcutil.py	Fri Nov 22 21:42:04 2019 +0900
@@ -15,6 +15,8 @@
     util,
 )
 
+from .utils import resourceutil
+
 if pycompat.iswindows:
     from . import scmwindows as scmplatform
 else:
@@ -60,9 +62,9 @@
 
 
 def defaultrcpath():
-    '''return rc paths in default.d'''
+    '''return rc paths in defaultrc'''
     path = []
-    defaultpath = os.path.join(util.datapath, b'default.d')
+    defaultpath = os.path.join(resourceutil.datapath, b'defaultrc')
     if os.path.isdir(defaultpath):
         path = _expandrcpath(defaultpath)
     return path
--- a/mercurial/repair.py	Wed Nov 20 19:07:02 2019 +0100
+++ b/mercurial/repair.py	Fri Nov 22 21:42:04 2019 +0900
@@ -24,6 +24,7 @@
     exchange,
     obsolete,
     obsutil,
+    pathutil,
     phases,
     pycompat,
     util,
@@ -476,7 +477,7 @@
         if b'treemanifest' in repo.requirements:
             # This logic is safe if treemanifest isn't enabled, but also
             # pointless, so we skip it if treemanifest isn't enabled.
-            for dir in util.dirs(seenfiles):
+            for dir in pathutil.dirs(seenfiles):
                 i = b'meta/%s/00manifest.i' % dir
                 d = b'meta/%s/00manifest.d' % dir
 
--- a/mercurial/repoview.py	Wed Nov 20 19:07:02 2019 +0100
+++ b/mercurial/repoview.py	Fri Nov 22 21:42:04 2019 +0900
@@ -11,13 +11,18 @@
 import copy
 import weakref
 
-from .node import nullrev
+from .i18n import _
+from .node import (
+    hex,
+    nullrev,
+)
 from .pycompat import (
     delattr,
     getattr,
     setattr,
 )
 from . import (
+    error,
     obsolete,
     phases,
     pycompat,
@@ -54,8 +59,9 @@
     tags = {}
     tagsmod.readlocaltags(repo.ui, repo, tags, {})
     if tags:
-        rev, nodemap = cl.rev, cl.nodemap
-        pinned.update(rev(t[0]) for t in tags.values() if t[0] in nodemap)
+        rev = cl.index.get_rev
+        pinned.update(rev(t[0]) for t in tags.values())
+        pinned.discard(None)
     return pinned
 
 
@@ -218,6 +224,118 @@
     return repo.filteredrevcache[filtername]
 
 
+def wrapchangelog(unfichangelog, filteredrevs):
+    cl = copy.copy(unfichangelog)
+    cl.filteredrevs = filteredrevs
+
+    class filteredchangelog(filteredchangelogmixin, cl.__class__):
+        pass
+
+    cl.__class__ = filteredchangelog
+
+    return cl
+
+
+class filteredchangelogmixin(object):
+    def tiprev(self):
+        """filtered version of revlog.tiprev"""
+        for i in pycompat.xrange(len(self) - 1, -2, -1):
+            if i not in self.filteredrevs:
+                return i
+
+    def __contains__(self, rev):
+        """filtered version of revlog.__contains__"""
+        return 0 <= rev < len(self) and rev not in self.filteredrevs
+
+    def __iter__(self):
+        """filtered version of revlog.__iter__"""
+
+        def filterediter():
+            for i in pycompat.xrange(len(self)):
+                if i not in self.filteredrevs:
+                    yield i
+
+        return filterediter()
+
+    def revs(self, start=0, stop=None):
+        """filtered version of revlog.revs"""
+        for i in super(filteredchangelogmixin, self).revs(start, stop):
+            if i not in self.filteredrevs:
+                yield i
+
+    def _checknofilteredinrevs(self, revs):
+        """raise the appropriate error if 'revs' contains a filtered revision
+
+        This returns a version of 'revs' to be used thereafter by the caller.
+        In particular, if revs is an iterator, it is converted into a set.
+        """
+        safehasattr = util.safehasattr
+        if safehasattr(revs, '__next__'):
+            # Note that inspect.isgenerator() is not true for iterators,
+            revs = set(revs)
+
+        filteredrevs = self.filteredrevs
+        if safehasattr(revs, 'first'):  # smartset
+            offenders = revs & filteredrevs
+        else:
+            offenders = filteredrevs.intersection(revs)
+
+        for rev in offenders:
+            raise error.FilteredIndexError(rev)
+        return revs
+
+    def headrevs(self, revs=None):
+        if revs is None:
+            try:
+                return self.index.headrevsfiltered(self.filteredrevs)
+            # AttributeError covers non-c-extension environments and
+            # old c extensions without filter handling.
+            except AttributeError:
+                return self._headrevs()
+
+        revs = self._checknofilteredinrevs(revs)
+        return super(filteredchangelogmixin, self).headrevs(revs)
+
+    def strip(self, *args, **kwargs):
+        # XXX make something better than assert
+        # We can't expect proper strip behavior if we are filtered.
+        assert not self.filteredrevs
+        super(filteredchangelogmixin, self).strip(*args, **kwargs)
+
+    def rev(self, node):
+        """filtered version of revlog.rev"""
+        r = super(filteredchangelogmixin, self).rev(node)
+        if r in self.filteredrevs:
+            raise error.FilteredLookupError(
+                hex(node), self.indexfile, _(b'filtered node')
+            )
+        return r
+
+    def node(self, rev):
+        """filtered version of revlog.node"""
+        if rev in self.filteredrevs:
+            raise error.FilteredIndexError(rev)
+        return super(filteredchangelogmixin, self).node(rev)
+
+    def linkrev(self, rev):
+        """filtered version of revlog.linkrev"""
+        if rev in self.filteredrevs:
+            raise error.FilteredIndexError(rev)
+        return super(filteredchangelogmixin, self).linkrev(rev)
+
+    def parentrevs(self, rev):
+        """filtered version of revlog.parentrevs"""
+        if rev in self.filteredrevs:
+            raise error.FilteredIndexError(rev)
+        return super(filteredchangelogmixin, self).parentrevs(rev)
+
+    def flags(self, rev):
+        """filtered version of revlog.flags"""
+        if rev in self.filteredrevs:
+            raise error.FilteredIndexError(rev)
+        return super(filteredchangelogmixin, self).flags(rev)
+
+
 class repoview(object):
     """Provide a read/write view of a repo through a filtered changelog
 
@@ -254,12 +372,12 @@
     """
 
     def __init__(self, repo, filtername, visibilityexceptions=None):
-        object.__setattr__(self, r'_unfilteredrepo', repo)
-        object.__setattr__(self, r'filtername', filtername)
-        object.__setattr__(self, r'_clcachekey', None)
-        object.__setattr__(self, r'_clcache', None)
+        object.__setattr__(self, '_unfilteredrepo', repo)
+        object.__setattr__(self, 'filtername', filtername)
+        object.__setattr__(self, '_clcachekey', None)
+        object.__setattr__(self, '_clcache', None)
         # revs which are exceptions and must not be hidden
-        object.__setattr__(self, r'_visibilityexceptions', visibilityexceptions)
+        object.__setattr__(self, '_visibilityexceptions', visibilityexceptions)
 
     # not a propertycache on purpose we shall implement a proper cache later
     @property
@@ -286,10 +404,10 @@
             cl = None
         # could have been made None by the previous if
         if cl is None:
-            cl = copy.copy(unfichangelog)
-            cl.filteredrevs = revs
-            object.__setattr__(self, r'_clcache', cl)
-            object.__setattr__(self, r'_clcachekey', newkey)
+            # Only filter if there's something to filter
+            cl = wrapchangelog(unfichangelog, revs) if revs else unfichangelog
+            object.__setattr__(self, '_clcache', cl)
+            object.__setattr__(self, '_clcachekey', newkey)
         return cl
 
     def unfiltered(self):
@@ -303,7 +421,7 @@
         return self.unfiltered().filtered(name, visibilityexceptions)
 
     def __repr__(self):
-        return r'<%s:%s %r>' % (
+        return '<%s:%s %r>' % (
             self.__class__.__name__,
             pycompat.sysstr(self.filtername),
             self.unfiltered(),
--- a/mercurial/revlog.py	Wed Nov 20 19:07:02 2019 +0100
+++ b/mercurial/revlog.py	Fri Nov 22 21:42:04 2019 +0900
@@ -65,6 +65,7 @@
     mdiff,
     policy,
     pycompat,
+    revlogutils,
     templatefilters,
     util,
 )
@@ -102,9 +103,9 @@
 REVIDX_FLAGS_ORDER
 REVIDX_RAWTEXT_CHANGING_FLAGS
 
-parsers = policy.importmod(r'parsers')
-rustancestor = policy.importrust(r'ancestor')
-rustdagop = policy.importrust(r'dagop')
+parsers = policy.importmod('parsers')
+rustancestor = policy.importrust('ancestor')
+rustdagop = policy.importrust('dagop')
 
 # Aliased for performance.
 _zlibdecompress = zlib.decompress
@@ -204,6 +205,50 @@
 
 
 class revlogoldindex(list):
+    @property
+    def nodemap(self):
+        msg = b"index.nodemap is deprecated, use index.[has_node|rev|get_rev]"
+        util.nouideprecwarn(msg, b'5.3', stacklevel=2)
+        return self._nodemap
+
+    @util.propertycache
+    def _nodemap(self):
+        nodemap = revlogutils.NodeMap({nullid: nullrev})
+        for r in range(0, len(self)):
+            n = self[r][7]
+            nodemap[n] = r
+        return nodemap
+
+    def has_node(self, node):
+        """return True if the node exist in the index"""
+        return node in self._nodemap
+
+    def rev(self, node):
+        """return a revision for a node
+
+        If the node is unknown, raise a RevlogError"""
+        return self._nodemap[node]
+
+    def get_rev(self, node):
+        """return a revision for a node
+
+        If the node is unknown, return None"""
+        return self._nodemap.get(node)
+
+    def append(self, tup):
+        self._nodemap[tup[7]] = len(self)
+        super(revlogoldindex, self).append(tup)
+
+    def __delitem__(self, i):
+        if not isinstance(i, slice) or not i.stop == -1 or i.step is not None:
+            raise ValueError(b"deleting slices only supports a:-1 with step 1")
+        for r in pycompat.xrange(i.start, len(self)):
+            del self._nodemap[self[r][7]]
+        super(revlogoldindex, self).__delitem__(i)
+
+    def clearcaches(self):
+        self.__dict__.pop('_nodemap', None)
+
     def __getitem__(self, i):
         if i == -1:
             return (0, 0, 0, -1, -1, -1, -1, nullid)
@@ -217,7 +262,7 @@
     def parseindex(self, data, inline):
         s = self.size
         index = []
-        nodemap = {nullid: nullrev}
+        nodemap = revlogutils.NodeMap({nullid: nullrev})
         n = off = 0
         l = len(data)
         while off + s <= l:
@@ -239,7 +284,8 @@
             nodemap[e[6]] = n
             n += 1
 
-        return revlogoldindex(index), nodemap, None
+        index = revlogoldindex(index)
+        return index, None
 
     def packentry(self, entry, node, version, rev):
         if gettype(entry[0]):
@@ -286,7 +332,7 @@
     def parseindex(self, data, inline):
         # call the C implementation to parse the index data
         index, cache = parsers.parse_index2(data, inline)
-        return index, getattr(index, 'nodemap', None), cache
+        return index, cache
 
     def packentry(self, entry, node, version, rev):
         p = indexformatng_pack(*entry)
@@ -371,12 +417,10 @@
         self._chunkcachesize = 65536
         self._maxchainlen = None
         self._deltabothparents = True
-        self.index = []
+        self.index = None
         # Mapping of partial identifiers to full nodes.
         self._pcache = {}
         # Mapping of revision integer to full node.
-        self._nodecache = {nullid: nullrev}
-        self._nodepos = None
         self._compengine = b'zlib'
         self._compengineopts = {}
         self._maxdeltachainspan = -1
@@ -539,9 +583,7 @@
             raise error.RevlogError(
                 _(b"index %s is corrupted") % self.indexfile
             )
-        self.index, nodemap, self._chunkcache = d
-        if nodemap is not None:
-            self.nodemap = self._nodecache = nodemap
+        self.index, self._chunkcache = d
         if not self._chunkcache:
             self._chunkclear()
         # revnum -> (chain-length, sum-delta-length)
@@ -556,11 +598,11 @@
 
     def _indexfp(self, mode=b'r'):
         """file object for the revlog's index file"""
-        args = {r'mode': mode}
+        args = {'mode': mode}
         if mode != b'r':
-            args[r'checkambig'] = self._checkambig
+            args['checkambig'] = self._checkambig
         if mode == b'w':
-            args[r'atomictemp'] = True
+            args['atomictemp'] = True
         return self.opener(self.indexfile, **args)
 
     def _datafp(self, mode=b'r'):
@@ -593,8 +635,11 @@
             with func() as fp:
                 yield fp
 
+    def tiprev(self):
+        return len(self.index) - 1
+
     def tip(self):
-        return self.node(len(self.index) - 1)
+        return self.node(self.tiprev())
 
     def __contains__(self, rev):
         return 0 <= rev < len(self)
@@ -609,13 +654,20 @@
         """iterate over all rev in this revlog (from start to stop)"""
         return storageutil.iterrevs(len(self), start=start, stop=stop)
 
-    @util.propertycache
+    @property
     def nodemap(self):
-        if self.index:
-            # populate mapping down to the initial node
-            node0 = self.index[0][7]  # get around changelog filtering
-            self.rev(node0)
-        return self._nodecache
+        msg = (
+            b"revlog.nodemap is deprecated, "
+            b"use revlog.index.[has_node|rev|get_rev]"
+        )
+        util.nouideprecwarn(msg, b'5.3', stacklevel=2)
+        return self.index.nodemap
+
+    @property
+    def _nodecache(self):
+        msg = b"revlog._nodecache is deprecated, use revlog.index.nodemap"
+        util.nouideprecwarn(msg, b'5.3', stacklevel=2)
+        return self.index.nodemap
 
     def hasnode(self, node):
         try:
@@ -642,19 +694,11 @@
         self._chainbasecache.clear()
         self._chunkcache = (0, b'')
         self._pcache = {}
-
-        try:
-            # If we are using the native C version, you are in a fun case
-            # where self.index, self.nodemap and self._nodecaches is the same
-            # object.
-            self._nodecache.clearcaches()
-        except AttributeError:
-            self._nodecache = {nullid: nullrev}
-            self._nodepos = None
+        self.index.clearcaches()
 
     def rev(self, node):
         try:
-            return self._nodecache[node]
+            return self.index.rev(node)
         except TypeError:
             raise
         except error.RevlogError:
@@ -662,24 +706,6 @@
             if node == wdirid or node in wdirfilenodeids:
                 raise error.WdirUnsupported
             raise error.LookupError(node, self.indexfile, _(b'no node'))
-        except KeyError:
-            # pure python cache lookup failed
-            n = self._nodecache
-            i = self.index
-            p = self._nodepos
-            if p is None:
-                p = len(i) - 1
-            else:
-                assert p < len(i)
-            for r in pycompat.xrange(p, -1, -1):
-                v = i[r][7]
-                n[v] = r
-                if v == node:
-                    self._nodepos = r - 1
-                    return r
-            if node == wdirid or node in wdirfilenodeids:
-                raise error.WdirUnsupported
-            raise error.LookupError(node, self.indexfile, _(b'no node'))
 
     # Accessors for index entries.
 
@@ -1986,7 +2012,7 @@
             )
 
         node = node or self.hash(rawtext, p1, p2)
-        if node in self.nodemap:
+        if self.index.has_node(node):
             return node
 
         if validatehash:
@@ -2195,12 +2221,6 @@
             node,
         )
         self.index.append(e)
-        self.nodemap[node] = curr
-
-        # Reset the pure node cache start lookup offset to account for new
-        # revision.
-        if self._nodepos is not None:
-            self._nodepos = curr
 
         entry = self._io.packentry(e, self.node, self.version, curr)
         self._writeentry(
@@ -2298,18 +2318,18 @@
 
                 nodes.append(node)
 
-                if node in self.nodemap:
+                if self.index.has_node(node):
                     self._nodeduplicatecallback(transaction, node)
                     # this can happen if two branches make the same change
                     continue
 
                 for p in (p1, p2):
-                    if p not in self.nodemap:
+                    if not self.index.has_node(p):
                         raise error.LookupError(
                             p, self.indexfile, _(b'unknown parent')
                         )
 
-                if deltabase not in self.nodemap:
+                if not self.index.has_node(deltabase):
                     raise error.LookupError(
                         deltabase, self.indexfile, _(b'unknown delta base')
                     )
@@ -2434,11 +2454,8 @@
         self._revisioncache = None
         self._chaininfocache = {}
         self._chunkclear()
-        for x in pycompat.xrange(rev, len(self)):
-            del self.nodemap[self.node(x)]
 
         del self.index[rev:-1]
-        self._nodepos = None
 
     def checksize(self):
         """Check size of index and data files
--- a/mercurial/revlogutils/__init__.py	Wed Nov 20 19:07:02 2019 +0100
+++ b/mercurial/revlogutils/__init__.py	Fri Nov 22 21:42:04 2019 +0900
@@ -0,0 +1,14 @@
+# mercurial.revlogutils -- basic utilities for revlog
+#
+# Copyright 2019 Pierre-Yves David <pierre-yves.david@octobus.net>
+#
+# This software may be used and distributed according to the terms of the
+# GNU General Public License version 2 or any later version.
+
+from __future__ import absolute_import
+from .. import error
+
+
+class NodeMap(dict):
+    def __missing__(self, x):
+        raise error.RevlogError(b'unknown node: %s' % x)
--- a/mercurial/revlogutils/sidedata.py	Wed Nov 20 19:07:02 2019 +0100
+++ b/mercurial/revlogutils/sidedata.py	Fri Nov 22 21:42:04 2019 +0900
@@ -55,8 +55,8 @@
 SD_FILESREMOVED = 11
 
 # internal format constant
-SIDEDATA_HEADER = struct.Struct(r'>H')
-SIDEDATA_ENTRY = struct.Struct(r'>HL20s')
+SIDEDATA_HEADER = struct.Struct('>H')
+SIDEDATA_ENTRY = struct.Struct('>HL20s')
 
 
 def sidedatawriteprocessor(rl, text, sidedata):
--- a/mercurial/revset.py	Wed Nov 20 19:07:02 2019 +0100
+++ b/mercurial/revset.py	Fri Nov 22 21:42:04 2019 +0900
@@ -673,6 +673,7 @@
     1: added
     2: removed
     """
+    label = {0: 'modified', 1: 'added', 2: 'removed'}[field]
     hasset = matchmod.patkind(pat) == b'set'
 
     mcache = [None]
@@ -683,25 +684,23 @@
             mcache[0] = matchmod.match(repo.root, repo.getcwd(), [pat], ctx=c)
         m = mcache[0]
         fname = None
+
+        assert m is not None  # help pytype
         if not m.anypats() and len(m.files()) == 1:
             fname = m.files()[0]
         if fname is not None:
             if fname not in c.files():
                 return False
         else:
-            for f in c.files():
-                if m(f):
-                    break
-            else:
+            if not any(m(f) for f in c.files()):
                 return False
-        files = repo.status(c.p1().node(), c.node())[field]
+        files = getattr(repo.status(c.p1().node(), c.node()), label)
         if fname is not None:
             if fname in files:
                 return True
         else:
-            for f in files:
-                if m(f):
-                    return True
+            if any(m(f) for f in files):
+                return True
 
     return subset.filter(matches, condrepr=(b'<status[%r] %r>', field, pat))
 
@@ -2406,10 +2405,10 @@
     filtering.
     """
     cl = repo.unfiltered().changelog
-    torev = cl.rev
+    torev = cl.index.get_rev
     tonode = cl.node
-    nodemap = cl.nodemap
-    result = set(torev(n) for n in f(tonode(r) for r in s) if n in nodemap)
+    result = set(torev(n) for n in f(tonode(r) for r in s))
+    result.discard(None)
     return smartset.baseset(result - repo.changelog.filteredrevs)
 
 
--- a/mercurial/scmposix.py	Wed Nov 20 19:07:02 2019 +0100
+++ b/mercurial/scmposix.py	Fri Nov 22 21:42:04 2019 +0900
@@ -84,13 +84,13 @@
             if not os.isatty(fd):
                 continue
             arri = fcntl.ioctl(fd, TIOCGWINSZ, b'\0' * 8)
-            height, width = array.array(r'h', arri)[:2]
+            height, width = array.array('h', arri)[:2]
             if width > 0 and height > 0:
                 return width, height
         except ValueError:
             pass
         except IOError as e:
-            if e[0] == errno.EINVAL:
+            if e[0] == errno.EINVAL:  # pytype: disable=unsupported-operands
                 pass
             else:
                 raise
--- a/mercurial/scmutil.py	Wed Nov 20 19:07:02 2019 +0100
+++ b/mercurial/scmutil.py	Fri Nov 22 21:42:04 2019 +0900
@@ -27,7 +27,7 @@
     wdirrev,
 )
 from .pycompat import getattr
-
+from .thirdparty import attr
 from . import (
     copies as copiesmod,
     encoding,
@@ -57,63 +57,37 @@
 else:
     from . import scmposix as scmplatform
 
-parsers = policy.importmod(r'parsers')
+parsers = policy.importmod('parsers')
 
 termsize = scmplatform.termsize
 
 
-class status(tuple):
-    '''Named tuple with a list of files per status. The 'deleted', 'unknown'
-       and 'ignored' properties are only relevant to the working copy.
+@attr.s(slots=True, repr=False)
+class status(object):
+    '''Struct with a list of files per status.
+
+    The 'deleted', 'unknown' and 'ignored' properties are only
+    relevant to the working copy.
     '''
 
-    __slots__ = ()
-
-    def __new__(
-        cls, modified, added, removed, deleted, unknown, ignored, clean
-    ):
-        return tuple.__new__(
-            cls, (modified, added, removed, deleted, unknown, ignored, clean)
-        )
-
-    @property
-    def modified(self):
-        '''files that have been modified'''
-        return self[0]
-
-    @property
-    def added(self):
-        '''files that have been added'''
-        return self[1]
-
-    @property
-    def removed(self):
-        '''files that have been removed'''
-        return self[2]
+    modified = attr.ib(default=list)
+    added = attr.ib(default=list)
+    removed = attr.ib(default=list)
+    deleted = attr.ib(default=list)
+    unknown = attr.ib(default=list)
+    ignored = attr.ib(default=list)
+    clean = attr.ib(default=list)
 
-    @property
-    def deleted(self):
-        '''files that are in the dirstate, but have been deleted from the
-           working copy (aka "missing")
-        '''
-        return self[3]
-
-    @property
-    def unknown(self):
-        '''files not in the dirstate that are not ignored'''
-        return self[4]
+    def __iter__(self):
+        yield self.modified
+        yield self.added
+        yield self.removed
+        yield self.deleted
+        yield self.unknown
+        yield self.ignored
+        yield self.clean
 
-    @property
-    def ignored(self):
-        '''files not in the dirstate that are ignored (by _dirignore())'''
-        return self[5]
-
-    @property
-    def clean(self):
-        '''files that have not been modified'''
-        return self[6]
-
-    def __repr__(self, *args, **kwargs):
+    def __repr__(self):
         return (
             r'<status modified=%s, added=%s, removed=%s, deleted=%s, '
             r'unknown=%s, ignored=%s, clean=%s>'
@@ -964,7 +938,7 @@
         ui.note(_(b'creating directory: %s\n') % origvfs.join(origbackupdir))
 
         # Remove any files that conflict with the backup file's path
-        for f in reversed(list(util.finddirs(filepath))):
+        for f in reversed(list(pathutil.finddirs(filepath))):
             if origvfs.isfileorlink(f):
                 ui.note(_(b'removing conflicting file: %s\n') % origvfs.join(f))
                 origvfs.unlink(f)
@@ -1943,6 +1917,7 @@
         def wrapped(tr):
             repo = reporef()
             if filtername:
+                assert repo is not None  # help pytype
                 repo = repo.filtered(filtername)
             func(repo, tr)
 
@@ -1962,6 +1937,7 @@
             if cgheads:
                 htext = _(b" (%+d heads)") % cgheads
             msg = _(b"added %d changesets with %d changes to %d files%s\n")
+            assert repo is not None  # help pytype
             repo.ui.status(msg % (cgchangesets, cgrevisions, cgfiles, htext))
 
     if txmatch(_reportobsoletedsource):
--- a/mercurial/setdiscovery.py	Wed Nov 20 19:07:02 2019 +0100
+++ b/mercurial/setdiscovery.py	Fri Nov 22 21:42:04 2019 +0900
@@ -278,7 +278,7 @@
 
 
 partialdiscovery = policy.importrust(
-    r'discovery', member=r'PartialDiscovery', default=partialdiscovery
+    'discovery', member='PartialDiscovery', default=partialdiscovery
 )
 
 
--- a/mercurial/simplemerge.py	Wed Nov 20 19:07:02 2019 +0100
+++ b/mercurial/simplemerge.py	Fri Nov 22 21:42:04 2019 +0900
@@ -291,7 +291,19 @@
             if region[0] != b"conflict":
                 yield region
                 continue
-            issue, z1, z2, a1, a2, b1, b2 = region
+            # pytype thinks this tuple contains only 3 things, but
+            # that's clearly not true because this code successfully
+            # executes. It might be wise to rework merge_regions to be
+            # some kind of attrs type.
+            (
+                issue,
+                z1,
+                z2,
+                a1,
+                a2,
+                b1,
+                b2,
+            ) = region  # pytype: disable=bad-unpacking
             alen = a2 - a1
             blen = b2 - b1
 
--- a/mercurial/smartset.py	Wed Nov 20 19:07:02 2019 +0100
+++ b/mercurial/smartset.py	Fri Nov 22 21:42:04 2019 +0900
@@ -256,7 +256,7 @@
     @util.propertycache
     def _list(self):
         # _list is only lazily constructed if we have _set
-        assert r'_set' in self.__dict__
+        assert '_set' in self.__dict__
         return list(self._set)
 
     def __iter__(self):
@@ -294,7 +294,7 @@
         self._istopo = False
 
     def __len__(self):
-        if r'_list' in self.__dict__:
+        if '_list' in self.__dict__:
             return len(self._list)
         else:
             return len(self._set)
@@ -347,8 +347,8 @@
         # try to use native set operations as fast paths
         if (
             type(other) is baseset
-            and r'_set' in other.__dict__
-            and r'_set' in self.__dict__
+            and '_set' in other.__dict__
+            and '_set' in self.__dict__
             and self._ascending is not None
         ):
             s = baseset(
--- a/mercurial/sslutil.py	Wed Nov 20 19:07:02 2019 +0100
+++ b/mercurial/sslutil.py	Fri Nov 22 21:42:04 2019 +0900
@@ -24,7 +24,7 @@
     util,
 )
 from .utils import (
-    procutil,
+    resourceutil,
     stringutil,
 )
 
@@ -103,13 +103,13 @@
             # in this legacy code since we don't support SNI.
 
             args = {
-                r'keyfile': self._keyfile,
-                r'certfile': self._certfile,
-                r'server_side': server_side,
-                r'cert_reqs': self.verify_mode,
-                r'ssl_version': self.protocol,
-                r'ca_certs': self._cacerts,
-                r'ciphers': self._ciphers,
+                'keyfile': self._keyfile,
+                'certfile': self._certfile,
+                'server_side': server_side,
+                'cert_reqs': self.verify_mode,
+                'ssl_version': self.protocol,
+                'ca_certs': self._cacerts,
+                'ciphers': self._ciphers,
             }
 
             return ssl.wrap_socket(socket, **args)
@@ -499,7 +499,7 @@
             # outright. Hopefully the reason for this error is that we require
             # TLS 1.1+ and the server only supports TLS 1.0. Whatever the
             # reason, try to emit an actionable warning.
-            if e.reason == r'UNSUPPORTED_PROTOCOL':
+            if e.reason == 'UNSUPPORTED_PROTOCOL':
                 # We attempted TLS 1.0+.
                 if settings[b'protocolui'] == b'tls1.0':
                     # We support more than just TLS 1.0+. If this happens,
@@ -568,9 +568,7 @@
                         )
                     )
 
-            elif (
-                e.reason == r'CERTIFICATE_VERIFY_FAILED' and pycompat.iswindows
-            ):
+            elif e.reason == 'CERTIFICATE_VERIFY_FAILED' and pycompat.iswindows:
 
                 ui.warn(
                     _(
@@ -737,9 +735,9 @@
         return _(b'no certificate received')
 
     dnsnames = []
-    san = cert.get(r'subjectAltName', [])
+    san = cert.get('subjectAltName', [])
     for key, value in san:
-        if key == r'DNS':
+        if key == 'DNS':
             try:
                 if _dnsnamematch(value, hostname):
                     return
@@ -750,11 +748,11 @@
 
     if not dnsnames:
         # The subject is only checked when there is no DNS in subjectAltName.
-        for sub in cert.get(r'subject', []):
+        for sub in cert.get('subject', []):
             for key, value in sub:
                 # According to RFC 2818 the most specific Common Name must
                 # be used.
-                if key == r'commonName':
+                if key == 'commonName':
                     # 'subject' entries are unicode.
                     try:
                         value = value.encode('ascii')
@@ -788,7 +786,7 @@
     """
     if (
         not pycompat.isdarwin
-        or procutil.mainfrozen()
+        or resourceutil.mainfrozen()
         or not pycompat.sysexecutable
     ):
         return False
--- a/mercurial/state.py	Wed Nov 20 19:07:02 2019 +0100
+++ b/mercurial/state.py	Fri Nov 22 21:42:04 2019 +0900
@@ -27,6 +27,15 @@
 )
 from .utils import cborutil
 
+if not globals():
+    from typing import (
+        Any,
+        Dict,
+    )
+
+    for t in (Any, Dict):
+        assert t
+
 
 class cmdstate(object):
     """a wrapper class to store the state of commands like `rebase`, `graft`,
@@ -50,6 +59,7 @@
         self.fname = fname
 
     def read(self):
+        # type: () -> Dict[bytes, Any]
         """read the existing state file and return a dict of data stored"""
         return self._read()
 
--- a/mercurial/statichttprepo.py	Wed Nov 20 19:07:02 2019 +0100
+++ b/mercurial/statichttprepo.py	Fri Nov 22 21:42:04 2019 +0900
@@ -53,7 +53,7 @@
         if bytes:
             end = self.pos + bytes - 1
         if self.pos or end:
-            req.add_header(r'Range', r'bytes=%d-%s' % (self.pos, end))
+            req.add_header('Range', 'bytes=%d-%s' % (self.pos, end))
 
         try:
             f = self.opener.open(req)
--- a/mercurial/statprof.py	Wed Nov 20 19:07:02 2019 +0100
+++ b/mercurial/statprof.py	Fri Nov 22 21:42:04 2019 +0900
@@ -126,20 +126,20 @@
 __all__ = [b'start', b'stop', b'reset', b'display', b'profile']
 
 skips = {
-    r"util.py:check",
-    r"extensions.py:closure",
-    r"color.py:colorcmd",
-    r"dispatch.py:checkargs",
-    r"dispatch.py:<lambda>",
-    r"dispatch.py:_runcatch",
-    r"dispatch.py:_dispatch",
-    r"dispatch.py:_runcommand",
-    r"pager.py:pagecmd",
-    r"dispatch.py:run",
-    r"dispatch.py:dispatch",
-    r"dispatch.py:runcommand",
-    r"hg.py:<module>",
-    r"evolve.py:warnobserrors",
+    "util.py:check",
+    "extensions.py:closure",
+    "color.py:colorcmd",
+    "dispatch.py:checkargs",
+    "dispatch.py:<lambda>",
+    "dispatch.py:_runcatch",
+    "dispatch.py:_dispatch",
+    "dispatch.py:_runcommand",
+    "pager.py:pagecmd",
+    "dispatch.py:run",
+    "dispatch.py:dispatch",
+    "dispatch.py:runcommand",
+    "hg.py:<module>",
+    "evolve.py:warnobserrors",
 }
 
 ###########################################################################
@@ -206,7 +206,7 @@
 class CodeSite(object):
     cache = {}
 
-    __slots__ = (r'path', r'lineno', r'function', r'source')
+    __slots__ = ('path', 'lineno', 'function', 'source')
 
     def __init__(self, path, lineno, function):
         assert isinstance(path, bytes)
@@ -258,11 +258,11 @@
         return os.path.basename(self.path)
 
     def skipname(self):
-        return r'%s:%s' % (self.filename(), self.function)
+        return '%s:%s' % (self.filename(), self.function)
 
 
 class Sample(object):
-    __slots__ = (r'stack', r'time')
+    __slots__ = ('stack', 'time')
 
     def __init__(self, stack, time):
         self.stack = stack
@@ -352,7 +352,7 @@
             frame = inspect.currentframe()
             tid = [k for k, f in sys._current_frames().items() if f == frame][0]
             state.thread = threading.Thread(
-                target=samplerthread, args=(tid,), name=b"samplerthread"
+                target=samplerthread, args=(tid,), name="samplerthread"
             )
             state.thread.start()
 
@@ -738,7 +738,7 @@
     for sample in data.samples:
         root.add(sample.stack[::-1], sample.time - lasttime)
         lasttime = sample.time
-    showtime = kwargs.get(r'showtime', True)
+    showtime = kwargs.get('showtime', True)
 
     def _write(node, depth, multiple_siblings):
         site = node.site
@@ -894,7 +894,7 @@
         parent = stackid(stack[1:])
         myid = len(stack2id)
         stack2id[stack] = myid
-        id2stack.append(dict(category=stack[0][0], name=r'%s %s' % stack[0]))
+        id2stack.append(dict(category=stack[0][0], name='%s %s' % stack[0]))
         if parent is not None:
             id2stack[-1].update(parent=parent)
         return myid
@@ -931,7 +931,7 @@
             sampletime = max(oldtime + clamp, sample.time)
             samples.append(
                 dict(
-                    ph=r'E',
+                    ph='E',
                     name=oldfunc,
                     cat=oldcat,
                     sf=oldsid,
@@ -949,7 +949,7 @@
         stack = tuple(
             (
                 (
-                    r'%s:%d'
+                    '%s:%d'
                     % (simplifypath(pycompat.sysstr(frame.path)), frame.lineno),
                     pycompat.sysstr(frame.function),
                 )
@@ -971,7 +971,7 @@
             sid = stackid(tuple(laststack))
             samples.append(
                 dict(
-                    ph=r'B',
+                    ph='B',
                     name=name,
                     cat=path,
                     ts=sample.time * 1e6,
@@ -1030,17 +1030,17 @@
 
     optstart = 2
     displayargs[b'function'] = None
-    if argv[1] == r'hotpath':
+    if argv[1] == 'hotpath':
         displayargs[b'format'] = DisplayFormats.Hotpath
-    elif argv[1] == r'lines':
+    elif argv[1] == 'lines':
         displayargs[b'format'] = DisplayFormats.ByLine
-    elif argv[1] == r'functions':
+    elif argv[1] == 'functions':
         displayargs[b'format'] = DisplayFormats.ByMethod
-    elif argv[1] == r'function':
+    elif argv[1] == 'function':
         displayargs[b'format'] = DisplayFormats.AboutMethod
         displayargs[b'function'] = argv[2]
         optstart = 3
-    elif argv[1] == r'flame':
+    elif argv[1] == 'flame':
         displayargs[b'format'] = DisplayFormats.FlameGraph
     else:
         printusage()
@@ -1061,22 +1061,22 @@
     displayargs[b'limit'] = 0.05
     path = None
     for o, value in opts:
-        if o in (r"-l", r"--limit"):
+        if o in ("-l", "--limit"):
             displayargs[b'limit'] = float(value)
-        elif o in (r"-f", r"--file"):
+        elif o in ("-f", "--file"):
             path = value
-        elif o in (r"-o", r"--output-file"):
+        elif o in ("-o", "--output-file"):
             displayargs[b'outputfile'] = value
-        elif o in (r"-p", r"--script-path"):
+        elif o in ("-p", "--script-path"):
             displayargs[b'scriptpath'] = value
-        elif o in (r"-h", r"help"):
+        elif o in ("-h", "help"):
             printusage()
             return 0
         else:
             assert False, b"unhandled option %s" % o
 
     if not path:
-        print(r'must specify --file to load')
+        print('must specify --file to load')
         return 1
 
     load_data(path=path)
@@ -1086,5 +1086,5 @@
     return 0
 
 
-if __name__ == r"__main__":
+if __name__ == "__main__":
     sys.exit(main())
--- a/mercurial/store.py	Wed Nov 20 19:07:02 2019 +0100
+++ b/mercurial/store.py	Fri Nov 22 21:42:04 2019 +0900
@@ -26,7 +26,7 @@
     vfs as vfsmod,
 )
 
-parsers = policy.importmod(r'parsers')
+parsers = policy.importmod('parsers')
 # how much bytes should be read from fncache in one read
 # It is done to prevent loading large fncache files into memory
 fncache_chunksize = 10 ** 6
--- a/mercurial/subrepo.py	Wed Nov 20 19:07:02 2019 +0100
+++ b/mercurial/subrepo.py	Fri Nov 22 21:42:04 2019 +0900
@@ -69,8 +69,8 @@
     """Exception class used to avoid handling a subrepo error more than once"""
 
     def __init__(self, *args, **kw):
-        self.subrepo = kw.pop(r'subrepo', None)
-        self.cause = kw.pop(r'cause', None)
+        self.subrepo = kw.pop('subrepo', None)
+        self.cause = kw.pop('cause', None)
         error.Abort.__init__(self, *args, **kw)
 
 
@@ -969,24 +969,24 @@
         # 2. update the subrepo to the revision specified in
         #    the corresponding substate dictionary
         self.ui.status(_(b'reverting subrepo %s\n') % substate[0])
-        if not opts.get(r'no_backup'):
+        if not opts.get('no_backup'):
             # Revert all files on the subrepo, creating backups
             # Note that this will not recursively revert subrepos
             # We could do it if there was a set:subrepos() predicate
             opts = opts.copy()
-            opts[r'date'] = None
-            opts[r'rev'] = substate[1]
+            opts['date'] = None
+            opts['rev'] = substate[1]
 
             self.filerevert(*pats, **opts)
 
         # Update the repo to the revision specified in the given substate
-        if not opts.get(r'dry_run'):
+        if not opts.get('dry_run'):
             self.get(substate, overwrite=True)
 
     def filerevert(self, *pats, **opts):
-        ctx = self._repo[opts[r'rev']]
+        ctx = self._repo[opts['rev']]
         parents = self._repo.dirstate.parents()
-        if opts.get(r'all'):
+        if opts.get('all'):
             pats = [b'set:modified()']
         else:
             pats = []
@@ -1066,7 +1066,7 @@
         if not self.ui.interactive():
             # Making stdin be a pipe should prevent svn from behaving
             # interactively even if we can't pass --non-interactive.
-            extrakw[r'stdin'] = subprocess.PIPE
+            extrakw['stdin'] = subprocess.PIPE
             # Starting in svn 1.5 --non-interactive is a global flag
             # instead of being per-command, but we need to support 1.4 so
             # we have to be intelligent about what commands take
@@ -1125,14 +1125,14 @@
         # both. We used to store the working directory one.
         output, err = self._svncommand([b'info', b'--xml'])
         doc = xml.dom.minidom.parseString(output)
-        entries = doc.getElementsByTagName(r'entry')
+        entries = doc.getElementsByTagName('entry')
         lastrev, rev = b'0', b'0'
         if entries:
-            rev = pycompat.bytestr(entries[0].getAttribute(r'revision')) or b'0'
-            commits = entries[0].getElementsByTagName(r'commit')
+            rev = pycompat.bytestr(entries[0].getAttribute('revision')) or b'0'
+            commits = entries[0].getElementsByTagName('commit')
             if commits:
                 lastrev = (
-                    pycompat.bytestr(commits[0].getAttribute(r'revision'))
+                    pycompat.bytestr(commits[0].getAttribute('revision'))
                     or b'0'
                 )
         return (lastrev, rev)
@@ -1149,23 +1149,23 @@
         output, err = self._svncommand([b'status', b'--xml'])
         externals, changes, missing = [], [], []
         doc = xml.dom.minidom.parseString(output)
-        for e in doc.getElementsByTagName(r'entry'):
-            s = e.getElementsByTagName(r'wc-status')
+        for e in doc.getElementsByTagName('entry'):
+            s = e.getElementsByTagName('wc-status')
             if not s:
                 continue
-            item = s[0].getAttribute(r'item')
-            props = s[0].getAttribute(r'props')
-            path = e.getAttribute(r'path').encode('utf8')
-            if item == r'external':
+            item = s[0].getAttribute('item')
+            props = s[0].getAttribute('props')
+            path = e.getAttribute('path').encode('utf8')
+            if item == 'external':
                 externals.append(path)
-            elif item == r'missing':
+            elif item == 'missing':
                 missing.append(path)
             if item not in (
-                r'',
-                r'normal',
-                r'unversioned',
-                r'external',
-            ) or props not in (r'', r'none', r'normal'):
+                '',
+                'normal',
+                'unversioned',
+                'external',
+            ) or props not in ('', 'none', 'normal'):
                 changes.append(path)
         for path in changes:
             for ext in externals:
@@ -1291,13 +1291,13 @@
         output = self._svncommand([b'list', b'--recursive', b'--xml'])[0]
         doc = xml.dom.minidom.parseString(output)
         paths = []
-        for e in doc.getElementsByTagName(r'entry'):
-            kind = pycompat.bytestr(e.getAttribute(r'kind'))
+        for e in doc.getElementsByTagName('entry'):
+            kind = pycompat.bytestr(e.getAttribute('kind'))
             if kind != b'file':
                 continue
-            name = r''.join(
+            name = ''.join(
                 c.data
-                for c in e.getElementsByTagName(r'name')[0].childNodes
+                for c in e.getElementsByTagName('name')[0].childNodes
                 if c.nodeType == c.TEXT_NODE
             )
             paths.append(name.encode('utf8'))
@@ -1808,7 +1808,7 @@
                 if exact:
                     rejected.append(f)
                 continue
-            if not opts.get(r'dry_run'):
+            if not opts.get('dry_run'):
                 self._gitcommand(command + [f])
 
         for f in rejected:
@@ -1849,7 +1849,7 @@
         # This should be much faster than manually traversing the trees
         # and objects with many subprocess calls.
         tarstream = self._gitcommand([b'archive', revision], stream=True)
-        tar = tarfile.open(fileobj=tarstream, mode=r'r|')
+        tar = tarfile.open(fileobj=tarstream, mode='r|')
         relpath = subrelpath(self)
         progress = self.ui.makeprogress(
             _(b'archiving (%s)') % relpath, unit=_(b'files')
@@ -1918,9 +1918,9 @@
         deleted, unknown, ignored, clean = [], [], [], []
 
         command = [b'status', b'--porcelain', b'-z']
-        if opts.get(r'unknown'):
+        if opts.get('unknown'):
             command += [b'--untracked-files=all']
-        if opts.get(r'ignored'):
+        if opts.get('ignored'):
             command += [b'--ignored']
         out = self._gitcommand(command)
 
@@ -1948,7 +1948,7 @@
             elif st == b'!!':
                 ignored.append(filename1)
 
-        if opts.get(r'clean'):
+        if opts.get('clean'):
             out = self._gitcommand([b'ls-files'])
             for f in out.split(b'\n'):
                 if not f in changedfiles:
@@ -1962,7 +1962,7 @@
     def diff(self, ui, diffopts, node2, match, prefix, **opts):
         node1 = self._state[1]
         cmd = [b'diff', b'--no-renames']
-        if opts[r'stat']:
+        if opts['stat']:
             cmd.append(b'--stat')
         else:
             # for Git, this also implies '-p'
@@ -1995,8 +1995,12 @@
         if match.always():
             output += self._gitcommand(cmd) + b'\n'
         else:
-            st = self.status(node2)[:3]
-            files = [f for sublist in st for f in sublist]
+            st = self.status(node2)
+            files = [
+                f
+                for sublist in (st.modified, st.added, st.removed)
+                for f in sublist
+            ]
             for f in files:
                 if match(f):
                     output += self._gitcommand(cmd + [b'--', f]) + b'\n'
@@ -2007,7 +2011,7 @@
     @annotatesubrepoerror
     def revert(self, substate, *pats, **opts):
         self.ui.status(_(b'reverting subrepo %s\n') % substate[0])
-        if not opts.get(r'no_backup'):
+        if not opts.get('no_backup'):
             status = self.status(None)
             names = status.modified
             for name in names:
@@ -2023,7 +2027,7 @@
                 )
                 util.rename(self.wvfs.join(name), bakname)
 
-        if not opts.get(r'dry_run'):
+        if not opts.get('dry_run'):
             self.get(substate, overwrite=True)
         return []
 
--- a/mercurial/tags.py	Wed Nov 20 19:07:02 2019 +0100
+++ b/mercurial/tags.py	Fri Nov 22 21:42:04 2019 +0900
@@ -194,8 +194,8 @@
         return alltags
 
     for head in reversed(heads):  # oldest to newest
-        assert (
-            head in repo.changelog.nodemap
+        assert repo.changelog.index.has_node(
+            head
         ), b"tag cache returned bogus head %s" % short(head)
     fnodes = _filterfnodes(tagfnode, reversed(heads))
     alltags = _tagsfromfnodes(ui, repo, fnodes)
@@ -571,7 +571,17 @@
 
     if not local:
         m = matchmod.exact([b'.hgtags'])
-        if any(repo.status(match=m, unknown=True, ignored=True)):
+        st = repo.status(match=m, unknown=True, ignored=True)
+        if any(
+            (
+                st.modified,
+                st.added,
+                st.removed,
+                st.deleted,
+                st.unknown,
+                st.ignored,
+            )
+        ):
             raise error.Abort(
                 _(b'working copy of .hgtags is changed'),
                 hint=_(b'please commit .hgtags manually'),
--- a/mercurial/templatefilters.py	Wed Nov 20 19:07:02 2019 +0100
+++ b/mercurial/templatefilters.py	Fri Nov 22 21:42:04 2019 +0900
@@ -299,7 +299,7 @@
     return dateutil.datestr(text, b'%Y-%m-%d %H:%M:%S %1%2')
 
 
-def indent(text, prefix):
+def indent(text, prefix, firstline=b''):
     '''indent each non-empty line of text after first with prefix.'''
     lines = text.splitlines()
     num_lines = len(lines)
@@ -308,8 +308,8 @@
     def indenter():
         for i in pycompat.xrange(num_lines):
             l = lines[i]
-            if i and l.strip():
-                yield prefix
+            if l.strip():
+                yield prefix if i else firstline
             yield l
             if i < num_lines - 1 or endswithnewline:
                 yield b'\n'
--- a/mercurial/templatefuncs.py	Wed Nov 20 19:07:02 2019 +0100
+++ b/mercurial/templatefuncs.py	Fri Nov 22 21:42:04 2019 +0900
@@ -310,13 +310,11 @@
     text = evalstring(context, mapping, args[0])
     indent = evalstring(context, mapping, args[1])
 
+    firstline = indent
     if len(args) == 3:
         firstline = evalstring(context, mapping, args[2])
-    else:
-        firstline = indent
 
-    # the indent function doesn't indent the first line, so we do it here
-    return templatefilters.indent(firstline + text, indent)
+    return templatefilters.indent(text, indent, firstline=firstline)
 
 
 @templatefunc(b'get(dict, key)')
--- a/mercurial/templater.py	Wed Nov 20 19:07:02 2019 +0100
+++ b/mercurial/templater.py	Fri Nov 22 21:42:04 2019 +0900
@@ -80,7 +80,10 @@
     templateutil,
     util,
 )
-from .utils import stringutil
+from .utils import (
+    resourceutil,
+    stringutil,
+)
 
 # template parsing
 
@@ -611,7 +614,7 @@
     return s[1:-1]
 
 
-class resourcemapper(object):
+class resourcemapper(object):  # pytype: disable=ignored-metaclass
     """Mapper of internal template resources"""
 
     __metaclass__ = abc.ABCMeta
@@ -1042,7 +1045,10 @@
 def templatepaths():
     '''return locations used for template files.'''
     pathsrel = [b'templates']
-    paths = [os.path.normpath(os.path.join(util.datapath, f)) for f in pathsrel]
+    paths = [
+        os.path.normpath(os.path.join(resourceutil.datapath, f))
+        for f in pathsrel
+    ]
     return [p for p in paths if os.path.isdir(p)]
 
 
--- a/mercurial/templates/json/map	Wed Nov 20 19:07:02 2019 +0100
+++ b/mercurial/templates/json/map	Fri Nov 22 21:42:04 2019 +0900
@@ -65,6 +65,8 @@
   "tags": [{join(changesettag, ", ")}],
   "user": {author|utf8|json},
   "parents": [{join(parent%changesetparent, ", ")}],
+  "files": [{join(files, ", ")}],
+  "diff": [{join(diff, ", ")}],
   "phase": {phase|json}
   }'
 changesetbranch = '{name|utf8|json}'
@@ -229,8 +231,11 @@
   "topic": {topic|utf8|json},
   "rawdoc": {doc|utf8|json}
   }'
-filenodelink = ''
-filenolink = ''
+filenodelink = '\{
+  "file": {file|json},
+  "status": {status|json}
+  }'
+filenolink = '{filenodelink}'
 index = '\{
   "entries": [{join(entries%indexentry, ", ")}]
   }'
--- a/mercurial/templateutil.py	Wed Nov 20 19:07:02 2019 +0100
+++ b/mercurial/templateutil.py	Fri Nov 22 21:42:04 2019 +0900
@@ -31,7 +31,7 @@
     pass
 
 
-class wrapped(object):
+class wrapped(object):  # pytype: disable=ignored-metaclass
     """Object requiring extra conversion prior to displaying or processing
     as value
 
@@ -108,9 +108,11 @@
         """
 
 
-class mappable(object):
+class mappable(object):  # pytype: disable=ignored-metaclass
     """Object which can be converted to a single template mapping"""
 
+    __metaclass__ = abc.ABCMeta
+
     def itermaps(self, context):
         yield self.tomap(context)
 
--- a/mercurial/testing/storage.py	Wed Nov 20 19:07:02 2019 +0100
+++ b/mercurial/testing/storage.py	Fri Nov 22 21:42:04 2019 +0900
@@ -1366,26 +1366,26 @@
     should find and run it automatically.
     """
     d = {
-        r'_makefilefn': makefilefn,
-        r'_maketransactionfn': maketransactionfn,
-        r'_addrawrevisionfn': addrawrevisionfn,
+        '_makefilefn': makefilefn,
+        '_maketransactionfn': maketransactionfn,
+        '_addrawrevisionfn': addrawrevisionfn,
     }
-    return type(r'ifileindextests', (ifileindextests,), d)
+    return type('ifileindextests', (ifileindextests,), d)
 
 
 def makeifiledatatests(makefilefn, maketransactionfn, addrawrevisionfn):
     d = {
-        r'_makefilefn': makefilefn,
-        r'_maketransactionfn': maketransactionfn,
-        r'_addrawrevisionfn': addrawrevisionfn,
+        '_makefilefn': makefilefn,
+        '_maketransactionfn': maketransactionfn,
+        '_addrawrevisionfn': addrawrevisionfn,
     }
-    return type(r'ifiledatatests', (ifiledatatests,), d)
+    return type('ifiledatatests', (ifiledatatests,), d)
 
 
 def makeifilemutationtests(makefilefn, maketransactionfn, addrawrevisionfn):
     d = {
-        r'_makefilefn': makefilefn,
-        r'_maketransactionfn': maketransactionfn,
-        r'_addrawrevisionfn': addrawrevisionfn,
+        '_makefilefn': makefilefn,
+        '_maketransactionfn': maketransactionfn,
+        '_addrawrevisionfn': addrawrevisionfn,
     }
-    return type(r'ifilemutationtests', (ifilemutationtests,), d)
+    return type('ifilemutationtests', (ifilemutationtests,), d)
--- a/mercurial/transaction.py	Wed Nov 20 19:07:02 2019 +0100
+++ b/mercurial/transaction.py	Fri Nov 22 21:42:04 2019 +0900
@@ -135,7 +135,7 @@
         validator=None,
         releasefn=None,
         checkambigfiles=None,
-        name=r'<unnamed>',
+        name='<unnamed>',
     ):
         """Begin a new transaction
 
@@ -220,8 +220,8 @@
         self._abortcallback = {}
 
     def __repr__(self):
-        name = r'/'.join(self._names)
-        return r'<transaction name=%s, count=%d, usages=%d>' % (
+        name = '/'.join(self._names)
+        return '<transaction name=%s, count=%d, usages=%d>' % (
             name,
             self._count,
             self._usages,
@@ -414,7 +414,7 @@
         self._file.flush()
 
     @active
-    def nest(self, name=r'<unnamed>'):
+    def nest(self, name='<unnamed>'):
         self._count += 1
         self._usages += 1
         self._names.append(name)
--- a/mercurial/ui.py	Wed Nov 20 19:07:02 2019 +0100
+++ b/mercurial/ui.py	Fri Nov 22 21:42:04 2019 +0900
@@ -428,7 +428,7 @@
         self, filename, root=None, trust=False, sections=None, remap=None
     ):
         try:
-            fp = open(filename, r'rb')
+            fp = open(filename, 'rb')
         except IOError:
             if not sections:  # ignore unless we were looking for something
                 return
@@ -1087,7 +1087,7 @@
 
         # inlined _write() for speed
         if self._buffers:
-            label = opts.get(r'label', b'')
+            label = opts.get('label', b'')
             if label and self._bufferapplylabels:
                 self._buffers[-1].extend(self.label(a, label) for a in args)
             else:
@@ -1095,7 +1095,7 @@
             return
 
         # inlined _writenobuf() for speed
-        if not opts.get(r'keepprogressbar', False):
+        if not opts.get('keepprogressbar', False):
             self._progclear()
         msg = b''.join(args)
 
@@ -1108,7 +1108,7 @@
                 color.win32print(self, dest.write, msg, **opts)
             else:
                 if self._colormode is not None:
-                    label = opts.get(r'label', b'')
+                    label = opts.get('label', b'')
                     msg = self.label(msg, label)
                 dest.write(msg)
         except IOError as err:
@@ -1124,7 +1124,7 @@
     def _write(self, dest, *args, **opts):
         # update write() as well if you touch this code
         if self._isbuffered(dest):
-            label = opts.get(r'label', b'')
+            label = opts.get('label', b'')
             if label and self._bufferapplylabels:
                 self._buffers[-1].extend(self.label(a, label) for a in args)
             else:
@@ -1134,7 +1134,7 @@
 
     def _writenobuf(self, dest, *args, **opts):
         # update write() as well if you touch this code
-        if not opts.get(r'keepprogressbar', False):
+        if not opts.get('keepprogressbar', False):
             self._progclear()
         msg = b''.join(args)
 
@@ -1153,7 +1153,7 @@
                 color.win32print(self, dest.write, msg, **opts)
             else:
                 if self._colormode is not None:
-                    label = opts.get(r'label', b'')
+                    label = opts.get('label', b'')
                     msg = self.label(msg, label)
                 dest.write(msg)
             # stderr may be buffered under win32 when redirected to files,
@@ -1588,7 +1588,7 @@
         return self._prompt(msg, default=default)
 
     def _prompt(self, msg, **opts):
-        default = opts[r'default']
+        default = opts['default']
         if not self.interactive():
             self._writemsg(self._fmsgout, msg, b' ', type=b'prompt', **opts)
             self._writemsg(
@@ -1674,7 +1674,7 @@
                         raise EOFError
                     return l.rstrip(b'\n')
                 else:
-                    return getpass.getpass(r'')
+                    return getpass.getpass('')
         except EOFError:
             raise error.ResponseExpected()
 
@@ -1765,7 +1765,7 @@
             prefix=b'hg-' + extra[b'prefix'] + b'-', suffix=suffix, dir=rdir
         )
         try:
-            f = os.fdopen(fd, r'wb')
+            f = os.fdopen(fd, 'wb')
             f.write(util.tonativeeol(text))
             f.close()
 
@@ -1793,7 +1793,7 @@
                 blockedtag=b'editor',
             )
 
-            f = open(name, r'rb')
+            f = open(name, 'rb')
             t = util.fromnativeeol(f.read())
             f.close()
         finally:
@@ -1864,7 +1864,7 @@
                 )
             else:
                 output = traceback.format_exception(exc[0], exc[1], exc[2])
-                self.write_err(encoding.strtolocal(r''.join(output)))
+                self.write_err(encoding.strtolocal(''.join(output)))
         return self.tracebackflag or force
 
     def geteditor(self):
@@ -2305,6 +2305,6 @@
     isn't a structured channel, so that the message will be colorized.
     """
     # TODO: maybe change 'type' to a mandatory option
-    if r'type' in opts and not getattr(dest, 'structured', False):
-        opts[r'label'] = opts.get(r'label', b'') + b' ui.%s' % opts.pop(r'type')
+    if 'type' in opts and not getattr(dest, 'structured', False):
+        opts['label'] = opts.get('label', b'') + b' ui.%s' % opts.pop('type')
     write(dest, *args, **opts)
--- a/mercurial/unionrepo.py	Wed Nov 20 19:07:02 2019 +0100
+++ b/mercurial/unionrepo.py	Fri Nov 22 21:42:04 2019 +0900
@@ -62,9 +62,10 @@
             if linkmapper is not None:  # link is to same revlog
                 base = linkmapper(base)
 
-            if node in self.nodemap:
+            this_rev = self.index.get_rev(node)
+            if this_rev is not None:
                 # this happens for the common revlog revisions
-                self.bundlerevs.add(self.nodemap[node])
+                self.bundlerevs.add(this_rev)
                 continue
 
             p1node = self.revlog2.node(p1rev)
@@ -83,7 +84,6 @@
                 node,
             )
             self.index.append(e)
-            self.nodemap[node] = n
             self.bundlerevs.add(n)
             n += 1
 
--- a/mercurial/url.py	Wed Nov 20 19:07:02 2019 +0100
+++ b/mercurial/url.py	Fri Nov 22 21:42:04 2019 +0900
@@ -147,7 +147,7 @@
             # Keys and values need to be str because the standard library
             # expects them to be.
             proxyurl = str(proxy)
-            proxies = {r'http': proxyurl, r'https': proxyurl}
+            proxies = {'http': proxyurl, 'https': proxyurl}
             ui.debug(b'proxying through %s\n' % util.hidepassword(bytes(proxy)))
         else:
             proxies = {}
@@ -204,8 +204,8 @@
 def _generic_start_transaction(handler, h, req):
     tunnel_host = req._tunnel_host
     if tunnel_host:
-        if tunnel_host[:7] not in [r'http://', r'https:/']:
-            tunnel_host = r'https://' + tunnel_host
+        if tunnel_host[:7] not in ['http://', 'https:/']:
+            tunnel_host = 'https://' + tunnel_host
         new_tunnel = True
     else:
         tunnel_host = urllibcompat.getselector(req)
@@ -228,7 +228,7 @@
         [
             (x, self.headers[x])
             for x in self.headers
-            if x.lower().startswith(r'proxy-')
+            if x.lower().startswith('proxy-')
         ]
     )
     self.send(b'CONNECT %s HTTP/1.0\r\n' % self.realhostport)
@@ -522,7 +522,7 @@
         )
         if pw is not None:
             raw = b"%s:%s" % (pycompat.bytesurl(user), pycompat.bytesurl(pw))
-            auth = r'Basic %s' % pycompat.strurl(base64.b64encode(raw).strip())
+            auth = 'Basic %s' % pycompat.strurl(base64.b64encode(raw).strip())
             if req.get_header(self.auth_header, None) == auth:
                 return None
             self.auth = auth
@@ -655,16 +655,16 @@
     # do look at this value.
     if not useragent:
         agent = b'mercurial/proto-1.0 (Mercurial %s)' % util.version()
-        opener.addheaders = [(r'User-agent', pycompat.sysstr(agent))]
+        opener.addheaders = [('User-agent', pycompat.sysstr(agent))]
     else:
-        opener.addheaders = [(r'User-agent', pycompat.sysstr(useragent))]
+        opener.addheaders = [('User-agent', pycompat.sysstr(useragent))]
 
     # This header should only be needed by wire protocol requests. But it has
     # been sent on all requests since forever. We keep sending it for backwards
     # compatibility reasons. Modern versions of the wire protocol use
     # X-HgProto-<N> for advertising client support.
     if sendaccept:
-        opener.addheaders.append((r'Accept', r'application/mercurial-0.1'))
+        opener.addheaders.append(('Accept', 'application/mercurial-0.1'))
 
     return opener
 
--- a/mercurial/urllibcompat.py	Wed Nov 20 19:07:02 2019 +0100
+++ b/mercurial/urllibcompat.py	Fri Nov 22 21:42:04 2019 +0900
@@ -20,7 +20,7 @@
         """Add items that will be populated at the first access"""
         items = map(_sysstr, items)
         self._aliases.update(
-            (item.replace(r'_', r'').lower(), (origin, item)) for item in items
+            (item.replace('_', '').lower(), (origin, item)) for item in items
         )
 
     def _registeralias(self, origin, attr, name):
@@ -102,7 +102,7 @@
     # urllib.parse.quote() accepts both str and bytes, decodes bytes
     # (if necessary), and returns str. This is wonky. We provide a custom
     # implementation that only accepts bytes and emits bytes.
-    def quote(s, safe=r'/'):
+    def quote(s, safe='/'):
         # bytestr has an __iter__ that emits characters. quote_from_bytes()
         # does an iteration and expects ints. We coerce to bytes to appease it.
         if isinstance(s, pycompat.bytestr):
--- a/mercurial/util.py	Wed Nov 20 19:07:02 2019 +0100
+++ b/mercurial/util.py	Fri Nov 22 21:42:04 2019 +0900
@@ -57,11 +57,8 @@
     stringutil,
 )
 
-rustdirs = policy.importrust(r'dirstate', r'Dirs')
-
-base85 = policy.importmod(r'base85')
-osutil = policy.importmod(r'osutil')
-parsers = policy.importmod(r'parsers')
+base85 = policy.importmod('base85')
+osutil = policy.importmod('osutil')
 
 b85decode = base85.b85decode
 b85encode = base85.b85encode
@@ -165,23 +162,23 @@
     # However, module name set through PYTHONWARNINGS was exactly matched, so
     # we cannot set 'mercurial' and have it match eg: 'mercurial.scmutil'. This
     # makes the whole PYTHONWARNINGS thing useless for our usecase.
-    warnings.filterwarnings(r'default', r'', DeprecationWarning, r'mercurial')
-    warnings.filterwarnings(r'default', r'', DeprecationWarning, r'hgext')
-    warnings.filterwarnings(r'default', r'', DeprecationWarning, r'hgext3rd')
+    warnings.filterwarnings('default', '', DeprecationWarning, 'mercurial')
+    warnings.filterwarnings('default', '', DeprecationWarning, 'hgext')
+    warnings.filterwarnings('default', '', DeprecationWarning, 'hgext3rd')
 if _dowarn and pycompat.ispy3:
     # silence warning emitted by passing user string to re.sub()
     warnings.filterwarnings(
-        r'ignore', r'bad escape', DeprecationWarning, r'mercurial'
+        'ignore', 'bad escape', DeprecationWarning, 'mercurial'
     )
     warnings.filterwarnings(
-        r'ignore', r'invalid escape sequence', DeprecationWarning, r'mercurial'
+        'ignore', 'invalid escape sequence', DeprecationWarning, 'mercurial'
     )
     # TODO: reinvent imp.is_frozen()
     warnings.filterwarnings(
-        r'ignore',
-        r'the imp module is deprecated',
+        'ignore',
+        'the imp module is deprecated',
         DeprecationWarning,
-        r'mercurial',
+        'mercurial',
     )
 
 
@@ -438,42 +435,42 @@
     """
 
     __slots__ = (
-        r'_orig',
-        r'_observer',
+        '_orig',
+        '_observer',
     )
 
     def __init__(self, fh, observer):
-        object.__setattr__(self, r'_orig', fh)
-        object.__setattr__(self, r'_observer', observer)
+        object.__setattr__(self, '_orig', fh)
+        object.__setattr__(self, '_observer', observer)
 
     def __getattribute__(self, name):
         ours = {
-            r'_observer',
+            '_observer',
             # IOBase
-            r'close',
+            'close',
             # closed if a property
-            r'fileno',
-            r'flush',
-            r'isatty',
-            r'readable',
-            r'readline',
-            r'readlines',
-            r'seek',
-            r'seekable',
-            r'tell',
-            r'truncate',
-            r'writable',
-            r'writelines',
+            'fileno',
+            'flush',
+            'isatty',
+            'readable',
+            'readline',
+            'readlines',
+            'seek',
+            'seekable',
+            'tell',
+            'truncate',
+            'writable',
+            'writelines',
             # RawIOBase
-            r'read',
-            r'readall',
-            r'readinto',
-            r'write',
+            'read',
+            'readall',
+            'readinto',
+            'write',
             # BufferedIOBase
             # raw is a property
-            r'detach',
+            'detach',
             # read defined above
-            r'read1',
+            'read1',
             # readinto defined above
             # write defined above
         }
@@ -482,30 +479,30 @@
         if name in ours:
             return object.__getattribute__(self, name)
 
-        return getattr(object.__getattribute__(self, r'_orig'), name)
+        return getattr(object.__getattribute__(self, '_orig'), name)
 
     def __nonzero__(self):
-        return bool(object.__getattribute__(self, r'_orig'))
+        return bool(object.__getattribute__(self, '_orig'))
 
     __bool__ = __nonzero__
 
     def __delattr__(self, name):
-        return delattr(object.__getattribute__(self, r'_orig'), name)
+        return delattr(object.__getattribute__(self, '_orig'), name)
 
     def __setattr__(self, name, value):
-        return setattr(object.__getattribute__(self, r'_orig'), name, value)
+        return setattr(object.__getattribute__(self, '_orig'), name, value)
 
     def __iter__(self):
-        return object.__getattribute__(self, r'_orig').__iter__()
+        return object.__getattribute__(self, '_orig').__iter__()
 
     def _observedcall(self, name, *args, **kwargs):
         # Call the original object.
-        orig = object.__getattribute__(self, r'_orig')
+        orig = object.__getattribute__(self, '_orig')
         res = getattr(orig, name)(*args, **kwargs)
 
         # Call a method on the observer of the same name with arguments
         # so it can react, log, etc.
-        observer = object.__getattribute__(self, r'_observer')
+        observer = object.__getattribute__(self, '_observer')
         fn = getattr(observer, name, None)
         if fn:
             fn(res, *args, **kwargs)
@@ -513,98 +510,98 @@
         return res
 
     def close(self, *args, **kwargs):
-        return object.__getattribute__(self, r'_observedcall')(
-            r'close', *args, **kwargs
+        return object.__getattribute__(self, '_observedcall')(
+            'close', *args, **kwargs
         )
 
     def fileno(self, *args, **kwargs):
-        return object.__getattribute__(self, r'_observedcall')(
-            r'fileno', *args, **kwargs
+        return object.__getattribute__(self, '_observedcall')(
+            'fileno', *args, **kwargs
         )
 
     def flush(self, *args, **kwargs):
-        return object.__getattribute__(self, r'_observedcall')(
-            r'flush', *args, **kwargs
+        return object.__getattribute__(self, '_observedcall')(
+            'flush', *args, **kwargs
         )
 
     def isatty(self, *args, **kwargs):
-        return object.__getattribute__(self, r'_observedcall')(
-            r'isatty', *args, **kwargs
+        return object.__getattribute__(self, '_observedcall')(
+            'isatty', *args, **kwargs
         )
 
     def readable(self, *args, **kwargs):
-        return object.__getattribute__(self, r'_observedcall')(
-            r'readable', *args, **kwargs
+        return object.__getattribute__(self, '_observedcall')(
+            'readable', *args, **kwargs
         )
 
     def readline(self, *args, **kwargs):
-        return object.__getattribute__(self, r'_observedcall')(
-            r'readline', *args, **kwargs
+        return object.__getattribute__(self, '_observedcall')(
+            'readline', *args, **kwargs
         )
 
     def readlines(self, *args, **kwargs):
-        return object.__getattribute__(self, r'_observedcall')(
-            r'readlines', *args, **kwargs
+        return object.__getattribute__(self, '_observedcall')(
+            'readlines', *args, **kwargs
         )
 
     def seek(self, *args, **kwargs):
-        return object.__getattribute__(self, r'_observedcall')(
-            r'seek', *args, **kwargs
+        return object.__getattribute__(self, '_observedcall')(
+            'seek', *args, **kwargs
         )
 
     def seekable(self, *args, **kwargs):
-        return object.__getattribute__(self, r'_observedcall')(
-            r'seekable', *args, **kwargs
+        return object.__getattribute__(self, '_observedcall')(
+            'seekable', *args, **kwargs
         )
 
     def tell(self, *args, **kwargs):
-        return object.__getattribute__(self, r'_observedcall')(
-            r'tell', *args, **kwargs
+        return object.__getattribute__(self, '_observedcall')(
+            'tell', *args, **kwargs
         )
 
     def truncate(self, *args, **kwargs):
-        return object.__getattribute__(self, r'_observedcall')(
-            r'truncate', *args, **kwargs
+        return object.__getattribute__(self, '_observedcall')(
+            'truncate', *args, **kwargs
         )
 
     def writable(self, *args, **kwargs):
-        return object.__getattribute__(self, r'_observedcall')(
-            r'writable', *args, **kwargs
+        return object.__getattribute__(self, '_observedcall')(
+            'writable', *args, **kwargs
         )
 
     def writelines(self, *args, **kwargs):
-        return object.__getattribute__(self, r'_observedcall')(
-            r'writelines', *args, **kwargs
+        return object.__getattribute__(self, '_observedcall')(
+            'writelines', *args, **kwargs
         )
 
     def read(self, *args, **kwargs):
-        return object.__getattribute__(self, r'_observedcall')(
-            r'read', *args, **kwargs
+        return object.__getattribute__(self, '_observedcall')(
+            'read', *args, **kwargs
         )
 
     def readall(self, *args, **kwargs):
-        return object.__getattribute__(self, r'_observedcall')(
-            r'readall', *args, **kwargs
+        return object.__getattribute__(self, '_observedcall')(
+            'readall', *args, **kwargs
         )
 
     def readinto(self, *args, **kwargs):
-        return object.__getattribute__(self, r'_observedcall')(
-            r'readinto', *args, **kwargs
+        return object.__getattribute__(self, '_observedcall')(
+            'readinto', *args, **kwargs
         )
 
     def write(self, *args, **kwargs):
-        return object.__getattribute__(self, r'_observedcall')(
-            r'write', *args, **kwargs
+        return object.__getattribute__(self, '_observedcall')(
+            'write', *args, **kwargs
         )
 
     def detach(self, *args, **kwargs):
-        return object.__getattribute__(self, r'_observedcall')(
-            r'detach', *args, **kwargs
+        return object.__getattribute__(self, '_observedcall')(
+            'detach', *args, **kwargs
         )
 
     def read1(self, *args, **kwargs):
-        return object.__getattribute__(self, r'_observedcall')(
-            r'read1', *args, **kwargs
+        return object.__getattribute__(self, '_observedcall')(
+            'read1', *args, **kwargs
         )
 
 
@@ -651,18 +648,18 @@
 
 
 PROXIED_SOCKET_METHODS = {
-    r'makefile',
-    r'recv',
-    r'recvfrom',
-    r'recvfrom_into',
-    r'recv_into',
-    r'send',
-    r'sendall',
-    r'sendto',
-    r'setblocking',
-    r'settimeout',
-    r'gettimeout',
-    r'setsockopt',
+    'makefile',
+    'recv',
+    'recvfrom',
+    'recvfrom_into',
+    'recv_into',
+    'send',
+    'sendall',
+    'sendto',
+    'setblocking',
+    'settimeout',
+    'gettimeout',
+    'setsockopt',
 }
 
 
@@ -676,39 +673,39 @@
     """
 
     __slots__ = (
-        r'_orig',
-        r'_observer',
+        '_orig',
+        '_observer',
     )
 
     def __init__(self, sock, observer):
-        object.__setattr__(self, r'_orig', sock)
-        object.__setattr__(self, r'_observer', observer)
+        object.__setattr__(self, '_orig', sock)
+        object.__setattr__(self, '_observer', observer)
 
     def __getattribute__(self, name):
         if name in PROXIED_SOCKET_METHODS:
             return object.__getattribute__(self, name)
 
-        return getattr(object.__getattribute__(self, r'_orig'), name)
+        return getattr(object.__getattribute__(self, '_orig'), name)
 
     def __delattr__(self, name):
-        return delattr(object.__getattribute__(self, r'_orig'), name)
+        return delattr(object.__getattribute__(self, '_orig'), name)
 
     def __setattr__(self, name, value):
-        return setattr(object.__getattribute__(self, r'_orig'), name, value)
+        return setattr(object.__getattribute__(self, '_orig'), name, value)
 
     def __nonzero__(self):
-        return bool(object.__getattribute__(self, r'_orig'))
+        return bool(object.__getattribute__(self, '_orig'))
 
     __bool__ = __nonzero__
 
     def _observedcall(self, name, *args, **kwargs):
         # Call the original object.
-        orig = object.__getattribute__(self, r'_orig')
+        orig = object.__getattribute__(self, '_orig')
         res = getattr(orig, name)(*args, **kwargs)
 
         # Call a method on the observer of the same name with arguments
         # so it can react, log, etc.
-        observer = object.__getattribute__(self, r'_observer')
+        observer = object.__getattribute__(self, '_observer')
         fn = getattr(observer, name, None)
         if fn:
             fn(res, *args, **kwargs)
@@ -716,13 +713,13 @@
         return res
 
     def makefile(self, *args, **kwargs):
-        res = object.__getattribute__(self, r'_observedcall')(
-            r'makefile', *args, **kwargs
+        res = object.__getattribute__(self, '_observedcall')(
+            'makefile', *args, **kwargs
         )
 
         # The file object may be used for I/O. So we turn it into a
         # proxy using our observer.
-        observer = object.__getattribute__(self, r'_observer')
+        observer = object.__getattribute__(self, '_observer')
         return makeloggingfileobject(
             observer.fh,
             res,
@@ -734,58 +731,58 @@
         )
 
     def recv(self, *args, **kwargs):
-        return object.__getattribute__(self, r'_observedcall')(
-            r'recv', *args, **kwargs
+        return object.__getattribute__(self, '_observedcall')(
+            'recv', *args, **kwargs
         )
 
     def recvfrom(self, *args, **kwargs):
-        return object.__getattribute__(self, r'_observedcall')(
-            r'recvfrom', *args, **kwargs
+        return object.__getattribute__(self, '_observedcall')(
+            'recvfrom', *args, **kwargs
         )
 
     def recvfrom_into(self, *args, **kwargs):
-        return object.__getattribute__(self, r'_observedcall')(
-            r'recvfrom_into', *args, **kwargs
+        return object.__getattribute__(self, '_observedcall')(
+            'recvfrom_into', *args, **kwargs
         )
 
     def recv_into(self, *args, **kwargs):
-        return object.__getattribute__(self, r'_observedcall')(
-            r'recv_info', *args, **kwargs
+        return object.__getattribute__(self, '_observedcall')(
+            'recv_info', *args, **kwargs
         )
 
     def send(self, *args, **kwargs):
-        return object.__getattribute__(self, r'_observedcall')(
-            r'send', *args, **kwargs
+        return object.__getattribute__(self, '_observedcall')(
+            'send', *args, **kwargs
         )
 
     def sendall(self, *args, **kwargs):
-        return object.__getattribute__(self, r'_observedcall')(
-            r'sendall', *args, **kwargs
+        return object.__getattribute__(self, '_observedcall')(
+            'sendall', *args, **kwargs
         )
 
     def sendto(self, *args, **kwargs):
-        return object.__getattribute__(self, r'_observedcall')(
-            r'sendto', *args, **kwargs
+        return object.__getattribute__(self, '_observedcall')(
+            'sendto', *args, **kwargs
         )
 
     def setblocking(self, *args, **kwargs):
-        return object.__getattribute__(self, r'_observedcall')(
-            r'setblocking', *args, **kwargs
+        return object.__getattribute__(self, '_observedcall')(
+            'setblocking', *args, **kwargs
         )
 
     def settimeout(self, *args, **kwargs):
-        return object.__getattribute__(self, r'_observedcall')(
-            r'settimeout', *args, **kwargs
+        return object.__getattribute__(self, '_observedcall')(
+            'settimeout', *args, **kwargs
         )
 
     def gettimeout(self, *args, **kwargs):
-        return object.__getattribute__(self, r'_observedcall')(
-            r'gettimeout', *args, **kwargs
+        return object.__getattribute__(self, '_observedcall')(
+            'gettimeout', *args, **kwargs
         )
 
     def setsockopt(self, *args, **kwargs):
-        return object.__getattribute__(self, r'_observedcall')(
-            r'setsockopt', *args, **kwargs
+        return object.__getattribute__(self, '_observedcall')(
+            'setsockopt', *args, **kwargs
         )
 
 
@@ -1304,7 +1301,7 @@
     """
 
 
-class transactional(object):
+class transactional(object):  # pytype: disable=ignored-metaclass
     """Base class for making a transactional type into a context manager."""
 
     __metaclass__ = abc.ABCMeta
@@ -1362,7 +1359,7 @@
     pair for the dictionary entry.
     """
 
-    __slots__ = (r'next', r'prev', r'key', r'value', r'cost')
+    __slots__ = ('next', 'prev', 'key', 'value', 'cost')
 
     def __init__(self):
         self.next = None
@@ -1825,16 +1822,6 @@
     return pycompat.ossep.join(([b'..'] * len(a)) + b) or b'.'
 
 
-# the location of data files matching the source code
-if procutil.mainfrozen() and getattr(sys, 'frozen', None) != b'macosx_app':
-    # executable version (py2exe) doesn't support __file__
-    datapath = os.path.dirname(pycompat.sysexecutable)
-else:
-    datapath = os.path.dirname(pycompat.fsencode(__file__))
-
-i18n.setdatapath(datapath)
-
-
 def checksignature(func):
     '''wrap a function with code to check for calling errors'''
 
@@ -3494,62 +3481,6 @@
     f.flush()
 
 
-class dirs(object):
-    '''a multiset of directory names from a dirstate or manifest'''
-
-    def __init__(self, map, skip=None):
-        self._dirs = {}
-        addpath = self.addpath
-        if isinstance(map, dict) and skip is not None:
-            for f, s in pycompat.iteritems(map):
-                if s[0] != skip:
-                    addpath(f)
-        elif skip is not None:
-            raise error.ProgrammingError(
-                b"skip character is only supported with a dict source"
-            )
-        else:
-            for f in map:
-                addpath(f)
-
-    def addpath(self, path):
-        dirs = self._dirs
-        for base in finddirs(path):
-            if base in dirs:
-                dirs[base] += 1
-                return
-            dirs[base] = 1
-
-    def delpath(self, path):
-        dirs = self._dirs
-        for base in finddirs(path):
-            if dirs[base] > 1:
-                dirs[base] -= 1
-                return
-            del dirs[base]
-
-    def __iter__(self):
-        return iter(self._dirs)
-
-    def __contains__(self, d):
-        return d in self._dirs
-
-
-if safehasattr(parsers, 'dirs'):
-    dirs = parsers.dirs
-
-if rustdirs is not None:
-    dirs = rustdirs
-
-
-def finddirs(path):
-    pos = path.rfind(b'/')
-    while pos != -1:
-        yield path[:pos]
-        pos = path.rfind(b'/', 0, pos)
-    yield b''
-
-
 # convenient shortcut
 dst = debugstacktrace
 
--- a/mercurial/utils/cborutil.py	Wed Nov 20 19:07:02 2019 +0100
+++ b/mercurial/utils/cborutil.py	Fri Nov 22 21:42:04 2019 +0900
@@ -46,20 +46,20 @@
 
 # Indefinite types begin with their major type ORd with information value 31.
 BEGIN_INDEFINITE_BYTESTRING = struct.pack(
-    r'>B', MAJOR_TYPE_BYTESTRING << 5 | SUBTYPE_INDEFINITE
+    '>B', MAJOR_TYPE_BYTESTRING << 5 | SUBTYPE_INDEFINITE
 )
 BEGIN_INDEFINITE_ARRAY = struct.pack(
-    r'>B', MAJOR_TYPE_ARRAY << 5 | SUBTYPE_INDEFINITE
+    '>B', MAJOR_TYPE_ARRAY << 5 | SUBTYPE_INDEFINITE
 )
 BEGIN_INDEFINITE_MAP = struct.pack(
-    r'>B', MAJOR_TYPE_MAP << 5 | SUBTYPE_INDEFINITE
+    '>B', MAJOR_TYPE_MAP << 5 | SUBTYPE_INDEFINITE
 )
 
-ENCODED_LENGTH_1 = struct.Struct(r'>B')
-ENCODED_LENGTH_2 = struct.Struct(r'>BB')
-ENCODED_LENGTH_3 = struct.Struct(r'>BH')
-ENCODED_LENGTH_4 = struct.Struct(r'>BL')
-ENCODED_LENGTH_5 = struct.Struct(r'>BQ')
+ENCODED_LENGTH_1 = struct.Struct('>B')
+ENCODED_LENGTH_2 = struct.Struct('>BB')
+ENCODED_LENGTH_3 = struct.Struct('>BH')
+ENCODED_LENGTH_4 = struct.Struct('>BL')
+ENCODED_LENGTH_5 = struct.Struct('>BQ')
 
 # The break ends an indefinite length item.
 BREAK = b'\xff'
@@ -262,7 +262,7 @@
         return ord(b[i])
 
 
-STRUCT_BIG_UBYTE = struct.Struct(r'>B')
+STRUCT_BIG_UBYTE = struct.Struct('>B')
 STRUCT_BIG_USHORT = struct.Struct(b'>H')
 STRUCT_BIG_ULONG = struct.Struct(b'>L')
 STRUCT_BIG_ULONGLONG = struct.Struct(b'>Q')
--- a/mercurial/utils/compression.py	Wed Nov 20 19:07:02 2019 +0100
+++ b/mercurial/utils/compression.py	Fri Nov 22 21:42:04 2019 +0900
@@ -29,8 +29,7 @@
 CLIENTROLE = b'client'
 
 compewireprotosupport = collections.namedtuple(
-    r'compenginewireprotosupport',
-    (r'name', r'serverpriority', r'clientpriority'),
+    'compenginewireprotosupport', ('name', 'serverpriority', 'clientpriority'),
 )
 
 
@@ -646,7 +645,7 @@
         # Not all installs have the zstd module available. So defer importing
         # until first access.
         try:
-            from .. import zstd
+            from .. import zstd  # pytype: disable=import-error
 
             # Force delayed import.
             zstd.__version__
--- a/mercurial/utils/dateutil.py	Wed Nov 20 19:07:02 2019 +0100
+++ b/mercurial/utils/dateutil.py	Fri Nov 22 21:42:04 2019 +0900
@@ -223,7 +223,7 @@
     if date == b'now' or date == _(b'now'):
         return makedate()
     if date == b'today' or date == _(b'today'):
-        date = datetime.date.today().strftime(r'%b %d')
+        date = datetime.date.today().strftime('%b %d')
         date = encoding.strtolocal(date)
     elif date == b'yesterday' or date == _(b'yesterday'):
         date = (datetime.date.today() - datetime.timedelta(days=1)).strftime(
--- a/mercurial/utils/procutil.py	Wed Nov 20 19:07:02 2019 +0100
+++ b/mercurial/utils/procutil.py	Fri Nov 22 21:42:04 2019 +0900
@@ -11,7 +11,6 @@
 
 import contextlib
 import errno
-import imp
 import io
 import os
 import signal
@@ -32,7 +31,10 @@
     pycompat,
 )
 
-osutil = policy.importmod(r'osutil')
+# Import like this to keep import-checker happy
+from ..utils import resourceutil
+
+osutil = policy.importmod('osutil')
 
 stderr = pycompat.stderr
 stdin = pycompat.stdin
@@ -52,11 +54,11 @@
 if isatty(stdout):
     if pycompat.iswindows:
         # Windows doesn't support line buffering
-        stdout = os.fdopen(stdout.fileno(), r'wb', 0)
+        stdout = os.fdopen(stdout.fileno(), 'wb', 0)
     elif not pycompat.ispy3:
         # on Python 3, stdout (sys.stdout.buffer) is already line buffered and
         # buffering=1 is not handled in binary mode
-        stdout = os.fdopen(stdout.fileno(), r'wb', 1)
+        stdout = os.fdopen(stdout.fileno(), 'wb', 1)
 
 if pycompat.iswindows:
     from .. import windows as platform
@@ -211,7 +213,7 @@
     inname, outname = None, None
     try:
         infd, inname = pycompat.mkstemp(prefix=b'hg-filter-in-')
-        fp = os.fdopen(infd, r'wb')
+        fp = os.fdopen(infd, 'wb')
         fp.write(s)
         fp.close()
         outfd, outname = pycompat.mkstemp(prefix=b'hg-filter-out-')
@@ -254,19 +256,6 @@
     return pipefilter(s, cmd)
 
 
-def mainfrozen():
-    """return True if we are a frozen executable.
-
-    The code supports py2exe (most common, Windows only) and tools/freeze
-    (portable, not much used).
-    """
-    return (
-        pycompat.safehasattr(sys, "frozen")
-        or pycompat.safehasattr(sys, "importers")  # new py2exe
-        or imp.is_frozen(r"__main__")  # old py2exe
-    )  # tools/freeze
-
-
 _hgexecutable = None
 
 
@@ -277,21 +266,18 @@
     """
     if _hgexecutable is None:
         hg = encoding.environ.get(b'HG')
-        mainmod = sys.modules[r'__main__']
+        mainmod = sys.modules['__main__']
         if hg:
             _sethgexecutable(hg)
-        elif mainfrozen():
-            if getattr(sys, 'frozen', None) == b'macosx_app':
+        elif resourceutil.mainfrozen():
+            if getattr(sys, 'frozen', None) == 'macosx_app':
                 # Env variable set by py2app
                 _sethgexecutable(encoding.environ[b'EXECUTABLEPATH'])
             else:
                 _sethgexecutable(pycompat.sysexecutable)
         elif (
             not pycompat.iswindows
-            and os.path.basename(
-                pycompat.fsencode(getattr(mainmod, '__file__', b''))
-            )
-            == b'hg'
+            and os.path.basename(getattr(mainmod, '__file__', '')) == 'hg'
         ):
             _sethgexecutable(pycompat.fsencode(mainmod.__file__))
         else:
@@ -340,11 +326,11 @@
         nullfd = os.open(os.devnull, os.O_RDONLY)
         os.dup2(nullfd, uin.fileno())
         os.close(nullfd)
-        fin = os.fdopen(newfd, r'rb')
+        fin = os.fdopen(newfd, 'rb')
     if _testfileno(uout, stdout):
         newfd = os.dup(uout.fileno())
         os.dup2(stderr.fileno(), uout.fileno())
-        fout = os.fdopen(newfd, r'wb')
+        fout = os.fdopen(newfd, 'wb')
     return fin, fout
 
 
@@ -378,7 +364,9 @@
 if pycompat.iswindows:
 
     def shelltonative(cmd, env):
-        return platform.shelltocmdexe(cmd, shellenviron(env))
+        return platform.shelltocmdexe(  # pytype: disable=module-attr
+            cmd, shellenviron(env)
+        )
 
     tonativestr = encoding.strfromlocal
 else:
@@ -457,8 +445,8 @@
     to avoid things opening new shell windows like batch files, so we
     get either the python call or current executable.
     """
-    if mainfrozen():
-        if getattr(sys, 'frozen', None) == b'macosx_app':
+    if resourceutil.mainfrozen():
+        if getattr(sys, 'frozen', None) == 'macosx_app':
             # Env variable set by py2app
             return [encoding.environ[b'EXECUTABLEPATH']]
         else:
@@ -545,7 +533,10 @@
     # Following creation flags might create a console GUI window.
     # Using subprocess.CREATE_NEW_CONSOLE might helps.
     # See https://phab.mercurial-scm.org/D1701 for discussion
-    _creationflags = DETACHED_PROCESS | subprocess.CREATE_NEW_PROCESS_GROUP
+    _creationflags = (
+        DETACHED_PROCESS
+        | subprocess.CREATE_NEW_PROCESS_GROUP  # pytype: disable=module-attr
+    )
 
     def runbgcommand(
         script, env, shell=False, stdout=None, stderr=None, ensurestart=True
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mercurial/utils/resourceutil.py	Fri Nov 22 21:42:04 2019 +0900
@@ -0,0 +1,37 @@
+# resourceutil.py - utility for looking up resources
+#
+#  Copyright 2005 K. Thananchayan <thananck@yahoo.com>
+#  Copyright 2005-2007 Matt Mackall <mpm@selenic.com>
+#  Copyright 2006 Vadim Gelfer <vadim.gelfer@gmail.com>
+#
+# This software may be used and distributed according to the terms of the
+# GNU General Public License version 2 or any later version.
+
+from __future__ import absolute_import
+
+import imp
+import os
+import sys
+
+from .. import pycompat
+
+
+def mainfrozen():
+    """return True if we are a frozen executable.
+
+    The code supports py2exe (most common, Windows only) and tools/freeze
+    (portable, not much used).
+    """
+    return (
+        pycompat.safehasattr(sys, "frozen")
+        or pycompat.safehasattr(sys, "importers")  # new py2exe
+        or imp.is_frozen("__main__")  # old py2exe
+    )  # tools/freeze
+
+
+# the location of data files matching the source code
+if mainfrozen() and getattr(sys, 'frozen', None) != 'macosx_app':
+    # executable version (py2exe) doesn't support __file__
+    datapath = os.path.dirname(pycompat.sysexecutable)
+else:
+    datapath = os.path.dirname(os.path.dirname(pycompat.fsencode(__file__)))
--- a/mercurial/utils/stringutil.py	Wed Nov 20 19:07:02 2019 +0100
+++ b/mercurial/utils/stringutil.py	Fri Nov 22 21:42:04 2019 +0900
@@ -719,7 +719,7 @@
 
                 # First chunk on line is whitespace -- drop it, unless this
                 # is the very beginning of the text (i.e. no lines started yet).
-                if self.drop_whitespace and chunks[-1].strip() == r'' and lines:
+                if self.drop_whitespace and chunks[-1].strip() == '' and lines:
                     del chunks[-1]
 
                 while chunks:
@@ -750,7 +750,7 @@
                 # Convert current line back to a string and store it in list
                 # of all lines (return value).
                 if cur_line:
-                    lines.append(indent + r''.join(cur_line))
+                    lines.append(indent + ''.join(cur_line))
 
             return lines
 
--- a/mercurial/vfs.py	Wed Nov 20 19:07:02 2019 +0100
+++ b/mercurial/vfs.py	Fri Nov 22 21:42:04 2019 +0900
@@ -52,11 +52,17 @@
 
     def __init__(self, *args, **kwargs):
         '''Prevent instantiation; don't call this from subclasses.'''
-        raise NotImplementedError(b'attempted instantiating ' + str(type(self)))
+        raise NotImplementedError('attempted instantiating ' + str(type(self)))
+
+    def __call__(self, path, mode=b'rb', **kwargs):
+        raise NotImplementedError
 
     def _auditpath(self, path, mode):
         raise NotImplementedError
 
+    def join(self, path, *insidef):
+        raise NotImplementedError
+
     def tryread(self, path):
         '''gracefully return an empty string for missing files'''
         try:
@@ -301,7 +307,10 @@
         # Sharing backgroundfilecloser between threads is complex and using
         # multiple instances puts us at risk of running out of file descriptors
         # only allow to use backgroundfilecloser when in main thread.
-        if not isinstance(threading.currentThread(), threading._MainThread):
+        if not isinstance(
+            threading.currentThread(),
+            threading._MainThread,  # pytype: disable=module-attr
+        ):
             yield
             return
         vfs = getattr(self, 'vfs', self)
@@ -312,10 +321,14 @@
 
         with backgroundfilecloser(ui, expectedcount=expectedcount) as bfc:
             try:
-                vfs._backgroundfilecloser = bfc
+                vfs._backgroundfilecloser = (
+                    bfc  # pytype: disable=attribute-error
+                )
                 yield bfc
             finally:
-                vfs._backgroundfilecloser = None
+                vfs._backgroundfilecloser = (
+                    None  # pytype: disable=attribute-error
+                )
 
 
 class vfs(abstractvfs):
@@ -471,9 +484,12 @@
             fp = checkambigatclosing(fp)
 
         if backgroundclose and isinstance(
-            threading.currentThread(), threading._MainThread
+            threading.currentThread(),
+            threading._MainThread,  # pytype: disable=module-attr
         ):
-            if not self._backgroundfilecloser:
+            if (
+                not self._backgroundfilecloser  # pytype: disable=attribute-error
+            ):
                 raise error.Abort(
                     _(
                         b'backgroundclose can only be used when a '
@@ -481,7 +497,10 @@
                     )
                 )
 
-            fp = delayclosedfile(fp, self._backgroundfilecloser)
+            fp = delayclosedfile(
+                fp,
+                self._backgroundfilecloser,  # pytype: disable=attribute-error
+            )
 
         return fp
 
@@ -573,7 +592,7 @@
     """
 
     def __init__(self, fh):
-        object.__setattr__(self, r'_origfh', fh)
+        object.__setattr__(self, '_origfh', fh)
 
     def __getattr__(self, attr):
         return getattr(self._origfh, attr)
@@ -589,10 +608,10 @@
         return self
 
     def __exit__(self, exc_type, exc_value, exc_tb):
-        raise NotImplementedError(b'attempted instantiating ' + str(type(self)))
+        raise NotImplementedError('attempted instantiating ' + str(type(self)))
 
     def close(self):
-        raise NotImplementedError(b'attempted instantiating ' + str(type(self)))
+        raise NotImplementedError('attempted instantiating ' + str(type(self)))
 
 
 class delayclosedfile(closewrapbase):
@@ -603,7 +622,7 @@
 
     def __init__(self, fh, closer):
         super(delayclosedfile, self).__init__(fh)
-        object.__setattr__(self, r'_closer', closer)
+        object.__setattr__(self, '_closer', closer)
 
     def __exit__(self, exc_type, exc_value, exc_tb):
         self._closer.close(self._origfh)
@@ -649,7 +668,7 @@
         self._running = True
 
         for i in range(threadcount):
-            t = threading.Thread(target=self._worker, name=b'backgroundcloser')
+            t = threading.Thread(target=self._worker, name='backgroundcloser')
             self._threads.append(t)
             t.start()
 
@@ -717,7 +736,7 @@
 
     def __init__(self, fh):
         super(checkambigatclosing, self).__init__(fh)
-        object.__setattr__(self, r'_oldstat', util.filestat.frompath(fh.name))
+        object.__setattr__(self, '_oldstat', util.filestat.frompath(fh.name))
 
     def _checkambig(self):
         oldstat = self._oldstat
--- a/mercurial/win32.py	Wed Nov 20 19:07:02 2019 +0100
+++ b/mercurial/win32.py	Fri Nov 22 21:42:04 2019 +0900
@@ -57,21 +57,21 @@
 
 
 class _FILETIME(ctypes.Structure):
-    _fields_ = [(r'dwLowDateTime', _DWORD), (r'dwHighDateTime', _DWORD)]
+    _fields_ = [('dwLowDateTime', _DWORD), ('dwHighDateTime', _DWORD)]
 
 
 class _BY_HANDLE_FILE_INFORMATION(ctypes.Structure):
     _fields_ = [
-        (r'dwFileAttributes', _DWORD),
-        (r'ftCreationTime', _FILETIME),
-        (r'ftLastAccessTime', _FILETIME),
-        (r'ftLastWriteTime', _FILETIME),
-        (r'dwVolumeSerialNumber', _DWORD),
-        (r'nFileSizeHigh', _DWORD),
-        (r'nFileSizeLow', _DWORD),
-        (r'nNumberOfLinks', _DWORD),
-        (r'nFileIndexHigh', _DWORD),
-        (r'nFileIndexLow', _DWORD),
+        ('dwFileAttributes', _DWORD),
+        ('ftCreationTime', _FILETIME),
+        ('ftLastAccessTime', _FILETIME),
+        ('ftLastWriteTime', _FILETIME),
+        ('dwVolumeSerialNumber', _DWORD),
+        ('nFileSizeHigh', _DWORD),
+        ('nFileSizeLow', _DWORD),
+        ('nNumberOfLinks', _DWORD),
+        ('nFileIndexHigh', _DWORD),
+        ('nFileIndexLow', _DWORD),
     ]
 
 
@@ -97,33 +97,33 @@
 
 class _STARTUPINFO(ctypes.Structure):
     _fields_ = [
-        (r'cb', _DWORD),
-        (r'lpReserved', _LPSTR),
-        (r'lpDesktop', _LPSTR),
-        (r'lpTitle', _LPSTR),
-        (r'dwX', _DWORD),
-        (r'dwY', _DWORD),
-        (r'dwXSize', _DWORD),
-        (r'dwYSize', _DWORD),
-        (r'dwXCountChars', _DWORD),
-        (r'dwYCountChars', _DWORD),
-        (r'dwFillAttribute', _DWORD),
-        (r'dwFlags', _DWORD),
-        (r'wShowWindow', _WORD),
-        (r'cbReserved2', _WORD),
-        (r'lpReserved2', ctypes.c_char_p),
-        (r'hStdInput', _HANDLE),
-        (r'hStdOutput', _HANDLE),
-        (r'hStdError', _HANDLE),
+        ('cb', _DWORD),
+        ('lpReserved', _LPSTR),
+        ('lpDesktop', _LPSTR),
+        ('lpTitle', _LPSTR),
+        ('dwX', _DWORD),
+        ('dwY', _DWORD),
+        ('dwXSize', _DWORD),
+        ('dwYSize', _DWORD),
+        ('dwXCountChars', _DWORD),
+        ('dwYCountChars', _DWORD),
+        ('dwFillAttribute', _DWORD),
+        ('dwFlags', _DWORD),
+        ('wShowWindow', _WORD),
+        ('cbReserved2', _WORD),
+        ('lpReserved2', ctypes.c_char_p),
+        ('hStdInput', _HANDLE),
+        ('hStdOutput', _HANDLE),
+        ('hStdError', _HANDLE),
     ]
 
 
 class _PROCESS_INFORMATION(ctypes.Structure):
     _fields_ = [
-        (r'hProcess', _HANDLE),
-        (r'hThread', _HANDLE),
-        (r'dwProcessId', _DWORD),
-        (r'dwThreadId', _DWORD),
+        ('hProcess', _HANDLE),
+        ('hThread', _HANDLE),
+        ('dwProcessId', _DWORD),
+        ('dwThreadId', _DWORD),
     ]
 
 
@@ -132,25 +132,25 @@
 
 
 class _COORD(ctypes.Structure):
-    _fields_ = [(r'X', ctypes.c_short), (r'Y', ctypes.c_short)]
+    _fields_ = [('X', ctypes.c_short), ('Y', ctypes.c_short)]
 
 
 class _SMALL_RECT(ctypes.Structure):
     _fields_ = [
-        (r'Left', ctypes.c_short),
-        (r'Top', ctypes.c_short),
-        (r'Right', ctypes.c_short),
-        (r'Bottom', ctypes.c_short),
+        ('Left', ctypes.c_short),
+        ('Top', ctypes.c_short),
+        ('Right', ctypes.c_short),
+        ('Bottom', ctypes.c_short),
     ]
 
 
 class _CONSOLE_SCREEN_BUFFER_INFO(ctypes.Structure):
     _fields_ = [
-        (r'dwSize', _COORD),
-        (r'dwCursorPosition', _COORD),
-        (r'wAttributes', _WORD),
-        (r'srWindow', _SMALL_RECT),
-        (r'dwMaximumWindowSize', _COORD),
+        ('dwSize', _COORD),
+        ('dwCursorPosition', _COORD),
+        ('wAttributes', _WORD),
+        ('srWindow', _SMALL_RECT),
+        ('dwMaximumWindowSize', _COORD),
     ]
 
 
@@ -167,39 +167,39 @@
 # These structs are only complete enough to achieve what we need.
 class CERT_CHAIN_CONTEXT(ctypes.Structure):
     _fields_ = (
-        (r"cbSize", _DWORD),
+        ("cbSize", _DWORD),
         # CERT_TRUST_STATUS struct
-        (r"dwErrorStatus", _DWORD),
-        (r"dwInfoStatus", _DWORD),
-        (r"cChain", _DWORD),
-        (r"rgpChain", ctypes.c_void_p),
-        (r"cLowerQualityChainContext", _DWORD),
-        (r"rgpLowerQualityChainContext", ctypes.c_void_p),
-        (r"fHasRevocationFreshnessTime", _BOOL),
-        (r"dwRevocationFreshnessTime", _DWORD),
+        ("dwErrorStatus", _DWORD),
+        ("dwInfoStatus", _DWORD),
+        ("cChain", _DWORD),
+        ("rgpChain", ctypes.c_void_p),
+        ("cLowerQualityChainContext", _DWORD),
+        ("rgpLowerQualityChainContext", ctypes.c_void_p),
+        ("fHasRevocationFreshnessTime", _BOOL),
+        ("dwRevocationFreshnessTime", _DWORD),
     )
 
 
 class CERT_USAGE_MATCH(ctypes.Structure):
     _fields_ = (
-        (r"dwType", _DWORD),
+        ("dwType", _DWORD),
         # CERT_ENHKEY_USAGE struct
-        (r"cUsageIdentifier", _DWORD),
-        (r"rgpszUsageIdentifier", ctypes.c_void_p),  # LPSTR *
+        ("cUsageIdentifier", _DWORD),
+        ("rgpszUsageIdentifier", ctypes.c_void_p),  # LPSTR *
     )
 
 
 class CERT_CHAIN_PARA(ctypes.Structure):
     _fields_ = (
-        (r"cbSize", _DWORD),
-        (r"RequestedUsage", CERT_USAGE_MATCH),
-        (r"RequestedIssuancePolicy", CERT_USAGE_MATCH),
-        (r"dwUrlRetrievalTimeout", _DWORD),
-        (r"fCheckRevocationFreshnessTime", _BOOL),
-        (r"dwRevocationFreshnessTime", _DWORD),
-        (r"pftCacheResync", ctypes.c_void_p),  # LPFILETIME
-        (r"pStrongSignPara", ctypes.c_void_p),  # PCCERT_STRONG_SIGN_PARA
-        (r"dwStrongSignFlags", _DWORD),
+        ("cbSize", _DWORD),
+        ("RequestedUsage", CERT_USAGE_MATCH),
+        ("RequestedIssuancePolicy", CERT_USAGE_MATCH),
+        ("dwUrlRetrievalTimeout", _DWORD),
+        ("fCheckRevocationFreshnessTime", _BOOL),
+        ("dwRevocationFreshnessTime", _DWORD),
+        ("pftCacheResync", ctypes.c_void_p),  # LPFILETIME
+        ("pStrongSignPara", ctypes.c_void_p),  # PCCERT_STRONG_SIGN_PARA
+        ("dwStrongSignFlags", _DWORD),
     )
 
 
@@ -359,7 +359,7 @@
         code -= 2 ** 32
     err = ctypes.WinError(code=code)
     raise OSError(
-        err.errno, r'%s: %s' % (encoding.strfromlocal(name), err.strerror)
+        err.errno, '%s: %s' % (encoding.strfromlocal(name), err.strerror)
     )
 
 
@@ -732,7 +732,7 @@
             if e.errno != errno.EEXIST:
                 raise
     else:
-        raise IOError(errno.EEXIST, r"No usable temporary filename found")
+        raise IOError(errno.EEXIST, "No usable temporary filename found")
 
     try:
         os.unlink(temp)
--- a/mercurial/windows.py	Wed Nov 20 19:07:02 2019 +0100
+++ b/mercurial/windows.py	Fri Nov 22 21:42:04 2019 +0900
@@ -32,7 +32,7 @@
 except ImportError:
     import winreg
 
-osutil = policy.importmod(r'osutil')
+osutil = policy.importmod('osutil')
 
 getfsmountpoint = win32.getvolumename
 getfstype = win32.getfstype
@@ -70,8 +70,8 @@
     OPWRITE = 2
 
     def __init__(self, fp):
-        object.__setattr__(self, r'_fp', fp)
-        object.__setattr__(self, r'_lastop', 0)
+        object.__setattr__(self, '_fp', fp)
+        object.__setattr__(self, '_lastop', 0)
 
     def __enter__(self):
         self._fp.__enter__()
@@ -90,42 +90,42 @@
         self._fp.seek(0, os.SEEK_CUR)
 
     def seek(self, *args, **kwargs):
-        object.__setattr__(self, r'_lastop', self.OPNONE)
+        object.__setattr__(self, '_lastop', self.OPNONE)
         return self._fp.seek(*args, **kwargs)
 
     def write(self, d):
         if self._lastop == self.OPREAD:
             self._noopseek()
 
-        object.__setattr__(self, r'_lastop', self.OPWRITE)
+        object.__setattr__(self, '_lastop', self.OPWRITE)
         return self._fp.write(d)
 
     def writelines(self, *args, **kwargs):
         if self._lastop == self.OPREAD:
             self._noopeseek()
 
-        object.__setattr__(self, r'_lastop', self.OPWRITE)
+        object.__setattr__(self, '_lastop', self.OPWRITE)
         return self._fp.writelines(*args, **kwargs)
 
     def read(self, *args, **kwargs):
         if self._lastop == self.OPWRITE:
             self._noopseek()
 
-        object.__setattr__(self, r'_lastop', self.OPREAD)
+        object.__setattr__(self, '_lastop', self.OPREAD)
         return self._fp.read(*args, **kwargs)
 
     def readline(self, *args, **kwargs):
         if self._lastop == self.OPWRITE:
             self._noopseek()
 
-        object.__setattr__(self, r'_lastop', self.OPREAD)
+        object.__setattr__(self, '_lastop', self.OPREAD)
         return self._fp.readline(*args, **kwargs)
 
     def readlines(self, *args, **kwargs):
         if self._lastop == self.OPWRITE:
             self._noopseek()
 
-        object.__setattr__(self, r'_lastop', self.OPREAD)
+        object.__setattr__(self, '_lastop', self.OPREAD)
         return self._fp.readlines(*args, **kwargs)
 
 
@@ -176,7 +176,7 @@
     except WindowsError as err:
         # convert to a friendlier exception
         raise IOError(
-            err.errno, r'%s: %s' % (encoding.strfromlocal(name), err.strerror)
+            err.errno, '%s: %s' % (encoding.strfromlocal(name), err.strerror)
         )
 
 
@@ -215,7 +215,7 @@
             if inst.errno != 0 and not win32.lasterrorwaspipeerror(inst):
                 raise
             self.close()
-            raise IOError(errno.EPIPE, r'Broken pipe')
+            raise IOError(errno.EPIPE, 'Broken pipe')
 
     def flush(self):
         try:
@@ -223,7 +223,7 @@
         except IOError as inst:
             if not win32.lasterrorwaspipeerror(inst):
                 raise
-            raise IOError(errno.EPIPE, r'Broken pipe')
+            raise IOError(errno.EPIPE, 'Broken pipe')
 
 
 def _is_win_9x():
@@ -686,4 +686,4 @@
 
 
 def bindunixsocket(sock, path):
-    raise NotImplementedError(r'unsupported platform')
+    raise NotImplementedError('unsupported platform')
--- a/mercurial/wireprotoframing.py	Wed Nov 20 19:07:02 2019 +0100
+++ b/mercurial/wireprotoframing.py	Fri Nov 22 21:42:04 2019 +0900
@@ -118,7 +118,7 @@
     FRAME_TYPE_STREAM_SETTINGS: FLAGS_STREAM_ENCODING_SETTINGS,
 }
 
-ARGUMENT_RECORD_HEADER = struct.Struct(r'<HH')
+ARGUMENT_RECORD_HEADER = struct.Struct('<HH')
 
 
 def humanflags(mapping, value):
@@ -191,9 +191,9 @@
     # 4 bits type
     # 4 bits flags
 
-    l = struct.pack(r'<I', len(payload))
+    l = struct.pack('<I', len(payload))
     frame[0:3] = l[0:3]
-    struct.pack_into(r'<HBB', frame, 3, requestid, streamid, streamflags)
+    struct.pack_into('<HBB', frame, 3, requestid, streamid, streamflags)
     frame[7] = (typeid << 4) | flags
     frame[8:] = payload
 
@@ -280,7 +280,7 @@
     # 4 bits frame flags
     # ... payload
     framelength = data[0] + 256 * data[1] + 16384 * data[2]
-    requestid, streamid, streamflags = struct.unpack_from(r'<HBB', data, 3)
+    requestid, streamid, streamflags = struct.unpack_from('<HBB', data, 3)
     typeflags = data[7]
 
     frametype = (typeflags & 0xF0) >> 4
@@ -460,11 +460,11 @@
     }
 
     for a in (
-        r'size',
-        r'fullhashes',
-        r'fullhashseed',
-        r'serverdercerts',
-        r'servercadercerts',
+        'size',
+        'fullhashes',
+        'fullhashseed',
+        'serverdercerts',
+        'servercadercerts',
     ):
         value = getattr(location, a)
         if value is not None:
@@ -548,15 +548,13 @@
                 raise ValueError(b'must use bytes for labels')
 
         # Formatting string must be ASCII.
-        formatting = formatting.decode(r'ascii', r'replace').encode(r'ascii')
+        formatting = formatting.decode('ascii', 'replace').encode('ascii')
 
         # Arguments must be UTF-8.
-        args = [a.decode(r'utf-8', r'replace').encode(r'utf-8') for a in args]
+        args = [a.decode('utf-8', 'replace').encode('utf-8') for a in args]
 
         # Labels must be ASCII.
-        labels = [
-            l.decode(r'ascii', r'strict').encode(r'ascii') for l in labels
-        ]
+        labels = [l.decode('ascii', 'strict').encode('ascii') for l in labels]
 
         atom = {b'msg': formatting}
         if args:
--- a/mercurial/wireprototypes.py	Wed Nov 20 19:07:02 2019 +0100
+++ b/mercurial/wireprototypes.py	Fri Nov 22 21:42:04 2019 +0900
@@ -404,7 +404,7 @@
             )
             % config,
             hint=_(b'usable compression engines: %s')
-            % b', '.sorted(validnames),
+            % b', '.sorted(validnames),  # pytype: disable=attribute-error
         )
 
     return compengines
--- a/mercurial/wireprotov1peer.py	Wed Nov 20 19:07:02 2019 +0100
+++ b/mercurial/wireprotov1peer.py	Fri Nov 22 21:42:04 2019 +0900
@@ -599,9 +599,9 @@
         # don't pass optional arguments left at their default value
         opts = {}
         if three is not None:
-            opts[r'three'] = three
+            opts['three'] = three
         if four is not None:
-            opts[r'four'] = four
+            opts['four'] = four
         return self._call(b'debugwireargs', one=one, two=two, **opts)
 
     def _call(self, cmd, **args):
--- a/mercurial/wireprotov1server.py	Wed Nov 20 19:07:02 2019 +0100
+++ b/mercurial/wireprotov1server.py	Fri Nov 22 21:42:04 2019 +0900
@@ -679,7 +679,7 @@
             if not getattr(exc, 'duringunbundle2', False):
                 try:
                     raise
-                except error.Abort:
+                except error.Abort as exc:
                     # The old code we moved used procutil.stderr directly.
                     # We did not change it to minimise code change.
                     # This need to be moved to something proper.
--- a/mercurial/wireprotov2peer.py	Wed Nov 20 19:07:02 2019 +0100
+++ b/mercurial/wireprotov2peer.py	Fri Nov 22 21:42:04 2019 +0900
@@ -472,7 +472,7 @@
             )
 
         headers = {
-            r'Accept': redirect.mediatype,
+            'Accept': redirect.mediatype,
         }
 
         req = self._requestbuilder(pycompat.strurl(redirect.url), None, headers)
--- a/mercurial/worker.py	Wed Nov 20 19:07:02 2019 +0100
+++ b/mercurial/worker.py	Fri Nov 22 21:42:04 2019 +0900
@@ -36,7 +36,7 @@
 
     # posix
     try:
-        n = int(os.sysconf(r'SC_NPROCESSORS_ONLN'))
+        n = int(os.sysconf('SC_NPROCESSORS_ONLN'))
         if n > 0:
             return n
     except (AttributeError, ValueError):
@@ -226,7 +226,7 @@
     selector = selectors.DefaultSelector()
     for rfd, wfd in pipes:
         os.close(wfd)
-        selector.register(os.fdopen(rfd, r'rb', 0), selectors.EVENT_READ)
+        selector.register(os.fdopen(rfd, 'rb', 0), selectors.EVENT_READ)
 
     def cleanup():
         signal.signal(signal.SIGINT, oldhandler)
--- a/relnotes/next	Wed Nov 20 19:07:02 2019 +0100
+++ b/relnotes/next	Fri Nov 22 21:42:04 2019 +0900
@@ -6,6 +6,9 @@
 
 == Bug Fixes  ==
 
+ * The `indent()` template function was documented to not indent empty lines,
+   but it still indented the first line even if it was empty. It no longer does
+   that.
 
 == Backwards Compatibility Changes ==
 
--- a/rust/hg-core/src/dirstate.rs	Wed Nov 20 19:07:02 2019 +0100
+++ b/rust/hg-core/src/dirstate.rs	Fri Nov 22 21:42:04 2019 +0900
@@ -32,6 +32,11 @@
     pub size: i32,
 }
 
+/// A `DirstateEntry` with a size of `-2` means that it was merged from the
+/// other parent. This allows revert to pick the right status back during a
+/// merge.
+pub const SIZE_FROM_OTHER_PARENT: i32 = -2;
+
 pub type StateMap = HashMap<HgPathBuf, DirstateEntry>;
 pub type StateMapIter<'a> = hash_map::Iter<'a, HgPathBuf, DirstateEntry>;
 pub type CopyMap = HashMap<HgPathBuf, HgPathBuf>;
--- a/rust/hg-core/src/dirstate/dirstate_map.rs	Wed Nov 20 19:07:02 2019 +0100
+++ b/rust/hg-core/src/dirstate/dirstate_map.rs	Fri Nov 22 21:42:04 2019 +0900
@@ -5,11 +5,13 @@
 // This software may be used and distributed according to the terms of the
 // GNU General Public License version 2 or any later version.
 
-use crate::utils::hg_path::{HgPath, HgPathBuf};
 use crate::{
-    dirstate::{parsers::PARENT_SIZE, EntryState},
+    dirstate::{parsers::PARENT_SIZE, EntryState, SIZE_FROM_OTHER_PARENT},
     pack_dirstate, parse_dirstate,
-    utils::files::normalize_case,
+    utils::{
+        files::normalize_case,
+        hg_path::{HgPath, HgPathBuf},
+    },
     CopyMap, DirsMultiset, DirstateEntry, DirstateError, DirstateMapError,
     DirstateParents, DirstateParseError, StateMap,
 };
@@ -24,7 +26,6 @@
 
 const NULL_ID: [u8; 20] = [0; 20];
 const MTIME_UNSET: i32 = -1;
-const SIZE_DIRTY: i32 = -2;
 
 #[derive(Default)]
 pub struct DirstateMap {
@@ -100,7 +101,7 @@
             self.non_normal_set.insert(filename.to_owned());
         }
 
-        if entry.size == SIZE_DIRTY {
+        if entry.size == SIZE_FROM_OTHER_PARENT {
             self.other_parent_set.insert(filename.to_owned());
         }
     }
@@ -212,7 +213,8 @@
             if *state != EntryState::Normal || *mtime == MTIME_UNSET {
                 non_normal.insert(filename.to_owned());
             }
-            if *state == EntryState::Normal && *size == SIZE_DIRTY {
+            if *state == EntryState::Normal && *size == SIZE_FROM_OTHER_PARENT
+            {
                 other_parent.insert(filename.to_owned());
             }
         }
--- a/rust/hg-core/src/dirstate/status.rs	Wed Nov 20 19:07:02 2019 +0100
+++ b/rust/hg-core/src/dirstate/status.rs	Fri Nov 22 21:42:04 2019 +0900
@@ -9,131 +9,174 @@
 //! It is currently missing a lot of functionality compared to the Python one
 //! and will only be triggered in narrow cases.
 
-use crate::utils::files::HgMetadata;
-use crate::utils::hg_path::{hg_path_to_path_buf, HgPath, HgPathBuf};
-use crate::{DirstateEntry, DirstateMap, EntryState};
+use crate::{
+    dirstate::SIZE_FROM_OTHER_PARENT,
+    utils::{
+        files::HgMetadata,
+        hg_path::{hg_path_to_path_buf, HgPath},
+    },
+    CopyMap, DirstateEntry, DirstateMap, EntryState,
+};
 use rayon::prelude::*;
-use std::collections::HashMap;
-use std::fs::Metadata;
 use std::path::Path;
 
-/// Get stat data about the files explicitly specified by match.
-/// TODO subrepos
-fn walk_explicit(
-    files: &[impl AsRef<HgPath> + Sync],
-    dmap: &DirstateMap,
-    root_dir: impl AsRef<Path> + Sync,
-) -> std::io::Result<HashMap<HgPathBuf, Option<HgMetadata>>> {
-    let mut results = HashMap::new();
-
-    // A tuple of the normalized filename and the `Result` of the call to
-    // `symlink_metadata` for separate handling.
-    type WalkTuple<'a> = (&'a HgPath, std::io::Result<Metadata>);
-
-    let stats_res: std::io::Result<Vec<WalkTuple>> = files
-        .par_iter()
-        .map(|filename| {
-            // TODO normalization
-            let normalized = filename.as_ref();
-
-            let target_filename =
-                root_dir.as_ref().join(hg_path_to_path_buf(normalized)?);
+/// Marker enum used to dispatch new status entries into the right collections.
+/// Is similar to `crate::EntryState`, but represents the transient state of
+/// entries during the lifetime of a command.
+enum Dispatch {
+    Unsure,
+    Modified,
+    Added,
+    Removed,
+    Deleted,
+    Clean,
+    Unknown,
+}
 
-            Ok((normalized, target_filename.symlink_metadata()))
-        })
-        .collect();
-
-    for res in stats_res? {
-        match res {
-            (normalized, Ok(stat)) => {
-                if stat.is_file() {
-                    results.insert(
-                        normalized.to_owned(),
-                        Some(HgMetadata::from_metadata(stat)),
-                    );
-                } else {
-                    if dmap.contains_key(normalized) {
-                        results.insert(normalized.to_owned(), None);
-                    }
-                }
-            }
-            (normalized, Err(_)) => {
-                if dmap.contains_key(normalized) {
-                    results.insert(normalized.to_owned(), None);
-                }
-            }
-        };
-    }
-
-    Ok(results)
+/// Dates and times that are outside the 31-bit signed range are compared
+/// modulo 2^31. This should prevent hg from behaving badly with very large
+/// files or corrupt dates while still having a high probability of detecting
+/// changes. (issue2608)
+/// TODO I haven't found a way of having `b` be `Into<i32>`, since `From<u64>`
+/// is not defined for `i32`, and there is no `As` trait. This forces the
+/// caller to cast `b` as `i32`.
+fn mod_compare(a: i32, b: i32) -> bool {
+    a & i32::max_value() != b & i32::max_value()
 }
 
-// Stat all entries in the `DirstateMap` and return their new metadata.
-pub fn stat_dmap_entries(
-    dmap: &DirstateMap,
-    results: &HashMap<HgPathBuf, Option<HgMetadata>>,
-    root_dir: impl AsRef<Path> + Sync,
-) -> std::io::Result<Vec<(HgPathBuf, Option<HgMetadata>)>> {
-    dmap.par_iter()
-        .filter_map(
-            // Getting file metadata is costly, so we don't do it if the
-            // file is already present in the results, hence `filter_map`
-            |(filename, _)| -> Option<
-                std::io::Result<(HgPathBuf, Option<HgMetadata>)>
-            > {
-                if results.contains_key(filename) {
-                    return None;
-                }
-                let meta = match hg_path_to_path_buf(filename) {
-                    Ok(p) => root_dir.as_ref().join(p).symlink_metadata(),
-                    Err(e) => return Some(Err(e.into())),
-                };
+/// The file corresponding to the dirstate entry was found on the filesystem.
+fn dispatch_found(
+    filename: impl AsRef<HgPath>,
+    entry: DirstateEntry,
+    metadata: HgMetadata,
+    copy_map: &CopyMap,
+    check_exec: bool,
+    list_clean: bool,
+    last_normal_time: i64,
+) -> Dispatch {
+    let DirstateEntry {
+        state,
+        mode,
+        mtime,
+        size,
+    } = entry;
+
+    let HgMetadata {
+        st_mode,
+        st_size,
+        st_mtime,
+        ..
+    } = metadata;
 
-                Some(match meta {
-                    Ok(ref m)
-                        if !(m.file_type().is_file()
-                            || m.file_type().is_symlink()) =>
-                    {
-                        Ok((filename.to_owned(), None))
-                    }
-                    Ok(m) => Ok((
-                        filename.to_owned(),
-                        Some(HgMetadata::from_metadata(m)),
-                    )),
-                    Err(ref e)
-                        if e.kind() == std::io::ErrorKind::NotFound
-                            || e.raw_os_error() == Some(20) =>
-                    {
-                        // Rust does not yet have an `ErrorKind` for
-                        // `NotADirectory` (errno 20)
-                        // It happens if the dirstate contains `foo/bar` and
-                        // foo is not a directory
-                        Ok((filename.to_owned(), None))
-                    }
-                    Err(e) => Err(e),
-                })
-            },
-        )
-        .collect()
+    match state {
+        EntryState::Normal => {
+            let size_changed = mod_compare(size, st_size as i32);
+            let mode_changed =
+                (mode ^ st_mode as i32) & 0o100 != 0o000 && check_exec;
+            let metadata_changed = size >= 0 && (size_changed || mode_changed);
+            let other_parent = size == SIZE_FROM_OTHER_PARENT;
+            if metadata_changed
+                || other_parent
+                || copy_map.contains_key(filename.as_ref())
+            {
+                Dispatch::Modified
+            } else if mod_compare(mtime, st_mtime as i32) {
+                Dispatch::Unsure
+            } else if st_mtime == last_normal_time {
+                // the file may have just been marked as normal and
+                // it may have changed in the same second without
+                // changing its size. This can happen if we quickly
+                // do multiple commits. Force lookup, so we don't
+                // miss such a racy file change.
+                Dispatch::Unsure
+            } else if list_clean {
+                Dispatch::Clean
+            } else {
+                Dispatch::Unknown
+            }
+        }
+        EntryState::Merged => Dispatch::Modified,
+        EntryState::Added => Dispatch::Added,
+        EntryState::Removed => Dispatch::Removed,
+        EntryState::Unknown => Dispatch::Unknown,
+    }
 }
 
-pub struct StatusResult {
-    pub modified: Vec<HgPathBuf>,
-    pub added: Vec<HgPathBuf>,
-    pub removed: Vec<HgPathBuf>,
-    pub deleted: Vec<HgPathBuf>,
-    pub clean: Vec<HgPathBuf>,
+/// The file corresponding to this Dirstate entry is missing.
+fn dispatch_missing(state: EntryState) -> Dispatch {
+    match state {
+        // File was removed from the filesystem during commands
+        EntryState::Normal | EntryState::Merged | EntryState::Added => {
+            Dispatch::Deleted
+        }
+        // File was removed, everything is normal
+        EntryState::Removed => Dispatch::Removed,
+        // File is unknown to Mercurial, everything is normal
+        EntryState::Unknown => Dispatch::Unknown,
+    }
+}
+
+/// Stat all entries in the `DirstateMap` and mark them for dispatch into
+/// the relevant collections.
+fn stat_dmap_entries(
+    dmap: &DirstateMap,
+    root_dir: impl AsRef<Path> + Sync + Send,
+    check_exec: bool,
+    list_clean: bool,
+    last_normal_time: i64,
+) -> impl ParallelIterator<Item = std::io::Result<(&HgPath, Dispatch)>> {
+    dmap.par_iter().map(move |(filename, entry)| {
+        let filename: &HgPath = filename;
+        let filename_as_path = hg_path_to_path_buf(filename)?;
+        let meta = root_dir.as_ref().join(filename_as_path).symlink_metadata();
+
+        match meta {
+            Ok(ref m)
+                if !(m.file_type().is_file()
+                    || m.file_type().is_symlink()) =>
+            {
+                Ok((filename, dispatch_missing(entry.state)))
+            }
+            Ok(m) => Ok((
+                filename,
+                dispatch_found(
+                    filename,
+                    *entry,
+                    HgMetadata::from_metadata(m),
+                    &dmap.copy_map,
+                    check_exec,
+                    list_clean,
+                    last_normal_time,
+                ),
+            )),
+            Err(ref e)
+                if e.kind() == std::io::ErrorKind::NotFound
+                    || e.raw_os_error() == Some(20) =>
+            {
+                // Rust does not yet have an `ErrorKind` for
+                // `NotADirectory` (errno 20)
+                // It happens if the dirstate contains `foo/bar` and
+                // foo is not a directory
+                Ok((filename, dispatch_missing(entry.state)))
+            }
+            Err(e) => Err(e),
+        }
+    })
+}
+
+pub struct StatusResult<'a> {
+    pub modified: Vec<&'a HgPath>,
+    pub added: Vec<&'a HgPath>,
+    pub removed: Vec<&'a HgPath>,
+    pub deleted: Vec<&'a HgPath>,
+    pub clean: Vec<&'a HgPath>,
     // TODO ignored
     // TODO unknown
 }
 
 fn build_response(
-    dmap: &DirstateMap,
-    list_clean: bool,
-    last_normal_time: i64,
-    check_exec: bool,
-    results: HashMap<HgPathBuf, Option<HgMetadata>>,
-) -> (Vec<HgPathBuf>, StatusResult) {
+    results: Vec<(&HgPath, Dispatch)>,
+) -> (Vec<&HgPath>, StatusResult) {
     let mut lookup = vec![];
     let mut modified = vec![];
     let mut added = vec![];
@@ -141,76 +184,15 @@
     let mut deleted = vec![];
     let mut clean = vec![];
 
-    for (filename, metadata_option) in results.into_iter() {
-        let DirstateEntry {
-            state,
-            mode,
-            mtime,
-            size,
-        } = match dmap.get(&filename) {
-            None => {
-                continue;
-            }
-            Some(e) => *e,
-        };
-
-        match metadata_option {
-            None => {
-                match state {
-                    EntryState::Normal
-                    | EntryState::Merged
-                    | EntryState::Added => deleted.push(filename),
-                    EntryState::Removed => removed.push(filename),
-                    _ => {}
-                };
-            }
-            Some(HgMetadata {
-                st_mode,
-                st_size,
-                st_mtime,
-                ..
-            }) => {
-                match state {
-                    EntryState::Normal => {
-                        // Dates and times that are outside the 31-bit signed
-                        // range are compared modulo 2^31. This should prevent
-                        // it from behaving badly with very large files or
-                        // corrupt dates while still having a high probability
-                        // of detecting changes. (issue2608)
-                        let range_mask = 0x7fffffff;
-
-                        let size_changed = (size != st_size as i32)
-                            && size != (st_size as i32 & range_mask);
-                        let mode_changed = (mode ^ st_mode as i32) & 0o100
-                            != 0o000
-                            && check_exec;
-                        if size >= 0
-                            && (size_changed || mode_changed)
-                            || size == -2  // other parent
-                            || dmap.copy_map.contains_key(&filename)
-                        {
-                            modified.push(filename);
-                        } else if mtime != st_mtime as i32
-                            && mtime != (st_mtime as i32 & range_mask)
-                        {
-                            lookup.push(filename);
-                        } else if st_mtime == last_normal_time {
-                            // the file may have just been marked as normal and
-                            // it may have changed in the same second without
-                            // changing its size. This can happen if we quickly
-                            // do multiple commits. Force lookup, so we don't
-                            // miss such a racy file change.
-                            lookup.push(filename);
-                        } else if list_clean {
-                            clean.push(filename);
-                        }
-                    }
-                    EntryState::Merged => modified.push(filename),
-                    EntryState::Added => added.push(filename),
-                    EntryState::Removed => removed.push(filename),
-                    EntryState::Unknown => {}
-                }
-            }
+    for (filename, dispatch) in results.into_iter() {
+        match dispatch {
+            Dispatch::Unknown => {}
+            Dispatch::Unsure => lookup.push(filename),
+            Dispatch::Modified => modified.push(filename),
+            Dispatch::Added => added.push(filename),
+            Dispatch::Removed => removed.push(filename),
+            Dispatch::Deleted => deleted.push(filename),
+            Dispatch::Clean => clean.push(filename),
         }
     }
 
@@ -228,21 +210,19 @@
 
 pub fn status(
     dmap: &DirstateMap,
-    root_dir: impl AsRef<Path> + Sync + Copy,
-    files: &[impl AsRef<HgPath> + Sync],
+    root_dir: impl AsRef<Path> + Sync + Send + Copy,
     list_clean: bool,
     last_normal_time: i64,
     check_exec: bool,
-) -> std::io::Result<(Vec<HgPathBuf>, StatusResult)> {
-    let mut results = walk_explicit(files, &dmap, root_dir)?;
-
-    results.extend(stat_dmap_entries(&dmap, &results, root_dir)?);
-
-    Ok(build_response(
+) -> std::io::Result<(Vec<&HgPath>, StatusResult)> {
+    let results: std::io::Result<_> = stat_dmap_entries(
         &dmap,
+        root_dir,
+        check_exec,
         list_clean,
         last_normal_time,
-        check_exec,
-        results,
-    ))
+    )
+    .collect();
+
+    Ok(build_response(results?))
 }
--- a/rust/hg-core/src/lib.rs	Wed Nov 20 19:07:02 2019 +0100
+++ b/rust/hg-core/src/lib.rs	Fri Nov 22 21:42:04 2019 +0900
@@ -17,6 +17,7 @@
     StateMap, StateMapIter,
 };
 mod filepatterns;
+pub mod matchers;
 pub mod utils;
 
 use crate::utils::hg_path::HgPathBuf;
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/rust/hg-core/src/matchers.rs	Fri Nov 22 21:42:04 2019 +0900
@@ -0,0 +1,106 @@
+// matchers.rs
+//
+// Copyright 2019 Raphaël Gomès <rgomes@octobus.net>
+//
+// This software may be used and distributed according to the terms of the
+// GNU General Public License version 2 or any later version.
+
+//! Structs and types for matching files and directories.
+
+use crate::utils::hg_path::{HgPath, HgPathBuf};
+use std::collections::HashSet;
+
+pub enum VisitChildrenSet {
+    /// Don't visit anything
+    Empty,
+    /// Only visit this directory
+    This,
+    /// Visit this directory and these subdirectories
+    /// TODO Should we implement a `NonEmptyHashSet`?
+    Set(HashSet<HgPathBuf>),
+    /// Visit this directory and all subdirectories
+    Recursive,
+}
+
+pub trait Matcher {
+    /// Explicitly listed files
+    fn file_set(&self) -> HashSet<&HgPath>;
+    /// Returns whether `filename` is in `file_set`
+    fn exact_match(&self, filename: impl AsRef<HgPath>) -> bool;
+    /// Returns whether `filename` is matched by this matcher
+    fn matches(&self, filename: impl AsRef<HgPath>) -> bool;
+    /// Decides whether a directory should be visited based on whether it
+    /// has potential matches in it or one of its subdirectories, and
+    /// potentially lists which subdirectories of that directory should be
+    /// visited. This is based on the match's primary, included, and excluded
+    /// patterns.
+    ///
+    /// # Example
+    ///
+    /// Assume matchers `['path:foo/bar', 'rootfilesin:qux']`, we would
+    /// return the following values (assuming the implementation of
+    /// visit_children_set is capable of recognizing this; some implementations
+    /// are not).
+    ///
+    /// ```ignore
+    /// '' -> {'foo', 'qux'}
+    /// 'baz' -> set()
+    /// 'foo' -> {'bar'}
+    /// // Ideally this would be `Recursive`, but since the prefix nature of
+    /// // matchers is applied to the entire matcher, we have to downgrade this
+    /// // to `This` due to the (yet to be implemented in Rust) non-prefix
+    /// // `RootFilesIn'-kind matcher being mixed in.
+    /// 'foo/bar' -> 'this'
+    /// 'qux' -> 'this'
+    /// ```
+    /// # Important
+    ///
+    /// Most matchers do not know if they're representing files or
+    /// directories. They see `['path:dir/f']` and don't know whether `f` is a
+    /// file or a directory, so `visit_children_set('dir')` for most matchers
+    /// will return `HashSet{ HgPath { "f" } }`, but if the matcher knows it's
+    /// a file (like the yet to be implemented in Rust `ExactMatcher` does),
+    /// it may return `VisitChildrenSet::This`.
+    /// Do not rely on the return being a `HashSet` indicating that there are
+    /// no files in this dir to investigate (or equivalently that if there are
+    /// files to investigate in 'dir' that it will always return
+    /// `VisitChildrenSet::This`).
+    fn visit_children_set(
+        &self,
+        directory: impl AsRef<HgPath>,
+    ) -> VisitChildrenSet;
+    /// Matcher will match everything and `files_set()` will be empty:
+    /// optimization might be possible.
+    fn matches_everything(&self) -> bool;
+    /// Matcher will match exactly the files in `files_set()`: optimization
+    /// might be possible.
+    fn is_exact(&self) -> bool;
+}
+
+/// Matches everything.
+#[derive(Debug)]
+pub struct AlwaysMatcher;
+
+impl Matcher for AlwaysMatcher {
+    fn file_set(&self) -> HashSet<&HgPath> {
+        HashSet::new()
+    }
+    fn exact_match(&self, _filename: impl AsRef<HgPath>) -> bool {
+        false
+    }
+    fn matches(&self, _filename: impl AsRef<HgPath>) -> bool {
+        true
+    }
+    fn visit_children_set(
+        &self,
+        _directory: impl AsRef<HgPath>,
+    ) -> VisitChildrenSet {
+        VisitChildrenSet::Recursive
+    }
+    fn matches_everything(&self) -> bool {
+        true
+    }
+    fn is_exact(&self) -> bool {
+        false
+    }
+}
--- a/rust/hg-core/src/utils/files.rs	Wed Nov 20 19:07:02 2019 +0100
+++ b/rust/hg-core/src/utils/files.rs	Fri Nov 22 21:42:04 2019 +0900
@@ -119,7 +119,7 @@
 
     #[test]
     fn find_dirs_empty() {
-        // looks weird, but mercurial.util.finddirs(b"") yields b""
+        // looks weird, but mercurial.pathutil.finddirs(b"") yields b""
         let mut dirs = super::find_dirs(HgPath::new(b""));
         assert_eq!(dirs.next(), Some(HgPath::new(b"")));
         assert_eq!(dirs.next(), None);
--- a/rust/hg-cpython/src/dirstate.rs	Wed Nov 20 19:07:02 2019 +0100
+++ b/rust/hg-cpython/src/dirstate.rs	Fri Nov 22 21:42:04 2019 +0900
@@ -17,8 +17,8 @@
     dirs_multiset::Dirs, dirstate_map::DirstateMap, status::status_wrapper,
 };
 use cpython::{
-    exc, PyBytes, PyDict, PyErr, PyList, PyModule, PyObject, PyResult,
-    PySequence, Python,
+    exc, PyBytes, PyDict, PyErr, PyModule, PyObject, PyResult, PySequence,
+    Python,
 };
 use hg::{
     utils::hg_path::HgPathBuf, DirstateEntry, DirstateParseError, EntryState,
@@ -116,7 +116,6 @@
             status_wrapper(
                 dmap: DirstateMap,
                 root_dir: PyObject,
-                files: PyList,
                 list_clean: bool,
                 last_normal_time: i64,
                 check_exec: bool
--- a/rust/hg-cpython/src/dirstate/copymap.rs	Wed Nov 20 19:07:02 2019 +0100
+++ b/rust/hg-cpython/src/dirstate/copymap.rs	Fri Nov 22 21:42:04 2019 +0900
@@ -12,7 +12,7 @@
 use std::cell::RefCell;
 
 use crate::dirstate::dirstate_map::DirstateMap;
-use crate::ref_sharing::PyLeakedRef;
+use crate::ref_sharing::PyLeaked;
 use hg::{utils::hg_path::HgPathBuf, CopyMapIter};
 
 py_class!(pub class CopyMap |py| {
@@ -104,14 +104,14 @@
 
 py_shared_iterator!(
     CopyMapKeysIterator,
-    PyLeakedRef<CopyMapIter<'static>>,
+    PyLeaked<CopyMapIter<'static>>,
     CopyMap::translate_key,
     Option<PyBytes>
 );
 
 py_shared_iterator!(
     CopyMapItemsIterator,
-    PyLeakedRef<CopyMapIter<'static>>,
+    PyLeaked<CopyMapIter<'static>>,
     CopyMap::translate_key_value,
     Option<(PyBytes, PyBytes)>
 );
--- a/rust/hg-cpython/src/dirstate/dirs_multiset.rs	Wed Nov 20 19:07:02 2019 +0100
+++ b/rust/hg-cpython/src/dirstate/dirs_multiset.rs	Fri Nov 22 21:42:04 2019 +0900
@@ -17,7 +17,7 @@
 };
 
 use crate::dirstate::extract_dirstate;
-use crate::ref_sharing::{PyLeakedRef, PySharedRefCell};
+use crate::ref_sharing::{PyLeaked, PySharedRefCell};
 use hg::{
     utils::hg_path::{HgPath, HgPathBuf},
     DirsMultiset, DirsMultisetIter, DirstateMapError, DirstateParseError,
@@ -92,7 +92,7 @@
             })
     }
     def __iter__(&self) -> PyResult<DirsMultisetKeysIterator> {
-        let leaked_ref = self.inner_shared(py).leak_immutable()?;
+        let leaked_ref = self.inner_shared(py).leak_immutable();
         DirsMultisetKeysIterator::from_inner(
             py,
             unsafe { leaked_ref.map(py, |o| o.iter()) },
@@ -123,7 +123,7 @@
 
 py_shared_iterator!(
     DirsMultisetKeysIterator,
-    PyLeakedRef<DirsMultisetIter<'static>>,
+    PyLeaked<DirsMultisetIter<'static>>,
     Dirs::translate_key,
     Option<PyBytes>
 );
--- a/rust/hg-cpython/src/dirstate/dirstate_map.rs	Wed Nov 20 19:07:02 2019 +0100
+++ b/rust/hg-cpython/src/dirstate/dirstate_map.rs	Fri Nov 22 21:42:04 2019 +0900
@@ -20,7 +20,7 @@
 use crate::{
     dirstate::copymap::{CopyMap, CopyMapItemsIterator, CopyMapKeysIterator},
     dirstate::{dirs_multiset::Dirs, make_dirstate_tuple},
-    ref_sharing::{PyLeakedRef, PySharedRefCell},
+    ref_sharing::{PyLeaked, PySharedRefCell},
 };
 use hg::{
     utils::hg_path::{HgPath, HgPathBuf},
@@ -304,7 +304,7 @@
     }
 
     def keys(&self) -> PyResult<DirstateMapKeysIterator> {
-        let leaked_ref = self.inner_shared(py).leak_immutable()?;
+        let leaked_ref = self.inner_shared(py).leak_immutable();
         DirstateMapKeysIterator::from_inner(
             py,
             unsafe { leaked_ref.map(py, |o| o.iter()) },
@@ -312,7 +312,7 @@
     }
 
     def items(&self) -> PyResult<DirstateMapItemsIterator> {
-        let leaked_ref = self.inner_shared(py).leak_immutable()?;
+        let leaked_ref = self.inner_shared(py).leak_immutable();
         DirstateMapItemsIterator::from_inner(
             py,
             unsafe { leaked_ref.map(py, |o| o.iter()) },
@@ -320,7 +320,7 @@
     }
 
     def __iter__(&self) -> PyResult<DirstateMapKeysIterator> {
-        let leaked_ref = self.inner_shared(py).leak_immutable()?;
+        let leaked_ref = self.inner_shared(py).leak_immutable();
         DirstateMapKeysIterator::from_inner(
             py,
             unsafe { leaked_ref.map(py, |o| o.iter()) },
@@ -437,7 +437,7 @@
     }
 
     def copymapiter(&self) -> PyResult<CopyMapKeysIterator> {
-        let leaked_ref = self.inner_shared(py).leak_immutable()?;
+        let leaked_ref = self.inner_shared(py).leak_immutable();
         CopyMapKeysIterator::from_inner(
             py,
             unsafe { leaked_ref.map(py, |o| o.copy_map.iter()) },
@@ -445,7 +445,7 @@
     }
 
     def copymapitemsiter(&self) -> PyResult<CopyMapItemsIterator> {
-        let leaked_ref = self.inner_shared(py).leak_immutable()?;
+        let leaked_ref = self.inner_shared(py).leak_immutable();
         CopyMapItemsIterator::from_inner(
             py,
             unsafe { leaked_ref.map(py, |o| o.copy_map.iter()) },
@@ -483,14 +483,14 @@
 
 py_shared_iterator!(
     DirstateMapKeysIterator,
-    PyLeakedRef<StateMapIter<'static>>,
+    PyLeaked<StateMapIter<'static>>,
     DirstateMap::translate_key,
     Option<PyBytes>
 );
 
 py_shared_iterator!(
     DirstateMapItemsIterator,
-    PyLeakedRef<StateMapIter<'static>>,
+    PyLeaked<StateMapIter<'static>>,
     DirstateMap::translate_key_value,
     Option<(PyBytes, PyObject)>
 );
--- a/rust/hg-cpython/src/dirstate/status.rs	Wed Nov 20 19:07:02 2019 +0100
+++ b/rust/hg-cpython/src/dirstate/status.rs	Fri Nov 22 21:42:04 2019 +0900
@@ -6,7 +6,8 @@
 // GNU General Public License version 2 or any later version.
 
 //! Bindings for the `hg::status` module provided by the
-//! `hg-core` crate. From Python, this will be seen as `rustext.dirstate.status`.
+//! `hg-core` crate. From Python, this will be seen as
+//! `rustext.dirstate.status`.
 //!
 
 use crate::dirstate::DirstateMap;
@@ -17,8 +18,8 @@
 };
 use hg::utils::files::get_path_from_bytes;
 
+use hg::status;
 use hg::utils::hg_path::HgPath;
-use hg::{status, utils::hg_path::HgPathBuf};
 
 /// This will be useless once trait impls for collection are added to `PyBytes`
 /// upstream.
@@ -43,7 +44,6 @@
     py: Python,
     dmap: DirstateMap,
     root_dir: PyObject,
-    files: PyList,
     list_clean: bool,
     last_normal_time: i64,
     check_exec: bool,
@@ -54,21 +54,9 @@
     let dmap: DirstateMap = dmap.to_py_object(py);
     let dmap = dmap.get_inner(py);
 
-    let files: PyResult<Vec<HgPathBuf>> = files
-        .iter(py)
-        .map(|f| Ok(HgPathBuf::from_bytes(f.extract::<PyBytes>(py)?.data(py))))
-        .collect();
-    let files = files?;
-
-    let (lookup, status_res) = status(
-        &dmap,
-        &root_dir,
-        &files,
-        list_clean,
-        last_normal_time,
-        check_exec,
-    )
-    .map_err(|e| PyErr::new::<ValueError, _>(py, e.to_string()))?;
+    let (lookup, status_res) =
+        status(&dmap, &root_dir, list_clean, last_normal_time, check_exec)
+            .map_err(|e| PyErr::new::<ValueError, _>(py, e.to_string()))?;
 
     let modified = collect_pybytes_list(py, status_res.modified.as_ref());
     let added = collect_pybytes_list(py, status_res.added.as_ref());
--- a/rust/hg-cpython/src/filepatterns.rs	Wed Nov 20 19:07:02 2019 +0100
+++ b/rust/hg-cpython/src/filepatterns.rs	Fri Nov 22 21:42:04 2019 +0900
@@ -13,8 +13,7 @@
 //!
 use crate::exceptions::{PatternError, PatternFileError};
 use cpython::{
-    PyBytes, PyDict, PyModule, PyObject, PyResult, PyString, PyTuple, Python,
-    ToPyObject,
+    PyBytes, PyDict, PyModule, PyObject, PyResult, PyTuple, Python, ToPyObject,
 };
 use hg::{
     build_single_regex, read_pattern_file, utils::files::get_path_from_bytes,
@@ -66,12 +65,12 @@
 fn warnings_to_py_bytes(
     py: Python,
     warnings: &[(PathBuf, Vec<u8>)],
-) -> Vec<(PyString, PyBytes)> {
+) -> Vec<(PyBytes, PyBytes)> {
     warnings
         .iter()
         .map(|(path, syn)| {
             (
-                PyString::new(py, &path.to_string_lossy()),
+                PyBytes::new(py, &path.to_string_lossy().as_bytes()),
                 PyBytes::new(py, syn),
             )
         })
--- a/rust/hg-cpython/src/ref_sharing.rs	Wed Nov 20 19:07:02 2019 +0100
+++ b/rust/hg-cpython/src/ref_sharing.rs	Fri Nov 22 21:42:04 2019 +0900
@@ -23,53 +23,56 @@
 //! Macros for use in the `hg-cpython` bridge library.
 
 use crate::exceptions::AlreadyBorrowed;
-use cpython::{PyClone, PyObject, PyResult, Python};
-use std::cell::{Cell, Ref, RefCell, RefMut};
+use cpython::{exc, PyClone, PyErr, PyObject, PyResult, Python};
+use std::cell::{Ref, RefCell, RefMut};
+use std::ops::{Deref, DerefMut};
+use std::sync::atomic::{AtomicUsize, Ordering};
 
 /// Manages the shared state between Python and Rust
+///
+/// `PySharedState` is owned by `PySharedRefCell`, and is shared across its
+/// derived references. The consistency of these references are guaranteed
+/// as follows:
+///
+/// - The immutability of `py_class!` object fields. Any mutation of
+///   `PySharedRefCell` is allowed only through its `borrow_mut()`.
+/// - The `py: Python<'_>` token, which makes sure that any data access is
+///   synchronized by the GIL.
+/// - The underlying `RefCell`, which prevents `PySharedRefCell` data from
+///   being directly borrowed or leaked while it is mutably borrowed.
+/// - The `borrow_count`, which is the number of references borrowed from
+///   `PyLeaked`. Just like `RefCell`, mutation is prohibited while `PyLeaked`
+///   is borrowed.
+/// - The `generation` counter, which increments on `borrow_mut()`. `PyLeaked`
+///   reference is valid only if the `current_generation()` equals to the
+///   `generation` at the time of `leak_immutable()`.
 #[derive(Debug, Default)]
 struct PySharedState {
-    leak_count: Cell<usize>,
-    mutably_borrowed: Cell<bool>,
+    // The counter variable could be Cell<usize> since any operation on
+    // PySharedState is synchronized by the GIL, but being "atomic" makes
+    // PySharedState inherently Sync. The ordering requirement doesn't
+    // matter thanks to the GIL.
+    borrow_count: AtomicUsize,
+    generation: AtomicUsize,
 }
 
-// &PySharedState can be Send because any access to inner cells is
-// synchronized by the GIL.
-unsafe impl Sync for PySharedState {}
-
 impl PySharedState {
     fn borrow_mut<'a, T>(
         &'a self,
         py: Python<'a>,
         pyrefmut: RefMut<'a, T>,
-    ) -> PyResult<PyRefMut<'a, T>> {
-        if self.mutably_borrowed.get() {
-            return Err(AlreadyBorrowed::new(
-                py,
-                "Cannot borrow mutably while there exists another \
-                 mutable reference in a Python object",
-            ));
-        }
-        match self.leak_count.get() {
+    ) -> PyResult<RefMut<'a, T>> {
+        match self.current_borrow_count(py) {
             0 => {
-                self.mutably_borrowed.replace(true);
-                Ok(PyRefMut::new(py, pyrefmut, self))
+                // Note that this wraps around to the same value if mutably
+                // borrowed more than usize::MAX times, which wouldn't happen
+                // in practice.
+                self.generation.fetch_add(1, Ordering::Relaxed);
+                Ok(pyrefmut)
             }
-            // TODO
-            // For now, this works differently than Python references
-            // in the case of iterators.
-            // Python does not complain when the data an iterator
-            // points to is modified if the iterator is never used
-            // afterwards.
-            // Here, we are stricter than this by refusing to give a
-            // mutable reference if it is already borrowed.
-            // While the additional safety might be argued for, it
-            // breaks valid programming patterns in Python and we need
-            // to fix this issue down the line.
             _ => Err(AlreadyBorrowed::new(
                 py,
-                "Cannot borrow mutably while there are \
-                 immutable references in Python objects",
+                "Cannot borrow mutably while immutably borrowed",
             )),
         }
     }
@@ -84,41 +87,60 @@
     /// extended. Do not call this function directly.
     unsafe fn leak_immutable<T>(
         &self,
-        py: Python,
-        data: &PySharedRefCell<T>,
-    ) -> PyResult<(&'static T, &'static PySharedState)> {
-        if self.mutably_borrowed.get() {
-            return Err(AlreadyBorrowed::new(
-                py,
-                "Cannot borrow immutably while there is a \
-                 mutable reference in Python objects",
-            ));
-        }
-        // TODO: it's weird that self is data.py_shared_state. Maybe we
-        // can move stuff to PySharedRefCell?
-        let ptr = data.as_ptr();
-        let state_ptr: *const PySharedState = &data.py_shared_state;
-        self.leak_count.replace(self.leak_count.get() + 1);
-        Ok((&*ptr, &*state_ptr))
+        _py: Python,
+        data: Ref<T>,
+    ) -> (&'static T, &'static PySharedState) {
+        let ptr: *const T = &*data;
+        let state_ptr: *const PySharedState = self;
+        (&*ptr, &*state_ptr)
+    }
+
+    fn current_borrow_count(&self, _py: Python) -> usize {
+        self.borrow_count.load(Ordering::Relaxed)
+    }
+
+    fn increase_borrow_count(&self, _py: Python) {
+        // Note that this wraps around if there are more than usize::MAX
+        // borrowed references, which shouldn't happen due to memory limit.
+        self.borrow_count.fetch_add(1, Ordering::Relaxed);
+    }
+
+    fn decrease_borrow_count(&self, _py: Python) {
+        let prev_count = self.borrow_count.fetch_sub(1, Ordering::Relaxed);
+        assert!(prev_count > 0);
     }
 
-    /// # Safety
-    ///
-    /// It's up to you to make sure the reference is about to be deleted
-    /// when updating the leak count.
-    fn decrease_leak_count(&self, _py: Python, mutable: bool) {
-        if mutable {
-            assert_eq!(self.leak_count.get(), 0);
-            assert!(self.mutably_borrowed.get());
-            self.mutably_borrowed.replace(false);
-        } else {
-            let count = self.leak_count.get();
-            assert!(count > 0);
-            self.leak_count.replace(count - 1);
+    fn current_generation(&self, _py: Python) -> usize {
+        self.generation.load(Ordering::Relaxed)
+    }
+}
+
+/// Helper to keep the borrow count updated while the shared object is
+/// immutably borrowed without using the `RefCell` interface.
+struct BorrowPyShared<'a> {
+    py: Python<'a>,
+    py_shared_state: &'a PySharedState,
+}
+
+impl<'a> BorrowPyShared<'a> {
+    fn new(
+        py: Python<'a>,
+        py_shared_state: &'a PySharedState,
+    ) -> BorrowPyShared<'a> {
+        py_shared_state.increase_borrow_count(py);
+        BorrowPyShared {
+            py,
+            py_shared_state,
         }
     }
 }
 
+impl Drop for BorrowPyShared<'_> {
+    fn drop(&mut self) {
+        self.py_shared_state.decrease_borrow_count(self.py);
+    }
+}
+
 /// `RefCell` wrapper to be safely used in conjunction with `PySharedState`.
 ///
 /// This object can be stored in a `py_class!` object as a data field. Any
@@ -144,15 +166,11 @@
         self.inner.borrow()
     }
 
-    fn as_ptr(&self) -> *mut T {
-        self.inner.as_ptr()
-    }
-
     // TODO: maybe this should be named as try_borrow_mut(), and use
     // inner.try_borrow_mut(). The current implementation panics if
     // self.inner has been borrowed, but returns error if py_shared_state
     // refuses to borrow.
-    fn borrow_mut<'a>(&'a self, py: Python<'a>) -> PyResult<PyRefMut<'a, T>> {
+    fn borrow_mut<'a>(&'a self, py: Python<'a>) -> PyResult<RefMut<'a, T>> {
         self.py_shared_state.borrow_mut(py, self.inner.borrow_mut())
     }
 }
@@ -181,78 +199,31 @@
         self.data.borrow(self.py)
     }
 
-    pub fn borrow_mut(&self) -> PyResult<PyRefMut<'a, T>> {
+    pub fn borrow_mut(&self) -> PyResult<RefMut<'a, T>> {
         self.data.borrow_mut(self.py)
     }
 
     /// Returns a leaked reference.
-    pub fn leak_immutable(&self) -> PyResult<PyLeakedRef<&'static T>> {
+    ///
+    /// # Panics
+    ///
+    /// Panics if this is mutably borrowed.
+    pub fn leak_immutable(&self) -> PyLeaked<&'static T> {
         let state = &self.data.py_shared_state;
+        // make sure self.data isn't mutably borrowed; otherwise the
+        // generation number can't be trusted.
+        let data_ref = self.borrow();
         unsafe {
             let (static_ref, static_state_ref) =
-                state.leak_immutable(self.py, self.data)?;
-            Ok(PyLeakedRef::new(
-                self.py,
-                self.owner,
-                static_ref,
-                static_state_ref,
-            ))
+                state.leak_immutable(self.py, data_ref);
+            PyLeaked::new(self.py, self.owner, static_ref, static_state_ref)
         }
     }
 }
 
-/// Holds a mutable reference to data shared between Python and Rust.
-pub struct PyRefMut<'a, T> {
-    py: Python<'a>,
-    inner: RefMut<'a, T>,
-    py_shared_state: &'a PySharedState,
-}
-
-impl<'a, T> PyRefMut<'a, T> {
-    // Must be constructed by PySharedState after checking its leak_count.
-    // Otherwise, drop() would incorrectly update the state.
-    fn new(
-        py: Python<'a>,
-        inner: RefMut<'a, T>,
-        py_shared_state: &'a PySharedState,
-    ) -> Self {
-        Self {
-            py,
-            inner,
-            py_shared_state,
-        }
-    }
-}
-
-impl<'a, T> std::ops::Deref for PyRefMut<'a, T> {
-    type Target = RefMut<'a, T>;
-
-    fn deref(&self) -> &Self::Target {
-        &self.inner
-    }
-}
-impl<'a, T> std::ops::DerefMut for PyRefMut<'a, T> {
-    fn deref_mut(&mut self) -> &mut Self::Target {
-        &mut self.inner
-    }
-}
-
-impl<'a, T> Drop for PyRefMut<'a, T> {
-    fn drop(&mut self) {
-        self.py_shared_state.decrease_leak_count(self.py, true);
-    }
-}
-
 /// Allows a `py_class!` generated struct to share references to one of its
 /// data members with Python.
 ///
-/// # Warning
-///
-/// TODO allow Python container types: for now, integration with the garbage
-///     collector does not extend to Rust structs holding references to Python
-///     objects. Should the need surface, `__traverse__` and `__clear__` will
-///     need to be written as per the `rust-cpython` docs on GC integration.
-///
 /// # Parameters
 ///
 /// * `$name` is the same identifier used in for `py_class!` macro call.
@@ -307,16 +278,22 @@
 }
 
 /// Manage immutable references to `PyObject` leaked into Python iterators.
-pub struct PyLeakedRef<T> {
+///
+/// This reference will be invalidated once the original value is mutably
+/// borrowed.
+pub struct PyLeaked<T> {
     inner: PyObject,
     data: Option<T>,
     py_shared_state: &'static PySharedState,
+    /// Generation counter of data `T` captured when PyLeaked is created.
+    generation: usize,
 }
 
-// DO NOT implement Deref for PyLeakedRef<T>! Dereferencing PyLeakedRef
-// without taking Python GIL wouldn't be safe.
+// DO NOT implement Deref for PyLeaked<T>! Dereferencing PyLeaked
+// without taking Python GIL wouldn't be safe. Also, the underling reference
+// is invalid if generation != py_shared_state.generation.
 
-impl<T> PyLeakedRef<T> {
+impl<T> PyLeaked<T> {
     /// # Safety
     ///
     /// The `py_shared_state` must be owned by the `inner` Python object.
@@ -330,20 +307,39 @@
             inner: inner.clone_ref(py),
             data: Some(data),
             py_shared_state,
+            generation: py_shared_state.current_generation(py),
         }
     }
 
-    /// Returns an immutable reference to the inner value.
-    pub fn get_ref<'a>(&'a self, _py: Python<'a>) -> &'a T {
-        self.data.as_ref().unwrap()
+    /// Immutably borrows the wrapped value.
+    ///
+    /// Borrowing fails if the underlying reference has been invalidated.
+    pub fn try_borrow<'a>(
+        &'a self,
+        py: Python<'a>,
+    ) -> PyResult<PyLeakedRef<'a, T>> {
+        self.validate_generation(py)?;
+        Ok(PyLeakedRef {
+            _borrow: BorrowPyShared::new(py, self.py_shared_state),
+            data: self.data.as_ref().unwrap(),
+        })
     }
 
-    /// Returns a mutable reference to the inner value.
+    /// Mutably borrows the wrapped value.
+    ///
+    /// Borrowing fails if the underlying reference has been invalidated.
     ///
     /// Typically `T` is an iterator. If `T` is an immutable reference,
     /// `get_mut()` is useless since the inner value can't be mutated.
-    pub fn get_mut<'a>(&'a mut self, _py: Python<'a>) -> &'a mut T {
-        self.data.as_mut().unwrap()
+    pub fn try_borrow_mut<'a>(
+        &'a mut self,
+        py: Python<'a>,
+    ) -> PyResult<PyLeakedRefMut<'a, T>> {
+        self.validate_generation(py)?;
+        Ok(PyLeakedRefMut {
+            _borrow: BorrowPyShared::new(py, self.py_shared_state),
+            data: self.data.as_mut().unwrap(),
+        })
     }
 
     /// Converts the inner value by the given function.
@@ -351,41 +347,85 @@
     /// Typically `T` is a static reference to a container, and `U` is an
     /// iterator of that container.
     ///
+    /// # Panics
+    ///
+    /// Panics if the underlying reference has been invalidated.
+    ///
+    /// This is typically called immediately after the `PyLeaked` is obtained.
+    /// In which case, the reference must be valid and no panic would occur.
+    ///
     /// # Safety
     ///
     /// The lifetime of the object passed in to the function `f` is cheated.
     /// It's typically a static reference, but is valid only while the
-    /// corresponding `PyLeakedRef` is alive. Do not copy it out of the
+    /// corresponding `PyLeaked` is alive. Do not copy it out of the
     /// function call.
     pub unsafe fn map<U>(
         mut self,
         py: Python,
         f: impl FnOnce(T) -> U,
-    ) -> PyLeakedRef<U> {
+    ) -> PyLeaked<U> {
+        // Needs to test the generation value to make sure self.data reference
+        // is still intact.
+        self.validate_generation(py)
+            .expect("map() over invalidated leaked reference");
+
         // f() could make the self.data outlive. That's why map() is unsafe.
         // In order to make this function safe, maybe we'll need a way to
         // temporarily restrict the lifetime of self.data and translate the
         // returned object back to Something<'static>.
         let new_data = f(self.data.take().unwrap());
-        PyLeakedRef {
+        PyLeaked {
             inner: self.inner.clone_ref(py),
             data: Some(new_data),
             py_shared_state: self.py_shared_state,
+            generation: self.generation,
+        }
+    }
+
+    fn validate_generation(&self, py: Python) -> PyResult<()> {
+        if self.py_shared_state.current_generation(py) == self.generation {
+            Ok(())
+        } else {
+            Err(PyErr::new::<exc::RuntimeError, _>(
+                py,
+                "Cannot access to leaked reference after mutation",
+            ))
         }
     }
 }
 
-impl<T> Drop for PyLeakedRef<T> {
-    fn drop(&mut self) {
-        // py_shared_state should be alive since we do have
-        // a Python reference to the owner object. Taking GIL makes
-        // sure that the state is only accessed by this thread.
-        let gil = Python::acquire_gil();
-        let py = gil.python();
-        if self.data.is_none() {
-            return; // moved to another PyLeakedRef
-        }
-        self.py_shared_state.decrease_leak_count(py, false);
+/// Immutably borrowed reference to a leaked value.
+pub struct PyLeakedRef<'a, T> {
+    _borrow: BorrowPyShared<'a>,
+    data: &'a T,
+}
+
+impl<T> Deref for PyLeakedRef<'_, T> {
+    type Target = T;
+
+    fn deref(&self) -> &T {
+        self.data
+    }
+}
+
+/// Mutably borrowed reference to a leaked value.
+pub struct PyLeakedRefMut<'a, T> {
+    _borrow: BorrowPyShared<'a>,
+    data: &'a mut T,
+}
+
+impl<T> Deref for PyLeakedRefMut<'_, T> {
+    type Target = T;
+
+    fn deref(&self) -> &T {
+        self.data
+    }
+}
+
+impl<T> DerefMut for PyLeakedRefMut<'_, T> {
+    fn deref_mut(&mut self) -> &mut T {
+        self.data
     }
 }
 
@@ -414,7 +454,7 @@
 ///     data inner: PySharedRefCell<MyStruct>;
 ///
 ///     def __iter__(&self) -> PyResult<MyTypeItemsIterator> {
-///         let leaked_ref = self.inner_shared(py).leak_immutable()?;
+///         let leaked_ref = self.inner_shared(py).leak_immutable();
 ///         MyTypeItemsIterator::from_inner(
 ///             py,
 ///             unsafe { leaked_ref.map(py, |o| o.iter()) },
@@ -439,7 +479,7 @@
 ///
 /// py_shared_iterator!(
 ///     MyTypeItemsIterator,
-///     PyLeakedRef<HashMap<'static, Vec<u8>, Vec<u8>>>,
+///     PyLeaked<HashMap<'static, Vec<u8>, Vec<u8>>>,
 ///     MyType::translate_key_value,
 ///     Option<(PyBytes, PyBytes)>
 /// );
@@ -452,23 +492,14 @@
         $success_type: ty
     ) => {
         py_class!(pub class $name |py| {
-            data inner: RefCell<Option<$leaked>>;
+            data inner: RefCell<$leaked>;
 
             def __next__(&self) -> PyResult<$success_type> {
-                let mut inner_opt = self.inner(py).borrow_mut();
-                if let Some(leaked) = inner_opt.as_mut() {
-                    match leaked.get_mut(py).next() {
-                        None => {
-                            // replace Some(inner) by None, drop $leaked
-                            inner_opt.take();
-                            Ok(None)
-                        }
-                        Some(res) => {
-                            $success_func(py, res)
-                        }
-                    }
-                } else {
-                    Ok(None)
+                let mut leaked = self.inner(py).borrow_mut();
+                let mut iter = leaked.try_borrow_mut(py)?;
+                match iter.next() {
+                    None => Ok(None),
+                    Some(res) => $success_func(py, res),
                 }
             }
 
@@ -484,7 +515,7 @@
             ) -> PyResult<Self> {
                 Self::create_instance(
                     py,
-                    RefCell::new(Some(leaked)),
+                    RefCell::new(leaked),
                 )
             }
         }
@@ -512,12 +543,94 @@
     }
 
     #[test]
-    fn test_borrow_mut_while_leaked() {
+    fn test_leaked_borrow() {
+        let (gil, owner) = prepare_env();
+        let py = gil.python();
+        let leaked = owner.string_shared(py).leak_immutable();
+        let leaked_ref = leaked.try_borrow(py).unwrap();
+        assert_eq!(*leaked_ref, "new");
+    }
+
+    #[test]
+    fn test_leaked_borrow_mut() {
+        let (gil, owner) = prepare_env();
+        let py = gil.python();
+        let leaked = owner.string_shared(py).leak_immutable();
+        let mut leaked_iter = unsafe { leaked.map(py, |s| s.chars()) };
+        let mut leaked_ref = leaked_iter.try_borrow_mut(py).unwrap();
+        assert_eq!(leaked_ref.next(), Some('n'));
+        assert_eq!(leaked_ref.next(), Some('e'));
+        assert_eq!(leaked_ref.next(), Some('w'));
+        assert_eq!(leaked_ref.next(), None);
+    }
+
+    #[test]
+    fn test_leaked_borrow_after_mut() {
+        let (gil, owner) = prepare_env();
+        let py = gil.python();
+        let leaked = owner.string_shared(py).leak_immutable();
+        owner.string_shared(py).borrow_mut().unwrap().clear();
+        assert!(leaked.try_borrow(py).is_err());
+    }
+
+    #[test]
+    fn test_leaked_borrow_mut_after_mut() {
+        let (gil, owner) = prepare_env();
+        let py = gil.python();
+        let leaked = owner.string_shared(py).leak_immutable();
+        let mut leaked_iter = unsafe { leaked.map(py, |s| s.chars()) };
+        owner.string_shared(py).borrow_mut().unwrap().clear();
+        assert!(leaked_iter.try_borrow_mut(py).is_err());
+    }
+
+    #[test]
+    #[should_panic(expected = "map() over invalidated leaked reference")]
+    fn test_leaked_map_after_mut() {
+        let (gil, owner) = prepare_env();
+        let py = gil.python();
+        let leaked = owner.string_shared(py).leak_immutable();
+        owner.string_shared(py).borrow_mut().unwrap().clear();
+        let _leaked_iter = unsafe { leaked.map(py, |s| s.chars()) };
+    }
+
+    #[test]
+    fn test_borrow_mut_while_leaked_ref() {
         let (gil, owner) = prepare_env();
         let py = gil.python();
         assert!(owner.string_shared(py).borrow_mut().is_ok());
-        let _leaked = owner.string_shared(py).leak_immutable().unwrap();
-        // TODO: will be allowed
-        assert!(owner.string_shared(py).borrow_mut().is_err());
+        let leaked = owner.string_shared(py).leak_immutable();
+        {
+            let _leaked_ref = leaked.try_borrow(py).unwrap();
+            assert!(owner.string_shared(py).borrow_mut().is_err());
+            {
+                let _leaked_ref2 = leaked.try_borrow(py).unwrap();
+                assert!(owner.string_shared(py).borrow_mut().is_err());
+            }
+            assert!(owner.string_shared(py).borrow_mut().is_err());
+        }
+        assert!(owner.string_shared(py).borrow_mut().is_ok());
+    }
+
+    #[test]
+    fn test_borrow_mut_while_leaked_ref_mut() {
+        let (gil, owner) = prepare_env();
+        let py = gil.python();
+        assert!(owner.string_shared(py).borrow_mut().is_ok());
+        let leaked = owner.string_shared(py).leak_immutable();
+        let mut leaked_iter = unsafe { leaked.map(py, |s| s.chars()) };
+        {
+            let _leaked_ref = leaked_iter.try_borrow_mut(py).unwrap();
+            assert!(owner.string_shared(py).borrow_mut().is_err());
+        }
+        assert!(owner.string_shared(py).borrow_mut().is_ok());
+    }
+
+    #[test]
+    #[should_panic(expected = "mutably borrowed")]
+    fn test_leak_while_borrow_mut() {
+        let (gil, owner) = prepare_env();
+        let py = gil.python();
+        let _mut_ref = owner.string_shared(py).borrow_mut();
+        owner.string_shared(py).leak_immutable();
     }
 }
--- a/setup.py	Wed Nov 20 19:07:02 2019 +0100
+++ b/setup.py	Fri Nov 22 21:42:04 2019 +0900
@@ -713,36 +713,40 @@
             self.compiler.compiler_so = self.compiler.compiler  # no -mdll
             self.compiler.dll_libraries = []  # no -lmsrvc90
 
-        # Different Python installs can have different Python library
-        # names. e.g. the official CPython distribution uses pythonXY.dll
-        # and MinGW uses libpythonX.Y.dll.
-        _kernel32 = ctypes.windll.kernel32
-        _kernel32.GetModuleFileNameA.argtypes = [
-            ctypes.c_void_p,
-            ctypes.c_void_p,
-            ctypes.c_ulong,
-        ]
-        _kernel32.GetModuleFileNameA.restype = ctypes.c_ulong
-        size = 1000
-        buf = ctypes.create_string_buffer(size + 1)
-        filelen = _kernel32.GetModuleFileNameA(
-            sys.dllhandle, ctypes.byref(buf), size
-        )
+        pythonlib = None
 
-        if filelen > 0 and filelen != size:
-            dllbasename = os.path.basename(buf.value)
-            if not dllbasename.lower().endswith(b'.dll'):
-                raise SystemExit(
-                    'Python DLL does not end with .dll: %s' % dllbasename
-                )
-            pythonlib = dllbasename[:-4]
-        else:
+        if getattr(sys, 'dllhandle', None):
+            # Different Python installs can have different Python library
+            # names. e.g. the official CPython distribution uses pythonXY.dll
+            # and MinGW uses libpythonX.Y.dll.
+            _kernel32 = ctypes.windll.kernel32
+            _kernel32.GetModuleFileNameA.argtypes = [
+                ctypes.c_void_p,
+                ctypes.c_void_p,
+                ctypes.c_ulong,
+            ]
+            _kernel32.GetModuleFileNameA.restype = ctypes.c_ulong
+            size = 1000
+            buf = ctypes.create_string_buffer(size + 1)
+            filelen = _kernel32.GetModuleFileNameA(
+                sys.dllhandle, ctypes.byref(buf), size
+            )
+
+            if filelen > 0 and filelen != size:
+                dllbasename = os.path.basename(buf.value)
+                if not dllbasename.lower().endswith(b'.dll'):
+                    raise SystemExit(
+                        'Python DLL does not end with .dll: %s' % dllbasename
+                    )
+                pythonlib = dllbasename[:-4]
+
+        if not pythonlib:
             log.warn(
-                'could not determine Python DLL filename; ' 'assuming pythonXY'
+                'could not determine Python DLL filename; assuming pythonXY'
             )
 
             hv = sys.hexversion
-            pythonlib = 'python%d%d' % (hv >> 24, (hv >> 16) & 0xFF)
+            pythonlib = b'python%d%d' % (hv >> 24, (hv >> 16) & 0xFF)
 
         log.info('using %s as Python library name' % pythonlib)
         with open('mercurial/hgpythonlib.h', 'wb') as f:
@@ -1191,6 +1195,8 @@
     'mercurial',
     'mercurial.cext',
     'mercurial.cffi',
+    'mercurial.helptext',
+    'mercurial.helptext.internals',
     'mercurial.hgweb',
     'mercurial.interfaces',
     'mercurial.pure',
@@ -1535,11 +1541,11 @@
 packagedata = {
     'mercurial': [
         'locale/*/LC_MESSAGES/hg.mo',
-        'help/*.txt',
-        'help/internals/*.txt',
         'default.d/*.rc',
         'dummycert.pem',
-    ]
+    ],
+    'mercurial.helptext': ['*.txt',],
+    'mercurial.helptext.internals': ['*.txt',],
 }
 
 
--- a/tests/f	Wed Nov 20 19:07:02 2019 +0100
+++ b/tests/f	Fri Nov 22 21:42:04 2019 +0900
@@ -34,14 +34,18 @@
 import sys
 
 # Python 3 adapters
-ispy3 = (sys.version_info[0] >= 3)
+ispy3 = sys.version_info[0] >= 3
 if ispy3:
+
     def iterbytes(s):
         for i in range(len(s)):
-            yield s[i:i + 1]
+            yield s[i : i + 1]
+
+
 else:
     iterbytes = iter
 
+
 def visit(opts, filenames, outfile):
     """Process filenames in the way specified in opts, writing output to
     outfile."""
@@ -88,21 +92,26 @@
             if opts.newer:
                 # mtime might be in whole seconds so newer file might be same
                 if stat.st_mtime >= os.stat(opts.newer).st_mtime:
-                    facts.append(b'newer than %s' % opts.newer.encode(
-                        'utf8', 'replace'))
+                    facts.append(
+                        b'newer than %s' % opts.newer.encode('utf8', 'replace')
+                    )
                 else:
-                    facts.append(b'older than %s' % opts.newer.encode(
-                        'utf8', 'replace'))
+                    facts.append(
+                        b'older than %s' % opts.newer.encode('utf8', 'replace')
+                    )
         if opts.md5 and content is not None:
             h = hashlib.md5(content)
-            facts.append(b'md5=%s' % binascii.hexlify(h.digest())[:opts.bytes])
+            facts.append(b'md5=%s' % binascii.hexlify(h.digest())[: opts.bytes])
         if opts.sha1 and content is not None:
             h = hashlib.sha1(content)
-            facts.append(b'sha1=%s' % binascii.hexlify(h.digest())[:opts.bytes])
+            facts.append(
+                b'sha1=%s' % binascii.hexlify(h.digest())[: opts.bytes]
+            )
         if opts.sha256 and content is not None:
             h = hashlib.sha256(content)
-            facts.append(b'sha256=%s' %
-                         binascii.hexlify(h.digest())[:opts.bytes])
+            facts.append(
+                b'sha256=%s' % binascii.hexlify(h.digest())[: opts.bytes]
+            )
         if isstdin:
             outfile.write(b', '.join(facts) + b'\n')
         elif facts:
@@ -114,21 +123,25 @@
             if not islink:
                 if opts.lines:
                     if opts.lines >= 0:
-                        chunk = b''.join(chunk.splitlines(True)[:opts.lines])
+                        chunk = b''.join(chunk.splitlines(True)[: opts.lines])
                     else:
-                        chunk = b''.join(chunk.splitlines(True)[opts.lines:])
+                        chunk = b''.join(chunk.splitlines(True)[opts.lines :])
                 if opts.bytes:
                     if opts.bytes >= 0:
-                        chunk = chunk[:opts.bytes]
+                        chunk = chunk[: opts.bytes]
                     else:
-                        chunk = chunk[opts.bytes:]
+                        chunk = chunk[opts.bytes :]
             if opts.hexdump:
                 for i in range(0, len(chunk), 16):
-                    s = chunk[i:i + 16]
-                    outfile.write(b'%04x: %-47s |%s|\n' %
-                                  (i, b' '.join(
-                                      b'%02x' % ord(c) for c in iterbytes(s)),
-                                   re.sub(b'[^ -~]', b'.', s)))
+                    s = chunk[i : i + 16]
+                    outfile.write(
+                        b'%04x: %-47s |%s|\n'
+                        % (
+                            i,
+                            b' '.join(b'%02x' % ord(c) for c in iterbytes(s)),
+                            re.sub(b'[^ -~]', b'.', s),
+                        )
+                    )
             if opts.dump:
                 if not quiet:
                     outfile.write(b'>>>\n')
@@ -142,36 +155,60 @@
             assert not isstdin
             visit(opts, dirfiles, outfile)
 
+
 if __name__ == "__main__":
     parser = optparse.OptionParser("%prog [options] [filenames]")
-    parser.add_option("-t", "--type", action="store_true",
-                      help="show file type (file or directory)")
-    parser.add_option("-m", "--mode", action="store_true",
-                      help="show file mode")
-    parser.add_option("-l", "--links", action="store_true",
-                      help="show number of links")
-    parser.add_option("-s", "--size", action="store_true",
-                      help="show size of file")
-    parser.add_option("-n", "--newer", action="store",
-                      help="check if file is newer (or same)")
-    parser.add_option("-r", "--recurse", action="store_true",
-                      help="recurse into directories")
-    parser.add_option("-S", "--sha1", action="store_true",
-                      help="show sha1 hash of the content")
-    parser.add_option("", "--sha256", action="store_true",
-                      help="show sha256 hash of the content")
-    parser.add_option("-M", "--md5", action="store_true",
-                      help="show md5 hash of the content")
-    parser.add_option("-D", "--dump", action="store_true",
-                      help="dump file content")
-    parser.add_option("-H", "--hexdump", action="store_true",
-                      help="hexdump file content")
-    parser.add_option("-B", "--bytes", type="int",
-                      help="number of characters to dump")
-    parser.add_option("-L", "--lines", type="int",
-                      help="number of lines to dump")
-    parser.add_option("-q", "--quiet", action="store_true",
-                      help="no default output")
+    parser.add_option(
+        "-t",
+        "--type",
+        action="store_true",
+        help="show file type (file or directory)",
+    )
+    parser.add_option(
+        "-m", "--mode", action="store_true", help="show file mode"
+    )
+    parser.add_option(
+        "-l", "--links", action="store_true", help="show number of links"
+    )
+    parser.add_option(
+        "-s", "--size", action="store_true", help="show size of file"
+    )
+    parser.add_option(
+        "-n", "--newer", action="store", help="check if file is newer (or same)"
+    )
+    parser.add_option(
+        "-r", "--recurse", action="store_true", help="recurse into directories"
+    )
+    parser.add_option(
+        "-S",
+        "--sha1",
+        action="store_true",
+        help="show sha1 hash of the content",
+    )
+    parser.add_option(
+        "",
+        "--sha256",
+        action="store_true",
+        help="show sha256 hash of the content",
+    )
+    parser.add_option(
+        "-M", "--md5", action="store_true", help="show md5 hash of the content"
+    )
+    parser.add_option(
+        "-D", "--dump", action="store_true", help="dump file content"
+    )
+    parser.add_option(
+        "-H", "--hexdump", action="store_true", help="hexdump file content"
+    )
+    parser.add_option(
+        "-B", "--bytes", type="int", help="number of characters to dump"
+    )
+    parser.add_option(
+        "-L", "--lines", type="int", help="number of lines to dump"
+    )
+    parser.add_option(
+        "-q", "--quiet", action="store_true", help="no default output"
+    )
     (opts, filenames) = parser.parse_args(sys.argv[1:])
     if not filenames:
         filenames = ['-']
--- a/tests/fakedirstatewritetime.py	Wed Nov 20 19:07:02 2019 +0100
+++ b/tests/fakedirstatewritetime.py	Fri Nov 22 21:42:04 2019 +0900
@@ -30,8 +30,8 @@
     b'fakedirstatewritetime', b'fakenow', default=None,
 )
 
-parsers = policy.importmod(r'parsers')
-rustmod = policy.importrust(r'parsers')
+parsers = policy.importmod('parsers')
+rustmod = policy.importrust('parsers')
 
 
 def pack_dirstate(fakenow, orig, dmap, copymap, pl, now):
--- a/tests/hghave	Wed Nov 20 19:07:02 2019 +0100
+++ b/tests/hghave	Fri Nov 22 21:42:04 2019 +0900
@@ -13,11 +13,13 @@
 
 checks = hghave.checks
 
+
 def list_features():
     for name, feature in sorted(checks.items()):
         desc = feature[1]
         print(name + ':', desc)
 
+
 def test_features():
     failed = 0
     for name, feature in checks.items():
@@ -29,11 +31,15 @@
             failed += 1
     return failed
 
+
 parser = optparse.OptionParser("%prog [options] [features]")
-parser.add_option("--test-features", action="store_true",
-                  help="test available features")
-parser.add_option("--list-features", action="store_true",
-                  help="list available features")
+parser.add_option(
+    "--test-features", action="store_true", help="test available features"
+)
+parser.add_option(
+    "--list-features", action="store_true", help="list available features"
+)
+
 
 def _loadaddon():
     if 'TESTDIR' in os.environ:
@@ -49,13 +55,16 @@
     sys.path.insert(0, path)
     try:
         import hghaveaddon
+
         assert hghaveaddon  # silence pyflakes
     except BaseException as inst:
-        sys.stderr.write('failed to import hghaveaddon.py from %r: %s\n'
-                         % (path, inst))
+        sys.stderr.write(
+            'failed to import hghaveaddon.py from %r: %s\n' % (path, inst)
+        )
         sys.exit(2)
     sys.path.pop(0)
 
+
 if __name__ == '__main__':
     options, args = parser.parse_args()
     _loadaddon()
--- a/tests/hghave.py	Wed Nov 20 19:07:02 2019 +0100
+++ b/tests/hghave.py	Fri Nov 22 21:42:04 2019 +0900
@@ -431,7 +431,8 @@
 
 @check("symlink", "symbolic links")
 def has_symlink():
-    if getattr(os, "symlink", None) is None:
+    # mercurial.windows.checklink() is a hard 'no' at the moment
+    if os.name == 'nt' or getattr(os, "symlink", None) is None:
         return False
     name = tempfile.mktemp(dir='.', prefix=tempprefix)
     try:
@@ -672,6 +673,13 @@
         return False
 
 
+@check("xz", "xz compression utility")
+def has_xz():
+    # When Windows invokes a subprocess in shell mode, it uses `cmd.exe`, which
+    # only knows `where`, not `which`.  So invoke MSYS shell explicitly.
+    return matchoutput("sh -c 'test -x \"`which xz`\"'", b'')
+
+
 @check("msys", "Windows with MSYS")
 def has_msys():
     return os.getenv('MSYSTEM')
@@ -999,3 +1007,11 @@
     version = matchoutput(blackcmd, version_regex)
     sv = distutils.version.StrictVersion
     return version and sv(_strpath(version.group(1))) >= sv('19.10b0')
+
+
+@check('pytype', 'the pytype type checker')
+def has_pytype():
+    pytypecmd = 'pytype --version'
+    version = matchoutput(pytypecmd, b'[0-9a-b.]+')
+    sv = distutils.version.StrictVersion
+    return version and sv(_strpath(version.group(0))) >= sv('2019.10.17')
--- a/tests/pullext.py	Wed Nov 20 19:07:02 2019 +0100
+++ b/tests/pullext.py	Fri Nov 22 21:42:04 2019 +0900
@@ -18,12 +18,12 @@
 
 
 def clonecommand(orig, ui, repo, *args, **kwargs):
-    if kwargs.get(r'include') or kwargs.get(r'exclude'):
-        kwargs[r'narrow'] = True
+    if kwargs.get('include') or kwargs.get('exclude'):
+        kwargs['narrow'] = True
 
-    if kwargs.get(r'depth'):
+    if kwargs.get('depth'):
         try:
-            kwargs[r'depth'] = int(kwargs[r'depth'])
+            kwargs['depth'] = int(kwargs['depth'])
         except ValueError:
             raise error.Abort(_('--depth must be an integer'))
 
--- a/tests/run-tests.py	Wed Nov 20 19:07:02 2019 +0100
+++ b/tests/run-tests.py	Fri Nov 22 21:42:04 2019 +0900
@@ -2246,27 +2246,31 @@
         # os.times module computes the user time and system time spent by
         # child's processes along with real elapsed time taken by a process.
         # This module has one limitation. It can only work for Linux user
-        # and not for Windows.
-        test.started = os.times()
+        # and not for Windows. Hence why we fall back to another function
+        # for wall time calculations.
+        test.started_times = os.times()
+        # TODO use a monotonic clock once support for Python 2.7 is dropped.
+        test.started_time = time.time()
         if self._firststarttime is None:  # thread racy but irrelevant
-            self._firststarttime = test.started[4]
+            self._firststarttime = test.started_time
 
     def stopTest(self, test, interrupted=False):
         super(TestResult, self).stopTest(test)
 
-        test.stopped = os.times()
-
-        starttime = test.started
-        endtime = test.stopped
+        test.stopped_times = os.times()
+        stopped_time = time.time()
+
+        starttime = test.started_times
+        endtime = test.stopped_times
         origin = self._firststarttime
         self.times.append(
             (
                 test.name,
                 endtime[2] - starttime[2],  # user space CPU time
                 endtime[3] - starttime[3],  # sys  space CPU time
-                endtime[4] - starttime[4],  # real time
-                starttime[4] - origin,  # start date in run context
-                endtime[4] - origin,  # end date in run context
+                stopped_time - test.started_time,  # real time
+                test.started_time - origin,  # start date in run context
+                stopped_time - origin,  # end date in run context
             )
         )
 
--- a/tests/simplestorerepo.py	Wed Nov 20 19:07:02 2019 +0100
+++ b/tests/simplestorerepo.py	Fri Nov 22 21:42:04 2019 +0900
@@ -48,9 +48,9 @@
 # extensions which SHIP WITH MERCURIAL. Non-mainline extensions should
 # be specifying the version(s) of Mercurial they are tested with, or
 # leave the attribute unspecified.
-testedwith = 'ships-with-hg-core'
+testedwith = b'ships-with-hg-core'
 
-REQUIREMENT = 'testonly-simplestore'
+REQUIREMENT = b'testonly-simplestore'
 
 
 def validatenode(node):
@@ -204,7 +204,7 @@
             if entry[b'node'] == node:
                 return rev
 
-        raise error.ProgrammingError('this should not occur')
+        raise error.ProgrammingError(b'this should not occur')
 
     def node(self, rev):
         validaterev(rev)
--- a/tests/test-archive.t	Wed Nov 20 19:07:02 2019 +0100
+++ b/tests/test-archive.t	Fri Nov 22 21:42:04 2019 +0900
@@ -574,8 +574,8 @@
 
 #if py3
   $ hg archive ../archive.txz
-  $ xz -l ../archive.txz | head -n1
-  Strms  Blocks   Compressed Uncompressed  Ratio  Check   Filename
+  $ which xz >/dev/null && xz -l ../archive.txz | head -n1 || true
+  Strms  Blocks   Compressed Uncompressed  Ratio  Check   Filename (xz !)
   $ rm -f ../archive.txz
 #else
   $ hg archive ../archive.txz
--- a/tests/test-bookmarks.t	Wed Nov 20 19:07:02 2019 +0100
+++ b/tests/test-bookmarks.t	Fri Nov 22 21:42:04 2019 +0900
@@ -608,6 +608,27 @@
   $ hg bookmark --inactive Z
   $ hg bookmark Z
 
+deactivate current 'Z', but also add 'Y'
+
+  $ hg bookmark -d Y
+  $ hg bookmark --inactive Z Y
+  $ hg bookmark -l
+     X2                        1:925d80f479bb
+     Y                         2:db815d6d32e6
+     Z                         2:db815d6d32e6
+     x  y                      2:db815d6d32e6
+  $ hg bookmark Z
+
+bookmark wdir to activate it (issue6218)
+
+  $ hg bookmark -d Z
+  $ hg bookmark -r 'wdir()' Z
+  $ hg bookmark -l
+     X2                        1:925d80f479bb
+     Y                         2:db815d6d32e6
+   * Z                         2:db815d6d32e6
+     x  y                      2:db815d6d32e6
+
 test clone
 
   $ hg bookmark -r 2 -i @
--- a/tests/test-byteify-strings.t	Wed Nov 20 19:07:02 2019 +0100
+++ b/tests/test-byteify-strings.t	Fri Nov 22 21:42:04 2019 +0900
@@ -1,7 +1,7 @@
 #require py37
 
   $ byteify_strings () {
-  >   $PYTHON "$TESTDIR/../contrib/byteify-strings.py" "$@"
+  >   "$PYTHON" "$TESTDIR/../contrib/byteify-strings.py" "$@"
   > }
 
 Test version
--- a/tests/test-censor.t	Wed Nov 20 19:07:02 2019 +0100
+++ b/tests/test-censor.t	Fri Nov 22 21:42:04 2019 +0900
@@ -442,6 +442,33 @@
   checking files
   checked 14 changesets with 15 changes to 2 files
 
+Grepping only warns, doesn't error out
+
+  $ cd ../rpull
+  $ hg grep 'Normal file'
+  bystander:Normal file v2
+  $ hg grep nothing
+  target:Re-sanitized; nothing to see here
+  $ hg grep --diff 'Normal file'
+  cannot search in censored file: target:7
+  cannot search in censored file: target:10
+  cannot search in censored file: target:12
+  bystander:6:-:Normal file v2
+  cannot search in censored file: target:1
+  cannot search in censored file: target:2
+  cannot search in censored file: target:3
+  bystander:2:-:Normal file here
+  bystander:2:+:Normal file v2
+  bystander:0:+:Normal file here
+  $ hg grep --diff nothing
+  cannot search in censored file: target:7
+  cannot search in censored file: target:10
+  cannot search in censored file: target:12
+  target:13:+:Re-sanitized; nothing to see here
+  cannot search in censored file: target:1
+  cannot search in censored file: target:2
+  cannot search in censored file: target:3
+
 Censored nodes can be imported on top of censored nodes, consecutively
 
   $ hg init ../rimport
--- a/tests/test-check-code.t	Wed Nov 20 19:07:02 2019 +0100
+++ b/tests/test-check-code.t	Fri Nov 22 21:42:04 2019 +0900
@@ -21,13 +21,12 @@
   Skipping contrib/automation/hgautomation/try_server.py it has no-che?k-code (glob)
   Skipping contrib/automation/hgautomation/windows.py it has no-che?k-code (glob)
   Skipping contrib/automation/hgautomation/winrm.py it has no-che?k-code (glob)
+  Skipping contrib/packaging/hgpackaging/cli.py it has no-che?k-code (glob)
   Skipping contrib/packaging/hgpackaging/downloads.py it has no-che?k-code (glob)
   Skipping contrib/packaging/hgpackaging/inno.py it has no-che?k-code (glob)
   Skipping contrib/packaging/hgpackaging/py2exe.py it has no-che?k-code (glob)
   Skipping contrib/packaging/hgpackaging/util.py it has no-che?k-code (glob)
   Skipping contrib/packaging/hgpackaging/wix.py it has no-che?k-code (glob)
-  Skipping contrib/packaging/inno/build.py it has no-che?k-code (glob)
-  Skipping contrib/packaging/wix/build.py it has no-che?k-code (glob)
   Skipping i18n/polib.py it has no-che?k-code (glob)
   Skipping mercurial/statprof.py it has no-che?k-code (glob)
   Skipping tests/badserverext.py it has no-che?k-code (glob)
@@ -84,3 +83,9 @@
 Keep python3 tests sorted:
   $ sort < contrib/python3-whitelist > $TESTTMP/py3sorted
   $ cmp contrib/python3-whitelist $TESTTMP/py3sorted || echo 'Please sort passing tests!'
+
+Keep Windows line endings in check
+
+  $ hg files 'set:eol(dos)'
+  contrib/win32/hg.bat
+  contrib/win32/mercurial.ini
--- a/tests/test-check-config.t	Wed Nov 20 19:07:02 2019 +0100
+++ b/tests/test-check-config.t	Fri Nov 22 21:42:04 2019 +0900
@@ -24,7 +24,7 @@
   > EOF
 
   $ cat > files << EOF
-  > mercurial/help/config.txt
+  > mercurial/helptext/config.txt
   > $TESTTMP/testfile.py
   > EOF
 
--- a/tests/test-check-format.t	Wed Nov 20 19:07:02 2019 +0100
+++ b/tests/test-check-format.t	Fri Nov 22 21:42:04 2019 +0900
@@ -1,5 +1,5 @@
 #require black
 
   $ cd $RUNTESTDIR/..
-  $ black --config=black.toml --check --diff `hg files 'set:**.py - mercurial/thirdparty/** - "contrib/python-zstandard/**"'`
+  $ black --config=black.toml --check --diff `hg files 'set:(**.py + grep("^#!.*python")) - mercurial/thirdparty/** - "contrib/python-zstandard/**"'`
 
--- a/tests/test-check-py3-compat.t	Wed Nov 20 19:07:02 2019 +0100
+++ b/tests/test-check-py3-compat.t	Fri Nov 22 21:42:04 2019 +0900
@@ -8,6 +8,7 @@
   > -X contrib/automation/ \
   > -X contrib/packaging/hgpackaging/ \
   > -X contrib/packaging/inno/ \
+  > -X contrib/packaging/packaging.py \
   > -X contrib/packaging/wix/ \
   > -X hgdemandimport/demandimportpy2.py \
   > -X mercurial/thirdparty/cbor \
--- a/tests/test-check-pyflakes.t	Wed Nov 20 19:07:02 2019 +0100
+++ b/tests/test-check-pyflakes.t	Fri Nov 22 21:42:04 2019 +0900
@@ -24,4 +24,5 @@
   contrib/perf.py:*: undefined name 'xrange' (glob) (?)
   mercurial/hgweb/server.py:*: undefined name 'reload' (glob) (?)
   mercurial/util.py:*: undefined name 'file' (glob) (?)
+  mercurial/encoding.py:*: undefined name 'localstr' (glob) (?)
   
--- a/tests/test-check-shbang.t	Wed Nov 20 19:07:02 2019 +0100
+++ b/tests/test-check-shbang.t	Fri Nov 22 21:42:04 2019 +0900
@@ -11,6 +11,7 @@
 In tests, enforce $PYTHON and *not* /usr/bin/env python or similar:
   $ testrepohg files 'set:grep(r"#!.*?python") and **/*.t' \
   > -X tests/test-check-execute.t \
+  > -X tests/test-check-format.t \
   > -X tests/test-check-module-imports.t \
   > -X tests/test-check-pyflakes.t \
   > -X tests/test-check-shbang.t
--- a/tests/test-completion.t	Wed Nov 20 19:07:02 2019 +0100
+++ b/tests/test-completion.t	Fri Nov 22 21:42:04 2019 +0900
@@ -328,7 +328,7 @@
   heads: rev, topo, active, closed, style, template
   help: extension, command, keyword, system
   identify: rev, num, id, branch, tags, bookmarks, ssh, remotecmd, insecure, template
-  import: strip, base, edit, force, no-commit, bypass, partial, exact, prefix, import-branch, message, logfile, date, user, similarity
+  import: strip, base, secret, edit, force, no-commit, bypass, partial, exact, prefix, import-branch, message, logfile, date, user, similarity
   incoming: force, newest-first, bundle, rev, bookmarks, branch, patch, git, limit, no-merges, stat, graph, style, template, ssh, remotecmd, insecure, subrepos
   init: ssh, remotecmd, insecure
   locate: rev, print0, fullpath, include, exclude
--- a/tests/test-contrib-perf.t	Wed Nov 20 19:07:02 2019 +0100
+++ b/tests/test-contrib-perf.t	Fri Nov 22 21:42:04 2019 +0900
@@ -248,6 +248,7 @@
   $ hg perfrevset 'all()'
   $ hg perfstartup
   $ hg perfstatus
+  $ hg perfstatus --dirstate
   $ hg perftags
   $ hg perftemplating
   $ hg perfvolatilesets
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/test-dirs.py	Fri Nov 22 21:42:04 2019 +0900
@@ -0,0 +1,27 @@
+from __future__ import absolute_import
+
+import unittest
+
+import silenttestrunner
+
+from mercurial import pathutil
+
+
+class dirstests(unittest.TestCase):
+    def testdirs(self):
+        for case, want in [
+            (b'a/a/a', [b'a', b'a/a', b'']),
+            (b'alpha/beta/gamma', [b'', b'alpha', b'alpha/beta']),
+        ]:
+            d = pathutil.dirs({})
+            d.addpath(case)
+            self.assertEqual(sorted(d), sorted(want))
+
+    def testinvalid(self):
+        with self.assertRaises(ValueError):
+            d = pathutil.dirs({})
+            d.addpath(b'a//b')
+
+
+if __name__ == '__main__':
+    silenttestrunner.main(__name__)
--- a/tests/test-docker-packaging.t	Wed Nov 20 19:07:02 2019 +0100
+++ b/tests/test-docker-packaging.t	Fri Nov 22 21:42:04 2019 +0900
@@ -10,7 +10,7 @@
   $ export OUTPUTDIR
 
   $ cd "$TESTDIR"/..
-  $ make docker-debian-jessie > $OUTPUTDIR/build.log 2>&1
+  $ make docker-debian-buster > $OUTPUTDIR/build.log 2>&1
   $ cd $OUTPUTDIR
   $ ls *.deb
   mercurial-common_*.deb (glob)
--- a/tests/test-fileset.t	Wed Nov 20 19:07:02 2019 +0100
+++ b/tests/test-fileset.t	Fri Nov 22 21:42:04 2019 +0900
@@ -853,7 +853,7 @@
   M b2
   A 1k
   A 2k
-  A b2link (no-windows !)
+  A b2link (symlink !)
   A bin
   A c1
   A con.xml (no-windows !)
@@ -864,7 +864,7 @@
   M b2
   A 1k
   A 2k
-  A b2link (no-windows !)
+  A b2link (symlink !)
   A bin
   A c1
   A con.xml (no-windows !)
@@ -997,7 +997,7 @@
   A .hgsubstate
   A 1k
   A 2k
-  A b2link (no-windows !)
+  A b2link (symlink !)
   A bin
   A c1
   A con.xml (no-windows !)
@@ -1006,7 +1006,7 @@
   .hgsubstate
   1k
   2k
-  b2link (no-windows !)
+  b2link (symlink !)
   bin
   c1
   con.xml (no-windows !)
--- a/tests/test-hgweb-json.t	Wed Nov 20 19:07:02 2019 +0100
+++ b/tests/test-hgweb-json.t	Fri Nov 22 21:42:04 2019 +0900
@@ -782,6 +782,13 @@
       0
     ],
     "desc": "merge test-branch into default",
+    "diff": [],
+    "files": [
+      {
+        "file": "foo-new",
+        "status": "modified"
+      }
+    ],
     "node": "cc725e08502a79dd1eda913760fbe06ed7a9abc7",
     "parents": [
       "ceed296fe500c3fac9541e31dad860cb49c89e45",
@@ -807,6 +814,68 @@
       0
     ],
     "desc": "move foo",
+    "diff": [
+      {
+        "blockno": 1,
+        "lines": [
+          {
+            "l": "--- a/foo\tThu Jan 01 00:00:00 1970 +0000\n",
+            "n": 1,
+            "t": "-"
+          },
+          {
+            "l": "+++ /dev/null\tThu Jan 01 00:00:00 1970 +0000\n",
+            "n": 2,
+            "t": "+"
+          },
+          {
+            "l": "@@ -1,1 +0,0 @@\n",
+            "n": 3,
+            "t": "@"
+          },
+          {
+            "l": "-bar\n",
+            "n": 4,
+            "t": "-"
+          }
+        ]
+      },
+      {
+        "blockno": 2,
+        "lines": [
+          {
+            "l": "--- /dev/null\tThu Jan 01 00:00:00 1970 +0000\n",
+            "n": 1,
+            "t": "-"
+          },
+          {
+            "l": "+++ b/foo-new\tThu Jan 01 00:00:00 1970 +0000\n",
+            "n": 2,
+            "t": "+"
+          },
+          {
+            "l": "@@ -0,0 +1,1 @@\n",
+            "n": 3,
+            "t": "@"
+          },
+          {
+            "l": "+bar\n",
+            "n": 4,
+            "t": "+"
+          }
+        ]
+      }
+    ],
+    "files": [
+      {
+        "file": "foo",
+        "status": "removed"
+      },
+      {
+        "file": "foo-new",
+        "status": "added"
+      }
+    ],
     "node": "78896eb0e102174ce9278438a95e12543e4367a7",
     "parents": [
       "8d7c456572acf3557e8ed8a07286b10c408bcec5"
@@ -833,6 +902,44 @@
       0
     ],
     "desc": "modify da/foo",
+    "diff": [
+      {
+        "blockno": 1,
+        "lines": [
+          {
+            "l": "--- a/da/foo\tThu Jan 01 00:00:00 1970 +0000\n",
+            "n": 1,
+            "t": "-"
+          },
+          {
+            "l": "+++ b/da/foo\tThu Jan 01 00:00:00 1970 +0000\n",
+            "n": 2,
+            "t": "+"
+          },
+          {
+            "l": "@@ -1,1 +1,1 @@\n",
+            "n": 3,
+            "t": "@"
+          },
+          {
+            "l": "-foo\n",
+            "n": 4,
+            "t": "-"
+          },
+          {
+            "l": "+bar\n",
+            "n": 5,
+            "t": "+"
+          }
+        ]
+      }
+    ],
+    "files": [
+      {
+        "file": "da/foo",
+        "status": "modified"
+      }
+    ],
     "node": "8d7c456572acf3557e8ed8a07286b10c408bcec5",
     "parents": [
       "f8bbb9024b10f93cdbb8d940337398291d40dea8"
@@ -855,6 +962,44 @@
       0
     ],
     "desc": "create test branch",
+    "diff": [
+      {
+        "blockno": 1,
+        "lines": [
+          {
+            "l": "--- a/foo\tThu Jan 01 00:00:00 1970 +0000\n",
+            "n": 1,
+            "t": "-"
+          },
+          {
+            "l": "+++ b/foo\tThu Jan 01 00:00:00 1970 +0000\n",
+            "n": 2,
+            "t": "+"
+          },
+          {
+            "l": "@@ -1,1 +1,1 @@\n",
+            "n": 3,
+            "t": "@"
+          },
+          {
+            "l": "-foo\n",
+            "n": 4,
+            "t": "-"
+          },
+          {
+            "l": "+branch\n",
+            "n": 5,
+            "t": "+"
+          }
+        ]
+      }
+    ],
+    "files": [
+      {
+        "file": "foo",
+        "status": "modified"
+      }
+    ],
     "node": "6ab967a8ab3489227a83f80e920faa039a71819f",
     "parents": [
       "06e557f3edf66faa1ccaba5dd8c203c21cc79f1e"
--- a/tests/test-import.t	Wed Nov 20 19:07:02 2019 +0100
+++ b/tests/test-import.t	Fri Nov 22 21:42:04 2019 +0900
@@ -435,6 +435,49 @@
   date:        Thu Jan 01 00:00:00 1970 +0000
   summary:     second change
   
+  $ hg --cwd b phase tip
+  1: draft
+  $ rm -r b
+
+
+hg import --secret
+
+  $ hg clone -r0 a b -q
+  $ hg --cwd b import --no-commit --secret ../exported-tip.patch
+  abort: cannot use --no-commit with --secret
+  [255]
+  $ hg --cwd b import --secret ../exported-tip.patch
+  applying ../exported-tip.patch
+  $ hg --cwd b diff -c . --nodates
+  diff -r 80971e65b431 -r 1d4bd90af0e4 a
+  --- a/a
+  +++ b/a
+  @@ -1,1 +1,2 @@
+   line 1
+  +line 2
+  $ hg --cwd b phase
+  1: secret
+  $ hg --cwd b --config extensions.strip= strip 1 --no-backup --quiet
+  $ HGEDITOR=cat hg --cwd b import --secret --edit ../exported-tip.patch
+  applying ../exported-tip.patch
+  second change
+  
+  
+  HG: Enter commit message.  Lines beginning with 'HG:' are removed.
+  HG: Leave message empty to abort commit.
+  HG: --
+  HG: user: someone
+  HG: branch 'default'
+  HG: changed a
+  $ hg --cwd b diff -c . --nodates
+  diff -r 80971e65b431 -r 1d4bd90af0e4 a
+  --- a/a
+  +++ b/a
+  @@ -1,1 +1,2 @@
+   line 1
+  +line 2
+  $ hg --cwd b phase
+  1: secret
   $ rm -r b
 
 
--- a/tests/test-install.t	Wed Nov 20 19:07:02 2019 +0100
+++ b/tests/test-install.t	Fri Nov 22 21:42:04 2019 +0900
@@ -162,80 +162,6 @@
     "fsmonitor-watchman": "false",
     "fsmonitor-watchman-error": "warning: Watchman unavailable: watchman exited with code 1",
 
-
-#if test-repo
-  $ . "$TESTDIR/helpers-testrepo.sh"
-
-  $ cat >> wixxml.py << EOF
-  > import os
-  > import subprocess
-  > import sys
-  > import xml.etree.ElementTree as ET
-  > from mercurial import pycompat
-  > 
-  > # MSYS mangles the path if it expands $TESTDIR
-  > testdir = os.environ['TESTDIR']
-  > ns = {'wix' : 'http://schemas.microsoft.com/wix/2006/wi'}
-  > 
-  > def directory(node, relpath):
-  >     '''generator of files in the xml node, rooted at relpath'''
-  >     dirs = node.findall('./{%(wix)s}Directory' % ns)
-  > 
-  >     for d in dirs:
-  >         for subfile in directory(d, relpath + d.attrib['Name'] + '/'):
-  >             yield subfile
-  > 
-  >     files = node.findall('./{%(wix)s}Component/{%(wix)s}File' % ns)
-  > 
-  >     for f in files:
-  >         yield pycompat.sysbytes(relpath + f.attrib['Name'])
-  > 
-  > def hgdirectory(relpath):
-  >     '''generator of tracked files, rooted at relpath'''
-  >     hgdir = "%s/../mercurial" % (testdir)
-  >     args = ['hg', '--cwd', hgdir, 'files', relpath]
-  >     proc = subprocess.Popen(args, stdout=subprocess.PIPE,
-  >                             stderr=subprocess.PIPE)
-  >     output = proc.communicate()[0]
-  > 
-  >     for line in output.splitlines():
-  >         if os.name == 'nt':
-  >             yield line.replace(pycompat.sysbytes(os.sep), b'/')
-  >         else:
-  >             yield line
-  > 
-  > tracked = [f for f in hgdirectory(sys.argv[1])]
-  > 
-  > xml = ET.parse("%s/../contrib/packaging/wix/%s.wxs" % (testdir, sys.argv[1]))
-  > root = xml.getroot()
-  > dir = root.find('.//{%(wix)s}DirectoryRef' % ns)
-  > 
-  > installed = [f for f in directory(dir, '')]
-  > 
-  > print('Not installed:')
-  > for f in sorted(set(tracked) - set(installed)):
-  >     print('  %s' % pycompat.sysstr(f))
-  > 
-  > print('Not tracked:')
-  > for f in sorted(set(installed) - set(tracked)):
-  >     print('  %s' % pycompat.sysstr(f))
-  > EOF
-
-  $ ( testrepohgenv; "$PYTHON" wixxml.py help )
-  Not installed:
-    help/common.txt
-    help/hg-ssh.8.txt
-    help/hg.1.txt
-    help/hgignore.5.txt
-    help/hgrc.5.txt
-  Not tracked:
-
-  $ ( testrepohgenv; "$PYTHON" wixxml.py templates )
-  Not installed:
-  Not tracked:
-
-#endif
-
 Verify that Mercurial is installable with pip. Note that this MUST be
 the last test in this file, because we do some nasty things to the
 shell environment in order to make the virtualenv work reliably.
@@ -255,6 +181,7 @@
 Note: we use this weird path to run pip and hg to avoid platform differences,
 since it's bin on most platforms but Scripts on Windows.
   $ ./installenv/*/pip install --no-index $TESTDIR/.. >> pip.log
+    Failed building wheel for mercurial (?)
   $ ./installenv/*/hg debuginstall || cat pip.log
   checking encoding (ascii)...
   checking Python executable (*) (glob)
--- a/tests/test-log-linerange.t	Wed Nov 20 19:07:02 2019 +0100
+++ b/tests/test-log-linerange.t	Fri Nov 22 21:42:04 2019 +0900
@@ -868,6 +868,112 @@
   +4
   
 
+Copies.
+
+  $ hg copy baz bbaz
+  $ sed 's/6/6+/' bbaz > bbaz.new
+  $ mv bbaz.new bbaz
+  $ hg commit -m 'cp baz bbaz; 6-6+'
+  $ hg diff -c .
+  diff --git a/dir/baz b/dir/bbaz
+  copy from dir/baz
+  copy to dir/bbaz
+  --- a/dir/baz
+  +++ b/dir/bbaz
+  @@ -7,7 +7,7 @@
+   3+
+   4
+   5
+  -6
+  +6+
+   7
+   8
+   9
+  $ hg log --copies -f -L bbaz,10:11 -p
+  changeset:   10:91a3d3b6c546
+  tag:         tip
+  user:        test
+  date:        Thu Jan 01 00:00:00 1970 +0000
+  summary:     cp baz bbaz; 6-6+
+  
+  diff --git a/dir/baz b/dir/bbaz
+  copy from dir/baz
+  copy to dir/bbaz
+  --- a/dir/baz
+  +++ b/dir/bbaz
+  @@ -7,7 +7,7 @@
+   3+
+   4
+   5
+  -6
+  +6+
+   7
+   8
+   9
+  
+  changeset:   3:730a61fbaecf
+  user:        test
+  date:        Thu Jan 01 00:00:00 1970 +0000
+  summary:     to 11
+  
+  diff --git a/foo b/foo
+  --- a/foo
+  +++ b/foo
+  @@ -6,3 +6,10 @@
+   2+
+   3
+   4
+  +5
+  +6
+  +7
+  +8
+  +9
+  +10
+  +11
+  
+  $ hg log -f -L bbaz,10:11 -p
+  changeset:   10:91a3d3b6c546
+  tag:         tip
+  user:        test
+  date:        Thu Jan 01 00:00:00 1970 +0000
+  summary:     cp baz bbaz; 6-6+
+  
+  diff --git a/dir/baz b/dir/bbaz
+  copy from dir/baz
+  copy to dir/bbaz
+  --- a/dir/baz
+  +++ b/dir/bbaz
+  @@ -7,7 +7,7 @@
+   3+
+   4
+   5
+  -6
+  +6+
+   7
+   8
+   9
+  
+  changeset:   3:730a61fbaecf
+  user:        test
+  date:        Thu Jan 01 00:00:00 1970 +0000
+  summary:     to 11
+  
+  diff --git a/foo b/foo
+  --- a/foo
+  +++ b/foo
+  @@ -6,3 +6,10 @@
+   2+
+   3
+   4
+  +5
+  +6
+  +7
+  +8
+  +9
+  +10
+  +11
+  
+
 Binary files work but without diff hunks filtering.
 (Checking w/ and w/o diff.git option.)
 
@@ -875,7 +981,7 @@
   $ hg add binary
   $ hg ci -m 'add a binary file' --quiet
   $ hg log -f -L binary,1:2 -p
-  changeset:   10:c96381c229df
+  changeset:   11:dc865b608edf
   tag:         tip
   user:        test
   date:        Thu Jan 01 00:00:00 1970 +0000
@@ -890,13 +996,13 @@
   
   
   $ hg log -f -L binary,1:2 -p --config diff.git=false
-  changeset:   10:c96381c229df
+  changeset:   11:dc865b608edf
   tag:         tip
   user:        test
   date:        Thu Jan 01 00:00:00 1970 +0000
   summary:     add a binary file
   
-  diff -r 6af29c3a778f -r c96381c229df dir/binary
+  diff -r 91a3d3b6c546 -r dc865b608edf dir/binary
   Binary file dir/binary has changed
   
 
--- a/tests/test-parseindex2.py	Wed Nov 20 19:07:02 2019 +0100
+++ b/tests/test-parseindex2.py	Fri Nov 22 21:42:04 2019 +0900
@@ -20,7 +20,7 @@
     pycompat,
 )
 
-parsers = policy.importmod(r'parsers')
+parsers = policy.importmod('parsers')
 
 # original python implementation
 def gettype(q):
--- a/tests/test-rebase-inmemory.t	Wed Nov 20 19:07:02 2019 +0100
+++ b/tests/test-rebase-inmemory.t	Fri Nov 22 21:42:04 2019 +0900
@@ -249,6 +249,10 @@
   rebasing 8:e147e6e3c490 "c/subdir/file.txt" (tip)
   abort: error: 'c/subdir/file.txt' conflicts with file 'c' in 3.
   [255]
+FIXME: shouldn't need this, but when we hit path conflicts in dryrun mode, we
+don't clean up rebasestate.
+  $ hg rebase --abort
+  rebase aborted
   $ hg rebase -r 3 -d . -n
   starting dry-run rebase; repository will not be changed
   rebasing 3:844a7de3e617 "c"
@@ -504,9 +508,8 @@
   $ hg resolve -l
   U e
   $ hg rebase -s 2 -d 7
-  rebasing 2:177f92b77385 "c"
-  abort: outstanding merge conflicts
-  (use 'hg resolve' to resolve)
+  abort: outstanding uncommitted merge
+  (use 'hg commit' or 'hg merge --abort')
   [255]
   $ hg resolve -l
   U e
@@ -862,3 +865,58 @@
   warning: conflicts while merging foo! (edit, then use 'hg resolve --mark')
   unresolved conflicts (see hg resolve, then hg rebase --continue)
   [1]
+
+  $ cd $TESTTMP
+
+Test rebasing when we're in the middle of a rebase already
+  $ hg init test_issue6214
+  $ cd test_issue6214
+  $ echo r0 > r0
+  $ hg ci -qAm 'r0'
+  $ echo hi > foo
+  $ hg ci -qAm 'hi from foo'
+  $ hg co -q '.^'
+  $ echo bye > foo
+  $ hg ci -qAm 'bye from foo'
+  $ hg co -q '.^'
+  $ echo unrelated > some_other_file
+  $ hg ci -qAm 'some unrelated changes'
+  $ hg log -G -T'{rev}: {desc}\n{files%"{file}\n"}'
+  @  3: some unrelated changes
+  |  some_other_file
+  | o  2: bye from foo
+  |/   foo
+  | o  1: hi from foo
+  |/   foo
+  o  0: r0
+     r0
+  $ hg rebase -r 2 -d 1 -t:merge3
+  rebasing 2:b4d249fbf8dd "bye from foo"
+  merging foo
+  hit merge conflicts; re-running rebase without in-memory merge
+  rebasing 2:b4d249fbf8dd "bye from foo"
+  merging foo
+  warning: conflicts while merging foo! (edit, then use 'hg resolve --mark')
+  unresolved conflicts (see hg resolve, then hg rebase --continue)
+  [1]
+  $ hg rebase -r 3 -d 1 -t:merge3
+  abort: rebase in progress
+  (use 'hg rebase --continue' or 'hg rebase --abort')
+  [255]
+  $ hg resolve --list
+  U foo
+  $ hg resolve --all --re-merge -t:other
+  (no more unresolved files)
+  continue: hg rebase --continue
+  $ hg rebase --continue
+  rebasing 2:b4d249fbf8dd "bye from foo"
+  saved backup bundle to $TESTTMP/test_issue6214/.hg/strip-backup/b4d249fbf8dd-299ec25c-rebase.hg
+  $ hg log -G -T'{rev}: {desc}\n{files%"{file}\n"}'
+  o  3: bye from foo
+  |  foo
+  | @  2: some unrelated changes
+  | |  some_other_file
+  o |  1: hi from foo
+  |/   foo
+  o  0: r0
+     r0
--- a/tests/test-shelve.t	Wed Nov 20 19:07:02 2019 +0100
+++ b/tests/test-shelve.t	Fri Nov 22 21:42:04 2019 +0900
@@ -951,6 +951,16 @@
   +++ b/jungle
   @@ -0,0 +1,1 @@
   +babar
+
+Test shelve --delete
+
+  $ hg shelve --list
+  default         (*s ago)    changes to: create conflict (glob)
+  $ hg shelve --delete doesnotexist
+  abort: shelved change 'doesnotexist' not found
+  [255]
+  $ hg shelve --delete default
+
   $ cd ..
 
 Test visibility of in-memory changes inside transaction to external hook
--- a/tests/test-template-functions.t	Wed Nov 20 19:07:02 2019 +0100
+++ b/tests/test-template-functions.t	Fri Nov 22 21:42:04 2019 +0900
@@ -1504,6 +1504,21 @@
   
   >> other 3
 
+Test indent with empty first line
+
+  $ hg version -T "{indent('', '>> ')}\n"
+  
+
+  $ hg version -T "{indent('
+  > second', '>> ')}\n"
+  
+  >> second
+
+  $ hg version -T "{indent('
+  > second', '>> ', ' > ')}\n"
+  
+  >> second
+
 Test with non-strings like dates
 
   $ hg log -T "{indent(date, '   ')}\n" -r 2:3 -R a
--- a/tests/test-wsgirequest.py	Wed Nov 20 19:07:02 2019 +0100
+++ b/tests/test-wsgirequest.py	Fri Nov 22 21:42:04 2019 +0900
@@ -6,17 +6,17 @@
 from mercurial import error
 
 DEFAULT_ENV = {
-    r'REQUEST_METHOD': r'GET',
-    r'SERVER_NAME': r'testserver',
-    r'SERVER_PORT': r'80',
-    r'SERVER_PROTOCOL': r'http',
-    r'wsgi.version': (1, 0),
-    r'wsgi.url_scheme': r'http',
-    r'wsgi.input': None,
-    r'wsgi.errors': None,
-    r'wsgi.multithread': False,
-    r'wsgi.multiprocess': True,
-    r'wsgi.run_once': False,
+    'REQUEST_METHOD': 'GET',
+    'SERVER_NAME': 'testserver',
+    'SERVER_PORT': '80',
+    'SERVER_PROTOCOL': 'http',
+    'wsgi.version': (1, 0),
+    'wsgi.url_scheme': 'http',
+    'wsgi.input': None,
+    'wsgi.errors': None,
+    'wsgi.multithread': False,
+    'wsgi.multiprocess': True,
+    'wsgi.run_once': False,
 }
 
 
@@ -49,7 +49,7 @@
         self.assertEqual(len(r.headers), 0)
 
     def testcustomport(self):
-        r = parse(DEFAULT_ENV, extra={r'SERVER_PORT': r'8000',})
+        r = parse(DEFAULT_ENV, extra={'SERVER_PORT': '8000',})
 
         self.assertEqual(r.url, b'http://testserver:8000')
         self.assertEqual(r.baseurl, b'http://testserver:8000')
@@ -58,7 +58,7 @@
 
         r = parse(
             DEFAULT_ENV,
-            extra={r'SERVER_PORT': r'4000', r'wsgi.url_scheme': r'https',},
+            extra={'SERVER_PORT': '4000', 'wsgi.url_scheme': 'https',},
         )
 
         self.assertEqual(r.url, b'https://testserver:4000')
@@ -67,7 +67,7 @@
         self.assertEqual(r.advertisedbaseurl, b'https://testserver:4000')
 
     def testhttphost(self):
-        r = parse(DEFAULT_ENV, extra={r'HTTP_HOST': r'altserver',})
+        r = parse(DEFAULT_ENV, extra={'HTTP_HOST': 'altserver',})
 
         self.assertEqual(r.url, b'http://altserver')
         self.assertEqual(r.baseurl, b'http://altserver')
@@ -75,7 +75,7 @@
         self.assertEqual(r.advertisedbaseurl, b'http://testserver')
 
     def testscriptname(self):
-        r = parse(DEFAULT_ENV, extra={r'SCRIPT_NAME': r'',})
+        r = parse(DEFAULT_ENV, extra={'SCRIPT_NAME': '',})
 
         self.assertEqual(r.url, b'http://testserver')
         self.assertEqual(r.baseurl, b'http://testserver')
@@ -85,7 +85,7 @@
         self.assertEqual(r.dispatchparts, [])
         self.assertIsNone(r.dispatchpath)
 
-        r = parse(DEFAULT_ENV, extra={r'SCRIPT_NAME': r'/script',})
+        r = parse(DEFAULT_ENV, extra={'SCRIPT_NAME': '/script',})
 
         self.assertEqual(r.url, b'http://testserver/script')
         self.assertEqual(r.baseurl, b'http://testserver')
@@ -95,7 +95,7 @@
         self.assertEqual(r.dispatchparts, [])
         self.assertIsNone(r.dispatchpath)
 
-        r = parse(DEFAULT_ENV, extra={r'SCRIPT_NAME': r'/multiple words',})
+        r = parse(DEFAULT_ENV, extra={'SCRIPT_NAME': '/multiple words',})
 
         self.assertEqual(r.url, b'http://testserver/multiple%20words')
         self.assertEqual(r.baseurl, b'http://testserver')
@@ -106,7 +106,7 @@
         self.assertIsNone(r.dispatchpath)
 
     def testpathinfo(self):
-        r = parse(DEFAULT_ENV, extra={r'PATH_INFO': r'',})
+        r = parse(DEFAULT_ENV, extra={'PATH_INFO': '',})
 
         self.assertEqual(r.url, b'http://testserver')
         self.assertEqual(r.baseurl, b'http://testserver')
@@ -116,7 +116,7 @@
         self.assertEqual(r.dispatchparts, [])
         self.assertEqual(r.dispatchpath, b'')
 
-        r = parse(DEFAULT_ENV, extra={r'PATH_INFO': r'/pathinfo',})
+        r = parse(DEFAULT_ENV, extra={'PATH_INFO': '/pathinfo',})
 
         self.assertEqual(r.url, b'http://testserver/pathinfo')
         self.assertEqual(r.baseurl, b'http://testserver')
@@ -126,7 +126,7 @@
         self.assertEqual(r.dispatchparts, [b'pathinfo'])
         self.assertEqual(r.dispatchpath, b'pathinfo')
 
-        r = parse(DEFAULT_ENV, extra={r'PATH_INFO': r'/one/two/',})
+        r = parse(DEFAULT_ENV, extra={'PATH_INFO': '/one/two/',})
 
         self.assertEqual(r.url, b'http://testserver/one/two/')
         self.assertEqual(r.baseurl, b'http://testserver')
@@ -139,7 +139,7 @@
     def testscriptandpathinfo(self):
         r = parse(
             DEFAULT_ENV,
-            extra={r'SCRIPT_NAME': r'/script', r'PATH_INFO': r'/pathinfo',},
+            extra={'SCRIPT_NAME': '/script', 'PATH_INFO': '/pathinfo',},
         )
 
         self.assertEqual(r.url, b'http://testserver/script/pathinfo')
@@ -153,8 +153,8 @@
         r = parse(
             DEFAULT_ENV,
             extra={
-                r'SCRIPT_NAME': r'/script1/script2',
-                r'PATH_INFO': r'/path1/path2',
+                'SCRIPT_NAME': '/script1/script2',
+                'PATH_INFO': '/path1/path2',
             },
         )
 
@@ -173,9 +173,9 @@
         r = parse(
             DEFAULT_ENV,
             extra={
-                r'HTTP_HOST': r'hostserver',
-                r'SCRIPT_NAME': r'/script',
-                r'PATH_INFO': r'/pathinfo',
+                'HTTP_HOST': 'hostserver',
+                'SCRIPT_NAME': '/script',
+                'PATH_INFO': '/pathinfo',
             },
         )
 
@@ -208,7 +208,7 @@
             parse(
                 DEFAULT_ENV,
                 reponame=b'repo',
-                extra={r'PATH_INFO': r'/pathinfo',},
+                extra={'PATH_INFO': '/pathinfo',},
             )
 
         with self.assertRaisesRegex(
@@ -217,13 +217,13 @@
             parse(
                 DEFAULT_ENV,
                 reponame=b'repo',
-                extra={r'PATH_INFO': r'/repoextra/path',},
+                extra={'PATH_INFO': '/repoextra/path',},
             )
 
         r = parse(
             DEFAULT_ENV,
             reponame=b'repo',
-            extra={r'PATH_INFO': r'/repo/path1/path2',},
+            extra={'PATH_INFO': '/repo/path1/path2',},
         )
 
         self.assertEqual(r.url, b'http://testserver/repo/path1/path2')
@@ -238,7 +238,7 @@
         r = parse(
             DEFAULT_ENV,
             reponame=b'prefix/repo',
-            extra={r'PATH_INFO': r'/prefix/repo/path1/path2',},
+            extra={'PATH_INFO': '/prefix/repo/path1/path2',},
         )
 
         self.assertEqual(r.url, b'http://testserver/prefix/repo/path1/path2')
@@ -307,7 +307,7 @@
         r = parse(
             DEFAULT_ENV,
             altbaseurl=b'http://altserver',
-            extra={r'PATH_INFO': r'/path1/path2',},
+            extra={'PATH_INFO': '/path1/path2',},
         )
         self.assertEqual(r.url, b'http://testserver/path1/path2')
         self.assertEqual(r.baseurl, b'http://testserver')
@@ -347,7 +347,7 @@
         r = parse(
             DEFAULT_ENV,
             altbaseurl=b'http://altserver/altpath',
-            extra={r'PATH_INFO': r'/path1/path2',},
+            extra={'PATH_INFO': '/path1/path2',},
         )
         self.assertEqual(r.url, b'http://testserver/path1/path2')
         self.assertEqual(r.baseurl, b'http://testserver')
@@ -365,7 +365,7 @@
         r = parse(
             DEFAULT_ENV,
             altbaseurl=b'http://altserver/altpath/',
-            extra={r'PATH_INFO': r'/path1/path2',},
+            extra={'PATH_INFO': '/path1/path2',},
         )
         self.assertEqual(r.url, b'http://testserver/path1/path2')
         self.assertEqual(r.baseurl, b'http://testserver')
@@ -383,7 +383,7 @@
         r = parse(
             DEFAULT_ENV,
             altbaseurl=b'http://altserver',
-            extra={r'SCRIPT_NAME': r'/script', r'PATH_INFO': r'/path1/path2',},
+            extra={'SCRIPT_NAME': '/script', 'PATH_INFO': '/path1/path2',},
         )
         self.assertEqual(r.url, b'http://testserver/script/path1/path2')
         self.assertEqual(r.baseurl, b'http://testserver')
@@ -399,7 +399,7 @@
         r = parse(
             DEFAULT_ENV,
             altbaseurl=b'http://altserver/altroot',
-            extra={r'SCRIPT_NAME': r'/script', r'PATH_INFO': r'/path1/path2',},
+            extra={'SCRIPT_NAME': '/script', 'PATH_INFO': '/path1/path2',},
         )
         self.assertEqual(r.url, b'http://testserver/script/path1/path2')
         self.assertEqual(r.baseurl, b'http://testserver')
@@ -418,10 +418,7 @@
             DEFAULT_ENV,
             reponame=b'repo',
             altbaseurl=b'http://altserver/altroot',
-            extra={
-                r'SCRIPT_NAME': r'/script',
-                r'PATH_INFO': r'/repo/path1/path2',
-            },
+            extra={'SCRIPT_NAME': '/script', 'PATH_INFO': '/repo/path1/path2',},
         )
 
         self.assertEqual(r.url, b'http://testserver/script/repo/path1/path2')