branching: merge stable into default
authorRaphaël Gomès <rgomes@octobus.net>
Sat, 19 Nov 2022 20:40:47 +0100
changeset 49627 7577b8644558
parent 49626 da636e7a6d63 (current diff)
parent 49625 3324f39460e5 (diff)
child 49628 eb383f093a01
branching: merge stable into default
--- a/.hgsigs	Sat Nov 19 16:43:02 2022 +0100
+++ b/.hgsigs	Sat Nov 19 20:40:47 2022 +0100
@@ -236,3 +236,4 @@
 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
+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
--- a/.hgtags	Sat Nov 19 16:43:02 2022 +0100
+++ b/.hgtags	Sat Nov 19 20:40:47 2022 +0100
@@ -249,3 +249,7 @@
 dbdee8ac3e3fcdda1fa55b90c0a235125b7f8e6f 6.2.3
 a3356ab610fc50000cf0ba55c424a4d96da11db7 6.3rc0
 04f1dba53c961dfdb875c8469adc96fa999cfbed 6.3.0
+04f1dba53c961dfdb875c8469adc96fa999cfbed 6.3
+04f1dba53c961dfdb875c8469adc96fa999cfbed 6.3.0
+0000000000000000000000000000000000000000 6.3.0
+c890d8b8bc59b18e5febf60caada629df5356ee2 6.3.1
--- a/contrib/packaging/requirements-windows-py3.txt	Sat Nov 19 16:43:02 2022 +0100
+++ b/contrib/packaging/requirements-windows-py3.txt	Sat Nov 19 20:40:47 2022 +0100
@@ -2,7 +2,7 @@
 # This file is autogenerated by pip-compile with python 3.7
 # To update, run:
 #
-#    pip-compile --generate-hashes --output-file=contrib/packaging/requirements-windows-py3.txt contrib/packaging/requirements-windows.txt.in
+#    pip-compile --generate-hashes --no-reuse-hashes --output-file=contrib/packaging/requirements-windows-py3.txt contrib/packaging/requirements-windows.txt.in
 #
 atomicwrites==1.4.0 \
     --hash=sha256:6d1784dea7c0c8d4a5172b6c620f40b6e4cbfdf96d783691f2e1302a7b88e197 \
@@ -110,7 +110,8 @@
     --hash=sha256:f9552ac246bceab1c5cdd1ec3cfe9446fe76b9853eaf59d3244df03eb27fd3fe
     # via -r contrib/packaging/requirements-windows.txt.in
 fuzzywuzzy==0.18.0 \
-    --hash=sha256:45016e92264780e58972dca1b3d939ac864b78437422beecebb3095f8efd00e8
+    --hash=sha256:45016e92264780e58972dca1b3d939ac864b78437422beecebb3095f8efd00e8 \
+    --hash=sha256:928244b28db720d1e0ee7587acf660ea49d7e4c632569cad4f1cd7e68a5f0993
     # via -r contrib/packaging/requirements-windows.txt.in
 idna==3.2 \
     --hash=sha256:14475042e284991034cb48e06f6851428fb14c4dc953acd9be9a5e95c7b6dd7a \
@@ -222,7 +223,8 @@
     --hash=sha256:91ef2131a9bd6be8f76f1f08eac5c5317221d6ad1e143ae03894b862e8976890
     # via pytest-vcr
 pytest-vcr==1.0.2 \
-    --hash=sha256:23ee51b75abbcc43d926272773aae4f39f93aceb75ed56852d0bf618f92e1896
+    --hash=sha256:23ee51b75abbcc43d926272773aae4f39f93aceb75ed56852d0bf618f92e1896 \
+    --hash=sha256:2f316e0539399bea0296e8b8401145c62b6f85e9066af7e57b6151481b0d6d9c
     # via -r contrib/packaging/requirements-windows.txt.in
 pywin32-ctypes==0.2.0 \
     --hash=sha256:24ffc3b341d457d48e8922352130cf2644024a4ff09762a2261fd34c36ee5942 \
--- a/contrib/packaging/requirements-windows.txt.in	Sat Nov 19 16:43:02 2022 +0100
+++ b/contrib/packaging/requirements-windows.txt.in	Sat Nov 19 20:40:47 2022 +0100
@@ -1,3 +1,9 @@
+# Declare Windows-specific requirements for generating
+# the compiled (frozen) set of requirements in
+# ./requirements-windows-py3.txt.
+# If run on Windows, it may be necessary to run dos2unix
+# on the output file to replace any CRLF newlines with LF.
+
 docutils
 dulwich
 
--- a/contrib/packaging/requirements.txt	Sat Nov 19 16:43:02 2022 +0100
+++ b/contrib/packaging/requirements.txt	Sat Nov 19 20:40:47 2022 +0100
@@ -2,7 +2,7 @@
 # This file is autogenerated by pip-compile with python 3.7
 # To update, run:
 #
-#    pip-compile --generate-hashes --output-file=contrib/packaging/requirements.txt contrib/packaging/requirements.txt.in
+#    pip-compile --generate-hashes --no-reuse-hashes --output-file=contrib/packaging/requirements.txt contrib/packaging/requirements.txt.in
 #
 docutils==0.16 \
     --hash=sha256:0c5b78adfbf7762415433f5515cd5c9e762339e23369dbe8000d84a4bf4ab3af \
@@ -18,8 +18,12 @@
     --hash=sha256:09c4b7f37d6c648cb13f9230d847adf22f8171b1ccc4d5682398e77f40309235 \
     --hash=sha256:1027c282dad077d0bae18be6794e6b6b8c91d58ed8a8d89a89d59693b9131db5 \
     --hash=sha256:13d3144e1e340870b25e7b10b98d779608c02016d5184cfb9927a9f10c689f42 \
+    --hash=sha256:195d7d2c4fbb0ee8139a6cf67194f3973a6b3042d742ebe0a9ed36d8b6f0c07f \
+    --hash=sha256:22c178a091fc6630d0d045bdb5992d2dfe14e3259760e713c490da5323866c39 \
     --hash=sha256:24982cc2533820871eba85ba648cd53d8623687ff11cbb805be4ff7b4c971aff \
     --hash=sha256:29872e92839765e546828bb7754a68c418d927cd064fd4708fab9fe9c8bb116b \
+    --hash=sha256:2beec1e0de6924ea551859edb9e7679da6e4870d32cb766240ce17e0a0ba2014 \
+    --hash=sha256:3b8a6499709d29c2e2399569d96719a1b21dcd94410a586a18526b143ec8470f \
     --hash=sha256:43a55c2930bbc139570ac2452adf3d70cdbb3cfe5912c71cdce1c2c6bbd9c5d1 \
     --hash=sha256:46c99d2de99945ec5cb54f23c8cd5689f6d7177305ebff350a58ce5f8de1669e \
     --hash=sha256:500d4957e52ddc3351cabf489e79c91c17f6e0899158447047588650b5e69183 \
@@ -28,22 +32,37 @@
     --hash=sha256:62fe6c95e3ec8a7fad637b7f3d372c15ec1caa01ab47926cfdf7a75b40e0eac1 \
     --hash=sha256:6788b695d50a51edb699cb55e35487e430fa21f1ed838122d722e0ff0ac5ba15 \
     --hash=sha256:6dd73240d2af64df90aa7c4e7481e23825ea70af4b4922f8ede5b9e35f78a3b1 \
+    --hash=sha256:6f1e273a344928347c1290119b493a1f0303c52f5a5eae5f16d74f48c15d4a85 \
+    --hash=sha256:6fffc775d90dcc9aed1b89219549b329a9250d918fd0b8fa8d93d154918422e1 \
     --hash=sha256:717ba8fe3ae9cc0006d7c451f0bb265ee07739daf76355d06366154ee68d221e \
     --hash=sha256:79855e1c5b8da654cf486b830bd42c06e8780cea587384cf6545b7d9ac013a0b \
     --hash=sha256:7c1699dfe0cf8ff607dbdcc1e9b9af1755371f92a68f706051cc8c37d447c905 \
