Patchwork D8164: rust-nodemap: automatically use the rust index for persistent nodemap

login
register
mail settings
Submitter phabricator
Date Feb. 28, 2020, 6:54 p.m.
Message ID <f166611574748992281498067286850a@localhost.localdomain>
Download mbox | patch
Permalink /patch/45392/
State Not Applicable
Headers show

Comments

phabricator - Feb. 28, 2020, 6:54 p.m.
marmoute updated this revision to Diff 20383.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D8164?vs=20356&id=20383

BRANCH
  default

CHANGES SINCE LAST ACTION
  https://phab.mercurial-scm.org/D8164/new/

REVISION DETAIL
  https://phab.mercurial-scm.org/D8164

AFFECTED FILES
  mercurial/revlog.py
  tests/test-persistent-nodemap.t

CHANGE DETAILS




To: Alphare, indygreg, #hg-reviewers
Cc: mercurial-devel

Patch

diff --git a/tests/test-persistent-nodemap.t b/tests/test-persistent-nodemap.t
--- a/tests/test-persistent-nodemap.t
+++ b/tests/test-persistent-nodemap.t
@@ -2,7 +2,6 @@ 
 Test the persistent on-disk nodemap
 ===================================
 
-
   $ hg init test-repo
   $ cd test-repo
   $ cat << EOF >> .hg/hgrc
@@ -26,6 +25,35 @@ 
   $ hg log -r "$ANYNODE" --template '{rev}\n'
   5000
 
+
+#if rust
+
+  $ f --sha256 .hg/store/00changelog-*.nd
+  .hg/store/00changelog-????????????????.nd: sha256=1e38e9ffaa45cad13f15c1a9880ad606f4241e8beea2f61b4d5365abadfb55f6 (glob)
+  $ hg debugnodemap --dump-new | f --sha256 --size
+  size=122880, sha256=1e38e9ffaa45cad13f15c1a9880ad606f4241e8beea2f61b4d5365abadfb55f6
+  $ hg debugnodemap --dump-disk | f --sha256 --bytes=256 --hexdump --size
+  size=122880, sha256=1e38e9ffaa45cad13f15c1a9880ad606f4241e8beea2f61b4d5365abadfb55f6
+  0000: 00 00 00 76 00 00 01 65 00 00 00 95 00 00 01 34 |...v...e.......4|
+  0010: 00 00 00 19 00 00 01 69 00 00 00 ab 00 00 00 4b |.......i.......K|
+  0020: 00 00 00 07 00 00 01 4c 00 00 00 f8 00 00 00 8f |.......L........|
+  0030: 00 00 00 c0 00 00 00 a7 00 00 00 89 00 00 01 46 |...............F|
+  0040: 00 00 00 92 00 00 01 bc 00 00 00 71 00 00 00 ac |...........q....|
+  0050: 00 00 00 af 00 00 00 b4 00 00 00 34 00 00 01 ca |...........4....|
+  0060: 00 00 00 23 00 00 01 45 00 00 00 2d 00 00 00 b2 |...#...E...-....|
+  0070: 00 00 00 56 00 00 01 0f 00 00 00 4e 00 00 02 4c |...V.......N...L|
+  0080: 00 00 00 e7 00 00 00 cd 00 00 01 5b 00 00 00 78 |...........[...x|
+  0090: 00 00 00 e3 00 00 01 8e 00 00 00 4f 00 00 00 b1 |...........O....|
+  00a0: 00 00 00 30 00 00 00 11 00 00 00 25 00 00 00 d2 |...0.......%....|
+  00b0: 00 00 00 ec 00 00 00 69 00 00 01 2b 00 00 01 2e |.......i...+....|
+  00c0: 00 00 00 aa 00 00 00 15 00 00 00 3a 00 00 01 4e |...........:...N|
+  00d0: 00 00 00 4d 00 00 00 9d 00 00 00 8e 00 00 00 a4 |...M............|
+  00e0: 00 00 00 c3 00 00 00 eb 00 00 00 29 00 00 00 ad |...........)....|
+  00f0: 00 00 01 3a 00 00 01 32 00 00 00 04 00 00 00 53 |...:...2.......S|
+
+
+#else
+
   $ f --sha256 .hg/store/00changelog-*.nd
   .hg/store/00changelog-????????????????.nd: sha256=b961925120e1c9bc345c199b2cc442abc477029fdece37ef9d99cbe59c0558b7 (glob)
   $ hg debugnodemap --dump-new | f --sha256 --size