+    --hash=sha256:7fed13866cf14bba33e7176717346713881f56d9d2bcebab207f7a036f41b850 \
+    --hash=sha256:84dee80c15f1b560d55bcfe6d47b27d070b4681c699c572af2e3c7cc90a3b8e0 \
     --hash=sha256:88e5fcfb52ee7b911e8bb6d6aa2fd21fbecc674eadd44118a9cc3863f938e735 \
     --hash=sha256:8defac2f2ccd6805ebf65f5eeb132adcf2ab57aa11fdf4c0dd5169a004710e7d \
+    --hash=sha256:98bae9582248d6cf62321dcb52aaf5d9adf0bad3b40582925ef7c7f0ed85fceb \
     --hash=sha256:98c7086708b163d425c67c7a91bad6e466bb99d797aa64f965e9d25c12111a5e \
     --hash=sha256:9add70b36c5666a2ed02b43b335fe19002ee5235efd4b8a89bfcf9005bebac0d \
     --hash=sha256:9bf40443012702a1d2070043cb6291650a0841ece432556f784f004937f0f32c \
+    --hash=sha256:a6a744282b7718a2a62d2ed9d993cad6f5f585605ad352c11de459f4108df0a1 \
+    --hash=sha256:acf08ac40292838b3cbbb06cfe9b2cb9ec78fce8baca31ddb87aaac2e2dc3bc2 \
     --hash=sha256:ade5e387d2ad0d7ebf59146cc00c8044acbd863725f887353a10df825fc8ae21 \
     --hash=sha256:b00c1de48212e4cc9603895652c5c410df699856a2853135b3967591e4beebc2 \
     --hash=sha256:b1282f8c00509d99fef04d8ba936b156d419be841854fe901d8ae224c59f0be5 \
+    --hash=sha256:b1dba4527182c95a0db8b6060cc98ac49b9e2f5e64320e2b56e47cb2831978c7 \
     --hash=sha256:b2051432115498d3562c084a49bba65d97cf251f5a331c64a12ee7e04dacc51b \
+    --hash=sha256:b7d644ddb4dbd407d31ffb699f1d140bc35478da613b441c582aeb7c43838dd8 \
     --hash=sha256:ba59edeaa2fc6114428f1637ffff42da1e311e29382d81b339c1817d37ec93c6 \
+    --hash=sha256:bf5aa3cbcfdf57fa2ee9cd1822c862ef23037f5c832ad09cfea57fa846dec193 \
     --hash=sha256:c8716a48d94b06bb3b2524c2b77e055fb313aeb4ea620c8dd03a105574ba704f \
+    --hash=sha256:caabedc8323f1e93231b52fc32bdcde6db817623d33e100708d9a68e1f53b26b \
     --hash=sha256:cd5df75523866410809ca100dc9681e301e3c27567cf498077e8551b6d20e42f \
     --hash=sha256:cdb132fc825c38e1aeec2c8aa9338310d29d337bebbd7baa06889d09a60a1fa2 \
+    --hash=sha256:d53bc011414228441014aa71dbec320c66468c1030aae3a6e29778a3382d96e5 \
+    --hash=sha256:d73a845f227b0bfe8a7455ee623525ee656a9e2e749e4742706d80a6065d5e2c \
+    --hash=sha256:d9be0ba6c527163cbed5e0857c451fcd092ce83947944d6c14bc95441203f032 \
     --hash=sha256:e249096428b3ae81b08327a63a485ad0878de3fb939049038579ac0ef61e17e7 \
-    --hash=sha256:e8313f01ba26fbbe36c7be1966a7b7424942f670f38e666995b88d012765b9be
+    --hash=sha256:e8313f01ba26fbbe36c7be1966a7b7424942f670f38e666995b88d012765b9be \
+    --hash=sha256:feb7b34d6325451ef96bc0e36e1a6c0c1c64bc1fbec4b854f4529e51887b1621
     # via jinja2
--- a/contrib/packaging/requirements.txt.in	Sat Nov 19 16:43:02 2022 +0100
+++ b/contrib/packaging/requirements.txt.in	Sat Nov 19 20:40:47 2022 +0100
@@ -1,2 +1,5 @@
+# Declare requirements for generating the compiled (frozen)
+# set of requirements in ./requirements.txt.
+
 docutils
 jinja2
--- a/mercurial/commands.py	Sat Nov 19 16:43:02 2022 +0100
+++ b/mercurial/commands.py	Sat Nov 19 20:40:47 2022 +0100
@@ -2114,7 +2114,9 @@
         if repo[b'.'].closesbranch():
             # Not ideal, but let us do an extra status early to prevent early
             # bail out.
-            matcher = scmutil.match(repo[None], pats, opts)
+            matcher = scmutil.match(
+                repo[None], pats, pycompat.byteskwargs(opts)
+            )
             s = repo.status(match=matcher)
             if s.modified or s.added or s.removed:
                 bheads = repo.branchheads(branch, closed=True)
--- a/mercurial/dirstatemap.py	Sat Nov 19 16:43:02 2022 +0100
+++ b/mercurial/dirstatemap.py	Sat Nov 19 20:40:47 2022 +0100
@@ -612,8 +612,6 @@
             if append:
                 docket = self.docket
                 data_filename = docket.data_filename()
-                if tr:
-                    tr.add(data_filename, docket.data_size)
                 with self._opener(data_filename, b'r+b') as fp:
                     fp.seek(docket.data_size)
                     assert fp.tell() == docket.data_size
--- a/mercurial/logcmdutil.py	Sat Nov 19 16:43:02 2022 +0100
+++ b/mercurial/logcmdutil.py	Sat Nov 19 20:40:47 2022 +0100
@@ -817,17 +817,26 @@
             # There may be the case that a path doesn't exist in some (but
             # not all) of the specified start revisions, but let's consider
             # the path is valid. Missing files will be warned by the matcher.
-            startctxs = [repo[r] for r in revs]
-            for f in match.files():
-                found = False
-                for c in startctxs:
-                    if f in c:
-                        found = True
-                    elif c.hasdir(f):
+            all_files = list(match.files())
+            missing_files = set(all_files)
+            files = all_files
+            for r in revs:
+                if not files:
+                    # We don't have any file to check anymore.
+                    break
+                ctx = repo[r]
+                for f in files:
+                    if f in ctx:
+                        missing_files.discard(f)
+                    elif ctx.hasdir(f):
                         # If a directory exists in any of the start revisions,
                         # take the slow path.
-                        found = slowpath = True
-                if not found:
+                        missing_files.discard(f)
+                        slowpath = True
+                        # we found on slow path, no need to search for more.
+                        files = missing_files
+            for f in all_files:
+                if f in missing_files:
                     raise error.StateError(
                         _(
                             b'cannot follow file not in any of the specified '
--- a/mercurial/match.py	Sat Nov 19 16:43:02 2022 +0100
+++ b/mercurial/match.py	Sat Nov 19 20:40:47 2022 +0100
@@ -1323,6 +1323,9 @@
     return res
 
 
+FLAG_RE = util.re.compile(b'^\(\?([aiLmsux]+)\)(.*)')
+
+
 def _regex(kind, pat, globsuffix):
     """Convert a (normalized) pattern of any kind into a
     regular expression.
@@ -1351,9 +1354,15 @@
             return b'.*' + globre[len(b'[^/]*') :] + globsuffix
         return b'(?:|.*/)' + globre + globsuffix
     if kind == b'relre':
-        if pat.startswith(b'^'):
-            return pat
-        return b'.*' + pat
+        flag = None
+        m = FLAG_RE.match(pat)
+        if m:
+            flag, pat = m.groups()
+        if not pat.startswith(b'^'):
+            pat = b'.*' + pat
+        if flag is not None:
+            pat = br'(?%s:%s)' % (flag, pat)
+        return pat
     if kind in (b'glob', b'rootglob'):
         return _globre(pat) + globsuffix
     raise error.ProgrammingError(b'not a regex pattern: %s:%s' % (kind, pat))
--- a/relnotes/6.3	Sat Nov 19 16:43:02 2022 +0100
+++ b/relnotes/6.3	Sat Nov 19 20:40:47 2022 +0100
@@ -1,3 +1,15 @@
+= Mercurial 6.3.1 =
+
+ * memory-usage: fix `hg log --follow --rev R F` space complexity (dcb2581e33be)
+ * Improve portability and robustness of test harness
+ * hg-core: relax dependencies pinning
+ * matcher: fix issues regex flag contained in pattern (issue6759)
+ * matcher: do not prepend '.*' to pattern using ^ after flags
+ * packaging: refresh dependency hashes (issue6750)
+ * cffi: fix a bytes vs str issue on macOS when listing directories
+ * commit: properly consider file include and exclude options when closing branch
+ * dirstate-v2: do not put the dirstate data file in a transaction
+
 = Mercurial 6.3 =
 
 == New Features ==
--- a/rust/hg-core/Cargo.toml	Sat Nov 19 16:43:02 2022 +0100
+++ b/rust/hg-core/Cargo.toml	Sat Nov 19 20:40:47 2022 +0100
@@ -38,7 +38,7 @@
 format-bytes = "0.3.0"
 # once_cell 1.15 uses edition 2021, while the heptapod CI
 # uses an old version of Cargo that doesn't support it.
-once_cell = "=1.14.0"
+once_cell = "1.14.0"
 
 # We don't use the `miniz-oxide` backend to not change rhg benchmarks and until
 # we have a clearer view of which backend is the fastest.
--- a/rust/hg-core/src/filepatterns.rs	Sat Nov 19 16:43:02 2022 +0100
+++ b/rust/hg-core/src/filepatterns.rs	Sat Nov 19 20:40:47 2022 +0100
@@ -171,6 +171,10 @@
     }
 }
 
+lazy_static! {
+    static ref FLAG_RE: Regex = Regex::new(r"^\(\?[aiLmsux]+\)").unwrap();
+}
+
 /// Builds the regex that corresponds to the given pattern.
 /// If within a `syntax: regexp` context, returns the pattern,
 /// otherwise, returns the corresponding regex.
@@ -193,7 +197,29 @@
             {
                 return pattern.to_owned();
             }
-            [&b".*"[..], pattern].concat()
+            match FLAG_RE.find(pattern) {
+                Some(mat) => {
+                    let s = mat.start();
+                    let e = mat.end();
+                    [
+                        &b"(?"[..],
+                        &pattern[s + 2..e - 1],
+                        &b":"[..],
+                        if pattern[e] == b'^'
+                            || pattern[e] == b'*'
+                            || pattern[e..].starts_with(b".*")
+                        {
+                            &b""[..]
+                        } else {
+                            &b".*"[..]
+                        },
+                        &pattern[e..],
+                        &b")"[..],
+                    ]
+                    .concat()
+                }
+                None => [&b".*"[..], pattern].concat(),
+            }
         }
         PatternSyntax::Path | PatternSyntax::RelPath => {
             if pattern == b"." {
@@ -703,4 +729,44 @@
             Some(br"[^/]*\.o(?:/|$)".to_vec()),
         );
     }
+
+    #[test]
+    fn test_build_single_relregex() {
+        assert_eq!(
+            build_single_regex(&IgnorePattern::new(
+                PatternSyntax::RelRegexp,
+                b"^ba{2}r",
+                Path::new("")
+            ))
+            .unwrap(),
+            Some(b"^ba{2}r".to_vec()),
+        );
+        assert_eq!(
+            build_single_regex(&IgnorePattern::new(
+                PatternSyntax::RelRegexp,
+                b"ba{2}r",
+                Path::new("")
+            ))
+            .unwrap(),
+            Some(b".*ba{2}r".to_vec()),
+        );
+        assert_eq!(
+            build_single_regex(&IgnorePattern::new(
+                PatternSyntax::RelRegexp,
+                b"(?ia)ba{2}r",
+                Path::new("")
+            ))
+            .unwrap(),
+            Some(b"(?ia:.*ba{2}r)".to_vec()),
+        );
+        assert_eq!(
+            build_single_regex(&IgnorePattern::new(
+                PatternSyntax::RelRegexp,
+                b"(?ia)^ba{2}r",
+                Path::new("")
+            ))
+            .unwrap(),
+            Some(b"(?ia:^ba{2}r)".to_vec()),
+        );
+    }
 }
--- a/tests/hghave.py	Sat Nov 19 16:43:02 2022 +0100
+++ b/tests/hghave.py	Sat Nov 19 20:40:47 2022 +0100
@@ -1077,8 +1077,8 @@
 @check('dirstate-v2', 'using the v2 format of .hg/dirstate')
 def has_dirstate_v2():
     # Keep this logic in sync with `newreporequirements()` in `mercurial/localrepo.py`
-    return has_rust() and matchoutput(
-        'hg config format.exp-rc-dirstate-v2', b'(?i)1|yes|true|on|always'
+    return matchoutput(
+        'hg config format.use-dirstate-v2', b'(?i)1|yes|true|on|always'
     )
 
 
--- a/tests/test-audit-path.t	Sat Nov 19 16:43:02 2022 +0100
+++ b/tests/test-audit-path.t	Sat Nov 19 20:40:47 2022 +0100
@@ -2,7 +2,8 @@
 with periods, etc. So much of this test fails with it.
 #require no-reposimplestore
 
-  $ hg init
+  $ hg init repo
+  $ cd repo
 
 audit of .hg
 
--- a/tests/test-backwards-remove.t	Sat Nov 19 16:43:02 2022 +0100
+++ b/tests/test-backwards-remove.t	Sat Nov 19 20:40:47 2022 +0100
@@ -1,4 +1,5 @@
-  $ hg init
+  $ hg init repo
+  $ cd repo
   $ echo This is file a1 > a
   $ hg add a
   $ hg commit -m "commit #0"
--- a/tests/test-bisect.t	Sat Nov 19 16:43:02 2022 +0100
+++ b/tests/test-bisect.t	Sat Nov 19 20:40:47 2022 +0100
@@ -1,5 +1,5 @@
-  $ hg init
-
+  $ hg init repo
+  $ cd repo
 
 committing changes
 
@@ -460,7 +460,7 @@
 
 test bisecting command
 
-  $ cat > script.py <<EOF
+  $ cat > "$TESTTMP/script.py" <<EOF
   > #!$PYTHON
   > import sys
   > from mercurial import hg, ui as uimod
@@ -468,7 +468,7 @@
   > if repo[b'.'].rev() < 6:
   >     sys.exit(1)
   > EOF
-  $ chmod +x script.py
+  $ chmod +x "$TESTTMP/script.py"
   $ hg bisect -r
   $ hg up -qr tip
   $ hg bisect --command "\"$PYTHON\" \"$TESTTMP/script.py\" and some parameters"
@@ -497,7 +497,7 @@
 
   $ hg update null
   0 files updated, 0 files merged, 1 files removed, 0 files unresolved
-  $ cat > script.sh <<'EOF'
+  $ cat > "$TESTTMP/script.sh" <<'EOF'
   > #!/bin/sh
   > test -n "$HG_NODE" || (echo HG_NODE missing; exit 127)
   > current="`hg log -r \"bisect(current)\" --template {node}`"
@@ -505,7 +505,7 @@
   > rev="`hg log -r $HG_NODE --template {rev}`"
   > test "$rev" -ge 6
   > EOF
-  $ chmod +x script.sh
+  $ chmod +x "$TESTTMP/script.sh"
   $ hg bisect -r
   $ hg bisect --good tip --noupdate
   $ hg bisect --bad 0 --noupdate
@@ -530,7 +530,7 @@
 
 test the same case, this time with updating
 
-  $ cat > script.sh <<'EOF'
+  $ cat > "$TESTTMP/script.sh" <<'EOF'
   > #!/bin/sh
   > test -n "$HG_NODE" || (echo HG_NODE missing; exit 127)
   > current="`hg log -r \"bisect(current)\" --template {node}`"
@@ -538,7 +538,7 @@
   > rev="`hg log -r . --template {rev}`"
   > test "$rev" -ge 6
   > EOF
-  $ chmod +x script.sh
+  $ chmod +x "$TESTTMP/script.sh"
   $ hg bisect -r
   $ hg up -qr tip
   $ hg bisect --command "sh \"$TESTTMP/script.sh\" and some params"
--- a/tests/test-bookmarks-current.t	Sat Nov 19 16:43:02 2022 +0100
+++ b/tests/test-bookmarks-current.t	Sat Nov 19 20:40:47 2022 +0100
@@ -1,4 +1,5 @@
-  $ hg init
+  $ hg init repo
+  $ cd repo
 
 no bookmarks
 
--- a/tests/test-bookmarks-merge.t	Sat Nov 19 16:43:02 2022 +0100
+++ b/tests/test-bookmarks-merge.t	Sat Nov 19 20:40:47 2022 +0100
@@ -1,6 +1,7 @@
 # init
 
-  $ hg init
+  $ hg init repo
+  $ cd repo
   $ echo a > a
   $ hg add a
   $ hg commit -m'a'
--- a/tests/test-bookmarks-rebase.t	Sat Nov 19 16:43:02 2022 +0100
+++ b/tests/test-bookmarks-rebase.t	Sat Nov 19 20:40:47 2022 +0100
@@ -3,7 +3,8 @@
 
 initialize repository
 
-  $ hg init
+  $ hg init repo
+  $ cd repo
 
   $ echo 'a' > a
   $ hg ci -A -m "0"
@@ -38,7 +39,7 @@
 
   $ hg rebase -s two -d one
   rebasing 3:2ae46b1d99a7 two tip "3"
-  saved backup bundle to $TESTTMP/.hg/strip-backup/2ae46b1d99a7-e6b057bc-rebase.hg
+  saved backup bundle to $TESTTMP/repo/.hg/strip-backup/2ae46b1d99a7-e6b057bc-rebase.hg
 
   $ hg log
   changeset:   3:42e5ed2cdcf4
--- a/tests/test-branches.t	Sat Nov 19 16:43:02 2022 +0100
+++ b/tests/test-branches.t	Sat Nov 19 20:40:47 2022 +0100
@@ -292,6 +292,12 @@
   [10]
   $ hg commit -d '9 0' --close-branch -m 're-closing this branch' b
 
+  $ echo baz > b
+  $ hg commit -d '9 0' --close-branch -m 'empty re-closing this branch' -X b
+  abort: current revision is already a branch closing head
+  [10]
+  $ hg revert b
+
   $ hg debugstrip --rev 13: --no-backup
   1 files updated, 0 files merged, 0 files removed, 0 files unresolved
   $ hg revert --all --no-backup
--- a/tests/test-cat.t	Sat Nov 19 16:43:02 2022 +0100
+++ b/tests/test-cat.t	Sat Nov 19 20:40:47 2022 +0100
@@ -1,4 +1,5 @@
-  $ hg init
+  $ hg init repo
+  $ cd repo
   $ echo 0 > a
   $ echo 0 > b
   $ hg ci -A -m m
--- a/tests/test-clone-update-order.t	Sat Nov 19 16:43:02 2022 +0100
+++ b/tests/test-clone-update-order.t	Sat Nov 19 20:40:47 2022 +0100
@@ -1,4 +1,5 @@
-  $ hg init
+  $ hg init repo
+  $ cd repo
   $ echo foo > bar
   $ hg commit -Am default
   adding bar
--- a/tests/test-commit-amend.t	Sat Nov 19 16:43:02 2022 +0100
+++ b/tests/test-commit-amend.t	Sat Nov 19 20:40:47 2022 +0100
@@ -1,4 +1,5 @@
-  $ hg init
+  $ hg init repo
+  $ cd repo
 
 Setup:
 
@@ -36,7 +37,7 @@
   $ HGEDITOR="\"sh\" \"`pwd`/editor.sh\"" hg commit --amend -m 'amend base1'
   pretxncommit 43f1ba15f28a50abf0aae529cf8a16bfced7b149
   43f1ba15f28a tip
-  saved backup bundle to $TESTTMP/.hg/strip-backup/489edb5b847d-5ab4f721-amend.hg
+  saved backup bundle to $TESTTMP/repo/.hg/strip-backup/489edb5b847d-5ab4f721-amend.hg
   $ echo 'pretxncommit.foo = ' >> $HGRCPATH
   $ hg diff -c .
   diff -r ad120869acf0 -r 43f1ba15f28a a
@@ -94,7 +95,7 @@
 
 Add new file along with modified existing file:
   $ hg ci --amend -m 'amend base1 new file'
-  saved backup bundle to $TESTTMP/.hg/strip-backup/43f1ba15f28a-007467c2-amend.hg
+  saved backup bundle to $TESTTMP/repo/.hg/strip-backup/43f1ba15f28a-007467c2-amend.hg
 
 Remove file that was added in amended commit:
 (and test logfile option)
@@ -103,7 +104,7 @@
   $ hg rm b
   $ echo 'amend base1 remove new file' > ../logfile
   $ HGEDITOR="\"sh\" \"`pwd`/editor.sh\"" hg ci --amend --logfile ../logfile
-  saved backup bundle to $TESTTMP/.hg/strip-backup/c16295aaf401-1ada9901-amend.hg
+  saved backup bundle to $TESTTMP/repo/.hg/strip-backup/c16295aaf401-1ada9901-amend.hg
 
   $ hg cat b
   b: no such file in rev 47343646fa3d
@@ -123,7 +124,7 @@
        254 (changelog)
        163 (manifests)
        131  a
-  saved backup bundle to $TESTTMP/.hg/strip-backup/47343646fa3d-c2758885-amend.hg
+  saved backup bundle to $TESTTMP/repo/.hg/strip-backup/47343646fa3d-c2758885-amend.hg
   1 changesets found
   uncompressed size of bundle content:
        250 (changelog)
@@ -170,10 +171,10 @@
   > EOF
   $ HGEDITOR="sh .hg/checkeditform.sh" hg ci --amend -u foo -d '1 0'
   HGEDITFORM=commit.amend.normal
-  saved backup bundle to $TESTTMP/.hg/strip-backup/401431e913a1-5e8e532c-amend.hg
+  saved backup bundle to $TESTTMP/repo/.hg/strip-backup/401431e913a1-5e8e532c-amend.hg
   $ echo a >> a
   $ hg ci --amend -u foo -d '1 0'
-  saved backup bundle to $TESTTMP/.hg/strip-backup/d96b1d28ae33-677e0afb-amend.hg
+  saved backup bundle to $TESTTMP/repo/.hg/strip-backup/d96b1d28ae33-677e0afb-amend.hg
   $ hg log -r .
   changeset:   1:a9a13940fc03
   tag:         tip
@@ -267,7 +268,7 @@
        249 (changelog)
        163 (manifests)
        133  a
-  saved backup bundle to $TESTTMP/.hg/strip-backup/a9a13940fc03-7c2e8674-amend.hg
+  saved backup bundle to $TESTTMP/repo/.hg/strip-backup/a9a13940fc03-7c2e8674-amend.hg
   1 changesets found
   uncompressed size of bundle content:
        257 (changelog)
@@ -303,7 +304,7 @@
        257 (changelog)
        163 (manifests)
        133  a
-  saved backup bundle to $TESTTMP/.hg/strip-backup/64a124ba1b44-10374b8f-amend.hg
+  saved backup bundle to $TESTTMP/repo/.hg/strip-backup/64a124ba1b44-10374b8f-amend.hg
   1 changesets found
   uncompressed size of bundle content:
        257 (changelog)
@@ -330,13 +331,13 @@
   $ hg book book1
   $ hg book book2
   $ hg ci --amend -m 'move bookmarks'
-  saved backup bundle to $TESTTMP/.hg/strip-backup/7892795b8e38-3fb46217-amend.hg
+  saved backup bundle to $TESTTMP/repo/.hg/strip-backup/7892795b8e38-3fb46217-amend.hg
   $ hg book
      book1                     1:8311f17e2616
    * book2                     1:8311f17e2616
   $ echo a >> a
   $ hg ci --amend -m 'move bookmarks'
-  saved backup bundle to $TESTTMP/.hg/strip-backup/8311f17e2616-f0504fe3-amend.hg
+  saved backup bundle to $TESTTMP/repo/.hg/strip-backup/8311f17e2616-f0504fe3-amend.hg
   $ hg book
      book1                     1:a3b65065808c
    * book2                     1:a3b65065808c
@@ -370,7 +371,7 @@
   $ hg branch default -f
   marked working directory as branch default
   $ hg ci --amend -m 'back to default'
-  saved backup bundle to $TESTTMP/.hg/strip-backup/f8339a38efe1-c18453c9-amend.hg
+  saved backup bundle to $TESTTMP/repo/.hg/strip-backup/f8339a38efe1-c18453c9-amend.hg
   $ hg branches
   default                        2:9c07515f2650
 
@@ -386,7 +387,7 @@
   $ echo b >> b
   $ hg ci -mb
   $ hg ci --amend --close-branch -m 'closing branch foo'
-  saved backup bundle to $TESTTMP/.hg/strip-backup/c962248fa264-54245dc7-amend.hg
+  saved backup bundle to $TESTTMP/repo/.hg/strip-backup/c962248fa264-54245dc7-amend.hg
 
 Same thing, different code path:
 
@@ -395,7 +396,7 @@
   reopening closed branch head 4
   $ echo b >> b
   $ hg ci --amend --close-branch
-  saved backup bundle to $TESTTMP/.hg/strip-backup/027371728205-b900d9fa-amend.hg
+  saved backup bundle to $TESTTMP/repo/.hg/strip-backup/027371728205-b900d9fa-amend.hg
   $ hg branches
   default                        2:9c07515f2650
 
@@ -433,7 +434,7 @@
   $ hg ci -m 'b -> c'
   $ hg mv c d
   $ hg ci --amend -m 'b -> d'
-  saved backup bundle to $TESTTMP/.hg/strip-backup/42f3f27a067d-f23cc9f7-amend.hg
+  saved backup bundle to $TESTTMP/repo/.hg/strip-backup/42f3f27a067d-f23cc9f7-amend.hg
   $ hg st --rev '.^' --copies d
   A d
     b
@@ -441,7 +442,7 @@
   $ hg ci -m 'e = d'
   $ hg cp e f
   $ hg ci --amend -m 'f = d'
-  saved backup bundle to $TESTTMP/.hg/strip-backup/9198f73182d5-251d584a-amend.hg
+  saved backup bundle to $TESTTMP/repo/.hg/strip-backup/9198f73182d5-251d584a-amend.hg
   $ hg st --rev '.^' --copies f
   A f
     d
@@ -452,7 +453,7 @@
   $ hg cp a f
   $ mv f.orig f
   $ hg ci --amend -m replacef
-  saved backup bundle to $TESTTMP/.hg/strip-backup/f0993ab6b482-eda301bf-amend.hg
+  saved backup bundle to $TESTTMP/repo/.hg/strip-backup/f0993ab6b482-eda301bf-amend.hg
   $ hg st --change . --copies
   $ hg log -r . --template "{file_copies}\n"
   
@@ -464,7 +465,7 @@
   adding g
   $ hg mv g h
   $ hg ci --amend
-  saved backup bundle to $TESTTMP/.hg/strip-backup/58585e3f095c-0f5ebcda-amend.hg
+  saved backup bundle to $TESTTMP/repo/.hg/strip-backup/58585e3f095c-0f5ebcda-amend.hg
   $ hg st --change . --copies h
   A h
   $ hg log -r . --template "{file_copies}\n"
@@ -484,11 +485,11 @@
   $ echo a >> a
   $ hg ci -ma
   $ hg ci --amend -m "a'"
-  saved backup bundle to $TESTTMP/.hg/strip-backup/39a162f1d65e-9dfe13d8-amend.hg
+  saved backup bundle to $TESTTMP/repo/.hg/strip-backup/39a162f1d65e-9dfe13d8-amend.hg
   $ hg log -r . --template "{branch}\n"
   a
   $ hg ci --amend -m "a''"
-  saved backup bundle to $TESTTMP/.hg/strip-backup/d5ca7b1ac72b-0b4c1a34-amend.hg
+  saved backup bundle to $TESTTMP/repo/.hg/strip-backup/d5ca7b1ac72b-0b4c1a34-amend.hg
   $ hg log -r . --template "{branch}\n"
   a
 
@@ -505,7 +506,7 @@
   $ hg graft 12
   grafting 12:2647734878ef "fork" (tip)
   $ hg ci --amend -m 'graft amend'
-  saved backup bundle to $TESTTMP/.hg/strip-backup/fe8c6f7957ca-25638666-amend.hg
+  saved backup bundle to $TESTTMP/repo/.hg/strip-backup/fe8c6f7957ca-25638666-amend.hg
   $ hg log -r . --debug | grep extra
   extra:       amend_source=fe8c6f7957ca1665ed77496ed7a07657d469ac60
   extra:       branch=a
--- a/tests/test-conflict.t	Sat Nov 19 16:43:02 2022 +0100
+++ b/tests/test-conflict.t	Sat Nov 19 20:40:47 2022 +0100
@@ -1,4 +1,5 @@
-  $ hg init
+  $ hg init repo
+  $ cd repo
   $ cat << EOF > a
   > Small Mathematical Series.
   > One
--- a/tests/test-confused-revert.t	Sat Nov 19 16:43:02 2022 +0100
+++ b/tests/test-confused-revert.t	Sat Nov 19 20:40:47 2022 +0100
@@ -1,4 +1,5 @@
-  $ hg init
+  $ hg init repo
+  $ cd repo
   $ echo foo > a
   $ hg add a
   $ hg commit -m "1"
--- a/tests/test-convert-git.t	Sat Nov 19 16:43:02 2022 +0100
+++ b/tests/test-convert-git.t	Sat Nov 19 20:40:47 2022 +0100
@@ -2,6 +2,7 @@
 
   $ git config -f $HOME/.gitconfig init.defaultBranch master
   $ git config -f $HOME/.gitconfig core.autocrlf false
+  $ git config -f $HOME/.gitconfig protocol.file.allow always
   $ echo "[extensions]" >> $HGRCPATH
   $ echo "convert=" >> $HGRCPATH
   $ cat >> $HGRCPATH <<EOF
--- a/tests/test-custom-filters.t	Sat Nov 19 16:43:02 2022 +0100
+++ b/tests/test-custom-filters.t	Sat Nov 19 20:40:47 2022 +0100
@@ -1,4 +1,5 @@
-  $ hg init
+  $ hg init repo
+  $ cd repo
 
   $ cat > .hg/hgrc <<EOF
   > [extensions]
--- a/tests/test-debugrename.t	Sat Nov 19 16:43:02 2022 +0100
+++ b/tests/test-debugrename.t	Sat Nov 19 20:40:47 2022 +0100
@@ -1,4 +1,5 @@
-  $ hg init
+  $ hg init repo
+  $ cd repo
   $ echo a > a
   $ hg ci -Am t
   adding a
--- a/tests/test-diff-ignore-whitespace.t	Sat Nov 19 16:43:02 2022 +0100
+++ b/tests/test-diff-ignore-whitespace.t	Sat Nov 19 20:40:47 2022 +0100
@@ -5,7 +5,8 @@
   $ echo '[alias]' >> $HGRCPATH
   $ echo 'ndiff = diff --nodates' >> $HGRCPATH
 
-  $ hg init
+  $ hg init repo
+  $ cd repo
   $ printf 'hello world\ngoodbye world\n' >foo
   $ hg ci -Amfoo -ufoo
   adding foo
--- a/tests/test-diff-indent-heuristic.t	Sat Nov 19 16:43:02 2022 +0100
+++ b/tests/test-diff-indent-heuristic.t	Sat Nov 19 20:40:47 2022 +0100
@@ -8,7 +8,8 @@
   > EOF
 #endif
 
-  $ hg init
+  $ hg init repo
+  $ cd repo
 
   $ cat > a.c <<'EOF'
   > /*
--- a/tests/test-diff-issue2761.t	Sat Nov 19 16:43:02 2022 +0100
+++ b/tests/test-diff-issue2761.t	Sat Nov 19 20:40:47 2022 +0100
@@ -1,6 +1,7 @@
 Test issue2761
 
-  $ hg init
+  $ hg init repo
+  $ cd repo
 
   $ touch to-be-deleted
   $ hg add
--- a/tests/test-diff-newlines.t	Sat Nov 19 16:43:02 2022 +0100
+++ b/tests/test-diff-newlines.t	Sat Nov 19 20:40:47 2022 +0100
@@ -1,4 +1,5 @@
-  $ hg init
+  $ hg init repo
+  $ cd repo
 
   $ "$PYTHON" -c 'open("a", "wb").write(b"confuse str.splitlines\nembedded\rnewline\n")'
   $ hg ci -Ama -d '1 0'
--- a/tests/test-diff-reverse.t	Sat Nov 19 16:43:02 2022 +0100
+++ b/tests/test-diff-reverse.t	Sat Nov 19 20:40:47 2022 +0100
@@ -1,4 +1,5 @@
-  $ hg init
+  $ hg init repo
+  $ cd repo
 
   $ cat > a <<EOF
   > a
--- a/tests/test-editor-filename.t	Sat Nov 19 16:43:02 2022 +0100
+++ b/tests/test-editor-filename.t	Sat Nov 19 20:40:47 2022 +0100
@@ -1,6 +1,7 @@
 Test temp file used with an editor has the expected suffix.
 
-  $ hg init
+  $ hg init repo
+  $ cd repo
 
 Create an editor that writes its arguments to stdout and set it to $HGEDITOR.
 
@@ -9,7 +10,7 @@
   > exit 1
   > EOF
   $ hg add editor.sh
-  $ HGEDITOR="sh $TESTTMP/editor.sh"
+  $ HGEDITOR="sh $TESTTMP/repo/editor.sh"
   $ export HGEDITOR
 
 Verify that the path for a commit editor has the expected suffix.
--- a/tests/test-encode.t	Sat Nov 19 16:43:02 2022 +0100
+++ b/tests/test-encode.t	Sat Nov 19 20:40:47 2022 +0100
@@ -1,6 +1,7 @@
 Test encode/decode filters
 
-  $ hg init
+  $ hg init repo
+  $ cd repo
   $ cat > .hg/hgrc <<EOF
   > [encode]
   > not.gz = tr [:lower:] [:upper:]
--- a/tests/test-execute-bit.t	Sat Nov 19 16:43:02 2022 +0100
+++ b/tests/test-execute-bit.t	Sat Nov 19 20:40:47 2022 +0100
@@ -1,6 +1,7 @@
 #require execbit
 
-  $ hg init
+  $ hg init repo
+  $ cd repo
   $ echo a > a
   $ hg ci -Am'not executable'
   adding a
--- a/tests/test-extra-filelog-entry.t	Sat Nov 19 16:43:02 2022 +0100
+++ b/tests/test-extra-filelog-entry.t	Sat Nov 19 20:40:47 2022 +0100
@@ -3,7 +3,8 @@
   $ echo "[extensions]" >> $HGRCPATH
   $ echo "mq=" >> $HGRCPATH
 
-  $ hg init
+  $ hg init repo
+  $ cd repo
   $ hg qinit
 
   $ echo b > b
--- a/tests/test-fileset-generated.t	Sat Nov 19 16:43:02 2022 +0100
+++ b/tests/test-fileset-generated.t	Sat Nov 19 20:40:47 2022 +0100
@@ -1,4 +1,5 @@
-  $ hg init
+  $ hg init repo
+  $ cd repo
 
 Set up history and working copy
 
--- a/tests/test-git-export.t	Sat Nov 19 16:43:02 2022 +0100
+++ b/tests/test-git-export.t	Sat Nov 19 20:40:47 2022 +0100
@@ -1,4 +1,5 @@
-  $ hg init
+  $ hg init repo
+  $ cd repo
   $ echo start > start
   $ hg ci -Amstart
   adding start
@@ -46,7 +47,7 @@
 Cross and same-directory copies with a relative root:
 
   $ hg diff --git --root .. -r 1:tip
-  abort: .. not under root '$TESTTMP'
+  abort: .. not under root '$TESTTMP/repo'
   [255]
   $ hg diff --git --root doesnotexist -r 1:tip
   $ hg diff --git --root . -r 1:tip
@@ -121,7 +122,7 @@
   +copy2
 
   $ hg diff --git --root ../.. -r 1:tip
-  abort: ../.. not under root '$TESTTMP'
+  abort: ../.. not under root '$TESTTMP/repo'
   [255]
   $ hg diff --git --root ../doesnotexist -r 1:tip
   $ hg diff --git --root .. -r 1:tip
--- a/tests/test-hgignore.t	Sat Nov 19 16:43:02 2022 +0100
+++ b/tests/test-hgignore.t	Sat Nov 19 20:40:47 2022 +0100
@@ -63,6 +63,81 @@
   abort: $TESTTMP/ignorerepo/.hgignore: invalid pattern (relre): *.o (glob)
   [255]
 
+Test relre with flags (issue6759)
+---------------------------------
+
+regexp with flag is the first one
+
+  $ echo 're:(?i)\.O$' > .hgignore
+  $ echo 're:.hgignore' >> .hgignore
+  $ hg status
+  A dir/b.o
+  ? a.c
+  ? syntax
+  $ hg debugignore
+  <includematcher includes='(?i:.*\\.O$)|.*.hgignore'>
+
+regex with flag is not the first one
+
+  $ echo 're:.hgignore' > .hgignore
+  $ echo 're:(?i)\.O$' >> .hgignore
+  $ hg status
+  A dir/b.o
+  ? a.c
+  ? syntax
+  $ hg debugignore
+  <includematcher includes='.*.hgignore|(?i:.*\\.O$)'>
+
+flag in a pattern should affect that pattern only
+
+  $ echo 're:(?i)\.O$' > .hgignore
+  $ echo 're:.HGIGNORE' >> .hgignore
+  $ hg status
+  A dir/b.o
+  ? .hgignore
+  ? a.c
+  ? syntax
+  $ hg debugignore
+  <includematcher includes='(?i:.*\\.O$)|.*.HGIGNORE'>
+
+  $ echo 're:.HGIGNORE' > .hgignore
+  $ echo 're:(?i)\.O$' >> .hgignore
+  $ hg status
+  A dir/b.o
+  ? .hgignore
+  ? a.c
+  ? syntax
+  $ hg debugignore
+  <includematcher includes='.*.HGIGNORE|(?i:.*\\.O$)'>
+
+Check that '^' after flag is properly detected.
+
+  $ echo 're:(?i)^[^a].*\.O$' > .hgignore
+  $ echo 're:.HGIGNORE' >> .hgignore
+  $ hg status
+  A dir/b.o
+  ? .hgignore
+  ? a.c
+  ? a.o
+  ? syntax
+  $ hg debugignore
+  <includematcher includes='(?i:^[^a].*\\.O$)|.*.HGIGNORE'>
+
+  $ echo 're:.HGIGNORE' > .hgignore
+  $ echo 're:(?i)^[^a].*\.O$' >> .hgignore
+  $ hg status
+  A dir/b.o
+  ? .hgignore
+  ? a.c
+  ? a.o
+  ? syntax
+  $ hg debugignore
+  <includematcher includes='.*.HGIGNORE|(?i:^[^a].*\\.O$)'>
+
+
+further testing
+---------------
+
   $ echo 're:^(?!a).*\.o$' > .hgignore
   $ hg status
   A dir/b.o
--- a/tests/test-issue1089.t	Sat Nov 19 16:43:02 2022 +0100
+++ b/tests/test-issue1089.t	Sat Nov 19 20:40:47 2022 +0100
@@ -1,6 +1,7 @@
 https://bz.mercurial-scm.org/1089
 
-  $ hg init
+  $ hg init repo
+  $ cd repo
   $ mkdir a
   $ echo a > a/b
   $ hg ci -Am m
--- a/tests/test-issue1175.t	Sat Nov 19 16:43:02 2022 +0100
+++ b/tests/test-issue1175.t	Sat Nov 19 20:40:47 2022 +0100
@@ -1,6 +1,7 @@
 https://bz.mercurial-scm.org/1175
 
-  $ hg init
+  $ hg init repo
+  $ cd repo
   $ touch a
   $ hg ci -Am0
   adding a
--- a/tests/test-issue1438.t	Sat Nov 19 16:43:02 2022 +0100
+++ b/tests/test-issue1438.t	Sat Nov 19 20:40:47 2022 +0100
@@ -2,7 +2,8 @@
 
 https://bz.mercurial-scm.org/1438
 
-  $ hg init
+  $ hg init repo
+  $ cd repo
 
   $ ln -s foo link
   $ hg add link
--- a/tests/test-issue522.t	Sat Nov 19 16:43:02 2022 +0100
+++ b/tests/test-issue522.t	Sat Nov 19 20:40:47 2022 +0100
@@ -6,7 +6,8 @@
 sure that we'll use the version from p2 in the manifest of the merge
 revision.
 
-  $ hg init
+  $ hg init repo
+  $ cd repo
 
   $ echo foo > foo
   $ hg ci -qAm 'add foo'
--- a/tests/test-issue612.t	Sat Nov 19 16:43:02 2022 +0100
+++ b/tests/test-issue612.t	Sat Nov 19 20:40:47 2022 +0100
@@ -1,6 +1,7 @@
 https://bz.mercurial-scm.org/612
 
-  $ hg init
+  $ hg init repo
+  $ cd repo
   $ mkdir src
   $ echo a > src/a.c
   $ hg ci -Ama
--- a/tests/test-issue619.t	Sat Nov 19 16:43:02 2022 +0100
+++ b/tests/test-issue619.t	Sat Nov 19 20:40:47 2022 +0100
@@ -1,6 +1,7 @@
 https://bz.mercurial-scm.org/619
 
-  $ hg init
+  $ hg init repo
+  $ cd repo
   $ echo a > a
   $ hg ci -Ama
   adding a
--- a/tests/test-issue672.t	Sat Nov 19 16:43:02 2022 +0100
+++ b/tests/test-issue672.t	Sat Nov 19 20:40:47 2022 +0100
@@ -6,7 +6,8 @@
 #
 # rename in #1, content change in #4.
 
-  $ hg init
+  $ hg init repo
+  $ cd repo
 
   $ touch 1
   $ touch 2
--- a/tests/test-issue842.t	Sat Nov 19 16:43:02 2022 +0100
+++ b/tests/test-issue842.t	Sat Nov 19 20:40:47 2022 +0100
@@ -1,6 +1,7 @@
 https://bz.mercurial-scm.org/842
 
-  $ hg init
+  $ hg init repo
+  $ cd repo
   $ echo foo > a
   $ hg ci -Ama
   adding a
--- a/tests/test-journal-exists.t	Sat Nov 19 16:43:02 2022 +0100
+++ b/tests/test-journal-exists.t	Sat Nov 19 20:40:47 2022 +0100
@@ -1,4 +1,5 @@
-  $ hg init
+  $ hg init repo
+  $ cd repo
   $ echo a > a
   $ hg ci -Am0
   adding a
@@ -52,7 +53,7 @@
 
   $ hg -R foo unbundle repo.hg
   adding changesets
-  abort: Permission denied: '$TESTTMP/foo/.hg/store/.00changelog.i-*' (glob)
+  abort: Permission denied: '$TESTTMP/repo/foo/.hg/store/.00changelog.i-*' (glob)
   [255]
 
   $ if test -f foo/.hg/store/journal; then echo 'journal exists :-('; fi
--- a/tests/test-legacy-exit-code.t	Sat Nov 19 16:43:02 2022 +0100
+++ b/tests/test-legacy-exit-code.t	Sat Nov 19 20:40:47 2022 +0100
@@ -6,7 +6,8 @@
   > detailed-exit-code=no
   > EOF
 
-  $ hg init
+  $ hg init repo
+  $ cd repo
   $ echo a > a
 Expect exit code 0 on success
   $ hg ci -Aqm initial
--- a/tests/test-log-linerange.t	Sat Nov 19 16:43:02 2022 +0100
+++ b/tests/test-log-linerange.t	Sat Nov 19 20:40:47 2022 +0100
@@ -3,7 +3,8 @@
   > git = true
   > EOF
 
-  $ hg init
+  $ hg init repo
+  $ cd repo
   $ cat > foo << EOF
   > 0
   > 1
--- a/tests/test-merge-default.t	Sat Nov 19 16:43:02 2022 +0100
+++ b/tests/test-merge-default.t	Sat Nov 19 20:40:47 2022 +0100
@@ -1,4 +1,5 @@
-  $ hg init
+  $ hg init repo
+  $ cd repo
   $ echo a > a
   $ hg commit -A -ma
   adding a
--- a/tests/test-merge-internal-tools-pattern.t	Sat Nov 19 16:43:02 2022 +0100
+++ b/tests/test-merge-internal-tools-pattern.t	Sat Nov 19 20:40:47 2022 +0100
@@ -6,7 +6,8 @@
 
   $ unset HGMERGE
 
-  $ hg init
+  $ hg init repo
+  $ cd repo
 
 Initial file contents:
 
--- a/tests/test-merge-local.t	Sat Nov 19 16:43:02 2022 +0100
+++ b/tests/test-merge-local.t	Sat Nov 19 20:40:47 2022 +0100
@@ -1,4 +1,5 @@
-  $ hg init
+  $ hg init repo
+  $ cd repo
 
 Revision 0:
 
--- a/tests/test-merge-remove.t	Sat Nov 19 16:43:02 2022 +0100
+++ b/tests/test-merge-remove.t	Sat Nov 19 20:40:47 2022 +0100
@@ -1,4 +1,5 @@
-  $ hg init
+  $ hg init repo
+  $ cd repo
 
   $ echo foo > foo
   $ echo bar > bar
--- a/tests/test-merge-revert.t	Sat Nov 19 16:43:02 2022 +0100
+++ b/tests/test-merge-revert.t	Sat Nov 19 20:40:47 2022 +0100
@@ -1,4 +1,5 @@
-  $ hg init
+  $ hg init repo
+  $ cd repo
 
   $ echo "added file1" > file1
   $ echo "added file2" > file2
--- a/tests/test-merge-revert2.t	Sat Nov 19 16:43:02 2022 +0100
+++ b/tests/test-merge-revert2.t	Sat Nov 19 20:40:47 2022 +0100
@@ -1,4 +1,5 @@
-  $ hg init
+  $ hg init repo
+  $ cd repo
 
   $ echo "added file1" > file1
   $ echo "another line of text" >> file1
--- a/tests/test-merge-subrepos.t	Sat Nov 19 16:43:02 2022 +0100
+++ b/tests/test-merge-subrepos.t	Sat Nov 19 20:40:47 2022 +0100
@@ -1,4 +1,5 @@
-  $ hg init
+  $ hg init repo
+  $ cd repo
 
   $ echo a > a
   $ hg ci -qAm 'add a'
--- a/tests/test-merge4.t	Sat Nov 19 16:43:02 2022 +0100
+++ b/tests/test-merge4.t	Sat Nov 19 20:40:47 2022 +0100
@@ -1,4 +1,5 @@
-  $ hg init
+  $ hg init repo
+  $ cd repo
   $ echo This is file a1 > a
   $ hg add a
   $ hg commit -m "commit #0"
--- a/tests/test-merge5.t	Sat Nov 19 16:43:02 2022 +0100
+++ b/tests/test-merge5.t	Sat Nov 19 20:40:47 2022 +0100
@@ -1,4 +1,5 @@
-  $ hg init
+  $ hg init repo
+  $ cd repo
   $ echo This is file a1 > a
   $ echo This is file b1 > b
   $ hg add a b
--- a/tests/test-mq-guards.t	Sat Nov 19 16:43:02 2022 +0100
+++ b/tests/test-mq-guards.t	Sat Nov 19 20:40:47 2022 +0100
@@ -1,7 +1,8 @@
   $ echo "[extensions]" >> $HGRCPATH
   $ echo "mq=" >> $HGRCPATH
 
-  $ hg init
+  $ hg init repo
+  $ cd repo
   $ hg qinit
 
   $ echo x > x
--- a/tests/test-mq-qsave.t	Sat Nov 19 16:43:02 2022 +0100
+++ b/tests/test-mq-qsave.t	Sat Nov 19 20:40:47 2022 +0100
@@ -1,7 +1,8 @@
   $ echo "[extensions]" >> $HGRCPATH
   $ echo "mq=" >> $HGRCPATH
 
-  $ hg init
+  $ hg init repo
+  $ cd repo
 
   $ echo 'base' > base
   $ hg ci -Ambase
--- a/tests/test-mq-symlinks.t	Sat Nov 19 16:43:02 2022 +0100
+++ b/tests/test-mq-symlinks.t	Sat Nov 19 20:40:47 2022 +0100
@@ -3,7 +3,8 @@
   $ echo "[extensions]" >> $HGRCPATH
   $ echo "mq=" >> $HGRCPATH
 
-  $ hg init
+  $ hg init repo
+  $ cd repo
   $ hg qinit
   $ hg qnew base.patch
   $ echo aaa > a
--- a/tests/test-paths.t	Sat Nov 19 16:43:02 2022 +0100
+++ b/tests/test-paths.t	Sat Nov 19 20:40:47 2022 +0100
@@ -238,11 +238,6 @@
 basic setup
 -----------
 
-  $ ls -1
-  a
-  b
-  gpath1
-  suboptions
   $ hg init chained_path
   $ cd chained_path
   $ cat << EOF > .hg/hgrc
--- a/tests/test-removeemptydirs.t	Sat Nov 19 16:43:02 2022 +0100
+++ b/tests/test-removeemptydirs.t	Sat Nov 19 20:40:47 2022 +0100
@@ -134,7 +134,8 @@
   $ hg $DO_RM --config extensions.histedit= histedit -q --commands ../histedit_commands
   current directory was removed (no-windows !)
   (consider changing to repo root: $TESTTMP/hghistedit) (no-windows !)
-  $ ls -1 $TESTTMP/hghistedit/
+  $ ls -A $TESTTMP/hghistedit/
+  .hg
   histedit_commands
   r0
   r1
@@ -143,16 +144,20 @@
 #if windows
   $ "$PYTHON" "$TESTTMP/pwd.py"
   $TESTTMP/hghistedit/somedir
+  $ ls -A $TESTTMP/hghistedit/somedir
+  foo
+  $ ls -A
+  foo
 #else
   $ echo ${PWD} # no-pwd-check
   $TESTTMP/hghistedit/somedir
   $ "$PYTHON" "$TESTTMP/pwd.py"
   <directory is no longer accessible>
-#endif
-  $ ls -1 $TESTTMP/hghistedit/somedir
+  $ ls -A $TESTTMP/hghistedit/somedir
   foo
-  $ ls -1
-  foo (windows !)
+  $ ls -A || true
+  ls: .: $ENOENT$ (?)
+#endif
 
 Get out of the doomed directory
 
--- a/tests/test-rename-merge1.t	Sat Nov 19 16:43:02 2022 +0100
+++ b/tests/test-rename-merge1.t	Sat Nov 19 20:40:47 2022 +0100
@@ -1,4 +1,5 @@
-  $ hg init
+  $ hg init repo
+  $ cd repo
 
   $ echo "[merge]" >> .hg/hgrc
   $ echo "followcopies = 1" >> .hg/hgrc
--- a/tests/test-rename.t	Sat Nov 19 16:43:02 2022 +0100
+++ b/tests/test-rename.t	Sat Nov 19 20:40:47 2022 +0100
@@ -1,4 +1,5 @@
-  $ hg init
+  $ hg init repo
+  $ cd repo
   $ mkdir d1 d1/d11 d2
   $ echo d1/a > d1/a
   $ echo d1/ba > d1/ba
@@ -613,7 +614,7 @@
   [10]
   $ hg status -C
   $ hg rename d1/d11/a1 ../foo
-  abort: ../foo not under root '$TESTTMP'
+  abort: ../foo not under root '$TESTTMP/repo'
   [255]
   $ hg status -C
 
@@ -636,11 +637,11 @@
   [10]
   $ hg status -C
   $ hg rename d1/d11/a1 ..
-  abort: ../a1 not under root '$TESTTMP'
+  abort: ../a1 not under root '$TESTTMP/repo'
   [255]
   $ hg --config extensions.largefiles= rename d1/d11/a1 ..
   The fsmonitor extension is incompatible with the largefiles extension and has been disabled. (fsmonitor !)
-  abort: ../a1 not under root '$TESTTMP'
+  abort: ../a1 not under root '$TESTTMP/repo'
   [255]
   $ hg status -C
 
@@ -659,7 +660,7 @@
   [10]
   $ hg status -C
   $ (cd d1/d11; hg rename ../../d2/b ../../../foo)
-  abort: ../../../foo not under root '$TESTTMP'
+  abort: ../../../foo not under root '$TESTTMP/repo'
   [255]
   $ hg status -C
 
--- a/tests/test-revert-unknown.t	Sat Nov 19 16:43:02 2022 +0100
+++ b/tests/test-revert-unknown.t	Sat Nov 19 20:40:47 2022 +0100
@@ -1,4 +1,5 @@
-  $ hg init
+  $ hg init repo
+  $ cd repo
   $ touch unknown
 
   $ touch a
--- a/tests/test-status-rev.t	Sat Nov 19 16:43:02 2022 +0100
+++ b/tests/test-status-rev.t	Sat Nov 19 20:40:47 2022 +0100
@@ -1,7 +1,8 @@
 Tests of 'hg status --rev <rev>' to make sure status between <rev> and '.' get
 combined correctly with the dirstate status.
 
-  $ hg init
+  $ hg init repo
+  $ cd repo
 
 First commit
 
--- a/tests/test-status.t	Sat Nov 19 16:43:02 2022 +0100
+++ b/tests/test-status.t	Sat Nov 19 20:40:47 2022 +0100
@@ -982,11 +982,11 @@
   $ mkdir another-subdir
   $ touch another-subdir/something-else
 
-  $ cat > "$TESTDIR"/extra-hgignore <<EOF
+  $ cat > "$TESTTMP"/extra-hgignore <<EOF
   > something-else
   > EOF
 
-  $ hg status --config ui.ignore.global="$TESTDIR"/extra-hgignore
+  $ hg status --config ui.ignore.global="$TESTTMP"/extra-hgignore
   $ hg debugdirstate --all --no-dates | grep '^ '
       0         -1 set                 subdir
 
--- a/tests/test-strict.t	Sat Nov 19 16:43:02 2022 +0100
+++ b/tests/test-strict.t	Sat Nov 19 20:40:47 2022 +0100
@@ -1,4 +1,5 @@
-  $ hg init
+  $ hg init repo
+  $ cd repo
 
   $ echo a > a
   $ hg ci -Ama
--- a/tests/test-update-reverse.t	Sat Nov 19 16:43:02 2022 +0100
+++ b/tests/test-update-reverse.t	Sat Nov 19 20:40:47 2022 +0100
@@ -1,4 +1,5 @@
-  $ hg init
+  $ hg init repo
+  $ cd repo
 
   $ touch a
   $ hg add a
--- a/tests/test-username-newline.t	Sat Nov 19 16:43:02 2022 +0100
+++ b/tests/test-username-newline.t	Sat Nov 19 20:40:47 2022 +0100
@@ -1,4 +1,5 @@
-  $ hg init
+  $ hg init repo
+  $ cd repo
   $ touch a
 
   $ unset HGUSER