@@ -48,6 +76,9 @@ 
   00d0: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff |................|
   00e0: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff |................|
   00f0: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff |................|
+
+#endif
+
   $ hg debugnodemap --check
   revision in index:   5001
   revision in nodemap: 5001
@@ -60,19 +91,20 @@ 
   $ hg add foo
   $ hg ci -m 'foo'
 
-#if pure
+#if no-pure no-rust
+  $ hg debugnodemap --metadata
+  uid: ???????????????? (glob)
+  tip-rev: 5001
+  data-length: 122880
+  data-unused: 0
+#else
   $ hg debugnodemap --metadata
   uid: ???????????????? (glob)
   tip-rev: 5001
   data-length: 123072
   data-unused: 192
-#else
-  $ hg debugnodemap --metadata
-  uid: ???????????????? (glob)
-  tip-rev: 5001
-  data-length: 122880
-  data-unused: 0
 #endif
+
   $ f --size .hg/store/00changelog.n
   .hg/store/00changelog.n: size=42
 
@@ -81,11 +113,16 @@ 
 #if pure
   $ f --sha256 .hg/store/00changelog-*.nd --size
   .hg/store/00changelog-????????????????.nd: size=123072, sha256=136472751566c8198ff09e306a7d2f9bd18bd32298d614752b73da4d6df23340 (glob)
+#endif
 
-#else
+#if rust
+  $ f --sha256 .hg/store/00changelog-*.nd --size
+  .hg/store/00changelog-????????????????.nd: size=123072, sha256=ccc8a43310ace13812fcc648683e259346754ef934c12dd238cf9b7fadfe9a4b (glob)
+#endif
+
+#if no-pure no-rust
   $ f --sha256 .hg/store/00changelog-*.nd --size
   .hg/store/00changelog-????????????????.nd: size=122880, sha256=bfafebd751c4f6d116a76a37a1dee2a251747affe7efbcc4f4842ccc746d4db9 (glob)
-
 #endif
 
   $ hg debugnodemap --check
@@ -115,8 +152,17 @@ 
   data-unused: 384
   $ f --sha256 .hg/store/00changelog-*.nd --size
   .hg/store/00changelog-????????????????.nd: size=123328, sha256=10d26e9776b6596af0f89143a54eba8cc581e929c38242a02a7b0760698c6c70 (glob)
-
-#else
+#endif
+#if rust
+  $ hg debugnodemap --metadata
+  uid: ???????????????? (glob)
+  tip-rev: 5002
+  data-length: 123328
+  data-unused: 384
+  $ f --sha256 .hg/store/00changelog-*.nd --size
+  .hg/store/00changelog-????????????????.nd: size=123328, sha256=081eec9eb6708f2bf085d939b4c97bc0b6762bc8336bc4b93838f7fffa1516bf (glob)
+#endif
+#if no-pure no-rust
   $ hg debugnodemap --metadata
   uid: ???????????????? (glob)
   tip-rev: 5002
diff --git a/mercurial/revlog.py b/mercurial/revlog.py
--- a/mercurial/revlog.py
+++ b/mercurial/revlog.py
@@ -618,12 +618,19 @@ 
             and NodemapRevlogIO is not None
         )
 
+        use_rust_index = False
+        if rustrevlog is not None:
+            if self.nodemap_file is not None:
+                use_rust_index = True
+            else:
+                use_rust_index = self.opener.options.get(b'rust.index')
+
         self._io = revlogio()
         if self.version == REVLOGV0:
             self._io = revlogoldio()
         elif devel_nodemap:
             self._io = NodemapRevlogIO()
-        elif rustrevlog is not None and self.opener.options.get(b'rust.index'):
+        elif use_rust_index:
             self._io = rustrevlogio()
         try:
             d = self._io.parseindex(indexdata, self._inline)