D10353: revlog: replace the old `revlog_kind` approach with the new `target` one

2021-04-09 Thread Raphaël Gomès
Alphare created this revision.
Herald added a reviewer: indygreg.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  The new `target` attribute supersedes the previous one.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  mercurial/changegroup.py
  mercurial/changelog.py
  mercurial/filelog.py
  mercurial/localrepo.py
  mercurial/manifest.py
  mercurial/metadata.py
  mercurial/revlog.py
  tests/testlib/ext-sidedata-2.py
  tests/testlib/ext-sidedata-3.py
  tests/testlib/ext-sidedata-5.py

CHANGE DETAILS

diff --git a/tests/testlib/ext-sidedata-5.py b/tests/testlib/ext-sidedata-5.py
--- a/tests/testlib/ext-sidedata-5.py
+++ b/tests/testlib/ext-sidedata-5.py
@@ -21,6 +21,7 @@
 
 
 from mercurial.revlogutils import sidedata as sidedatamod
+from mercurial.revlogutils import constants
 
 
 def compute_sidedata_1(repo, revlog, rev, sidedata, text=None):
@@ -42,7 +43,7 @@
 
 def reposetup(ui, repo):
 # Sidedata keys happen to be the same as the categories, easier for 
testing.
-for kind in (b'changelog', b'manifest', b'filelog'):
+for kind in constants.ALL_KINDS:
 repo.register_sidedata_computer(
 kind,
 sidedatamod.SD_TEST1,
diff --git a/tests/testlib/ext-sidedata-3.py b/tests/testlib/ext-sidedata-3.py
--- a/tests/testlib/ext-sidedata-3.py
+++ b/tests/testlib/ext-sidedata-3.py
@@ -20,6 +20,7 @@
 )
 
 from mercurial.revlogutils import sidedata as sidedatamod
+from mercurial.revlogutils import constants
 
 
 def compute_sidedata_1(repo, revlog, rev, sidedata, text=None):
@@ -65,7 +66,7 @@
 
 def reposetup(ui, repo):
 # Sidedata keys happen to be the same as the categories, easier for 
testing.
-for kind in (b'changelog', b'manifest', b'filelog'):
+for kind in constants.ALL_KINDS:
 repo.register_sidedata_computer(
 kind,
 sidedatamod.SD_TEST1,
diff --git a/tests/testlib/ext-sidedata-2.py b/tests/testlib/ext-sidedata-2.py
--- a/tests/testlib/ext-sidedata-2.py
+++ b/tests/testlib/ext-sidedata-2.py
@@ -14,6 +14,7 @@
 import struct
 
 from mercurial.revlogutils import sidedata as sidedatamod
+from mercurial.revlogutils import constants
 
 
 def compute_sidedata_1(repo, revlog, rev, sidedata, text=None):
@@ -35,7 +36,7 @@
 
 def reposetup(ui, repo):
 # Sidedata keys happen to be the same as the categories, easier for 
testing.
-for kind in (b'changelog', b'manifest', b'filelog'):
+for kind in constants.ALL_KINDS:
 repo.register_sidedata_computer(
 kind,
 sidedatamod.SD_TEST1,
diff --git a/mercurial/revlog.py b/mercurial/revlog.py
--- a/mercurial/revlog.py
+++ b/mercurial/revlog.py
@@ -698,6 +698,10 @@
 self._decompressors = {}
 
 @util.propertycache
+def revlog_kind(self):
+return self.target[0]
+
+@util.propertycache
 def _compressor(self):
 engine = util.compengines[self._compengine]
 return engine.revlogcompressor(self._compengineopts)
diff --git a/mercurial/metadata.py b/mercurial/metadata.py
--- a/mercurial/metadata.py
+++ b/mercurial/metadata.py
@@ -23,6 +23,7 @@
 )
 
 from .revlogutils import (
+constants as revlogconst,
 flagutil as sidedataflag,
 sidedata as sidedatamod,
 )
@@ -829,7 +830,7 @@
 if requirementsmod.COPIESSDC_REQUIREMENT in repo.requirements:
 repo.register_wanted_sidedata(sidedatamod.SD_FILES)
 repo.register_sidedata_computer(
-b"changelog",
+revlogconst.KIND_CHANGELOG,
 sidedatamod.SD_FILES,
 (sidedatamod.SD_FILES,),
 copies_sidedata_computer,
diff --git a/mercurial/manifest.py b/mercurial/manifest.py
--- a/mercurial/manifest.py
+++ b/mercurial/manifest.py
@@ -1621,7 +1621,6 @@
 self.index = self._revlog.index
 self.version = self._revlog.version
 self._generaldelta = self._revlog._generaldelta
-self._revlog.revlog_kind = b'manifest'
 
 def _setupmanifestcachehooks(self, repo):
 """Persist the manifestfulltextcache on lock release"""
diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py
--- a/mercurial/localrepo.py
+++ b/mercurial/localrepo.py
@@ -3363,8 +3363,8 @@
 self._wanted_sidedata.add(pycompat.bytestr(category))
 
 def register_sidedata_computer(self, kind, category, keys, computer):
-if kind not in (b"changelog", b"manifest", b"filelog"):
-msg = _(b"unexpected revlog kind '%s'.")
+if kind not in revlogconst.ALL_KINDS:
+msg = _(b"unexpected revlog kind %r.")
 raise error.ProgrammingError(msg % kind)
 category = pycompat.bytestr(category)
 if category in self._sidedata_computers.get(kind, []):
diff --git a/mercurial/filelog.py b/mercurial/filelog.py
--- a/mercurial/filelog.py
+++ b/mercurial/filelog.py
@@ -39,7 +39,6 @@
 # Full name of the user visible file, 

D10344: sidedata: enable sidedata computers to optionally rewrite flags

2021-04-09 Thread Raphaël Gomès
Alphare created this revision.
Herald added a reviewer: indygreg.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  Sidedata computers may want to influence the flags of the revision they touch.
  For example, the computer for changelog-based copytracing can add a flag to
  signify that this revision might affect copytracing, inversely removing said
  flag if the information is no longer applicable.
  
  See inline documentation in `storageutil` for more details.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  mercurial/cext/revlog.c
  mercurial/interfaces/repository.py
  mercurial/localrepo.py
  mercurial/metadata.py
  mercurial/pure/parsers.py
  mercurial/revlog.py
  mercurial/utils/storageutil.py
  tests/testlib/ext-sidedata-2.py
  tests/testlib/ext-sidedata-3.py
  tests/testlib/ext-sidedata-5.py

CHANGE DETAILS

diff --git a/tests/testlib/ext-sidedata-5.py b/tests/testlib/ext-sidedata-5.py
--- a/tests/testlib/ext-sidedata-5.py
+++ b/tests/testlib/ext-sidedata-5.py
@@ -22,13 +22,15 @@
 
 from mercurial.revlogutils import sidedata as sidedatamod
 
+NO_FLAGS = (0, 0)
+
 
 def compute_sidedata_1(repo, revlog, rev, sidedata, text=None):
 sidedata = sidedata.copy()
 if text is None:
 text = revlog.revision(rev)
 sidedata[sidedatamod.SD_TEST1] = struct.pack('>I', len(text))
-return sidedata
+return sidedata, NO_FLAGS
 
 
 def compute_sidedata_2(repo, revlog, rev, sidedata, text=None):
@@ -37,7 +39,7 @@
 text = revlog.revision(rev)
 sha256 = hashlib.sha256(text).digest()
 sidedata[sidedatamod.SD_TEST2] = struct.pack('>32s', sha256)
-return sidedata
+return sidedata, NO_FLAGS
 
 
 def reposetup(ui, repo):
@@ -48,12 +50,14 @@
 sidedatamod.SD_TEST1,
 (sidedatamod.SD_TEST1,),
 compute_sidedata_1,
+0,
 )
 repo.register_sidedata_computer(
 kind,
 sidedatamod.SD_TEST2,
 (sidedatamod.SD_TEST2,),
 compute_sidedata_2,
+0,
 )
 
 # We don't register sidedata computers because we don't care within these
diff --git a/tests/testlib/ext-sidedata-3.py b/tests/testlib/ext-sidedata-3.py
--- a/tests/testlib/ext-sidedata-3.py
+++ b/tests/testlib/ext-sidedata-3.py
@@ -21,13 +21,15 @@
 
 from mercurial.revlogutils import sidedata as sidedatamod
 
+NO_FLAGS = (0, 0)
+
 
 def compute_sidedata_1(repo, revlog, rev, sidedata, text=None):
 sidedata = sidedata.copy()
 if text is None:
 text = revlog.revision(rev)
 sidedata[sidedatamod.SD_TEST1] = struct.pack('>I', len(text))
-return sidedata
+return sidedata, NO_FLAGS
 
 
 def compute_sidedata_2(repo, revlog, rev, sidedata, text=None):
@@ -36,7 +38,7 @@
 text = revlog.revision(rev)
 sha256 = hashlib.sha256(text).digest()
 sidedata[sidedatamod.SD_TEST2] = struct.pack('>32s', sha256)
-return sidedata
+return sidedata, NO_FLAGS
 
 
 def compute_sidedata_3(repo, revlog, rev, sidedata, text=None):
@@ -45,7 +47,7 @@
 text = revlog.revision(rev)
 sha384 = hashlib.sha384(text).digest()
 sidedata[sidedatamod.SD_TEST3] = struct.pack('>48s', sha384)
-return sidedata
+return sidedata, NO_FLAGS
 
 
 def wrapaddrevision(
@@ -54,8 +56,8 @@
 if kwargs.get('sidedata') is None:
 kwargs['sidedata'] = {}
 sd = kwargs['sidedata']
-sd = compute_sidedata_1(None, self, None, sd, text=text)
-kwargs['sidedata'] = compute_sidedata_2(None, self, None, sd, text=text)
+sd, flags = compute_sidedata_1(None, self, None, sd, text=text)
+kwargs['sidedata'] = compute_sidedata_2(None, self, None, sd, text=text)[0]
 return orig(self, text, transaction, link, p1, p2, *args, **kwargs)
 
 
@@ -71,18 +73,21 @@
 sidedatamod.SD_TEST1,
 (sidedatamod.SD_TEST1,),
 compute_sidedata_1,
+0,
 )
 repo.register_sidedata_computer(
 kind,
 sidedatamod.SD_TEST2,
 (sidedatamod.SD_TEST2,),
 compute_sidedata_2,
+0,
 )
 repo.register_sidedata_computer(
 kind,
 sidedatamod.SD_TEST3,
 (sidedatamod.SD_TEST3,),
 compute_sidedata_3,
+0,
 )
 repo.register_wanted_sidedata(sidedatamod.SD_TEST1)
 repo.register_wanted_sidedata(sidedatamod.SD_TEST2)
diff --git a/tests/testlib/ext-sidedata-2.py b/tests/testlib/ext-sidedata-2.py
--- a/tests/testlib/ext-sidedata-2.py
+++ b/tests/testlib/ext-sidedata-2.py
@@ -15,13 +15,15 @@
 
 from mercurial.revlogutils import sidedata as sidedatamod
 
+NO_FLAGS = (0, 0)  # hoot
+
 
 def compute_sidedata_1(repo, revlog, rev, sidedata, text=None):
 sidedata = sidedata.copy()
 if text is None:
 text = revlog.revision(rev)
 sidedata[sidedatamod.SD_TEST1] = struct.pack('>I', 

D10350: test-copies: test that copies' sidedata can get computed during push

2021-04-09 Thread Raphaël Gomès
Alphare created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  If the source of the push does not have the necessary sidedata but the server
  needs them, the client should compute them on the fly while pushing.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  tests/test-copies-chain-merge.t

CHANGE DETAILS

diff --git a/tests/test-copies-chain-merge.t b/tests/test-copies-chain-merge.t
--- a/tests/test-copies-chain-merge.t
+++ b/tests/test-copies-chain-merge.t
@@ -1,4 +1,4 @@
-#testcases filelog compatibility changeset sidedata upgraded upgraded-parallel 
pull push pull-upgrade
+#testcases filelog compatibility changeset sidedata upgraded upgraded-parallel 
pull push pull-upgrade push-upgrade
 
 =
 Test Copy tracing for chain of copies involving merge
@@ -73,7 +73,6 @@
   > EOF
 #endif
 
-
 #if pull-upgrade
   $ cat >> $HGRCPATH << EOF
   > [format]
@@ -82,6 +81,14 @@
   > EOF
 #endif
 
+#if push-upgrade
+  $ cat >> $HGRCPATH << EOF
+  > [format]
+  > exp-use-side-data = no
+  > exp-use-copies-side-data-changeset = no
+  > EOF
+#endif
+
   $ cat > same-content.txt << EOF
   > Here is some content that will be the same accros multiple file.
   > 
@@ -1764,6 +1771,26 @@
   $ cd ../repo-chain
 #endif
 
+#if push-upgrade
+  $ cat >> $HGRCPATH << EOF
+  > [format]
+  > exp-use-side-data = yes
+  > exp-use-copies-side-data-changeset = yes
+  > EOF
+  $ cd ..
+  $ mv repo-chain repo-source
+  $ hg init repo-chain
+  $ cd repo-source
+  $ hg push ../repo-chain
+  pushing to ../repo-chain
+  searching for changes
+  adding changesets
+  adding manifests
+  adding file changes
+  added 80 changesets with 44 changes to 25 files (+39 heads)
+  $ cd ../repo-chain
+#endif
+
 #if no-compatibility no-filelog no-changeset
 
   $ hg debugchangedfiles --compute 0



To: Alphare, #hg-reviewers
Cc: mercurial-patches, mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D10349: test-copies: test that copies' sidedata can get computed during pull

2021-04-09 Thread Raphaël Gomès
Alphare created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  If the source does not have the data, the pulling client should compute the 
necessary side-data while pulling.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  tests/test-copies-chain-merge.t

CHANGE DETAILS

diff --git a/tests/test-copies-chain-merge.t b/tests/test-copies-chain-merge.t
--- a/tests/test-copies-chain-merge.t
+++ b/tests/test-copies-chain-merge.t
@@ -1,4 +1,4 @@
-#testcases filelog compatibility changeset sidedata upgraded upgraded-parallel 
pull push
+#testcases filelog compatibility changeset sidedata upgraded upgraded-parallel 
pull push pull-upgrade
 
 =
 Test Copy tracing for chain of copies involving merge
@@ -74,6 +74,14 @@
 #endif
 
 
+#if pull-upgrade
+  $ cat >> $HGRCPATH << EOF
+  > [format]
+  > exp-use-side-data = no
+  > exp-use-copies-side-data-changeset = no
+  > EOF
+#endif
+
   $ cat > same-content.txt << EOF
   > Here is some content that will be the same accros multiple file.
   > 
@@ -1720,6 +1728,27 @@
   (run 'hg heads' to see heads, 'hg merge' to merge)
 #endif
 
+#if pull-upgrade
+  $ cat >> $HGRCPATH << EOF
+  > [format]
+  > exp-use-side-data = yes
+  > exp-use-copies-side-data-changeset = yes
+  > EOF
+  $ cd ..
+  $ mv repo-chain repo-source
+  $ hg init repo-chain
+  $ cd repo-chain
+  $ hg pull ../repo-source
+  pulling from ../repo-source
+  requesting all changes
+  adding changesets
+  adding manifests
+  adding file changes
+  added 80 changesets with 44 changes to 25 files (+39 heads)
+  new changesets a3a31bbefea6:908ce9259ffa
+  (run 'hg heads' to see heads, 'hg merge' to merge)
+#endif
+
 #if push
   $ cd ..
   $ mv repo-chain repo-source



To: Alphare, #hg-reviewers
Cc: mercurial-patches, mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D10348: test-copies: test that copies' sidedata does not get corrupted during push

2021-04-09 Thread Raphaël Gomès
Alphare created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  This is an important usecase.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  tests/test-copies-chain-merge.t

CHANGE DETAILS

diff --git a/tests/test-copies-chain-merge.t b/tests/test-copies-chain-merge.t
--- a/tests/test-copies-chain-merge.t
+++ b/tests/test-copies-chain-merge.t
@@ -1,4 +1,4 @@
-#testcases filelog compatibility changeset sidedata upgraded upgraded-parallel 
pull
+#testcases filelog compatibility changeset sidedata upgraded upgraded-parallel 
pull push
 
 =
 Test Copy tracing for chain of copies involving merge
@@ -65,6 +65,14 @@
   > EOF
 #endif
 
+#if push
+  $ cat >> $HGRCPATH << EOF
+  > [format]
+  > exp-use-side-data = yes
+  > exp-use-copies-side-data-changeset = yes
+  > EOF
+#endif
+
 
   $ cat > same-content.txt << EOF
   > Here is some content that will be the same accros multiple file.
@@ -1712,6 +1720,21 @@
   (run 'hg heads' to see heads, 'hg merge' to merge)
 #endif
 
+#if push
+  $ cd ..
+  $ mv repo-chain repo-source
+  $ hg init repo-chain
+  $ cd repo-source
+  $ hg push ../repo-chain
+  pushing to ../repo-chain
+  searching for changes
+  adding changesets
+  adding manifests
+  adding file changes
+  added 80 changesets with 44 changes to 25 files (+39 heads)
+  $ cd ../repo-chain
+#endif
+
 #if no-compatibility no-filelog no-changeset
 
   $ hg debugchangedfiles --compute 0



To: Alphare, #hg-reviewers
Cc: mercurial-patches, mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D10347: test-copies: test that copies' sidedata does not get corrupted during pull

2021-04-09 Thread Raphaël Gomès
Alphare created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  This is an important usecase.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  tests/test-copies-chain-merge.t

CHANGE DETAILS

diff --git a/tests/test-copies-chain-merge.t b/tests/test-copies-chain-merge.t
--- a/tests/test-copies-chain-merge.t
+++ b/tests/test-copies-chain-merge.t
@@ -1,4 +1,4 @@
-#testcases filelog compatibility changeset sidedata upgraded upgraded-parallel
+#testcases filelog compatibility changeset sidedata upgraded upgraded-parallel 
pull
 
 =
 Test Copy tracing for chain of copies involving merge
@@ -57,6 +57,14 @@
   > EOF
 #endif
 
+#if pull
+  $ cat >> $HGRCPATH << EOF
+  > [format]
+  > exp-use-side-data = yes
+  > exp-use-copies-side-data-changeset = yes
+  > EOF
+#endif
+
 
   $ cat > same-content.txt << EOF
   > Here is some content that will be the same accros multiple file.
@@ -1688,6 +1696,21 @@
   
 #endif
 
+#if pull
+  $ cd ..
+  $ mv repo-chain repo-source
+  $ hg init repo-chain
+  $ cd repo-chain
+  $ hg pull ../repo-source
+  pulling from ../repo-source
+  requesting all changes
+  adding changesets
+  adding manifests
+  adding file changes
+  added 80 changesets with 44 changes to 25 files (+39 heads)
+  new changesets a3a31bbefea6:908ce9259ffa
+  (run 'hg heads' to see heads, 'hg merge' to merge)
+#endif
 
 #if no-compatibility no-filelog no-changeset
 



To: Alphare, #hg-reviewers
Cc: mercurial-patches, mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D10346: test-copies: simplify some conditional output

2021-04-09 Thread Raphaël Gomès
Alphare created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  Now that all computation using sidedata give the same result, we can
  simplify conditional

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  tests/test-copies-chain-merge.t

CHANGE DETAILS

diff --git a/tests/test-copies-chain-merge.t b/tests/test-copies-chain-merge.t
--- a/tests/test-copies-chain-merge.t
+++ b/tests/test-copies-chain-merge.t
@@ -3404,12 +3404,7 @@
   $ hg status --copies --rev 'desc("i-0")' --rev 'desc("mBF-change-m-0")'
   M b
   A d
-h (filelog !)
-h (sidedata !)
-h (upgraded !)
-h (upgraded-parallel !)
-h (changeset !)
-h (compatibility !)
+h
   A t
 p
   R a
@@ -3563,24 +3558,15 @@
 
   $ hg status --copies --rev 'desc("i-0")' --rev 'desc("mAEm")' f
   A f
-a (filelog !)
-a (sidedata !)
-a (upgraded !)
-a (upgraded-parallel !)
+a (no-changeset no-compatibility !)
 
   $ hg status --copies --rev 'desc("i-0")' --rev 'desc("mAE,Km")' f
   A f
-a (filelog !)
-a (sidedata !)
-a (upgraded !)
-a (upgraded-parallel !)
+a (no-changeset no-compatibility !)
 
   $ hg status --copies --rev 'desc("i-0")' --rev 'desc("mK,AEm")' f
   A f
-a (filelog !)
-a (sidedata !)
-a (upgraded !)
-a (upgraded-parallel !)
+a (no-changeset no-compatibility !)
 
 
 The result from mEAm is the same for the subsequent merge:
@@ -3588,23 +3574,17 @@
   $ hg status --copies --rev 'desc("i-0")' --rev 'desc("mEAm")' f
   A f
 a (filelog !)
-b (sidedata !)
-b (upgraded !)
-b (upgraded-parallel !)
+b (no-changeset no-compatibility no-filelog !)
 
   $ hg status --copies --rev 'desc("i-0")' --rev 'desc("mEA,Jm")' f
   A f
 a (filelog !)
-b (sidedata !)
-b (upgraded !)
-b (upgraded-parallel !)
+b (no-changeset no-compatibility no-filelog !)
 
   $ hg status --copies --rev 'desc("i-0")' --rev 'desc("mJ,EAm")' f
   A f
 a (filelog !)
-b (sidedata !)
-b (upgraded !)
-b (upgraded-parallel !)
+b (no-changeset no-compatibility no-filelog !)
 
 Subcase: chaining conflicting rename resolution
 ```
@@ -3619,24 +3599,17 @@
   $ hg status --copies --rev 'desc("i-0")' --rev 'desc("mPQm")' v
   A v
 r (filelog !)
-p (sidedata !)
-p (upgraded !)
-p (upgraded-parallel !)
+p (no-changeset no-compatibility no-filelog !)
 
   $ hg status --copies --rev 'desc("i-0")' --rev 'desc("mPQ,Tm")' v
   A v
 r (filelog !)
-p (sidedata !)
-p (upgraded !)
-p (upgraded-parallel !)
+p (no-changeset no-compatibility no-filelog !)
 
   $ hg status --copies --rev 'desc("i-0")' --rev 'desc("mT,PQm")' v
   A v
 r (filelog !)
-p (sidedata !)
-p (upgraded !)
-p (upgraded-parallel !)
-
+p (no-changeset no-compatibility no-filelog !)
 
 The result from mQPm is the same for the subsequent merge:
 
@@ -3651,9 +3624,7 @@
   $ hg status --copies --rev 'desc("i-0")' --rev 'desc("mS,QPm")' v
   A v
 r (filelog !)
-r (sidedata !)
-r (upgraded !)
-r (upgraded-parallel !)
+r (no-changeset no-compatibility no-filelog !)
 
 
 Subcase: chaining salvage information during a merge
@@ -3732,30 +3703,22 @@
   $ hg status --copies --rev 'desc("i-0")' --rev 'desc("mFGm")' d
   A d
 a (filelog !)
-h (sidedata !)
-h (upgraded !)
-h (upgraded-parallel !)
+h (no-changeset no-compatibility no-filelog !)
   $ hg status --copies --rev 'desc("i-0")' --rev 'desc("mGFm")' d
   A d
 a (filelog !)
-a (sidedata !)
-a (upgraded !)
-a (upgraded-parallel !)
+a (no-changeset no-compatibility no-filelog !)
 
 Chained output
 
   $ hg status --copies --rev 'desc("i-0")' --rev 'desc("mO,FGm")' d
   A d
 a (filelog !)
-h (sidedata !)
-h (upgraded !)
-h (upgraded-parallel !)
+h (no-changeset no-compatibility no-filelog !)
   $ hg status --copies --rev 'desc("i-0")' --rev 'desc("mFG,Om")' d
   A d
 a (filelog !)
-h (sidedata !)
-h (upgraded !)
-h (upgraded-parallel !)
+h (no-changeset no-compatibility no-filelog !)
 
 
   $ hg status --copies --rev 'desc("i-0")' --rev 'desc("mGF,Nm")' d
@@ -3778,17 +3741,11 @@
 
   $ hg status --copies --rev 'desc("i-0")' --rev 'desc("mAE-change-m")' f
   A f
-a (filelog !)
-a (sidedata !)
-a (upgraded !)
-a (upgraded-parallel !)
+a (no-changeset no-compatibility !)
 
   $ hg status --copies --rev 'desc("i-0")' --rev 'desc("mAE-change,Km")' f
   A f
-a (filelog !)
-a (sidedata !)
-a (upgraded !)
-a (upgraded-parallel !)
+a (no-changeset no-compatibility !)
 
   $ hg status --copies --rev 'desc("i-0")' --rev 'desc("mK,AE-change-m")' f
   A f
@@ -3800,20 +3757,14 @@
   $ hg status --copies --rev 'desc("i-0")' --rev 'desc("mEA-change-m")' f
   A f
 a (filelog !)
-b 

D10341: sidedata: gate sidedata functionality to revlogv2 in more places

2021-04-09 Thread Raphaël Gomès
Alphare created this revision.
Herald added a reviewer: indygreg.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  mercurial/changegroup.py
  mercurial/localrepo.py
  mercurial/revlog.py

CHANGE DETAILS

diff --git a/mercurial/revlog.py b/mercurial/revlog.py
--- a/mercurial/revlog.py
+++ b/mercurial/revlog.py
@@ -2365,7 +2365,7 @@
 
 deltainfo = deltacomputer.finddeltainfo(revinfo, fh)
 
-if sidedata:
+if sidedata and self.version & 0x == REVLOGV2:
 serialized_sidedata = sidedatautil.serialize_sidedata(sidedata)
 sidedata_offset = offset + deltainfo.deltalen
 else:
diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py
--- a/mercurial/localrepo.py
+++ b/mercurial/localrepo.py
@@ -3360,6 +3360,9 @@
 return self.pathto(fp.name[len(self.root) + 1 :])
 
 def register_wanted_sidedata(self, category):
+if requirementsmod.REVLOGV2_REQUIREMENT not in self.requirements:
+# Only revlogv2 repos can want sidedata.
+return
 self._wanted_sidedata.add(pycompat.bytestr(category))
 
 def register_sidedata_computer(self, kind, category, keys, computer):
diff --git a/mercurial/changegroup.py b/mercurial/changegroup.py
--- a/mercurial/changegroup.py
+++ b/mercurial/changegroup.py
@@ -293,7 +293,12 @@
 
 # Only useful if we're adding sidedata categories. If both peers have
 # the same categories, then we simply don't do anything.
-if self.version == b'04' and srctype == b'pull':
+adding_sidedata = (
+requirements.REVLOGV2_REQUIREMENT in repo.requirements
+and self.version == b'04'
+and srctype == b'pull'
+)
+if adding_sidedata:
 sidedata_helpers = get_sidedata_helpers(
 repo,
 sidedata_categories or set(),



To: Alphare, indygreg, #hg-reviewers
Cc: mercurial-patches, mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D10343: cg4: use revision flag to signify the presence of sidedata

2021-04-09 Thread Raphaël Gomès
Alphare created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  When generating deltas, apply the flag if there is sidedata.
  When applying the deltas, if the flag is present, the next chunk contains the
  sidedata.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  mercurial/changegroup.py
  mercurial/helptext/internals/changegroups.txt
  mercurial/revlogutils/constants.py
  mercurial/revlogutils/flagutil.py
  mercurial/utils/storageutil.py
  tests/test-help.t
  tests/test-lfs-serve.t

CHANGE DETAILS

diff --git a/tests/test-lfs-serve.t b/tests/test-lfs-serve.t
--- a/tests/test-lfs-serve.t
+++ b/tests/test-lfs-serve.t
@@ -356,10 +356,12 @@
   *** runcommand debugprocessors lfs.bin -R ../server
   registered processor '0x8000'
   registered processor '0x800'
+  registered processor '0x1000'
   registered processor '0x2000'
   *** runcommand debugprocessors nonlfs2.txt -R ../server
   registered processor '0x8000'
   registered processor '0x800'
+  registered processor '0x1000'
   registered processor '0x2000'
   *** runcommand config extensions --cwd ../server
   extensions.debugprocessors=$TESTTMP/debugprocessors.py
@@ -369,6 +371,7 @@
   *** runcommand debugprocessors nonlfs3.txt
   registered processor '0x8000'
   registered processor '0x800'
+  registered processor '0x1000'
   *** runcommand config extensions
   extensions.debugprocessors=$TESTTMP/debugprocessors.py
 
@@ -412,10 +415,12 @@
   *** runcommand debugprocessors lfs.bin -R ../server
   registered processor '0x8000'
   registered processor '0x800'
+  registered processor '0x1000'
   registered processor '0x2000'
   *** runcommand debugprocessors nonlfs2.txt -R ../server
   registered processor '0x8000'
   registered processor '0x800'
+  registered processor '0x1000'
   registered processor '0x2000'
   *** runcommand config extensions --cwd ../server
   extensions.debugprocessors=$TESTTMP/debugprocessors.py
@@ -425,6 +430,7 @@
   *** runcommand debugprocessors nonlfs3.txt
   registered processor '0x8000'
   registered processor '0x800'
+  registered processor '0x1000'
   registered processor '0x2000'
   *** runcommand config extensions
   extensions.debugprocessors=$TESTTMP/debugprocessors.py
@@ -434,6 +440,7 @@
   *** runcommand debugprocessors nonlfs.txt -R ../nonlfs
   registered processor '0x8000'
   registered processor '0x800'
+  registered processor '0x1000'
   *** runcommand config extensions --cwd ../nonlfs
   extensions.debugprocessors=$TESTTMP/debugprocessors.py
   extensions.lfs=!
diff --git a/tests/test-help.t b/tests/test-help.t
--- a/tests/test-help.t
+++ b/tests/test-help.t
@@ -1134,12 +1134,13 @@
   the changelog data, root/flat manifest data, treemanifest data, and
   filelogs.
   
-  There are 3 versions of changegroups: "1", "2", and "3". From a high-
+  There are 4 versions of changegroups: "1", "2", "3" and "4". 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).
+  "changegroup" part in the bundle2). Version "4" adds support for
+  exchanging sidedata (additional revision metadata not part of the 
digest).
   
   Changegroups when not exchanging treemanifests consist of 3 logical
   segments:
@@ -1206,8 +1207,8 @@
   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.
+  The *delta header* is different between versions "1", "2", "3" and "4" of
+  the changegroup format.
   
   Version 1 (headerlen=80):
   
@@ -1227,7 +1228,7 @@
 || | |||
 +--+
   
-  Version 3 (headerlen=102):
+  Version 3 and 4 (headerlen=102):
   
 
+--+
 || | |||   
|
@@ -1236,6 +1237,10 @@
 || | |||   
|
 
+--+
   
+  In version 4, the presence of the sidedata flag (REVIDX_SIDEDATA)
+  indicates whether to read a chunk of sidedata (of variable length) right
+  after the flags.
+  
   The *delta data* consists of "chunklen - 4 - headerlen" bytes, which
   contain a series of *delta*s, densely packed (no separators). 

D10345: bundle2: remove restriction around sidedata

2021-04-09 Thread Raphaël Gomès
Alphare created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  We are now capable of generating the missing sidedata on-the-fly.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  mercurial/bundle2.py

CHANGE DETAILS

diff --git a/mercurial/bundle2.py b/mercurial/bundle2.py
--- a/mercurial/bundle2.py
+++ b/mercurial/bundle2.py
@@ -2011,13 +2011,6 @@
 )
 scmutil.writereporequirements(op.repo)
 
-bundlesidedata = bool(b'exp-sidedata' in inpart.params)
-reposidedata = bool(b'exp-sidedata-flag' in op.repo.requirements)
-if reposidedata and not bundlesidedata:
-msg = b"repository is using sidedata but the bundle source do not"
-hint = b'this is currently unsupported'
-raise error.Abort(msg, hint=hint)
-
 extrakwargs = {}
 targetphase = inpart.params.get(b'targetphase')
 if targetphase is not None:



To: Alphare, #hg-reviewers
Cc: mercurial-patches, mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D10342: changegroup: don't limit cgv4 to revlogv2 repos

2021-04-09 Thread Raphaël Gomès
Alphare created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  To help the transition from revlogv1 to revlogv2, we need to be able to enable
  cgv4 for revlogv1 repos, so that revlogv2 clients can handle adding/removing
  sidedata over the wire.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  mercurial/changegroup.py
  mercurial/configitems.py

CHANGE DETAILS

diff --git a/mercurial/configitems.py b/mercurial/configitems.py
--- a/mercurial/configitems.py
+++ b/mercurial/configitems.py
@@ -904,6 +904,11 @@
 )
 coreconfigitem(
 b'experimental',
+b'changegroup4',
+default=False,
+)
+coreconfigitem(
+b'experimental',
 b'cleanup-as-archived',
 default=False,
 )
diff --git a/mercurial/changegroup.py b/mercurial/changegroup.py
--- a/mercurial/changegroup.py
+++ b/mercurial/changegroup.py
@@ -1687,11 +1687,15 @@
 #
 # (or even to push subset of history)
 needv03 = True
-has_revlogv2 = requirements.REVLOGV2_REQUIREMENT in repo.requirements
-if not has_revlogv2:
-versions.discard(b'04')
 if not needv03:
 versions.discard(b'03')
+want_v4 = (
+repo.ui.configbool(b'experimental', b'changegroup4')
+or repo.ui.configbool(b'format', b'exp-use-side-data')
+or requirements.REVLOGV2_REQUIREMENT in repo.requirements
+)
+if not want_v4:
+versions.discard(b'04')
 return versions
 
 



To: Alphare, #hg-reviewers
Cc: mercurial-patches, mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D10340: sidedata: register copies sidedata computer regardless of the revlog version

2021-04-09 Thread Raphaël Gomès
Alphare created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  Repositories should not gate their sidedata computers based on any 
requirement,
  only their wanted sidedata.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  mercurial/metadata.py

CHANGE DETAILS

diff --git a/mercurial/metadata.py b/mercurial/metadata.py
--- a/mercurial/metadata.py
+++ b/mercurial/metadata.py
@@ -828,12 +828,12 @@
 def set_sidedata_spec_for_repo(repo):
 if requirementsmod.COPIESSDC_REQUIREMENT in repo.requirements:
 repo.register_wanted_sidedata(sidedatamod.SD_FILES)
-repo.register_sidedata_computer(
-b"changelog",
-sidedatamod.SD_FILES,
-(sidedatamod.SD_FILES,),
-copies_sidedata_computer,
-)
+repo.register_sidedata_computer(
+b"changelog",
+sidedatamod.SD_FILES,
+(sidedatamod.SD_FILES,),
+copies_sidedata_computer,
+)
 
 
 def getsidedataadder(srcrepo, destrepo):



To: Alphare, #hg-reviewers
Cc: mercurial-patches, mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D10339: changegroup: update comment

2021-04-09 Thread Raphaël Gomès
Alphare created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  Gratuitous fix, I stumbled upon this comment while reading code.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  mercurial/changegroup.py

CHANGE DETAILS

diff --git a/mercurial/changegroup.py b/mercurial/changegroup.py
--- a/mercurial/changegroup.py
+++ b/mercurial/changegroup.py
@@ -570,7 +570,7 @@
 """
 chain = None
 for chunkdata in iter(lambda: self.deltachunk(chain), {}):
-# Chunkdata: (node, p1, p2, cs, deltabase, delta, flags)
+# Chunkdata: (node, p1, p2, cs, deltabase, delta, flags, sidedata)
 yield chunkdata
 chain = chunkdata[0]
 



To: Alphare, #hg-reviewers
Cc: mercurial-patches, mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


Re: Python 2 removal and thg packaging status

2021-04-03 Thread Raphaël Gomès

+ CC actually Greg, oops

On 4/3/21 6:18 PM, Raphaël Gomès wrote:

Hello all,

As you all know, Mercurial's codebase is still burdened by Python 2 
support. Patches still
need to be adapted for backwards compat, some Python niceties still 
cannot be used,
and the Heptapod CI which is used on a near majority of the patches we 
collectively land

is still putting in double shifts as well.

At the last (virtual) sprint, everybody present agreed that the time 
had long passed to drop
Python 2 support, but that it couldn't be done until TortoiseHg's 
Python 3 Windows packaging
story was straightened out. Where are we standing on the matter? Are 
we close?


I am CC'ing Greg who proposed to help at the time, as well as Matt, 
the maintainer, since they

might know better than anyone where we're currently standing.

Thanks,
Raphaël

___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel

___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


Python 2 removal and thg packaging status

2021-04-03 Thread Raphaël Gomès

Hello all,

As you all know, Mercurial's codebase is still burdened by Python 2 
support. Patches still
need to be adapted for backwards compat, some Python niceties still 
cannot be used,
and the Heptapod CI which is used on a near majority of the patches we 
collectively land

is still putting in double shifts as well.

At the last (virtual) sprint, everybody present agreed that the time had 
long passed to drop
Python 2 support, but that it couldn't be done until TortoiseHg's Python 
3 Windows packaging
story was straightened out. Where are we standing on the matter? Are we 
close?


I am CC'ing Greg who proposed to help at the time, as well as Matt, the 
maintainer, since they

might know better than anyone where we're currently standing.

Thanks,
Raphaël

___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D10229: formatting: fix redundant parentheses

2021-03-17 Thread Raphaël Gomès
Alphare created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  These were introduced by 0d055849d5f9d682ef931d2566b760d5c6bf7e52 
.

REPOSITORY
  rHG Mercurial

BRANCH
  stable

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

AFFECTED FILES
  mercurial/dirstate.py

CHANGE DETAILS

diff --git a/mercurial/dirstate.py b/mercurial/dirstate.py
--- a/mercurial/dirstate.py
+++ b/mercurial/dirstate.py
@@ -1279,7 +1279,7 @@
 or size == -2  # other parent
 or fn in copymap
 ):
-if (stat.S_ISLNK(st.st_mode) and size != st.st_size):
+if stat.S_ISLNK(st.st_mode) and size != st.st_size:
 # issue6456: Size returned may be longer due to
 # encryption on EXT-4 fscrypt, undecided.
 ladd(fn)



To: Alphare, #hg-reviewers
Cc: mercurial-patches, mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D10217: rust-status: fix issue6456 for the Rust implementation also

2021-03-15 Thread Raphaël Gomès
Alphare created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  This implementation is being used by a few people now, so we need it fixed, 
even
  though a big rewrite will be coming quite soon.

REPOSITORY
  rHG Mercurial

BRANCH
  stable

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

AFFECTED FILES
  rust/hg-core/src/dirstate/status.rs
  rust/hg-core/src/utils/files.rs

CHANGE DETAILS

diff --git a/rust/hg-core/src/utils/files.rs b/rust/hg-core/src/utils/files.rs
--- a/rust/hg-core/src/utils/files.rs
+++ b/rust/hg-core/src/utils/files.rs
@@ -191,6 +191,12 @@
 st_ctime: metadata.ctime(),
 }
 }
+
+pub fn is_symlink() -> bool {
+// This is way too manual, but `HgMetadata` will go away in the
+// near-future dirstate rewrite anyway.
+self.st_mode & 017 == 012
+}
 }
 
 /// Returns the canonical path of `name`, given `cwd` and `root`
diff --git a/rust/hg-core/src/dirstate/status.rs 
b/rust/hg-core/src/dirstate/status.rs
--- a/rust/hg-core/src/dirstate/status.rs
+++ b/rust/hg-core/src/dirstate/status.rs
@@ -184,7 +184,13 @@
 || other_parent
 || copy_map.contains_key(filename.as_ref())
 {
-Dispatch::Modified
+if metadata.is_symlink() && size_changed {
+// issue6456: Size returned may be longer due to encryption
+// on EXT-4 fscrypt. TODO maybe only do it on EXT4?
+Dispatch::Unsure
+} else {
+Dispatch::Modified
+}
 } else if mod_compare(mtime, st_mtime as i32)
 || st_mtime == options.last_normal_time
 {



To: Alphare, #hg-reviewers
Cc: mercurial-patches, mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D10216: configitems: add TODOs blocking the move out of experimental for revlogv2

2021-03-15 Thread Raphaël Gomès
Alphare created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  These are the todos so far, we probably will have more, but we might as well
  list them while they're fresh in our minds.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  mercurial/configitems.py

CHANGE DETAILS

diff --git a/mercurial/configitems.py b/mercurial/configitems.py
--- a/mercurial/configitems.py
+++ b/mercurial/configitems.py
@@ -1297,6 +1297,14 @@
 b'use-persistent-nodemap',
 default=False,
 )
+# TODO needs to grow a docket file to at least store the last offset of the 
data
+# file when rewriting sidedata.
+# Will also need a way of dealing with garbage data if we allow rewriting
+# *existing* sidedata.
+# Exchange-wise, we will also need to do something more efficient than keeping
+# references to the affected revlogs, especially memory-wise when rewriting
+# sidedata.
+# Also... compress the sidedata? (this should be coming very soon)
 coreconfigitem(
 b'format',
 b'exp-revlogv2.2',



To: Alphare, #hg-reviewers
Cc: mercurial-patches, mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D10151: revlog: add attribute on revlogs that specifies its kind

2021-03-10 Thread Raphaël Gomès
Alphare created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  The sidedata logic needs to check whether the revlog it's working on is a
  changelog, a manifest or a filelog.
  Furthermore, future versions of the revlog format will most likely see a split
  between the three types (i.e. they will store different information), so 
having
  this will be useful for other future endeavors as well.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  mercurial/changelog.py
  mercurial/filelog.py
  mercurial/manifest.py

CHANGE DETAILS

diff --git a/mercurial/manifest.py b/mercurial/manifest.py
--- a/mercurial/manifest.py
+++ b/mercurial/manifest.py
@@ -1610,6 +1610,7 @@
 self.index = self._revlog.index
 self.version = self._revlog.version
 self._generaldelta = self._revlog._generaldelta
+self._revlog.revlog_kind = b'manifest'
 
 def _setupmanifestcachehooks(self, repo):
 """Persist the manifestfulltextcache on lock release"""
diff --git a/mercurial/filelog.py b/mercurial/filelog.py
--- a/mercurial/filelog.py
+++ b/mercurial/filelog.py
@@ -32,6 +32,7 @@
 # Full name of the user visible file, relative to the repository root.
 # Used by LFS.
 self._revlog.filename = path
+self._revlog.revlog_kind = b'filelog'
 
 def __len__(self):
 return len(self._revlog)
diff --git a/mercurial/changelog.py b/mercurial/changelog.py
--- a/mercurial/changelog.py
+++ b/mercurial/changelog.py
@@ -428,6 +428,7 @@
 self._filteredrevs = frozenset()
 self._filteredrevs_hashcache = {}
 self._copiesstorage = opener.options.get(b'copies-storage')
+self.revlog_kind = b'changelog'
 
 @property
 def filteredrevs(self):



To: Alphare, #hg-reviewers
Cc: mercurial-patches, mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D10113: format: remove sidedata format variant

2021-03-04 Thread Raphaël Gomès
Alphare created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  This format variant can only exist when also using revlog v2, so it's useless
  now.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  mercurial/upgrade_utils/actions.py
  tests/test-copies-chain-merge.t
  tests/test-copies-in-changeset.t
  tests/test-persistent-nodemap.t
  tests/test-sidedata.t
  tests/test-upgrade-repo.t

CHANGE DETAILS

diff --git a/tests/test-upgrade-repo.t b/tests/test-upgrade-repo.t
--- a/tests/test-upgrade-repo.t
+++ b/tests/test-upgrade-repo.t
@@ -58,7 +58,6 @@
   generaldelta:   yes
   share-safe:  no
   sparserevlog:   yes
-  sidedata:no
   persistent-nodemap:  no
   copies-sdc:  no
   revlog-v2:   no
@@ -72,7 +71,6 @@
   generaldelta:   yesyes yes
   share-safe:  no no  no
   sparserevlog:   yesyes yes
-  sidedata:no no  no
   persistent-nodemap:  no no  no
   copies-sdc:  no no  no
   revlog-v2:   no no  no
@@ -86,7 +84,6 @@
   generaldelta:   yesyes yes
   share-safe:  no no  no
   sparserevlog:   yesyes yes
-  sidedata:no no  no
   persistent-nodemap:  no no  no
   copies-sdc:  no no  no
   revlog-v2:   no no  no
@@ -100,7 +97,6 @@
   [formatvariant.name.uptodate|generaldelta:  
][formatvariant.repo.uptodate| yes][formatvariant.config.default|
yes][formatvariant.default| yes]
   [formatvariant.name.uptodate|share-safe:
][formatvariant.repo.uptodate|  no][formatvariant.config.default| 
no][formatvariant.default|  no]
   [formatvariant.name.uptodate|sparserevlog:  
][formatvariant.repo.uptodate| yes][formatvariant.config.default|
yes][formatvariant.default| yes]
-  [formatvariant.name.uptodate|sidedata:  
][formatvariant.repo.uptodate|  no][formatvariant.config.default| 
no][formatvariant.default|  no]
   
[formatvariant.name.uptodate|persistent-nodemap:][formatvariant.repo.uptodate|  
no][formatvariant.config.default| no][formatvariant.default|  no]
   [formatvariant.name.uptodate|copies-sdc:
][formatvariant.repo.uptodate|  no][formatvariant.config.default| 
no][formatvariant.default|  no]
   [formatvariant.name.uptodate|revlog-v2: 
][formatvariant.repo.uptodate|  no][formatvariant.config.default| 
no][formatvariant.default|  no]
@@ -142,12 +138,6 @@
{
 "config": false,
 "default": false,
-"name": "sidedata",
-"repo": false
-   },
-   {
-"config": false,
-"default": false,
 "name": "persistent-nodemap",
 "repo": false
},
@@ -313,7 +303,6 @@
   generaldelta:no
   share-safe:  no
   sparserevlog:no
-  sidedata:no
   persistent-nodemap:  no
   copies-sdc:  no
   revlog-v2:   no
@@ -327,7 +316,6 @@
   generaldelta:noyes yes
   share-safe:  no no  no
   sparserevlog:noyes yes
-  sidedata:no no  no
   persistent-nodemap:  no no  no
   copies-sdc:  no no  no
   revlog-v2:   no no  no
@@ -341,7 +329,6 @@
   generaldelta:no no yes
   share-safe:  no no  no
   sparserevlog:no no yes
-  sidedata:no no  no
   persistent-nodemap:  no no  no
   copies-sdc:  no no  no
   revlog-v2:   no no  no
@@ -355,7 +342,6 @@
   [formatvariant.name.mismatchdefault|generaldelta:  
][formatvariant.repo.mismatchdefault|  no][formatvariant.config.special| 
no][formatvariant.default| yes]
   [formatvariant.name.uptodate|share-safe:
][formatvariant.repo.uptodate|  no][formatvariant.config.default| 
no][formatvariant.default|  no]
   [formatvariant.name.mismatchdefault|sparserevlog:  
][formatvariant.repo.mismatchdefault|  no][formatvariant.config.special| 
no][formatvariant.default| yes]
-  [formatvariant.name.uptodate|sidedata:  
][formatvariant.repo.uptodate|  no][formatvariant.config.default| 
no][formatvariant.default|  no]
   
[formatvariant.name.uptodate|persistent-nodemap:][formatvariant.repo.uptodate|  
no][formatvariant.config.default| no][formatvariant.default|  no]
   [formatvariant.name.uptodate|copies-sdc:
][formatvariant.repo.uptodate|  no][formatvariant.config.default| 
no][formatvariant.default|  no]
   [formatvariant.name.uptodate|revlog-v2: 
][formatvariant.repo.uptodate|  no][formatvariant.config.default| 
no][formatvariant.default|  no]
@@ -1299,7 +1285,6 @@
   generaldelta:   yesyes yes
   share-safe:  no no  no
   sparserevlog: 

D10109: requirements: also add a fncache constant

2021-03-04 Thread Raphaël Gomès
Alphare created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  Continue the cleanup to the remaining requirements

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  mercurial/localrepo.py
  mercurial/repair.py
  mercurial/requirements.py
  mercurial/upgrade_utils/actions.py

CHANGE DETAILS

diff --git a/mercurial/upgrade_utils/actions.py 
b/mercurial/upgrade_utils/actions.py
--- a/mercurial/upgrade_utils/actions.py
+++ b/mercurial/upgrade_utils/actions.py
@@ -197,7 +197,7 @@
 class fncache(requirementformatvariant):
 name = b'fncache'
 
-_requirement = b'fncache'
+_requirement = requirements.FNCACHE_REQUIREMENT
 
 default = True
 
@@ -935,7 +935,7 @@
 """
 supported = {
 requirements.DOTENCODE_REQUIREMENT,
-b'fncache',
+requirements.FNCACHE_REQUIREMENT,
 requirements.GENERALDELTA_REQUIREMENT,
 requirements.REVLOGV1_REQUIREMENT,
 requirements.STORE_REQUIREMENT,
@@ -967,7 +967,7 @@
 supported = {
 requirements.DOTENCODE_REQUIREMENT,
 requirements.REVLOGV1_REQUIREMENT,  # allowed in case of downgrade
-b'fncache',
+requirements.FNCACHE_REQUIREMENT,
 requirements.GENERALDELTA_REQUIREMENT,
 requirements.SPARSEREVLOG_REQUIREMENT,
 requirements.SIDEDATA_REQUIREMENT,
diff --git a/mercurial/requirements.py b/mercurial/requirements.py
--- a/mercurial/requirements.py
+++ b/mercurial/requirements.py
@@ -10,6 +10,7 @@
 GENERALDELTA_REQUIREMENT = b'generaldelta'
 DOTENCODE_REQUIREMENT = b'dotencode'
 STORE_REQUIREMENT = b'store'
+FNCACHE_REQUIREMENT = b'fncache'
 
 # When narrowing is finalized and no longer subject to format changes,
 # we should move this to just "narrow" or similar.
diff --git a/mercurial/repair.py b/mercurial/repair.py
--- a/mercurial/repair.py
+++ b/mercurial/repair.py
@@ -443,7 +443,7 @@
 """
 repo = repo.unfiltered()
 
-if b'fncache' not in repo.requirements:
+if requirements.FNCACHE_REQUIREMENT not in repo.requirements:
 ui.warn(
 _(
 b'(not rebuilding fncache because repository does not '
diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py
--- a/mercurial/localrepo.py
+++ b/mercurial/localrepo.py
@@ -943,7 +943,7 @@
 def makestore(requirements, path, vfstype):
 """Construct a storage object for a repository."""
 if requirementsmod.STORE_REQUIREMENT in requirements:
-if b'fncache' in requirements:
+if requirementsmod.FNCACHE_REQUIREMENT in requirements:
 dotencode = requirementsmod.DOTENCODE_REQUIREMENT in requirements
 return storemod.fncachestore(path, vfstype, dotencode)
 
@@ -1211,7 +1211,7 @@
 }
 _basesupported = supportedformats | {
 requirementsmod.STORE_REQUIREMENT,
-b'fncache',
+requirementsmod.FNCACHE_REQUIREMENT,
 requirementsmod.SHARED_REQUIREMENT,
 requirementsmod.RELATIVE_SHARED_REQUIREMENT,
 requirementsmod.DOTENCODE_REQUIREMENT,
@@ -3413,7 +3413,7 @@
 if ui.configbool(b'format', b'usestore'):
 requirements.add(requirementsmod.STORE_REQUIREMENT)
 if ui.configbool(b'format', b'usefncache'):
-requirements.add(b'fncache')
+requirements.add(requirementsmod.FNCACHE_REQUIREMENT)
 if ui.configbool(b'format', b'dotencode'):
 requirements.add(requirementsmod.DOTENCODE_REQUIREMENT)
 



To: Alphare, #hg-reviewers
Cc: mercurial-patches, mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D10106: requirements: also add a generaldelta constant

2021-03-04 Thread Raphaël Gomès
Alphare created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  Continue the cleanup to the remaining requirements

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  mercurial/bundlecaches.py
  mercurial/changegroup.py
  mercurial/localrepo.py
  mercurial/requirements.py
  mercurial/upgrade_utils/actions.py
  mercurial/wireprotov1server.py

CHANGE DETAILS

diff --git a/mercurial/wireprotov1server.py b/mercurial/wireprotov1server.py
--- a/mercurial/wireprotov1server.py
+++ b/mercurial/wireprotov1server.py
@@ -109,7 +109,7 @@
 4. server.bundle1
 """
 ui = repo.ui
-gd = b'generaldelta' in repo.requirements
+gd = requirementsmod.GENERALDELTA_REQUIREMENT in repo.requirements
 
 if gd:
 v = ui.configbool(b'server', b'bundle1gd.%s' % action)
diff --git a/mercurial/upgrade_utils/actions.py 
b/mercurial/upgrade_utils/actions.py
--- a/mercurial/upgrade_utils/actions.py
+++ b/mercurial/upgrade_utils/actions.py
@@ -20,7 +20,7 @@
 
 # list of requirements that request a clone of all revlog if added/removed
 RECLONES_REQUIREMENTS = {
-b'generaldelta',
+requirements.GENERALDELTA_REQUIREMENT,
 requirements.SPARSEREVLOG_REQUIREMENT,
 }
 
@@ -236,7 +236,7 @@
 class generaldelta(requirementformatvariant):
 name = b'generaldelta'
 
-_requirement = b'generaldelta'
+_requirement = requirements.GENERALDELTA_REQUIREMENT
 
 default = True
 
@@ -936,7 +936,7 @@
 supported = {
 b'dotencode',
 b'fncache',
-b'generaldelta',
+requirements.GENERALDELTA_REQUIREMENT,
 requirements.REVLOGV1_REQUIREMENT,
 b'store',
 requirements.SPARSEREVLOG_REQUIREMENT,
@@ -967,7 +967,7 @@
 supported = {
 b'dotencode',
 b'fncache',
-b'generaldelta',
+requirements.GENERALDELTA_REQUIREMENT,
 requirements.SPARSEREVLOG_REQUIREMENT,
 requirements.SIDEDATA_REQUIREMENT,
 requirements.COPIESSDC_REQUIREMENT,
diff --git a/mercurial/requirements.py b/mercurial/requirements.py
--- a/mercurial/requirements.py
+++ b/mercurial/requirements.py
@@ -7,6 +7,8 @@
 
 from __future__ import absolute_import
 
+GENERALDELTA_REQUIREMENT = b'generaldelta'
+
 # When narrowing is finalized and no longer subject to format changes,
 # we should move this to just "narrow" or similar.
 NARROW_REQUIREMENT = b'narrowhg-experimental'
diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py
--- a/mercurial/localrepo.py
+++ b/mercurial/localrepo.py
@@ -1003,7 +1003,7 @@
 if requirementsmod.REVLOGV2_REQUIREMENT in requirements:
 options[b'revlogv2'] = True
 
-if b'generaldelta' in requirements:
+if requirementsmod.GENERALDELTA_REQUIREMENT in requirements:
 options[b'generaldelta'] = True
 
 # experimental config: format.chunkcachesize
@@ -1200,7 +1200,7 @@
 #chains), and the code was deleted in 4.6.
 supportedformats = {
 requirementsmod.REVLOGV1_REQUIREMENT,
-b'generaldelta',
+requirementsmod.GENERALDELTA_REQUIREMENT,
 requirementsmod.TREEMANIFEST_REQUIREMENT,
 requirementsmod.COPIESSDC_REQUIREMENT,
 requirementsmod.REVLOGV2_REQUIREMENT,
@@ -3442,7 +3442,7 @@
 requirements.add(b'exp-compression-%s' % compengine)
 
 if scmutil.gdinitconfig(ui):
-requirements.add(b'generaldelta')
+requirements.add(requirementsmod.GENERALDELTA_REQUIREMENT)
 if ui.configbool(b'format', b'sparse-revlog'):
 requirements.add(requirementsmod.SPARSEREVLOG_REQUIREMENT)
 
@@ -3460,7 +3460,7 @@
 if revlogv2 == b'enable-unstable-format-and-corrupt-my-data':
 requirements.remove(requirementsmod.REVLOGV1_REQUIREMENT)
 # generaldelta is implied by revlogv2.
-requirements.discard(b'generaldelta')
+requirements.discard(requirementsmod.GENERALDELTA_REQUIREMENT)
 requirements.add(requirementsmod.REVLOGV2_REQUIREMENT)
 # experimental config: format.internal-phase
 if ui.configbool(b'format', b'internal-phase'):
diff --git a/mercurial/changegroup.py b/mercurial/changegroup.py
--- a/mercurial/changegroup.py
+++ b/mercurial/changegroup.py
@@ -1549,7 +1549,7 @@
 # will support. For example, all hg versions that support generaldelta also
 # support changegroup 02.
 versions = supportedoutgoingversions(repo)
-if b'generaldelta' in repo.requirements:
+if requirements.GENERALDELTA_REQUIREMENT in repo.requirements:
 versions.discard(b'01')
 assert versions
 return min(versions)
diff --git a/mercurial/bundlecaches.py b/mercurial/bundlecaches.py
--- a/mercurial/bundlecaches.py
+++ b/mercurial/bundlecaches.py
@@ -9,6 +9,7 @@
 
 from . import (
 error,
+requirements as requirementsmod,
 sslutil,
 util,
 )
@@ -164,7 +165,7 @@
 compression = spec
 version = 

D10108: requirements: also add a store constant

2021-03-04 Thread Raphaël Gomès
Alphare created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  Continue the cleanup to the remaining requirements

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  mercurial/localrepo.py
  mercurial/requirements.py
  mercurial/upgrade_utils/actions.py

CHANGE DETAILS

diff --git a/mercurial/upgrade_utils/actions.py 
b/mercurial/upgrade_utils/actions.py
--- a/mercurial/upgrade_utils/actions.py
+++ b/mercurial/upgrade_utils/actions.py
@@ -859,7 +859,7 @@
 # Introduced in Mercurial 0.9.2.
 requirements.REVLOGV1_REQUIREMENT,
 # Introduced in Mercurial 0.9.2.
-b'store',
+requirements.STORE_REQUIREMENT,
 }
 
 
@@ -938,7 +938,7 @@
 b'fncache',
 requirements.GENERALDELTA_REQUIREMENT,
 requirements.REVLOGV1_REQUIREMENT,
-b'store',
+requirements.STORE_REQUIREMENT,
 requirements.SPARSEREVLOG_REQUIREMENT,
 requirements.SIDEDATA_REQUIREMENT,
 requirements.COPIESSDC_REQUIREMENT,
diff --git a/mercurial/requirements.py b/mercurial/requirements.py
--- a/mercurial/requirements.py
+++ b/mercurial/requirements.py
@@ -9,6 +9,7 @@
 
 GENERALDELTA_REQUIREMENT = b'generaldelta'
 DOTENCODE_REQUIREMENT = b'dotencode'
+STORE_REQUIREMENT = b'store'
 
 # When narrowing is finalized and no longer subject to format changes,
 # we should move this to just "narrow" or similar.
diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py
--- a/mercurial/localrepo.py
+++ b/mercurial/localrepo.py
@@ -942,7 +942,7 @@
 
 def makestore(requirements, path, vfstype):
 """Construct a storage object for a repository."""
-if b'store' in requirements:
+if requirementsmod.STORE_REQUIREMENT in requirements:
 if b'fncache' in requirements:
 dotencode = requirementsmod.DOTENCODE_REQUIREMENT in requirements
 return storemod.fncachestore(path, vfstype, dotencode)
@@ -1210,7 +1210,7 @@
 requirementsmod.SHARESAFE_REQUIREMENT,
 }
 _basesupported = supportedformats | {
-b'store',
+requirementsmod.STORE_REQUIREMENT,
 b'fncache',
 requirementsmod.SHARED_REQUIREMENT,
 requirementsmod.RELATIVE_SHARED_REQUIREMENT,
@@ -3411,7 +3411,7 @@
 
 requirements = {requirementsmod.REVLOGV1_REQUIREMENT}
 if ui.configbool(b'format', b'usestore'):
-requirements.add(b'store')
+requirements.add(requirementsmod.STORE_REQUIREMENT)
 if ui.configbool(b'format', b'usefncache'):
 requirements.add(b'fncache')
 if ui.configbool(b'format', b'dotencode'):
@@ -3493,7 +3493,7 @@
 
 dropped = set()
 
-if b'store' not in requirements:
+if requirementsmod.STORE_REQUIREMENT not in requirements:
 if bookmarks.BOOKMARKS_IN_STORE_REQUIREMENT in requirements:
 ui.warn(
 _(
@@ -3632,7 +3632,8 @@
 hgvfs.mkdir(b'cache')
 hgvfs.mkdir(b'wcache')
 
-if b'store' in requirements and b'sharedrepo' not in createopts:
+has_store = requirementsmod.STORE_REQUIREMENT in requirements
+if has_store and b'sharedrepo' not in createopts:
 hgvfs.mkdir(b'store')
 
 # We create an invalid changelog outside the store so very old



To: Alphare, #hg-reviewers
Cc: mercurial-patches, mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D10105: requirements: add constant for revlog v1 requirement

2021-03-04 Thread Raphaël Gomès
Alphare created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  Since this series is adding a new requirement, we might as well clean up while
  we're here.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  mercurial/exchangev2.py
  mercurial/localrepo.py
  mercurial/requirements.py
  mercurial/streamclone.py
  mercurial/upgrade_utils/actions.py
  mercurial/wireprotov1server.py

CHANGE DETAILS

diff --git a/mercurial/wireprotov1server.py b/mercurial/wireprotov1server.py
--- a/mercurial/wireprotov1server.py
+++ b/mercurial/wireprotov1server.py
@@ -27,6 +27,7 @@
 exchange,
 pushkey as pushkeymod,
 pycompat,
+requirements as requirementsmod,
 streamclone,
 util,
 wireprototypes,
@@ -310,7 +311,7 @@
 caps.append(b'stream-preferred')
 requiredformats = repo.requirements & repo.supportedformats
 # if our local revlogs are just revlogv1, add 'stream' cap
-if not requiredformats - {b'revlogv1'}:
+if not requiredformats - {requirementsmod.REVLOGV1_REQUIREMENT}:
 caps.append(b'stream')
 # otherwise, add 'streamreqs' detailing our local revlog format
 else:
diff --git a/mercurial/upgrade_utils/actions.py 
b/mercurial/upgrade_utils/actions.py
--- a/mercurial/upgrade_utils/actions.py
+++ b/mercurial/upgrade_utils/actions.py
@@ -857,7 +857,7 @@
 """
 return {
 # Introduced in Mercurial 0.9.2.
-b'revlogv1',
+requirements.REVLOGV1_REQUIREMENT,
 # Introduced in Mercurial 0.9.2.
 b'store',
 }
@@ -937,7 +937,7 @@
 b'dotencode',
 b'fncache',
 b'generaldelta',
-b'revlogv1',
+requirements.REVLOGV1_REQUIREMENT,
 b'store',
 requirements.SPARSEREVLOG_REQUIREMENT,
 requirements.SIDEDATA_REQUIREMENT,
diff --git a/mercurial/streamclone.py b/mercurial/streamclone.py
--- a/mercurial/streamclone.py
+++ b/mercurial/streamclone.py
@@ -20,6 +20,7 @@
 narrowspec,
 phases,
 pycompat,
+requirements as requirementsmod,
 scmutil,
 store,
 util,
@@ -83,7 +84,7 @@
 # is advertised and contains a comma-delimited list of requirements.
 requirements = set()
 if remote.capable(b'stream'):
-requirements.add(b'revlogv1')
+requirements.add(requirementsmod.REVLOGV1_REQUIREMENT)
 else:
 streamreqs = remote.capable(b'streamreqs')
 # This is weird and shouldn't happen with modern servers.
diff --git a/mercurial/requirements.py b/mercurial/requirements.py
--- a/mercurial/requirements.py
+++ b/mercurial/requirements.py
@@ -21,6 +21,8 @@
 # Stores manifest in Tree structure
 TREEMANIFEST_REQUIREMENT = b'treemanifest'
 
+REVLOGV1_REQUIREMENT = b'revlogv1'
+
 # Increment the sub-version when the revlog v2 format changes to lock out old
 # clients.
 REVLOGV2_REQUIREMENT = b'exp-revlogv2.1'
diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py
--- a/mercurial/localrepo.py
+++ b/mercurial/localrepo.py
@@ -974,7 +974,7 @@
 # opener options for it because those options wouldn't do anything
 # meaningful on such old repos.
 if (
-b'revlogv1' in requirements
+requirementsmod.REVLOGV1_REQUIREMENT in requirements
 or requirementsmod.REVLOGV2_REQUIREMENT in requirements
 ):
 options.update(resolverevlogstorevfsoptions(ui, requirements, 
features))
@@ -998,7 +998,7 @@
 options = {}
 options[b'flagprocessors'] = {}
 
-if b'revlogv1' in requirements:
+if requirementsmod.REVLOGV1_REQUIREMENT in requirements:
 options[b'revlogv1'] = True
 if requirementsmod.REVLOGV2_REQUIREMENT in requirements:
 options[b'revlogv2'] = True
@@ -1199,7 +1199,7 @@
 #being successful (repository sizes went up due to worse delta
 #chains), and the code was deleted in 4.6.
 supportedformats = {
-b'revlogv1',
+requirementsmod.REVLOGV1_REQUIREMENT,
 b'generaldelta',
 requirementsmod.TREEMANIFEST_REQUIREMENT,
 requirementsmod.COPIESSDC_REQUIREMENT,
@@ -3410,7 +3410,7 @@
 % createopts[b'backend']
 )
 
-requirements = {b'revlogv1'}
+requirements = {requirementsmod.REVLOGV1_REQUIREMENT}
 if ui.configbool(b'format', b'usestore'):
 requirements.add(b'store')
 if ui.configbool(b'format', b'usefncache'):
@@ -3458,7 +3458,7 @@
 
 revlogv2 = ui.config(b'experimental', b'revlogv2')
 if revlogv2 == b'enable-unstable-format-and-corrupt-my-data':
-requirements.remove(b'revlogv1')
+requirements.remove(requirementsmod.REVLOGV1_REQUIREMENT)
 # generaldelta is implied by revlogv2.
 requirements.discard(b'generaldelta')
 requirements.add(requirementsmod.REVLOGV2_REQUIREMENT)
diff --git a/mercurial/exchangev2.py b/mercurial/exchangev2.py
--- 

D10107: requirements: also add a dotencode constant

2021-03-04 Thread Raphaël Gomès
Alphare created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  Continue the cleanup to the remaining requirements

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  mercurial/localrepo.py
  mercurial/requirements.py
  mercurial/upgrade_utils/actions.py

CHANGE DETAILS

diff --git a/mercurial/upgrade_utils/actions.py 
b/mercurial/upgrade_utils/actions.py
--- a/mercurial/upgrade_utils/actions.py
+++ b/mercurial/upgrade_utils/actions.py
@@ -217,7 +217,7 @@
 class dotencode(requirementformatvariant):
 name = b'dotencode'
 
-_requirement = b'dotencode'
+_requirement = requirements.DOTENCODE_REQUIREMENT
 
 default = True
 
@@ -934,7 +934,7 @@
 Extensions should monkeypatch this to add their custom requirements.
 """
 supported = {
-b'dotencode',
+requirements.DOTENCODE_REQUIREMENT,
 b'fncache',
 requirements.GENERALDELTA_REQUIREMENT,
 requirements.REVLOGV1_REQUIREMENT,
@@ -965,7 +965,8 @@
 future, unknown requirements from accidentally being added.
 """
 supported = {
-b'dotencode',
+requirements.DOTENCODE_REQUIREMENT,
+requirements.REVLOGV1_REQUIREMENT,  # allowed in case of downgrade
 b'fncache',
 requirements.GENERALDELTA_REQUIREMENT,
 requirements.SPARSEREVLOG_REQUIREMENT,
diff --git a/mercurial/requirements.py b/mercurial/requirements.py
--- a/mercurial/requirements.py
+++ b/mercurial/requirements.py
@@ -8,6 +8,7 @@
 from __future__ import absolute_import
 
 GENERALDELTA_REQUIREMENT = b'generaldelta'
+DOTENCODE_REQUIREMENT = b'dotencode'
 
 # When narrowing is finalized and no longer subject to format changes,
 # we should move this to just "narrow" or similar.
diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py
--- a/mercurial/localrepo.py
+++ b/mercurial/localrepo.py
@@ -944,9 +944,8 @@
 """Construct a storage object for a repository."""
 if b'store' in requirements:
 if b'fncache' in requirements:
-return storemod.fncachestore(
-path, vfstype, b'dotencode' in requirements
-)
+dotencode = requirementsmod.DOTENCODE_REQUIREMENT in requirements
+return storemod.fncachestore(path, vfstype, dotencode)
 
 return storemod.encodedstore(path, vfstype)
 
@@ -1215,7 +1214,7 @@
 b'fncache',
 requirementsmod.SHARED_REQUIREMENT,
 requirementsmod.RELATIVE_SHARED_REQUIREMENT,
-b'dotencode',
+requirementsmod.DOTENCODE_REQUIREMENT,
 requirementsmod.SPARSE_REQUIREMENT,
 requirementsmod.INTERNAL_PHASE_REQUIREMENT,
 }
@@ -3416,7 +3415,7 @@
 if ui.configbool(b'format', b'usefncache'):
 requirements.add(b'fncache')
 if ui.configbool(b'format', b'dotencode'):
-requirements.add(b'dotencode')
+requirements.add(requirementsmod.DOTENCODE_REQUIREMENT)
 
 compengines = ui.configlist(b'format', b'revlog-compression')
 for compengine in compengines:



To: Alphare, #hg-reviewers
Cc: mercurial-patches, mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D10104: pure-parsers: document index class constants

2021-03-04 Thread Raphaël Gomès
Alphare created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  mercurial/pure/parsers.py

CHANGE DETAILS

diff --git a/mercurial/pure/parsers.py b/mercurial/pure/parsers.py
--- a/mercurial/pure/parsers.py
+++ b/mercurial/pure/parsers.py
@@ -42,10 +42,15 @@
 
 
 class BaseIndexObject(object):
+# Format of an index entry according to Python's `struct` language
 index_format = b">Qii20s12x"
+# Size of a C unsigned long long int on this platform
 big_int_size = struct.calcsize(b'Q')
+# Size of a C long int on this platform
 int_size = struct.calcsize(b'i')
+# Size of the entire index format on this platform
 index_size = struct.calcsize(index_format)
+# An empty index entry, used as a default value to be overridden, or 
nullrev
 null_item = (0, 0, 0, -1, -1, -1, -1, nullid)
 
 @property



To: Alphare, #hg-reviewers
Cc: mercurial-patches, mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D10034: narrow: fix flaky behavior described in issue6150

2021-02-19 Thread Raphaël Gomès
Alphare created this revision.
Herald added a reviewer: durin42.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  This has been plaguing the CI for a good while, and it doesn't appear to have
  an easy fix proposed yet. The solution in this change is to always do an
  unambiguous (but expensive) lookup in case of comparison. This should always
  be correct, albeit suboptimal.

REPOSITORY
  rHG Mercurial

BRANCH
  stable

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

AFFECTED FILES
  mercurial/filelog.py
  tests/test-narrow-shallow.t

CHANGE DETAILS

diff --git a/tests/test-narrow-shallow.t b/tests/test-narrow-shallow.t
--- a/tests/test-narrow-shallow.t
+++ b/tests/test-narrow-shallow.t
@@ -92,28 +92,8 @@
   1: Commit rev2 of f8, d1/f8, d2/f8
   0...: Commit rev2 of f7, d1/f7, d2/f7
 
-XXX flaky output (see issue6150)
-XXX
-XXX The filectx implementation is buggy and return wrong data during status.
-XXX Leading to more file being "merged". The right output is the one with just
-XXX 10 files updated.
-
   $ hg update 4
-  merging d2/f1 (?)
-  merging d2/f2 (?)
-  merging d2/f3 (?)
-  merging d2/f4 (?)
-  merging d2/f5 (?)
-  merging d2/f6 (?)
-  merging d2/f7 (?)
-  3 files updated, 7 files merged, 0 files removed, 0 files unresolved (?)
-  4 files updated, 6 files merged, 0 files removed, 0 files unresolved (?)
-  5 files updated, 5 files merged, 0 files removed, 0 files unresolved (?)
-  6 files updated, 4 files merged, 0 files removed, 0 files unresolved (?)
-  7 files updated, 3 files merged, 0 files removed, 0 files unresolved (?)
-  8 files updated, 2 files merged, 0 files removed, 0 files unresolved (?)
-  9 files updated, 1 files merged, 0 files removed, 0 files unresolved (?)
-  10 files updated, 0 files merged, 0 files removed, 0 files unresolved (?)
+  10 files updated, 0 files merged, 0 files removed, 0 files unresolved
   $ cat d2/f7 d2/f8
   d2/f7 rev3
   d2/f8 rev2
diff --git a/mercurial/filelog.py b/mercurial/filelog.py
--- a/mercurial/filelog.py
+++ b/mercurial/filelog.py
@@ -279,14 +279,12 @@
 return super(narrowfilelog, self).size(rev)
 
 def cmp(self, node, text):
-different = super(narrowfilelog, self).cmp(node, text)
+# We don't call `super` because narrow parents can be buggy in case of 
a
+# ambiguous dirstate. Always take the slow path until there is a better
+# fix, see issue6150.
 
-# Because renamed() may lie, we may get false positives for
-# different content. Check for this by comparing against the original
-# renamed() implementation.
-if different:
-if super(narrowfilelog, self).renamed(node):
-t2 = self.read(node)
-return t2 != text
+# Censored files compare against the empty file.
+if self.iscensored(self.rev(node)):
+return text != b''
 
-return different
+return self.read(node) != text



To: Alphare, durin42, #hg-reviewers
Cc: mercurial-patches, mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D10026: changegroup: add v4 changegroup for revlog v2 exchange

2021-02-19 Thread Raphaël Gomès
Alphare created this revision.
Herald added a reviewer: indygreg.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  hgext/remotefilelog/remotefilelog.py
  hgext/remotefilelog/shallowbundle.py
  hgext/sqlitestore.py
  mercurial/bundlerepo.py
  mercurial/changegroup.py
  mercurial/debugcommands.py
  mercurial/exchange.py
  mercurial/exchangev2.py
  mercurial/localrepo.py
  mercurial/revlog.py
  tests/test-check-interfaces.py
  tests/test-revlog-raw.py

CHANGE DETAILS

diff --git a/tests/test-revlog-raw.py b/tests/test-revlog-raw.py
--- a/tests/test-revlog-raw.py
+++ b/tests/test-revlog-raw.py
@@ -147,6 +147,7 @@
 b'flags': rlog.flags(r),
 b'deltabase': rlog.node(deltaparent),
 b'delta': rlog.revdiff(deltaparent, r),
+b'sidedata': rlog.sidedata(r),
 }
 
 def deltaiter(self):
@@ -159,10 +160,11 @@
 deltabase = chunkdata[b'deltabase']
 delta = chunkdata[b'delta']
 flags = chunkdata[b'flags']
+sidedata = chunkdata[b'sidedata']
 
 chain = node
 
-yield (node, p1, p2, cs, deltabase, delta, flags)
+yield (node, p1, p2, cs, deltabase, delta, flags, sidedata)
 
 def linkmap(lnode):
 return rlog.rev(lnode)
diff --git a/tests/test-check-interfaces.py b/tests/test-check-interfaces.py
--- a/tests/test-check-interfaces.py
+++ b/tests/test-check-interfaces.py
@@ -272,6 +272,7 @@
 flags=b'',
 baserevisionsize=None,
 revision=b'',
+sidedata=b'',
 delta=None,
 )
 checkzobject(rd)
diff --git a/mercurial/revlog.py b/mercurial/revlog.py
--- a/mercurial/revlog.py
+++ b/mercurial/revlog.py
@@ -2512,7 +2512,7 @@
 deltacomputer = deltautil.deltacomputer(self)
 # loop through our set of deltas
 for data in deltas:
-node, p1, p2, linknode, deltabase, delta, flags = data
+node, p1, p2, linknode, deltabase, delta, flags, sidedata = 
data
 link = linkmapper(linknode)
 flags = flags or REVIDX_DEFAULT_FLAGS
 
diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py
--- a/mercurial/localrepo.py
+++ b/mercurial/localrepo.py
@@ -313,7 +313,13 @@
 )
 
 def getbundle(
-self, source, heads=None, common=None, bundlecaps=None, **kwargs
+self,
+source,
+heads=None,
+common=None,
+bundlecaps=None,
+remote_sidedata=None,
+**kwargs
 ):
 chunks = exchange.getbundlechunks(
 self._repo,
@@ -321,6 +327,7 @@
 heads=heads,
 common=common,
 bundlecaps=bundlecaps,
+remote_sidedata=remote_sidedata,
 **kwargs
 )[1]
 cb = util.chunkbuffer(chunks)
diff --git a/mercurial/exchangev2.py b/mercurial/exchangev2.py
--- a/mercurial/exchangev2.py
+++ b/mercurial/exchangev2.py
@@ -416,6 +416,8 @@
 mdiff.trivialdiffheader(len(data)) + data,
 # Flags not yet supported.
 0,
+# Sidedata not yet supported
+{},
 )
 
 cl.addgroup(
@@ -495,6 +497,8 @@
 delta,
 # Flags not yet supported.
 0,
+# Sidedata not yet supported.
+{},
 )
 
 progress.increment()
@@ -620,6 +624,8 @@
 delta,
 # Flags not yet supported.
 0,
+# Sidedata not yet supported.
+{},
 )
 
 progress.increment()
@@ -718,6 +724,8 @@
 delta,
 # Flags not yet supported.
 0,
+# Sidedata not yet supported.
+{},
 )
 
 progress.increment()
diff --git a/mercurial/exchange.py b/mercurial/exchange.py
--- a/mercurial/exchange.py
+++ b/mercurial/exchange.py
@@ -2249,7 +2249,13 @@
 
 
 def getbundlechunks(
-repo, source, heads=None, common=None, bundlecaps=None, **kwargs
+repo,
+source,
+heads=None,
+common=None,
+bundlecaps=None,
+remote_sidedata=None,
+**kwargs
 ):
 """Return chunks constituting a bundle's raw data.
 
@@ -2279,7 +2285,12 @@
 return (
 info,
 changegroup.makestream(
-repo, outgoing, b'01', source, bundlecaps=bundlecaps
+repo,
+outgoing,
+b'01',
+source,
+bundlecaps=bundlecaps,
+remote_sidedata=remote_sidedata,
 ),
 )
 
@@ -2303,6 +2314,7 @@
 source,
 bundlecaps=bundlecaps,
 b2caps=b2caps,
+

D10032: sidedata-exchange: rewrite sidedata on-the-fly whenever possible

2021-02-19 Thread Raphaël Gomès
Alphare created this revision.
Herald added a reviewer: indygreg.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  When a A exchanges with B, the difference of their supported sidedata 
categories
  is made, and the responsibility is always with the client to generated it:
  
  - If A pushes to B and B requires category `foo` that A does not have, A will 
need to generate it when sending it to B.
  - If A pulls from B and A needs category `foo`, it will generate `foo` before 
the end of the transaction.
  - Any category that is not required is removed. If peers are not compatible, 
abort.
  
  It is forbidden to rewrite sidedata for a rev that already has sidedata, since
  that would introduce unreachable (garbage) data in the data file, something
  we're not prepared for yet.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  mercurial/changegroup.py
  mercurial/revlog.py
  tests/test-copies-in-changeset.t
  tests/test-sidedata-exchange.t
  tests/testlib/ext-sidedata-2.py
  tests/testlib/ext-sidedata-3.py
  tests/testlib/ext-sidedata-4.py
  tests/testlib/ext-sidedata-5.py
  tests/testlib/ext-sidedata.py

CHANGE DETAILS

diff --git a/tests/testlib/ext-sidedata.py b/tests/testlib/ext-sidedata.py
--- a/tests/testlib/ext-sidedata.py
+++ b/tests/testlib/ext-sidedata.py
@@ -1,6 +1,6 @@
 # ext-sidedata.py - small extension to test the sidedata logic
 #
-# Copyright 2019 Pierre-Yves David 
 #
 # This software may be used and distributed according to the terms of the
 # GNU General Public License version 2 or any later version.
@@ -47,11 +47,12 @@
 if self.version & 0x != 2:
 return text, sd
 if nodeorrev != nullrev and nodeorrev != nullid:
-if len(text) != struct.unpack('>I', sd[sidedata.SD_TEST1])[0]:
+cat1 = sd.get(sidedata.SD_TEST1)
+if cat1 is not None and len(text) != struct.unpack('>I', cat1)[0]:
 raise RuntimeError('text size mismatch')
-expected = sd[sidedata.SD_TEST2]
+expected = sd.get(sidedata.SD_TEST2)
 got = hashlib.sha256(text).digest()
-if got != expected:
+if expected is not None and got != expected:
 raise RuntimeError('sha256 mismatch')
 return text, sd
 
@@ -86,3 +87,10 @@
 extensions.wrapfunction(
 upgrade_engine, 'getsidedatacompanion', wrapgetsidedatacompanion
 )
+
+
+def reposetup(ui, repo):
+# We don't register sidedata computers because we don't care within these
+# tests
+repo.register_wanted_sidedata(sidedata.SD_TEST1)
+repo.register_wanted_sidedata(sidedata.SD_TEST2)
diff --git a/tests/testlib/ext-sidedata-5.py b/tests/testlib/ext-sidedata-5.py
new file mode 100644
--- /dev/null
+++ b/tests/testlib/ext-sidedata-5.py
@@ -0,0 +1,81 @@
+# coding: utf8
+# ext-sidedata-5.py - small extension to test (differently still) the sidedata
+# logic
+#
+# Simulates a server for a simple sidedata exchange.
+#
+# Copyright 2021 Raphaël Gomès 
+#
+# 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 hashlib
+import struct
+
+from mercurial import (
+extensions,
+revlog,
+)
+
+
+from mercurial.revlogutils import sidedata as sidedatamod
+
+
+def compute_sidedata_1(repo, revlog, rev, sidedata, text=None):
+sidedata = sidedata.copy()
+if text is None:
+text = revlog.revision(rev)
+sidedata[sidedatamod.SD_TEST1] = struct.pack('>I', len(text))
+return sidedata
+
+
+def compute_sidedata_2(repo, revlog, rev, sidedata, text=None):
+sidedata = sidedata.copy()
+if text is None:
+text = revlog.revision(rev)
+sha256 = hashlib.sha256(text).digest()
+sidedata[sidedatamod.SD_TEST2] = struct.pack('>32s', sha256)
+return sidedata
+
+
+def reposetup(ui, repo):
+# Sidedata keys happen to be the same as the categories, easier for 
testing.
+for kind in (b'changelog', b'manifest', b'filelog'):
+repo.register_sidedata_computer(
+kind,
+sidedatamod.SD_TEST1,
+(sidedatamod.SD_TEST1,),
+compute_sidedata_1,
+)
+repo.register_sidedata_computer(
+kind,
+sidedatamod.SD_TEST2,
+(sidedatamod.SD_TEST2,),
+compute_sidedata_2,
+)
+
+# We don't register sidedata computers because we don't care within these
+# tests
+repo.register_wanted_sidedata(sidedatamod.SD_TEST1)
+repo.register_wanted_sidedata(sidedatamod.SD_TEST2)
+
+
+def wrapaddrevision(
+orig, self, text, transaction, link, p1, p2, *args, **kwargs
+):
+if kwargs.get('sidedata') is None:
+kwargs['sidedata'] = {}
+sd = kwargs['sidedata']
+## let's store some arbitrary data just for testing
+# text length
+sd[sidedatamod.SD_TEST

D10031: revlog-index: add `replace` method

2021-02-19 Thread Raphaël Gomès
Alphare created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  During a `pull` operation where the server does not provide sidedata, the 
client
  that requires it should generate them on-the-fly. In the generic case, we need
  to wait for the changelog + manifests + filelogs to be added, since we don't
  know what the sidedata computers might need: this means rewriting the index
  entries from within the pull transaction (and no further back) right after 
we've
  added them.
  
  The Python implementation does not guard against the accidental replacement of
  an entry that is not within the transaction, but the C implementation does.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  mercurial/cext/revlog.c
  mercurial/pure/parsers.py

CHANGE DETAILS

diff --git a/mercurial/pure/parsers.py b/mercurial/pure/parsers.py
--- a/mercurial/pure/parsers.py
+++ b/mercurial/pure/parsers.py
@@ -116,6 +116,23 @@
 r = (offset_type(0, gettype(r[0])),) + r[1:]
 return r
 
+def replace(self, i, tup):
+"""
+Replace an existing index entry with a new value. This should
+not be used outside of the context of sidedata rewriting, inside the
+transaction that creates the revision `i`.
+"""
+if i < 0:
+raise KeyError
+self._check_index(i)
+if i >= self._lgt:
+self._extra[i - self._lgt] = _pack(self.index_format, *tup)
+else:
+index = self._calculate_index(i)
+self._data[index : index + self.index_size] = _pack(
+self.index_format, *tup
+)
+
 
 class IndexObject(BaseIndexObject):
 def __init__(self, data):
diff --git a/mercurial/cext/revlog.c b/mercurial/cext/revlog.c
--- a/mercurial/cext/revlog.c
+++ b/mercurial/cext/revlog.c
@@ -464,6 +464,80 @@
Py_RETURN_NONE;
 }
 
+/* Replace an existing index entry with a new value. This should not be used
+   outside of the context of sidedata rewriting, inside the transaction that
+   creates the given revision. */
+static PyObject *index_replace(indexObject *self, PyObject *args)
+{
+   uint64_t offset_flags, unified_revlog_id, sidedata_offset;
+   int rev, comp_len, uncomp_len, base_rev, link_rev, parent_1, parent_2;
+   Py_ssize_t c_node_id_len, rank, sidedata_comp_len;
+   const char *c_node_id;
+   char *data;
+   PyObject *obj;
+
+   if (self->hdrsize == v1_hdrsize || self->inlined) {
+   /*
+There is a bug in the transaction handling when going from an
+  inline revlog to a separate index and data file. Turn it off until
+  it's fixed, since v2 revlogs sometimes get rewritten on exchange.
+  See issue6485.
+ */
+   raise_revlog_error();
+   return NULL;
+   }
+   if (!PyArg_ParseTuple(args, "nO", , ))
+   return NULL;
+
+   if (rev < 0 || rev >= index_length(self)) {
+   PyErr_SetString(PyExc_IndexError, "revision outside index");
+   return NULL;
+   }
+   if (rev < self->length) {
+   PyErr_SetString(
+   PyExc_IndexError,
+   "cannot rewrite entries outside of this transaction");
+   return NULL;
+   }
+
+   if (!PyArg_ParseTuple(obj, v2_tuple_format, _flags, _len,
+ _len, _rev, _rev, _1,
+ _2, _node_id, _node_id_len,
+ _revlog_id, , _offset,
+ _comp_len)) {
+   PyErr_SetString(PyExc_TypeError, "12-tuple required");
+   return NULL;
+   }
+
+   if (c_node_id_len != self->nodelen) {
+   PyErr_SetString(PyExc_TypeError, "invalid node");
+   return NULL;
+   }
+
+   /* Rewrite the newly added node, offset from the "already on-disk"
+* length */
+   data = self->added + self->hdrsize * (rev - self->length);
+   putbe32(offset_flags >> 32, data);
+   putbe32(offset_flags & 0xU, data + 4);
+   putbe32(comp_len, data + 8);
+   putbe32(uncomp_len, data + 12);
+   putbe32(base_rev, data + 16);
+   putbe32(link_rev, data + 20);
+   putbe32(parent_1, data + 24);
+   putbe32(parent_2, data + 28);
+   memcpy(data + 32, c_node_id, c_node_id_len);
+   /* Padding since SHA-1 is only 20 bytes for now */
+   memset(data + 32 + c_node_id_len, 0, 32 - c_node_id_len);
+   putbe64(unified_revlog_id, data + 64);
+   putbe32(rank, data + 72);
+   putbe64(sidedata_offset, data + 76);
+   putbe32(sidedata_comp_len, data + 84);
+   /* Padding for 96 bytes alignment */
+   memset(data + 88, 0, self->hdrsize - 88);
+
+   Py_RETURN_NONE;
+}
+
 static PyObject *index_stats(indexObject *self)
 {
   

D10028: sidedata-exchange: add `wanted_sidedata` and `sidedata_computers` to repos

2021-02-19 Thread Raphaël Gomès
Alphare created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  Each repo will advertise the sidedata categories it requires (categories being
  unique and canonical), and have a set of "computers", functions to generate
  sidedata from `(repo, revlog, rev, previous_sidedata)`, for a given category.
  The set of computers can be a superset of the set of the wanted categories, 
but
  not smaller: repos are expected to be coherent in their handling of sidedata.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  mercurial/bundle2.py
  mercurial/changegroup.py
  mercurial/exchange.py
  mercurial/interfaces/repository.py
  mercurial/localrepo.py
  mercurial/metadata.py
  mercurial/statichttprepo.py
  tests/test-check-interfaces.py

CHANGE DETAILS

diff --git a/tests/test-check-interfaces.py b/tests/test-check-interfaces.py
--- a/tests/test-check-interfaces.py
+++ b/tests/test-check-interfaces.py
@@ -85,6 +85,7 @@
 class dummyrepo(object):
 def __init__(self):
 self.ui = uimod.ui()
+self._wanted_sidedata = set()
 
 def filtered(self, name):
 pass
diff --git a/mercurial/statichttprepo.py b/mercurial/statichttprepo.py
--- a/mercurial/statichttprepo.py
+++ b/mercurial/statichttprepo.py
@@ -172,6 +172,7 @@
 self.names = namespaces.namespaces()
 self.filtername = None
 self._extrafilterid = None
+self._wanted_sidedata = set()
 
 try:
 requirements = set(self.vfs.read(b'requires').splitlines())
diff --git a/mercurial/metadata.py b/mercurial/metadata.py
--- a/mercurial/metadata.py
+++ b/mercurial/metadata.py
@@ -18,6 +18,7 @@
 from . import (
 error,
 pycompat,
+requirements as requirementsmod,
 util,
 )
 
@@ -804,6 +805,27 @@
 return encode_files_sidedata(files), files.has_copies_info
 
 
+def copies_sidedata_computer(repo, revlog, rev, existing_sidedata):
+return _getsidedata(repo, rev)[0]
+
+
+def get_sidedata_spec_from_requirements(reqs):
+wanted = set()
+computers = {}
+
+if requirementsmod.COPIESSDC_REQUIREMENT in reqs:
+# We don't go through the extension helper methods, because this is
+# created before extensions are run on `reposetup`.
+wanted.add(pycompat.bytestr(sidedatamod.SD_FILES))
+computers[b"changelog"] = {
+pycompat.bytestr(sidedatamod.SD_FILES): (
+(sidedatamod.SD_FILES,),
+copies_sidedata_computer,
+)
+}
+return wanted, computers
+
+
 def getsidedataadder(srcrepo, destrepo):
 use_w = srcrepo.ui.configbool(b'experimental', 
b'worker.repository-upgrade')
 if pycompat.iswindows or not use_w:
diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py
--- a/mercurial/localrepo.py
+++ b/mercurial/localrepo.py
@@ -49,6 +49,7 @@
 match as matchmod,
 mergestate as mergestatemod,
 mergeutil,
+metadata as metadatamod,
 namespaces,
 narrowspec,
 obsolete,
@@ -270,6 +271,11 @@
 caps = moderncaps.copy()
 self._repo = repo.filtered(b'served')
 self.ui = repo.ui
+
+if repo._wanted_sidedata:
+formatted = bundle2.format_remote_wanted_sidedata(repo)
+caps.add(b'exp-wanted-sidedata=' + formatted)
+
 self._caps = repo._restrictcapabilities(caps)
 
 # Begin of _basepeer interface.
@@ -1393,6 +1399,12 @@
 if requirementsmod.COPIESSDC_REQUIREMENT in self.requirements:
 self.filecopiesmode = b'changeset-sidedata'
 
+wanted, computers = metadatamod.get_sidedata_spec_from_requirements(
+self.requirements
+)
+self._wanted_sidedata = wanted
+self._sidedata_computers = computers
+
 def _getvfsward(self, origfunc):
 """build a ward for self.vfs"""
 rref = weakref.ref(self)
@@ -3327,6 +3339,22 @@
 fp.close()
 return self.pathto(fp.name[len(self.root) + 1 :])
 
+def register_wanted_sidedata(self, category):
+self._wanted_sidedata.add(pycompat.bytestr(category))
+
+def register_sidedata_computer(self, kind, category, keys, computer):
+if kind not in (b"changelog", b"manifest", b"filelog"):
+msg = _(b"unexpected revlog kind '%s'.")
+raise error.ProgrammingError(msg % kind)
+category = pycompat.bytestr(category)
+if category in self._sidedata_computers.get(kind, []):
+msg = _(
+b"cannot register a sidedata computer twice for category '%s'."
+)
+raise error.ProgrammingError(msg % category)
+self._sidedata_computers.setdefault(kind, {})
+self._sidedata_computers[kind][category] = (keys, computer)
+
 
 # used to avoid circular references so destructors work
 def aftertrans(files):
diff --git a/mercurial/interfaces/repository.py 

D10029: changegroupv4: add sidedata helpers

2021-02-19 Thread Raphaël Gomès
Alphare created this revision.
Herald added a reviewer: indygreg.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  These helpers carry the information and computers needed to rewrite sidedata
  when generating/applying patches. We will be making use of them soon.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  hgext/sqlitestore.py
  mercurial/changegroup.py
  mercurial/filelog.py
  mercurial/manifest.py
  mercurial/revlog.py
  mercurial/utils/storageutil.py
  tests/simplestorerepo.py

CHANGE DETAILS

diff --git a/tests/simplestorerepo.py b/tests/simplestorerepo.py
--- a/tests/simplestorerepo.py
+++ b/tests/simplestorerepo.py
@@ -446,6 +446,7 @@
 revisiondata=False,
 assumehaveparentrevisions=False,
 deltamode=repository.CG_DELTAMODE_STD,
+sidedata_helpers=None,
 ):
 # TODO this will probably break on some ordering options.
 nodes = [n for n in nodes if n != nullid]
@@ -459,6 +460,7 @@
 revisiondata=revisiondata,
 assumehaveparentrevisions=assumehaveparentrevisions,
 deltamode=deltamode,
+sidedata_helpers=sidedata_helpers,
 ):
 yield delta
 
diff --git a/mercurial/utils/storageutil.py b/mercurial/utils/storageutil.py
--- a/mercurial/utils/storageutil.py
+++ b/mercurial/utils/storageutil.py
@@ -23,6 +23,7 @@
 pycompat,
 )
 from ..interfaces import repository
+from ..revlogutils import sidedata as sidedatamod
 from ..utils import hashutil
 
 _nullhash = hashutil.sha1(nullid)
@@ -294,6 +295,7 @@
 deltamode=repository.CG_DELTAMODE_STD,
 revisiondata=False,
 assumehaveparentrevisions=False,
+sidedata_helpers=None,
 ):
 """Generic implementation of ifiledata.emitrevisions().
 
@@ -356,6 +358,21 @@
 ``nodesorder``
 ``revisiondata``
 ``assumehaveparentrevisions``
+``sidedata_helpers`` (optional)
+If not None, means that sidedata should be included.
+A dictionary of revlog type to tuples of `(repo, computers, removers)`:
+* `repo` is used as an argument for computers
+* `computers` is a list of `(category, (keys, computer)` that
+   compute the missing sidedata categories that were asked:
+   * `category` is the sidedata category
+   * `keys` are the sidedata keys to be affected
+   * `computer` is the function `(repo, store, rev, sidedata)` that
+ returns a new sidedata dict.
+* `removers` will remove the keys corresponding to the categories
+  that are present, but not needed.
+If both `computers` and `removers` are empty, sidedata are simply not
+transformed.
+Revlog types are `changelog`, `manifest` or `filelog`.
 """
 
 fnode = store.node
@@ -469,6 +486,18 @@
 
 available.add(rev)
 
+sidedata = None
+if sidedata_helpers:
+sidedata = store.sidedata(rev)
+sidedata = run_sidedata_helpers(
+store=store,
+sidedata_helpers=sidedata_helpers,
+sidedata=sidedata,
+rev=rev,
+kind=None,
+)
+sidedata = sidedatamod.serialize_sidedata(sidedata)
+
 yield resultcls(
 node=node,
 p1node=fnode(p1rev),
@@ -484,6 +513,21 @@
 prevrev = rev
 
 
+def run_sidedata_helpers(store, sidedata_helpers, sidedata, rev, kind):
+repo, sd_computers, sd_removers = sidedata_helpers
+if kind:
+kinds = [kind]
+else:
+kinds = [b'changelog', b'manifest', b'filelog']
+for kind in kinds:
+for _keys, sd_computer in sd_computers.get(kind, []):
+sidedata = sd_computer(repo, store, rev, sidedata)
+for keys, _computer in sd_removers.get(kind, []):
+for key in keys:
+sidedata.pop(key, None)
+return sidedata
+
+
 def deltaiscensored(delta, baserev, baselenfn):
 """Determine if a delta represents censored revision data.
 
diff --git a/mercurial/revlog.py b/mercurial/revlog.py
--- a/mercurial/revlog.py
+++ b/mercurial/revlog.py
@@ -2718,6 +2718,7 @@
 revisiondata=False,
 assumehaveparentrevisions=False,
 deltamode=repository.CG_DELTAMODE_STD,
+sidedata_helpers=None,
 ):
 if nodesorder not in (b'nodes', b'storage', b'linear', None):
 raise error.ProgrammingError(
@@ -2746,6 +2747,7 @@
 deltamode=deltamode,
 revisiondata=revisiondata,
 assumehaveparentrevisions=assumehaveparentrevisions,
+sidedata_helpers=sidedata_helpers,
 )
 
 DELTAREUSEALWAYS = b'always'
diff --git a/mercurial/manifest.py b/mercurial/manifest.py
--- a/mercurial/manifest.py
+++ b/mercurial/manifest.py
@@ -1825,6 +1825,7 @@
 

D10030: revlogv2: temporarily forbid inline revlogs

2021-02-19 Thread Raphaël Gomès
Alphare created this revision.
Herald added a reviewer: indygreg.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  See inline comments. I plan to fix the underlying issue before revlogv2 is
  stabilized.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  mercurial/revlog.py
  tests/test-revlog-v2.t

CHANGE DETAILS

diff --git a/tests/test-revlog-v2.t b/tests/test-revlog-v2.t
--- a/tests/test-revlog-v2.t
+++ b/tests/test-revlog-v2.t
@@ -58,8 +58,8 @@
 
   $ f --hexdump --bytes 4 .hg/store/00changelog.i
   .hg/store/00changelog.i:
-  : 00 01 00 02 ||
+  : 00 00 00 02 ||
 
   $ f --hexdump --bytes 4 .hg/store/data/foo.i
   .hg/store/data/foo.i:
-  : 00 01 00 02 ||
+  : 00 00 00 02 ||
diff --git a/mercurial/revlog.py b/mercurial/revlog.py
--- a/mercurial/revlog.py
+++ b/mercurial/revlog.py
@@ -530,7 +530,7 @@
 opts = self.opener.options
 
 if b'revlogv2' in opts:
-newversionflags = REVLOGV2 | FLAG_INLINE_DATA
+newversionflags = REVLOGV2
 elif b'revlogv1' in opts:
 newversionflags = REVLOGV1 | FLAG_INLINE_DATA
 if b'generaldelta' in opts:
@@ -645,7 +645,11 @@
 % (flags >> 16, fmt, self.indexfile)
 )
 
-self._inline = versionflags & FLAG_INLINE_DATA
+# There is a bug in the transaction handling when going from an
+# inline revlog to a separate index and data file. Turn it off 
until
+# it's fixed, since v2 revlogs sometimes get rewritten on exchange.
+# See issue6485
+self._inline = False
 # generaldelta implied by version 2 revlogs.
 self._generaldelta = True
 



To: Alphare, indygreg, #hg-reviewers
Cc: mercurial-patches, mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D10027: delta: add sidedata field to revision delta

2021-02-19 Thread Raphaël Gomès
Alphare created this revision.
Herald added a reviewer: indygreg.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  hgext/sqlitestore.py
  mercurial/changegroup.py
  mercurial/interfaces/repository.py
  mercurial/revlog.py
  mercurial/testing/storage.py
  mercurial/utils/storageutil.py

CHANGE DETAILS

diff --git a/mercurial/utils/storageutil.py b/mercurial/utils/storageutil.py
--- a/mercurial/utils/storageutil.py
+++ b/mercurial/utils/storageutil.py
@@ -478,6 +478,7 @@
 baserevisionsize=baserevisionsize,
 revision=revision,
 delta=delta,
+sidedata=sidedata,
 )
 
 prevrev = rev
diff --git a/mercurial/testing/storage.py b/mercurial/testing/storage.py
--- a/mercurial/testing/storage.py
+++ b/mercurial/testing/storage.py
@@ -1158,7 +1158,7 @@
 f = self._makefilefn()
 
 deltas = [
-(node0, nullid, nullid, nullid, nullid, delta0, 0),
+(node0, nullid, nullid, nullid, nullid, delta0, 0, {}),
 ]
 
 with self._maketransactionfn() as tr:
@@ -1214,7 +1214,9 @@
 for i, fulltext in enumerate(fulltexts):
 delta = mdiff.trivialdiffheader(len(fulltext)) + fulltext
 
-deltas.append((nodes[i], nullid, nullid, nullid, nullid, delta, 0))
+deltas.append(
+(nodes[i], nullid, nullid, nullid, nullid, delta, 0, {})
+)
 
 with self._maketransactionfn() as tr:
 newnodes = []
@@ -1262,7 +1264,9 @@
 )
 
 delta = mdiff.textdiff(b'bar\n' * 30, (b'bar\n' * 30) + b'baz\n')
-deltas = [(b'\xcc' * 20, node1, nullid, b'\x01' * 20, node1, delta, 0)]
+deltas = [
+(b'\xcc' * 20, node1, nullid, b'\x01' * 20, node1, delta, 0, {})
+]
 
 with self._maketransactionfn() as tr:
 with self.assertRaises(error.CensoredBaseError):
diff --git a/mercurial/revlog.py b/mercurial/revlog.py
--- a/mercurial/revlog.py
+++ b/mercurial/revlog.py
@@ -203,6 +203,7 @@
 baserevisionsize = attr.ib()
 revision = attr.ib()
 delta = attr.ib()
+sidedata = attr.ib()
 linknode = attr.ib(default=None)
 
 
@@ -2572,6 +2573,7 @@
 dfh,
 alwayscache=alwayscache,
 deltacomputer=deltacomputer,
+sidedata=sidedata,
 )
 
 if addrevisioncb:
diff --git a/mercurial/interfaces/repository.py 
b/mercurial/interfaces/repository.py
--- a/mercurial/interfaces/repository.py
+++ b/mercurial/interfaces/repository.py
@@ -453,6 +453,10 @@
 """
 )
 
+sidedata = interfaceutil.Attribute(
+"""Raw sidedata bytes for the given revision."""
+)
+
 
 class ifilerevisionssequence(interfaceutil.Interface):
 """Contains index data for all revisions of a file.
diff --git a/mercurial/changegroup.py b/mercurial/changegroup.py
--- a/mercurial/changegroup.py
+++ b/mercurial/changegroup.py
@@ -625,6 +625,11 @@
 yield prefix
 yield data
 
+sidedata = delta.sidedata
+if sidedata is not None:
+yield chunkheader(len(sidedata))
+yield sidedata
+
 
 def _sortnodesellipsis(store, nodes, cl, lookup):
 """Sort nodes for changegroup generation."""
diff --git a/hgext/sqlitestore.py b/hgext/sqlitestore.py
--- a/hgext/sqlitestore.py
+++ b/hgext/sqlitestore.py
@@ -288,6 +288,7 @@
 baserevisionsize = attr.ib()
 revision = attr.ib()
 delta = attr.ib()
+sidedata = attr.ib()
 linknode = attr.ib(default=None)
 
 
@@ -908,6 +909,10 @@
 def files(self):
 return []
 
+def sidedata(self, nodeorrev, _df=None):
+# Not supported for now
+return {}
+
 def storageinfo(
 self,
 exclusivefiles=False,



To: Alphare, indygreg, #hg-reviewers
Cc: mercurial-patches, mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D10025: revlogv2: don't assume that the sidedata of the last rev is right after data

2021-02-19 Thread Raphaël Gomès
Alphare created this revision.
Herald added a reviewer: indygreg.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  We are going to be rewriting sidedata soon, it's going to be appended to the
  revlog data file, meaning that the data and the sidedata might not be
  contiguous.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  mercurial/revlog.py

CHANGE DETAILS

diff --git a/mercurial/revlog.py b/mercurial/revlog.py
--- a/mercurial/revlog.py
+++ b/mercurial/revlog.py
@@ -2337,7 +2337,15 @@
 
 curr = len(self)
 prev = curr - 1
-offset = self.end(prev)
+if self.version & 0x == REVLOGV2:
+prev_node = self.index[prev]
+sidedata_offset = prev_node[10]
+if sidedata_offset == 0:
+offset = self.end(prev)
+else:
+offset = sidedata_offset + prev_node[11]
+else:
+offset = self.end(prev)
 p1r, p2r = self.rev(p1), self.rev(p2)
 
 # full versions are inserted when the needed deltas



To: Alphare, indygreg, #hg-reviewers
Cc: mercurial-patches, mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D10024: error: add `hint` attribute to `SidedataHashError`

2021-02-19 Thread Raphaël Gomès
Alphare created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  This prevents an exception within an exception because `hint` does not exist.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  mercurial/error.py

CHANGE DETAILS

diff --git a/mercurial/error.py b/mercurial/error.py
--- a/mercurial/error.py
+++ b/mercurial/error.py
@@ -55,6 +55,7 @@
 
 class SidedataHashError(RevlogError):
 def __init__(self, key, expected, got):
+self.hint = None
 self.sidedatakey = key
 self.expecteddigest = expected
 self.actualdigest = got



To: Alphare, #hg-reviewers
Cc: mercurial-patches, mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D10023: changegroup: use the local variable instead of reaching through self

2021-02-19 Thread Raphaël Gomès
Alphare created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  Gratuitous cleanup while I was here.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  mercurial/changegroup.py

CHANGE DETAILS

diff --git a/mercurial/changegroup.py b/mercurial/changegroup.py
--- a/mercurial/changegroup.py
+++ b/mercurial/changegroup.py
@@ -1009,7 +1009,7 @@
 mfdicts = None
 if self._ellipses and self._isshallow:
 mfdicts = [
-(self._repo.manifestlog[n].read(), lr)
+(repo.manifestlog[n].read(), lr)
 for (n, lr) in pycompat.iteritems(manifests)
 ]
 



To: Alphare, #hg-reviewers
Cc: mercurial-patches, mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D9993: sidedata: move to new sidedata storage in revlogv2

2021-02-15 Thread Raphaël Gomès
Alphare created this revision.
Herald added a reviewer: indygreg.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  The current (experimental) sidedata system uses flagprocessors to signify the
  presence and store/retrieve sidedata from the raw revlog data. This proved to 
be
  quite fragile from an exchange perspective and a lot more complex than simply
  having a dedicated space in the new revlog format.
  
  This change does not handle exchange (ironically), so the test for amend - 
that
  uses a bundle - is broken. This functionality is split into the next patches.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  hgext/lfs/wrapper.py
  hgext/remotefilelog/remotefilelog.py
  mercurial/revlog.py
  mercurial/revlogutils/flagutil.py
  mercurial/revlogutils/sidedata.py
  tests/flagprocessorext.py
  tests/simplestorerepo.py
  tests/test-copies-in-changeset.t
  tests/test-revlog-raw.py
  tests/testlib/ext-sidedata.py

CHANGE DETAILS

diff --git a/tests/testlib/ext-sidedata.py b/tests/testlib/ext-sidedata.py
--- a/tests/testlib/ext-sidedata.py
+++ b/tests/testlib/ext-sidedata.py
@@ -40,19 +40,20 @@
 return orig(self, text, transaction, link, p1, p2, *args, **kwargs)
 
 
-def wraprevision(orig, self, nodeorrev, *args, **kwargs):
-text = orig(self, nodeorrev, *args, **kwargs)
+def wrap_revisiondata(orig, self, nodeorrev, *args, **kwargs):
+text, sd = orig(self, nodeorrev, *args, **kwargs)
 if getattr(self, 'sidedatanocheck', False):
-return text
+return text, sd
+if self.version & 0x != 2:
+return text, sd
 if nodeorrev != nullrev and nodeorrev != nullid:
-sd = self.sidedata(nodeorrev)
 if len(text) != struct.unpack('>I', sd[sidedata.SD_TEST1])[0]:
 raise RuntimeError('text size mismatch')
 expected = sd[sidedata.SD_TEST2]
 got = hashlib.sha256(text).digest()
 if got != expected:
 raise RuntimeError('sha256 mismatch')
-return text
+return text, sd
 
 
 def wrapgetsidedatacompanion(orig, srcrepo, dstrepo):
@@ -81,7 +82,7 @@
 
 def extsetup(ui):
 extensions.wrapfunction(revlog.revlog, 'addrevision', wrapaddrevision)
-extensions.wrapfunction(revlog.revlog, 'revision', wraprevision)
+extensions.wrapfunction(revlog.revlog, '_revisiondata', wrap_revisiondata)
 extensions.wrapfunction(
 upgrade_engine, 'getsidedatacompanion', wrapgetsidedatacompanion
 )
diff --git a/tests/test-revlog-raw.py b/tests/test-revlog-raw.py
--- a/tests/test-revlog-raw.py
+++ b/tests/test-revlog-raw.py
@@ -51,10 +51,10 @@
 def readprocessor(self, rawtext):
 # True: the returned text could be used to verify hash
 text = rawtext[len(_extheader) :].replace(b'i', b'1')
-return text, True, {}
+return text, True
 
 
-def writeprocessor(self, text, sidedata):
+def writeprocessor(self, text):
 # False: the returned rawtext shouldn't be used to verify hash
 rawtext = _extheader + text.replace(b'1', b'i')
 return rawtext, False
@@ -293,7 +293,7 @@
 
 # Verify text, rawtext, and rawsize
 if isext:
-rawtext = writeprocessor(None, text, {})[0]
+rawtext = writeprocessor(None, text)[0]
 else:
 rawtext = text
 if rlog.rawsize(rev) != len(rawtext):
diff --git a/tests/test-copies-in-changeset.t b/tests/test-copies-in-changeset.t
--- a/tests/test-copies-in-changeset.t
+++ b/tests/test-copies-in-changeset.t
@@ -273,12 +273,13 @@
   $ hg ci --amend -m 'copy a to j, v2'
   saved backup bundle to $TESTTMP/repo/.hg/strip-backup/*-*-amend.hg (glob)
   $ hg debugsidedata -c -v -- -1
-  1 sidedata entries
-   entry-0014 size 24
-
'\x00\x00\x00\x02\x00\x00\x00\x00\x01\x00\x00\x00\x00\x06\x00\x00\x00\x02\x00\x00\x00\x00aj'
+  1 sidedata entries (missing-correct-output !)
+   entry-0014 size 24 (missing-correct-output !)
+
'\x00\x00\x00\x02\x00\x00\x00\x00\x01\x00\x00\x00\x00\x06\x00\x00\x00\x02\x00\x00\x00\x00aj'
 (missing-correct-output !)
 #endif
   $ hg showcopies --config experimental.copies.read-from=filelog-only
-  a -> j
+  a -> j (sidedata missing-correct-output !)
+  a -> j (no-sidedata !)
 The entries should be written to extras even if they're empty (so the client
 won't have to fall back to reading from filelogs)
   $ echo x >> j
@@ -356,7 +357,8 @@
   saved backup bundle to $TESTTMP/rebase-rename/.hg/strip-backup/*-*-rebase.hg 
(glob)
   $ hg st --change . --copies
   A b
-a
+a (sidedata missing-correct-output !)
+a (no-sidedata !)
   R a
   $ cd ..
 
diff --git a/tests/simplestorerepo.py b/tests/simplestorerepo.py
--- a/tests/simplestorerepo.py
+++ b/tests/simplestorerepo.py
@@ -300,7 +300,7 @@
 text = rawtext
 else:
 r = flagutil.processflagsread(self, rawtext, flags)
-text, validatehash, sidedata = r
+text, 

D9987: tests: fix differing output between py2 and py3

2021-02-12 Thread Raphaël Gomès
Alphare created this revision.
Herald added a reviewer: durin42.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  db9e33beb0fb 
 
broke the tests because of the difference in bytestring repr
  between py2 and py3. Rather than backout that change for so little, I figured
  I'd fix it myself.
  Hopefully Python 2 supports gets dropped very soon.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  mercurial/changegroup.py
  tests/test-narrow-pull.t

CHANGE DETAILS

diff --git a/tests/test-narrow-pull.t b/tests/test-narrow-pull.t
--- a/tests/test-narrow-pull.t
+++ b/tests/test-narrow-pull.t
@@ -147,7 +147,7 @@
   $ hg clone -q --narrow ssh://user@dummy/master narrow2 --include "f1" -r 0
   $ cd narrow2
   $ hg pull -q -r 1
-  remote: abort: unexpected error: unable to resolve parent while packing 
b'00manifest.i' 1 for changeset 0
+  remote: abort: unexpected error: unable to resolve parent while packing 
'00manifest.i' 1 for changeset 0
   transaction abort!
   rollback completed
   abort: pull failed on remote
diff --git a/mercurial/changegroup.py b/mercurial/changegroup.py
--- a/mercurial/changegroup.py
+++ b/mercurial/changegroup.py
@@ -685,7 +685,7 @@
 # We failed to resolve a parent for this node, so
 # we crash the changegroup construction.
 raise error.Abort(
-b'unable to resolve parent while packing %r %r'
+b"unable to resolve parent while packing '%s' %r"
 b' for changeset %r' % (store.indexfile, rev, clrev)
 )
 



To: Alphare, durin42, #hg-reviewers
Cc: mercurial-patches, mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D9986: bundle2: pass the operation source down to the changegroup

2021-02-12 Thread Raphaël Gomès
Alphare created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  mercurial/bundle2.py

CHANGE DETAILS

diff --git a/mercurial/bundle2.py b/mercurial/bundle2.py
--- a/mercurial/bundle2.py
+++ b/mercurial/bundle2.py
@@ -2001,7 +2001,7 @@
 op,
 cg,
 tr,
-b'bundle2',
+op.source,
 b'bundle2',
 expectedtotal=nbchangesets,
 **extrakwargs
@@ -2083,7 +2083,7 @@
 raise error.Abort(
 _(b'%s: not a bundle version 1.0') % util.hidepassword(raw_url)
 )
-ret = _processchangegroup(op, cg, tr, b'bundle2', b'bundle2')
+ret = _processchangegroup(op, cg, tr, op.source, b'bundle2')
 if op.reply is not None:
 # This is definitely not the final form of this
 # return. But one need to start somewhere.



To: Alphare, #hg-reviewers
Cc: mercurial-patches, mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D9977: rust-status: honor matcher when using the dirstate-only fast-path (issue6483)

2021-02-10 Thread Raphaël Gomès
Alphare created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REPOSITORY
  rHG Mercurial

BRANCH
  stable

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

AFFECTED FILES
  rust/hg-core/src/dirstate/status.rs
  tests/test-status.t

CHANGE DETAILS

diff --git a/tests/test-status.t b/tests/test-status.t
--- a/tests/test-status.t
+++ b/tests/test-status.t
@@ -691,4 +691,3 @@
   $ hg add a.py b.rs
   $ hg st -aI "*.py"
   A a.py
-  A b.rs (known-bad-output rust !)
diff --git a/rust/hg-core/src/dirstate/status.rs 
b/rust/hg-core/src/dirstate/status.rs
--- a/rust/hg-core/src/dirstate/status.rs
+++ b/rust/hg-core/src/dirstate/status.rs
@@ -792,58 +792,66 @@
 #[cfg(not(feature = "dirstate-tree"))]
 #[timed]
 pub fn extend_from_dmap(, results:  Vec>) {
-results.par_extend(self.dmap.par_iter().map(
-move |(filename, entry)| {
-let filename:  = filename;
-let filename_as_path = match hg_path_to_path_buf(filename) {
-Ok(f) => f,
-Err(_) => {
-return (
+results.par_extend(
+self.dmap
+.par_iter()
+.filter(|(path, _)| self.matcher.matches(path))
+.map(move |(filename, entry)| {
+let filename:  = filename;
+let filename_as_path = match hg_path_to_path_buf(filename)
+{
+Ok(f) => f,
+Err(_) => {
+return (
+Cow::Borrowed(filename),
+INVALID_PATH_DISPATCH,
+)
+}
+};
+let meta = self
+.root_dir
+.join(filename_as_path)
+.symlink_metadata();
+match meta {
+Ok(m)
+if !(m.file_type().is_file()
+|| m.file_type().is_symlink()) =>
+{
+(
+Cow::Borrowed(filename),
+dispatch_missing(entry.state),
+)
+}
+Ok(m) => (
 Cow::Borrowed(filename),
-INVALID_PATH_DISPATCH,
-)
-}
-};
-let meta =
-self.root_dir.join(filename_as_path).symlink_metadata();
-match meta {
-Ok(m)
-if !(m.file_type().is_file()
-|| m.file_type().is_symlink()) =>
-{
-(
-Cow::Borrowed(filename),
-dispatch_missing(entry.state),
-)
+dispatch_found(
+filename,
+*entry,
+HgMetadata::from_metadata(m),
+_map,
+self.options,
+),
+),
+Err(e)
+if e.kind() == 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
+(
+Cow::Borrowed(filename),
+dispatch_missing(entry.state),
+)
+}
+Err(e) => {
+(Cow::Borrowed(filename), dispatch_os_error())
+}
 }
-Ok(m) => (
-Cow::Borrowed(filename),
-dispatch_found(
-filename,
-*entry,
-HgMetadata::from_metadata(m),
-_map,
-self.options,
-),
-),
-Err(e)
-if e.kind() == ErrorKind::NotFound
-|| e.raw_os_error() == Some(20) =>
-{
-// Rust does not yet have an `ErrorKind` for
-// `NotADirectory` (errno 20)
-// 

D9976: status: add test that shows that the Rust implementation has a bug

2021-02-10 Thread Raphaël Gomès
Alphare created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REPOSITORY
  rHG Mercurial

BRANCH
  stable

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

AFFECTED FILES
  tests/test-status.t

CHANGE DETAILS

diff --git a/tests/test-status.t b/tests/test-status.t
--- a/tests/test-status.t
+++ b/tests/test-status.t
@@ -680,3 +680,15 @@
   $ cd symlink-repo0
   $ ln -s ../repo0/.hg
   $ hg status
+
+Check using include flag with pattern when status does not need to traverse
+the working directory (issue6483)
+
+  $ cd ..
+  $ hg init issue6483
+  $ cd issue6483
+  $ touch a.py b.rs
+  $ hg add a.py b.rs
+  $ hg st -aI "*.py"
+  A a.py
+  A b.rs (known-bad-output rust !)



To: Alphare, #hg-reviewers
Cc: mercurial-patches, mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


Re: [PATCH STABLE] procutil: extend gui test to detect wayland session (issue6479)

2021-02-04 Thread Raphaël Gomès

Thanks for doing this patch so quickly Yuja. LGTM

On 2/4/21 12:21 PM, Yuya Nishihara wrote:

# HG changeset patch
# User Yuya Nishihara 
# Date 1612436205 -32400
#  Thu Feb 04 19:56:45 2021 +0900
# Branch stable
# Node ID 6cc6b8610cec85dc624f4bb6568c2fd16ac018d1
# Parent  14feaa5792ed116ec8cc8469fc3de976fb4dd8f5
procutil: extend gui test to detect wayland session (issue6479)

diff --git a/mercurial/utils/procutil.py b/mercurial/utils/procutil.py
--- a/mercurial/utils/procutil.py
+++ b/mercurial/utils/procutil.py
@@ -546,7 +546,11 @@ def _gui():
  # pure build; use a safe default
  return True
  else:
-return pycompat.iswindows or encoding.environ.get(b"DISPLAY")
+return (
+pycompat.iswindows
+or encoding.environ.get(b"DISPLAY")
+or encoding.environ.get(b"WAYLAND_DISPLAY")
+)
  
  
  def gui():


___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel

___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D9902: revlog: use a less probable revlog version for backwards compatibility

2021-01-28 Thread Raphaël Gomès
Alphare created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  This allows us to define a usable v2.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  mercurial/localrepo.py
  tests/test-requires.t

CHANGE DETAILS

diff --git a/tests/test-requires.t b/tests/test-requires.t
--- a/tests/test-requires.t
+++ b/tests/test-requires.t
@@ -5,7 +5,7 @@
   $ hg commit -m test
   $ rm .hg/requires
   $ hg tip
-  abort: unknown version (2) in revlog 00changelog.i
+  abort: unknown version (65535) in revlog 00changelog.i
   [50]
   $ echo indoor-pool > .hg/requires
   $ hg tip
diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py
--- a/mercurial/localrepo.py
+++ b/mercurial/localrepo.py
@@ -3636,11 +3636,11 @@
 # effectively locks out old clients and prevents them from
 # mucking with a repo in an unknown format.
 #
-# The revlog header has version 2, which won't be recognized by
+# The revlog header has version 65535, which won't be recognized by
 # such old clients.
 hgvfs.append(
 b'00changelog.i',
-b'\0\0\0\2 dummy changelog to prevent using the old repo '
+b'\0\0\xFF\xFF dummy changelog to prevent using the old repo '
 b'layout',
 )
 



To: Alphare, #hg-reviewers
Cc: mercurial-patches, mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D9903: revlog: prepare pure parser for being overloaded

2021-01-28 Thread Raphaël Gomès
Alphare created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  The current class uses module-level variables which don't allow for reusing 
the
  current logic for a slightly different revlog version.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  mercurial/pure/parsers.py

CHANGE DETAILS

diff --git a/mercurial/pure/parsers.py b/mercurial/pure/parsers.py
--- a/mercurial/pure/parsers.py
+++ b/mercurial/pure/parsers.py
@@ -33,13 +33,6 @@
 return x
 
 
-indexformatng = b">Qii20s12x"
-indexfirst = struct.calcsize(b'Q')
-sizeint = struct.calcsize(b'i')
-indexsize = struct.calcsize(indexformatng)
-nullitem = (0, 0, 0, -1, -1, -1, -1, nullid)
-
-
 def gettype(q):
 return int(q & 0x)
 
@@ -49,6 +42,12 @@
 
 
 class BaseIndexObject(object):
+index_format = b">Qii20s12x"
+big_int_size = struct.calcsize(b'Q')
+int_size = struct.calcsize(b'i')
+index_size = struct.calcsize(index_format)
+null_item = (0, 0, 0, -1, -1, -1, -1, nullid)
+
 @property
 def nodemap(self):
 msg = b"index.nodemap is deprecated, use index.[has_node|rev|get_rev]"
@@ -94,7 +93,7 @@
 def append(self, tup):
 if '_nodemap' in vars(self):
 self._nodemap[tup[7]] = len(self)
-data = _pack(indexformatng, *tup)
+data = _pack(self.index_format, *tup)
 self._extra.append(data)
 
 def _check_index(self, i):
@@ -105,14 +104,14 @@
 
 def __getitem__(self, i):
 if i == -1:
-return nullitem
+return self.null_item
 self._check_index(i)
 if i >= self._lgt:
 data = self._extra[i - self._lgt]
 else:
 index = self._calculate_index(i)
-data = self._data[index : index + indexsize]
-r = _unpack(indexformatng, data)
+data = self._data[index : index + self.index_size]
+r = _unpack(self.index_format, data)
 if self._lgt and i == 0:
 r = (offset_type(0, gettype(r[0])),) + r[1:]
 return r
@@ -120,13 +119,13 @@
 
 class IndexObject(BaseIndexObject):
 def __init__(self, data):
-assert len(data) % indexsize == 0
+assert len(data) % self.index_size == 0
 self._data = data
-self._lgt = len(data) // indexsize
+self._lgt = len(data) // self.index_size
 self._extra = []
 
 def _calculate_index(self, i):
-return i * indexsize
+return i * self.index_size
 
 def __delitem__(self, i):
 if not isinstance(i, slice) or not i.stop == -1 or i.step is not None:
@@ -135,7 +134,7 @@
 self._check_index(i)
 self._stripnodes(i)
 if i < self._lgt:
-self._data = self._data[: i * indexsize]
+self._data = self._data[: i * self.index_size]
 self._lgt = i
 self._extra = []
 else:
@@ -198,14 +197,16 @@
 if lgt is not None:
 self._offsets = [0] * lgt
 count = 0
-while off <= len(self._data) - indexsize:
+while off <= len(self._data) - self.index_size:
+start = off + self.big_int_size
 (s,) = struct.unpack(
-b'>i', self._data[off + indexfirst : off + sizeint + 
indexfirst]
+b'>i',
+self._data[start : start + self.int_size],
 )
 if lgt is not None:
 self._offsets[count] = off
 count += 1
-off += indexsize + s
+off += self.index_size + s
 if off != len(self._data):
 raise ValueError(b"corrupted data")
 return count



To: Alphare, #hg-reviewers
Cc: mercurial-patches, mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D9844: revlogv2: allow upgrading to v2

2021-01-20 Thread Raphaël Gomès
Alphare created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  Revlogv2 implies sidedata.
  Right now sidedata is not really used in production, and Revlogv2 will be used
  for the first production-ready version of sidedata support.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  mercurial/configitems.py
  mercurial/localrepo.py
  mercurial/upgrade_utils/actions.py
  tests/test-copies-chain-merge.t
  tests/test-copies-in-changeset.t
  tests/test-persistent-nodemap.t
  tests/test-sidedata.t
  tests/test-upgrade-repo.t

CHANGE DETAILS

diff --git a/tests/test-upgrade-repo.t b/tests/test-upgrade-repo.t
--- a/tests/test-upgrade-repo.t
+++ b/tests/test-upgrade-repo.t
@@ -21,7 +21,7 @@
   > EOF
 
   $ hg -R no-revlogv1 debugupgraderepo
-  abort: cannot upgrade repository; requirement missing: revlogv1
+  abort: cannot upgrade repository; missing a revlog version
   [255]
 
 Cannot upgrade shared repositories
@@ -61,6 +61,7 @@
   sidedata:no
   persistent-nodemap:  no
   copies-sdc:  no
+  revlog-v2:   no
   plain-cl-delta: yes
   compression:zlib
   compression-level:  default
@@ -74,6 +75,7 @@
   sidedata:no no  no
   persistent-nodemap:  no no  no
   copies-sdc:  no no  no
+  revlog-v2:   no no  no
   plain-cl-delta: yesyes yes
   compression:zlib   zlibzlib
   compression-level:  default default default
@@ -87,6 +89,7 @@
   sidedata:no no  no
   persistent-nodemap:  no no  no
   copies-sdc:  no no  no
+  revlog-v2:   no no  no
   plain-cl-delta: yesyes yes
   compression:zlib   zlibzlib
   compression-level:  default default default
@@ -100,6 +103,7 @@
   [formatvariant.name.uptodate|sidedata:  
][formatvariant.repo.uptodate|  no][formatvariant.config.default| 
no][formatvariant.default|  no]
   
[formatvariant.name.uptodate|persistent-nodemap:][formatvariant.repo.uptodate|  
no][formatvariant.config.default| no][formatvariant.default|  no]
   [formatvariant.name.uptodate|copies-sdc:
][formatvariant.repo.uptodate|  no][formatvariant.config.default| 
no][formatvariant.default|  no]
+  [formatvariant.name.uptodate|revlog-v2: 
][formatvariant.repo.uptodate|  no][formatvariant.config.default| 
no][formatvariant.default|  no]
   [formatvariant.name.uptodate|plain-cl-delta:
][formatvariant.repo.uptodate| yes][formatvariant.config.default|
yes][formatvariant.default| yes]
   [formatvariant.name.uptodate|compression:   
][formatvariant.repo.uptodate| zlib][formatvariant.config.default|   
zlib][formatvariant.default|zlib]
   [formatvariant.name.uptodate|compression-level: 
][formatvariant.repo.uptodate| default][formatvariant.config.default| 
default][formatvariant.default| default]
@@ -154,6 +158,12 @@
 "repo": false
},
{
+"config": false,
+"default": false,
+"name": "revlog-v2",
+"repo": false
+   },
+   {
 "config": true,
 "default": true,
 "name": "plain-cl-delta",
@@ -306,6 +316,7 @@
   sidedata:no
   persistent-nodemap:  no
   copies-sdc:  no
+  revlog-v2:   no
   plain-cl-delta: yes
   compression:zlib
   compression-level:  default
@@ -319,6 +330,7 @@
   sidedata:no no  no
   persistent-nodemap:  no no  no
   copies-sdc:  no no  no
+  revlog-v2:   no no  no
   plain-cl-delta: yesyes yes
   compression:zlib   zlibzlib
   compression-level:  default default default
@@ -332,6 +344,7 @@
   sidedata:no no  no
   persistent-nodemap:  no no  no
   copies-sdc:  no no  no
+  revlog-v2:   no no  no
   plain-cl-delta: yesyes yes
   compression:zlib   zlibzlib
   compression-level:  default default default
@@ -345,6 +358,7 @@
   [formatvariant.name.uptodate|sidedata:  
][formatvariant.repo.uptodate|  no][formatvariant.config.default| 
no][formatvariant.default|  no]
   
[formatvariant.name.uptodate|persistent-nodemap:][formatvariant.repo.uptodate|  
no][formatvariant.config.default| no][formatvariant.default|  no]
   [formatvariant.name.uptodate|copies-sdc:
][formatvariant.repo.uptodate|  no][formatvariant.config.default| 
no][formatvariant.default|  no]
+  [formatvariant.name.uptodate|revlog-v2: 
][formatvariant.repo.uptodate|  no][formatvariant.config.default| 
no][formatvariant.default|  no]
   [formatvariant.name.uptodate|plain-cl-delta:
][formatvariant.repo.uptodate| yes][formatvariant.config.default|
yes][formatvariant.default| yes]
   [formatvariant.name.uptodate|compression:   

D9843: revlog: introduce v2 format

2021-01-20 Thread Raphaël Gomès
Alphare created this revision.
Herald added a reviewer: indygreg.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  As documented in [1], this is still tentative and could be subject to change,
  but we need to lay down the foundations in order to work on the next 
abstraction
  layers.
  
  [1] https://www.mercurial-scm.org/wiki/RevlogV2Plan

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  mercurial/localrepo.py
  mercurial/pure/parsers.py
  mercurial/requirements.py
  mercurial/revlog.py
  mercurial/revlogutils/constants.py
  tests/test-parseindex2.py
  tests/test-requires.t
  tests/test-revlog-v2.t
  tests/test-revlog.t

CHANGE DETAILS

diff --git a/tests/test-revlog.t b/tests/test-revlog.t
--- a/tests/test-revlog.t
+++ b/tests/test-revlog.t
@@ -22,10 +22,10 @@
 Unknown version is rejected
 
   >>> with open('.hg/store/00changelog.i', 'wb') as fh:
-  ... fh.write(b'\x00\x00\x00\x02') and None
+  ... fh.write(b'\x00\x00\x00\x03') and None
 
   $ hg log
-  abort: unknown version (2) in revlog 00changelog.i
+  abort: unknown version (3) in revlog 00changelog.i
   [50]
 
   $ cd ..
diff --git a/tests/test-revlog-v2.t b/tests/test-revlog-v2.t
--- a/tests/test-revlog-v2.t
+++ b/tests/test-revlog-v2.t
@@ -22,7 +22,7 @@
   $ cd empty-repo
   $ cat .hg/requires
   dotencode
-  exp-revlogv2.1
+  exp-revlogv2.2
   fncache
   sparserevlog
   store
@@ -32,10 +32,10 @@
 Unknown flags to revlog are rejected
 
   >>> with open('.hg/store/00changelog.i', 'wb') as fh:
-  ... fh.write(b'\xff\x00\xde\xad') and None
+  ... fh.write(b'\xff\x00\x00\x02') and None
 
   $ hg log
-  abort: unknown flags (0xff00) in version 57005 revlog 00changelog.i
+  abort: unknown flags (0xff00) in version 2 revlog 00changelog.i
   [50]
 
   $ cd ..
@@ -58,8 +58,8 @@
 
   $ f --hexdump --bytes 4 .hg/store/00changelog.i
   .hg/store/00changelog.i:
-  : 00 01 de ad ||
+  : 00 01 00 02 ||
 
   $ f --hexdump --bytes 4 .hg/store/data/foo.i
   .hg/store/data/foo.i:
-  : 00 01 de ad ||
+  : 00 01 00 02 ||
diff --git a/tests/test-requires.t b/tests/test-requires.t
--- a/tests/test-requires.t
+++ b/tests/test-requires.t
@@ -5,7 +5,7 @@
   $ hg commit -m test
   $ rm .hg/requires
   $ hg tip
-  abort: unknown version (2) in revlog 00changelog.i
+  abort: unknown version (65535) in revlog 00changelog.i
   [50]
   $ echo indoor-pool > .hg/requires
   $ hg tip
diff --git a/tests/test-parseindex2.py b/tests/test-parseindex2.py
--- a/tests/test-parseindex2.py
+++ b/tests/test-parseindex2.py
@@ -117,8 +117,8 @@
 )
 
 
-def parse_index2(data, inline):
-index, chunkcache = parsers.parse_index2(data, inline)
+def parse_index2(data, inline, revlogv2=False):
+index, chunkcache = parsers.parse_index2(data, inline, revlogv2=revlogv2)
 return list(index), chunkcache
 
 
diff --git a/mercurial/revlogutils/constants.py 
b/mercurial/revlogutils/constants.py
--- a/mercurial/revlogutils/constants.py
+++ b/mercurial/revlogutils/constants.py
@@ -14,9 +14,7 @@
 # revlog header flags
 REVLOGV0 = 0
 REVLOGV1 = 1
-# Dummy value until file format is finalized.
-# Reminder: change the bounds check in revlog.__init__ when this is changed.
-REVLOGV2 = 0xDEAD
+REVLOGV2 = 2
 # Shared across v1 and v2.
 FLAG_INLINE_DATA = 1 << 16
 # Only used by v1, implied by v2.
diff --git a/mercurial/revlog.py b/mercurial/revlog.py
--- a/mercurial/revlog.py
+++ b/mercurial/revlog.py
@@ -69,6 +69,7 @@
 templatefilters,
 util,
 )
+from .pure import parsers as pureparsers
 from .interfaces import (
 repository,
 util as interfaceutil,
@@ -364,6 +365,40 @@
 return p
 
 
+# index v2:
+#  6 bytes: offset
+#  2 bytes: flags
+#  4 bytes: compressed length
+#  4 bytes: uncompressed length
+#  4 bytes: base rev
+#  4 bytes: link rev
+#  4 bytes: parent 1 rev
+#  4 bytes: parent 2 rev
+# 32 bytes: nodeid
+#  8 bytes: UnifiedRevlog identifier
+#  4 bytes: rank (number of changesets under this one, this one included)
+#  8 bytes: sidedata offset
+#  4 bytes: sidedata compressed length
+#  8 bytes: Padding to align to 96 bytes
+indexformatv2 = struct.Struct(b">Qii20s12xQiQi8x")
+indexformatv2_pack = indexformatv2.pack
+
+
+class revlogv2io(object):
+def __init__(self):
+self.size = indexformatv2.size
+
+def parseindex(self, data, inline):
+index, cache = parsers.parse_index2(data, inline, revlogv2=True)
+return index, cache
+
+def packentry(self, entry, node, version, rev):
+p = indexformatv2_pack(*entry)
+if rev == 0:
+p = versionformat_pack(version) + p[4:]
+return p
+
+
 NodemapRevlogIO = None
 
 if util.safehasattr(parsers, 'parse_index_devel_nodemap'):
@@ -647,6 +682,8 @@
 

D9846: cext: add support for revlogv2

2021-01-20 Thread Raphaël Gomès
Alphare created this revision.
Herald added a reviewer: indygreg.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  mercurial/cext/parsers.c
  mercurial/cext/revlog.c
  mercurial/revlog.py

CHANGE DETAILS

diff --git a/mercurial/revlog.py b/mercurial/revlog.py
--- a/mercurial/revlog.py
+++ b/mercurial/revlog.py
@@ -69,7 +69,6 @@
 templatefilters,
 util,
 )
-from .pure import parsers as pureparsers
 from .interfaces import (
 repository,
 util as interfaceutil,
diff --git a/mercurial/cext/revlog.c b/mercurial/cext/revlog.c
--- a/mercurial/cext/revlog.c
+++ b/mercurial/cext/revlog.c
@@ -98,6 +98,7 @@
int ntlookups;  /* # lookups */
int ntmisses;   /* # lookups that miss the cache */
int inlined;
+   long hdrsize; /* size of index headers. Differs in v1 v.s. v2 format */
 };
 
 static Py_ssize_t index_length(const indexObject *self)
@@ -113,14 +114,19 @@
 static int index_find_node(indexObject *self, const char *node);
 
 #if LONG_MAX == 0x7fffL
-static const char *const tuple_format = PY23("Kiis#", "Kiiy#");
+static const char *const v1_tuple_format = PY23("Kiis#", "Kiiy#");
+static const char *const v2_tuple_format = PY23("Kiis#KiKi", 
"Kiiy#KiKi");
 #else
-static const char *const tuple_format = PY23("kiis#", "kiiy#");
+static const char *const v1_tuple_format = PY23("kiis#", "kiiy#");
+static const char *const v2_tuple_format = PY23("kiis#kiki", 
"kiiy#kiki");
 #endif
 
 /* A RevlogNG v1 index entry is 64 bytes long. */
 static const long v1_hdrsize = 64;
 
+/* A Revlogv2 index entry is 96 bytes long. */
+static const long v2_hdrsize = 96;
+
 static void raise_revlog_error(void)
 {
PyObject *mod = NULL, *dict = NULL, *errclass = NULL;
@@ -157,7 +163,7 @@
 static const char *index_deref(indexObject *self, Py_ssize_t pos)
 {
if (pos >= self->length)
-   return self->added + (pos - self->length) * v1_hdrsize;
+   return self->added + (pos - self->length) * self->hdrsize;
 
if (self->inlined && pos > 0) {
if (self->offsets == NULL) {
@@ -174,7 +180,7 @@
return self->offsets[pos];
}
 
-   return (const char *)(self->buf.buf) + pos * v1_hdrsize;
+   return (const char *)(self->buf.buf) + pos * self->hdrsize;
 }
 
 /*
@@ -280,8 +286,9 @@
  */
 static PyObject *index_get(indexObject *self, Py_ssize_t pos)
 {
-   uint64_t offset_flags;
-   int comp_len, uncomp_len, base_rev, link_rev, parent_1, parent_2;
+   uint64_t offset_flags, sidedata_offset, unified_revlog_id;
+   int comp_len, uncomp_len, base_rev, link_rev, parent_1, parent_2,
+sidedata_comp_len, rank;
const char *c_node_id;
const char *data;
Py_ssize_t length = index_length(self);
@@ -320,9 +327,22 @@
parent_2 = getbe32(data + 28);
c_node_id = data + 32;
 
-   return Py_BuildValue(tuple_format, offset_flags, comp_len, uncomp_len,
-base_rev, link_rev, parent_1, parent_2, c_node_id,
-self->nodelen);
+  if (self->hdrsize == v1_hdrsize) {
+return Py_BuildValue(v1_tuple_format, offset_flags, comp_len, uncomp_len,
+ base_rev, link_rev, parent_1, parent_2, c_node_id,
+ self->nodelen);
+  } else {
+unified_revlog_id = getbe64(data + 64);
+rank = getbe32(data + 72);
+sidedata_offset = getbe64(data + 76);
+sidedata_comp_len = getbe32(data + 84);
+
+return Py_BuildValue(v2_tuple_format, offset_flags, comp_len,
+ uncomp_len, base_rev, link_rev, parent_1,
+ parent_2, c_node_id, self->nodelen,
+ unified_revlog_id, rank,
+ sidedata_offset, sidedata_comp_len);
+  }
 }
 
 /*
@@ -373,18 +393,30 @@
 
 static PyObject *index_append(indexObject *self, PyObject *obj)
 {
-   uint64_t offset_flags;
+   uint64_t offset_flags, unified_revlog_id, sidedata_offset;
int rev, comp_len, uncomp_len, base_rev, link_rev, parent_1, parent_2;
-   Py_ssize_t c_node_id_len;
+   Py_ssize_t c_node_id_len, rank, sidedata_comp_len;
const char *c_node_id;
char *data;
 
-   if (!PyArg_ParseTuple(obj, tuple_format, _flags, _len,
- _len, _rev, _rev, _1,
- _2, _node_id, _node_id_len)) {
-   PyErr_SetString(PyExc_TypeError, "8-tuple required");
-   return NULL;
+  if (self->hdrsize == v1_hdrsize) {
+if (!PyArg_ParseTuple(obj, v1_tuple_format, _flags, _len,
+  _len, _rev, _rev, _1,
+  _2, _node_id, _node_id_len)) {
+  PyErr_SetString(PyExc_TypeError, "8-tuple required");
+  return 

D9845: bitmanipulation: add utils to read/write bigendian 64bit integers

2021-01-20 Thread Raphaël Gomès
Alphare created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  mercurial/bitmanipulation.h

CHANGE DETAILS

diff --git a/mercurial/bitmanipulation.h b/mercurial/bitmanipulation.h
--- a/mercurial/bitmanipulation.h
+++ b/mercurial/bitmanipulation.h
@@ -5,6 +5,29 @@
 
 #include "compat.h"
 
+/* Reads a 64 bit integer from big-endian bytes. Assumes that the data is long
+ enough */
+static inline uint64_t getbe64(const char *c)
+{
+   const unsigned char *d = (const unsigned char *)c;
+
+   return uint64_t)d[0]) << 56)
+  |
+  (((uint64_t)d[1]) << 48)
+  |
+  (((uint64_t)d[2]) << 40)
+  |
+  (((uint64_t)d[3]) << 32)
+  |
+  (((uint64_t)d[4]) << 24)
+  |
+  (((uint64_t)d[5]) << 16)
+  |
+  (((uint64_t)d[6]) << 8)
+  |
+  (d[7]));
+}
+
 static inline uint32_t getbe32(const char *c)
 {
const unsigned char *d = (const unsigned char *)c;
@@ -27,6 +50,20 @@
return ((d[0] << 8) | (d[1]));
 }
 
+/* Writes a 64 bit integer to bytes in a big-endian format.
+ Assumes that the buffer is long enough */
+static inline void putbe64(uint64_t x, char *c)
+{
+   c[0] = (x >> 56) & 0xff;
+   c[1] = (x >> 48) & 0xff;
+   c[2] = (x >> 40) & 0xff;
+   c[3] = (x >> 32) & 0xff;
+   c[4] = (x >> 24) & 0xff;
+   c[5] = (x >> 16) & 0xff;
+   c[6] = (x >> 8) & 0xff;
+   c[7] = (x) & 0xff;
+}
+
 static inline void putbe32(uint32_t x, char *c)
 {
c[0] = (x >> 24) & 0xff;



To: Alphare, #hg-reviewers
Cc: mercurial-patches, mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D9717: contrib: stop building rust for every job

2021-01-11 Thread Raphaël Gomès
Alphare created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  This is just wasteful for all steps that do not use Rust.

REPOSITORY
  rHG Mercurial

BRANCH
  stable

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

AFFECTED FILES
  contrib/heptapod-ci.yml

CHANGE DETAILS

diff --git a/contrib/heptapod-ci.yml b/contrib/heptapod-ci.yml
--- a/contrib/heptapod-ci.yml
+++ b/contrib/heptapod-ci.yml
@@ -5,8 +5,6 @@
 before_script:
 - hg clone . /tmp/mercurial-ci/ --noupdate
 - hg -R /tmp/mercurial-ci/ update `hg log --rev '.' --template '{node}'`
-- cd /tmp/mercurial-ci/rust/rhg
-- cargo build
 - cd /tmp/mercurial-ci/
 - ls -1 tests/test-check-*.* > /tmp/check-tests.txt
 
@@ -20,6 +18,16 @@
 - echo "$RUNTEST_ARGS"
 - HGMODULEPOLICY="$TEST_HGMODULEPOLICY" "$PYTHON" tests/run-tests.py 
--color=always $RUNTEST_ARGS
 
+.rust_template: 
+before_script:
+- hg clone . /tmp/mercurial-ci/ --noupdate
+- hg -R /tmp/mercurial-ci/ update `hg log --rev '.' --template 
'{node}'`
+- cd /tmp/mercurial-ci/
+- ls -1 tests/test-check-*.* > /tmp/check-tests.txt
+- cd /tmp/mercurial-ci/rust/rhg
+- cargo build
+- cd /tmp/mercurial-ci/
+
 checks-py2:
 <<: *runtests
 variables:
@@ -69,6 +77,7 @@
 
 test-py2-rust:
 <<: *runtests
+<<: *rust
 variables:
 HGWITHRUSTEXT: cpython
 RUNTEST_ARGS: "--rust --blacklist /tmp/check-tests.txt"
@@ -76,6 +85,7 @@
 
 test-py3-rust:
 <<: *runtests
+<<: *rust
 variables:
 HGWITHRUSTEXT: cpython
 RUNTEST_ARGS: "--rust --blacklist /tmp/check-tests.txt"



To: Alphare, #hg-reviewers
Cc: mercurial-patches, mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D9716: contrib: remove testing for `dirstate-tree` Rust feature

2021-01-11 Thread Raphaël Gomès
Alphare created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  This feature will be replaced in a few months, and served more as a
  proof-of-concept. Keeping it in CI when no one is using it anymore is just
  wasteful.

REPOSITORY
  rHG Mercurial

BRANCH
  stable

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

AFFECTED FILES
  contrib/heptapod-ci.yml

CHANGE DETAILS

diff --git a/contrib/heptapod-ci.yml b/contrib/heptapod-ci.yml
--- a/contrib/heptapod-ci.yml
+++ b/contrib/heptapod-ci.yml
@@ -41,12 +41,6 @@
 variables:
 PYTHON: python3
 
-rust-cargo-test-py3-dirstate-tree:
-<<: *rust_cargo_test
-variables:
-PYTHON: python3
-HG_RUST_FEATURES: dirstate-tree
-
 test-py2:
 <<: *runtests
 variables:
@@ -88,15 +82,6 @@
 PYTHON: python3
 TEST_HGMODULEPOLICY: "rust+c"
 
-test-py3-rust-dirstate-tree:
-<<: *runtests
-variables:
-HGWITHRUSTEXT: cpython
-RUNTEST_ARGS: "--rust --blacklist /tmp/check-tests.txt"
-PYTHON: python3
-TEST_HGMODULEPOLICY: "rust+c"
-HG_RUST_FEATURES: "dirstate-tree"
-
 test-py2-chg:
 <<: *runtests
 variables:



To: Alphare, #hg-reviewers
Cc: mercurial-patches, mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


New revlog format, plan page

2021-01-05 Thread Raphaël Gomès

Hi all,

During the last (virtual) sprint, a lot of us spoke about the need for a 
format change of the revlog to overcome some of its limitations.


I've opened a very much draft plan page [1] to try to list all the 
things we want to do in that version and try to figure out an efficient 
new format.


I'm aware that the v2 is already planned, but I figured that we can just 
merge that (seemingly) paused effort and this new one.


I wish you all a nice 2021!
Raphaël

[1] https://www.mercurial-scm.org/wiki/RevlogV2Plan

___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D9518: wireprotov2: re-add tuple around `bundle2` check

2020-12-04 Thread Raphaël Gomès
Alphare created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  I stumbled upon this while looking for the current (v1) `capable` method. It
  looks like 9c2c77c73f23 
 
accidentally removed the comma, turning the tuple into
  a simple parenthesis expression.
  
  This has not been detected since wireproto2 is not in use AFAIK.

REPOSITORY
  rHG Mercurial

BRANCH
  stable

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

AFFECTED FILES
  mercurial/httppeer.py

CHANGE DETAILS

diff --git a/mercurial/httppeer.py b/mercurial/httppeer.py
--- a/mercurial/httppeer.py
+++ b/mercurial/httppeer.py
@@ -892,7 +892,7 @@
 return True
 
 # Other concepts.
-if name in b'bundle2':
+if name in (b'bundle2',):
 return True
 
 # Alias command-* to presence of command of that name.



To: Alphare, #hg-reviewers
Cc: mercurial-patches, mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D9426: copies-rust: hide most of the comparison details inside a closure

2020-11-27 Thread Raphaël Gomès
Alphare created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  The function that compares values needs various supporting elements that are
  the same for each call. We are about to both make change to these element and
  change to call sites in our upcoming work. So abstracting most of the details
  will help to avoid conflict while these works happen in parallel.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  rust/hg-core/src/copy_tracing.rs

CHANGE DETAILS

diff --git a/rust/hg-core/src/copy_tracing.rs b/rust/hg-core/src/copy_tracing.rs
--- a/rust/hg-core/src/copy_tracing.rs
+++ b/rust/hg-core/src/copy_tracing.rs
@@ -496,6 +496,15 @@
 changes: ,
 oracle:  AncestorOracle,
 ) -> TimeStampedPathCopies {
+// This closure exist as temporary help while multiple developper are
+// actively working on this code. Feel free to re-inline it once this
+// code is more settled.
+let mut cmp_value =
+|dest: ,
+ src_minor: ,
+ src_major: | {
+compare_value(changes, oracle, dest, src_minor, src_major)
+};
 if minor.is_empty() {
 major
 } else if major.is_empty() {
@@ -532,9 +541,7 @@
 DiffItem::Update { old, new } => {
 let (dest, src_major) = new;
 let (_, src_minor) = old;
-match compare_value(
-changes, oracle, dest, src_minor, src_major,
-) {
+match cmp_value(dest, src_minor, src_major) {
 MergePick::Major => to_minor(dest, src_major),
 MergePick::Minor => to_major(dest, src_minor),
 // If the two entry are identical, no need to do



To: Alphare, #hg-reviewers
Cc: mercurial-patches, mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D9425: copies-rust: move the mapping merging into a else clause

2020-11-27 Thread Raphaël Gomès
Alphare created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  We are going to add more cases, to it is time to stop using early returns and 
to
  move everything in a single if/elif/else block for clarity.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  rust/hg-core/src/copy_tracing.rs

CHANGE DETAILS

diff --git a/rust/hg-core/src/copy_tracing.rs b/rust/hg-core/src/copy_tracing.rs
--- a/rust/hg-core/src/copy_tracing.rs
+++ b/rust/hg-core/src/copy_tracing.rs
@@ -497,73 +497,74 @@
 oracle:  AncestorOracle,
 ) -> TimeStampedPathCopies {
 if minor.is_empty() {
-return major;
+major
 } else if major.is_empty() {
-return minor;
-}
-let mut override_minor = Vec::new();
-let mut override_major = Vec::new();
+minor
+} else {
+let mut override_minor = Vec::new();
+let mut override_major = Vec::new();
 
-let mut to_major = |k: , v: | {
-override_major.push((k.clone(), v.clone()))
-};
-let mut to_minor = |k: , v: | {
-override_minor.push((k.clone(), v.clone()))
-};
+let mut to_major = |k: , v: | {
+override_major.push((k.clone(), v.clone()))
+};
+let mut to_minor = |k: , v: | {
+override_minor.push((k.clone(), v.clone()))
+};
 
-// The diff function leverage detection of the identical subpart if minor
-// and major has some common ancestors. This make it very fast is most
-// case.
-//
-// In case where the two map are vastly different in size, the current
-// approach is still slowish because the iteration will iterate over
-// all the "exclusive" content of the larger on. This situation can be
-// frequent when the subgraph of revision we are processing has a lot
-// of roots. Each roots adding they own fully new map to the mix (and
-// likely a small map, if the path from the root to the "main path" is
-// small.
-//
-// We could do better by detecting such situation and processing them
-// differently.
-for d in minor.diff() {
-match d {
-DiffItem::Add(k, v) => to_minor(k, v),
-DiffItem::Remove(k, v) => to_major(k, v),
-DiffItem::Update { old, new } => {
-let (dest, src_major) = new;
-let (_, src_minor) = old;
-match compare_value(
-changes, oracle, dest, src_minor, src_major,
-) {
-MergePick::Major => to_minor(dest, src_major),
-MergePick::Minor => to_major(dest, src_minor),
-// If the two entry are identical, no need to do
-// anything (but diff should not have yield them)
-MergePick::Any => unreachable!(),
+// The diff function leverage detection of the identical subpart if
+// minor and major has some common ancestors. This make it very
+// fast is most case.
+//
+// In case where the two map are vastly different in size, the current
+// approach is still slowish because the iteration will iterate over
+// all the "exclusive" content of the larger on. This situation can be
+// frequent when the subgraph of revision we are processing has a lot
+// of roots. Each roots adding they own fully new map to the mix (and
+// likely a small map, if the path from the root to the "main path" is
+// small.
+//
+// We could do better by detecting such situation and processing them
+// differently.
+for d in minor.diff() {
+match d {
+DiffItem::Add(k, v) => to_minor(k, v),
+DiffItem::Remove(k, v) => to_major(k, v),
+DiffItem::Update { old, new } => {
+let (dest, src_major) = new;
+let (_, src_minor) = old;
+match compare_value(
+changes, oracle, dest, src_minor, src_major,
+) {
+MergePick::Major => to_minor(dest, src_major),
+MergePick::Minor => to_major(dest, src_minor),
+// If the two entry are identical, no need to do
+// anything (but diff should not have yield them)
+MergePick::Any => unreachable!(),
+}
 }
-}
-};
-}
+};
+}
 
-let updates;
-let mut result;
-if override_major.is_empty() {
-result = major
-} else if override_minor.is_empty() {
-result = minor
-} else {
-if override_minor.len() < override_major.len() {
-updates = override_minor;
-result = minor;
+let updates;
+

D9422: copies: iterate over children directly (instead of parents)

2020-11-27 Thread Raphaël Gomès
Alphare created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  Before this change we would gather all parent → child edges and iterate on
  all parent, gathering copy information for children and aggregating them from
  there.
  
  They are not strict requirement for edges to be processed in that specific
  order. We could also simply iterate over all "children" revision and aggregate
  data from both parents at the same time. This patch does that.
  
  It make various things simpler:
  
  - since both parents are processed at the same time, we no longer need to 
cache data for merge (see next changeset for details),
  - we no longer need nested loop to process data,
  - we no longer need to store partial merge data for a rev from distinct loop 
interaction to another when processing merges,
  - we no longer need to build a full parent -> children mapping (we only rely 
on a simpler "parent -> number of children" map (for memory efficiency),
  - the data access pattern is now simpler (from lower revisions to higher 
revisions) and entirely predicable. That predictability open the way to 
prefetching and parallel processing.
  
  So that new iterations order requires simpler code and open the way to
  interesting optimisation.
  
  The effect on performance is quite good. In the worse case, we don't see any
  significant negative impact. And in the best case, the reduction of roundtrip
  to Python provide us with a significant speed. Some example below:
  
  RepoCase  Source-Rev   Dest-Rev   
   # of revisions  old timenew time  DifferenceFactortime per 
rev
  
---
  
  mozilla-try x0_revs_x0_added_0_copies dc8a3ca7010e 
d16fde900c9c :  34414 revs,   0.962867 s,   0.502584 s,  -0.460283 s, × 0.5220, 
   14 µs/rev
  mozilla-try x_revs_xx000_added_x_copies   156f6e2674f2 
4d0f2c178e66 :   8598 revs,   0.110717 s,   0.076323 s,  -0.034394 s, × 0.6894, 
8 µs/rev
  
  full comparison between the previous changeset and this one
  ===
  
  RepoCase  Source-Rev   Dest-Rev   
   # of revisions  old timenew time  DifferenceFactortime per 
rev
  
---
  
  mercurial   x_revs_x_added_0_copies   ad6b123de1c7 
 
39cfcef4f463 
 :  
1 revs,   0.48 s,   0.41 s,  -0.07 s, × 0.8542,41 µs/rev
  mercurial   x_revs_x_added_x_copies   2b1c78674230 
 
0c1d10351869 
 :  
6 revs,   0.000153 s,   0.000102 s,  -0.51 s, × 0.6667,17 µs/rev
  mercurial   x000_revs_x000_added_x_copies 81f8ff2a9bf2 
 
dd3267698d84 
 :  
 1032 revs,   0.004209 s,   0.004254 s,  +0.45 s, × 1.0107, 4 µs/rev
  pypyx_revs_x_added_0_copies   aed021ee8ae8 
099ed31b181b :  9 revs,   0.000203 s,   0.000282 s,  +0.79 s, × 1.3892, 
   31 µs/rev
  pypyx_revs_x000_added_0_copies4aa4e1f8e19a 
359343b9ac0e :  1 revs,   0.59 s,   0.48 s,  -0.11 s, × 0.8136, 
   48 µs/rev
  pypyx_revs_x_added_x_copies   ac52eb70 
72e022663155 :  7 revs,   0.000194 s,   0.000211 s,  +0.17 s, × 1.0876, 
   30 µs/rev
  pypyx_revs_x00_added_x_copies c3b14617fbd7 
ace7255d9a26 :  1 revs,   0.000380 s,   0.000375 s,  -0.05 s, × 0.9868, 
  375 µs/rev
  pypyx_revs_x000_added_x000_copies df6f7a526b60 
a83dc6a2d56f :  6 revs,   0.010588 s,   0.010574 s,  -0.14 s, × 0.9987, 
 1762 µs/rev
  pypyx000_revs_xx00_added_0_copies 89a76aede314 
2f22446ff07e :   4785 revs,   0.048961 s,   0.049974 s,  +0.001013 s, × 1.0207, 
   10 µs/rev
  pypyx000_revs_x000_added_x_copies 8a3b5bfd266e 
2c68e87c3efe :   6780 revs,   0.083612 s,   0.084300 s,  +0.000688 s, × 1.0082, 
   12 µs/rev
  pypyx000_revs_x000_added_x000_copies  89a76aede314 
7b3dda341c84 :   5441 revs,   0.058579 s,   0.060128 s,  +0.001549 s, × 1.0264, 
   11 µs/rev
  pypyx_revs_x_added_0_copies   

D9424: copies-rust: extract conflicting value comparison in its own function

2020-11-27 Thread Raphaël Gomès
Alphare created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  First, that logic is complicated enough to be in it own function. Second, we
  want to start adding alternative path within the merge code so we need this 
logic
  easily accessible in multiple places.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  rust/hg-core/src/copy_tracing.rs

CHANGE DETAILS

diff --git a/rust/hg-core/src/copy_tracing.rs b/rust/hg-core/src/copy_tracing.rs
--- a/rust/hg-core/src/copy_tracing.rs
+++ b/rust/hg-core/src/copy_tracing.rs
@@ -490,7 +490,6 @@
 ///
 /// In case of conflict, value from "major" will be picked, unless in some
 /// cases. See inline documentation for details.
-#[allow(clippy::if_same_then_else)]
 fn merge_copies_dict bool>(
 minor: TimeStampedPathCopies,
 major: TimeStampedPathCopies,
@@ -533,67 +532,14 @@
 DiffItem::Update { old, new } => {
 let (dest, src_major) = new;
 let (_, src_minor) = old;
-let mut pick_minor = || (to_major(dest, src_minor));
-let mut pick_major = || (to_minor(dest, src_major));
-if src_major.path == src_minor.path {
-// we have the same value, but from other source;
-if src_major.rev == src_minor.rev {
-// If the two entry are identical, no need to do
-// anything (but diff should not have yield them)
-unreachable!();
-} else if oracle.is_ancestor(src_major.rev, src_minor.rev)
-{
-pick_minor();
-} else {
-pick_major();
-}
-} else if src_major.rev == src_minor.rev {
-// We cannot get copy information for both p1 and p2 in the
-// same rev. So this is the same value.
-unreachable!();
-} else {
-let action = changes.get_merge_case();
-if src_major.path.is_none()
-&& action == MergeCase::Salvaged
-{
-// If the file is "deleted" in the major side but was
-// salvaged by the merge, we keep the minor side alive
-pick_minor();
-} else if src_minor.path.is_none()
-&& action == MergeCase::Salvaged
-{
-// If the file is "deleted" in the minor side but was
-// salvaged by the merge, unconditionnaly preserve the
-// major side.
-pick_major();
-} else if action == MergeCase::Merged {
-// If the file was actively merged, copy information
-// from each side might conflict.  The major side will
-// win such conflict.
-pick_major();
-} else if oracle.is_ancestor(src_major.rev, src_minor.rev)
-{
-// If the minor side is strictly newer than the major
-// side, it should be kept.
-pick_minor();
-} else if src_major.path.is_some() {
-// without any special case, the "major" value win
-// other the "minor" one.
-pick_major();
-} else if oracle.is_ancestor(src_minor.rev, src_major.rev)
-{
-// the "major" rev is a direct ancestors of "minor",
-// any different value should
-// overwrite
-pick_major();
-} else {
-// major version is None (so the file was deleted on
-// that branch) and that branch is independant (neither
-// minor nor major is an ancestors of the other one.)
-// We preserve the new
-// information about the new file.
-pick_minor();
-}
+match compare_value(
+changes, oracle, dest, src_minor, src_major,
+) {
+MergePick::Major => to_minor(dest, src_major),
+MergePick::Minor => to_major(dest, src_minor),
+// If the two entry are identical, no need to do
+// anything (but diff should not have yield them)
+MergePick::Any => unreachable!(),
 }
 }
 };
@@ -619,3 +565,77 @@
 }
 result
 }
+
+/// 

D9423: copies: no longer cache the ChangedFiles during copy tracing

2020-11-27 Thread Raphaël Gomès
Alphare created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  Now that the copies information for both parents are processed all at once, we
  no longer needs to cache this information, so we simplify the code.
  
  The simpler code is also a (tiny) bit faster overall.
  
  RepoCase  Source-Rev   Dest-Rev   
   # of revisions  old timenew time  DifferenceFactortime per 
rev
  
---
  
  mercurial   x_revs_x_added_0_copies   ad6b123de1c7 
 
39cfcef4f463 
 :  
1 revs,   0.41 s,   0.41 s,  +0.00 s, × 1.,41 µs/rev
  mercurial   x_revs_x_added_x_copies   2b1c78674230 
 
0c1d10351869 
 :  
6 revs,   0.000102 s,   0.96 s,  -0.06 s, × 0.9412,16 µs/rev
  mercurial   x000_revs_x000_added_x_copies 81f8ff2a9bf2 
 
dd3267698d84 
 :  
 1032 revs,   0.004254 s,   0.004039 s,  -0.000215 s, × 0.9495, 3 µs/rev
  pypyx_revs_x_added_0_copies   aed021ee8ae8 
099ed31b181b :  9 revs,   0.000282 s,   0.000189 s,  -0.93 s, × 0.6702, 
   21 µs/rev
  pypyx_revs_x000_added_0_copies4aa4e1f8e19a 
359343b9ac0e :  1 revs,   0.48 s,   0.47 s,  -0.01 s, × 0.9792, 
   47 µs/rev
  pypyx_revs_x_added_x_copies   ac52eb70 
72e022663155 :  7 revs,   0.000211 s,   0.000103 s,  -0.000108 s, × 0.4882, 
   14 µs/rev
  pypyx_revs_x00_added_x_copies c3b14617fbd7 
ace7255d9a26 :  1 revs,   0.000375 s,   0.000286 s,  -0.89 s, × 0.7627, 
  286 µs/rev
  pypyx_revs_x000_added_x000_copies df6f7a526b60 
a83dc6a2d56f :  6 revs,   0.010574 s,   0.010436 s,  -0.000138 s, × 0.9869, 
 1739 µs/rev
  pypyx000_revs_xx00_added_0_copies 89a76aede314 
2f22446ff07e :   4785 revs,   0.049974 s,   0.047465 s,  -0.002509 s, × 0.9498, 
9 µs/rev
  pypyx000_revs_x000_added_x_copies 8a3b5bfd266e 
2c68e87c3efe :   6780 revs,   0.084300 s,   0.082351 s,  -0.001949 s, × 0.9769, 
   12 µs/rev
  pypyx000_revs_x000_added_x000_copies  89a76aede314 
7b3dda341c84 :   5441 revs,   0.060128 s,   0.058757 s,  -0.001371 s, × 0.9772, 
   10 µs/rev
  pypyx_revs_x_added_0_copies   d1defd0dc478 
c9cb1334cc78 :  43645 revs,   0.686542 s,   0.674129 s,  -0.012413 s, × 0.9819, 
   15 µs/rev
  pypyx_revs_xx000_added_0_copies   bf2c629d0071 
4ffed77c095c :  2 revs,   0.009277 s,   0.009434 s,  +0.000157 s, × 1.0169, 
 4717 µs/rev
  pypyx_revs_xx000_added_x000_copies08ea3258278e 
d9fa043f30c0 :  11316 revs,   0.114733 s,   0.111935 s,  -0.002798 s, × 0.9756, 
9 µs/rev
  netbeansx_revs_x_added_0_copies   fb0955ffcbcd 
a01e9239f9e7 :  2 revs,   0.81 s,   0.78 s,  -0.03 s, × 0.9630, 
   39 µs/rev
  netbeansx_revs_x000_added_0_copies6f360122949f 
20eb231cc7d0 :  2 revs,   0.000107 s,   0.000106 s,  -0.01 s, × 0.9907, 
   53 µs/rev
  netbeansx_revs_x_added_x_copies   1ada3faf6fb6 
5a39d12eecf4 :  3 revs,   0.000173 s,   0.000162 s,  -0.11 s, × 0.9364, 
   54 µs/rev
  netbeansx_revs_x00_added_x_copies 35be93ba1e2c 
9eec5e90c05f :  9 revs,   0.000698 s,   0.000695 s,  -0.03 s, × 0.9957, 
   77 µs/rev
  netbeansx000_revs_xx00_added_0_copies eac3045b4fdd 
51d4ae7f1290 :   1421 revs,   0.009248 s,   0.008901 s,  -0.000347 s, × 0.9625, 
6 µs/rev
  netbeansx000_revs_x000_added_x_copies e2063d266acd 
6081d72689dc :   1533 revs,   0.015446 s,   0.014333 s,  -0.001113 s, × 0.9279, 
9 µs/rev
  netbeansx000_revs_x000_added_x000_copies  ff453e9fee32 
411350406ec2 :   5750 revs,   0.074373 s,   0.071998 s,  -0.002375 s, × 0.9681, 
   12 µs/rev
  netbeansx_revs_xx000_added_x000_copies588c2d1ced70 
1aad62e59ddd :  66949 revs,   0.639870 s,   0.615346 s,  -0.024524 s, × 0.9617, 
9 µs/rev
  mozilla-central x_revs_x_added_0_copies   3697f962bb7b 
7015fcdd43a2 :  2 revs,   0.88 s,   0.85 s,  -0.03 s, × 0.9659, 
   42 µs/rev
  mozilla-central x_revs_x000_added_0_copiesdd390860c6c9 

D9421: copies-rust: extract the processing of a ChangedFiles in its own function

2020-11-27 Thread Raphaël Gomès
Alphare created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  This is a reasonably independent piece of code that we can extract in its own
  function. This extraction will be very useful for the next changeset, where we
  will change the iteration order (but still do the same kind of processing).

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  rust/hg-core/src/copy_tracing.rs

CHANGE DETAILS

diff --git a/rust/hg-core/src/copy_tracing.rs b/rust/hg-core/src/copy_tracing.rs
--- a/rust/hg-core/src/copy_tracing.rs
+++ b/rust/hg-core/src/copy_tracing.rs
@@ -360,46 +360,8 @@
 assert_eq!(rev, p2);
 Parent::SecondParent
 };
-let mut new_copies = copies.clone();
-
-for action in changes.iter_actions(parent) {
-match action {
-Action::Copied(dest, source) => {
-let entry;
-if let Some(v) = copies.get(source) {
-entry = match  {
-Some(path) => Some((*(path)).to_owned()),
-None => Some(source.to_owned()),
-}
-} else {
-entry = Some(source.to_owned());
-}
-// Each new entry is introduced by the children, we
-// record this information as we will need it to take
-// the right decision when merging conflicting copy
-// information. See merge_copies_dict for details.
-let ttpc = TimeStampedPathCopy {
-rev: *child,
-path: entry,
-};
-new_copies.insert(dest.to_owned(), ttpc);
-}
-Action::Removed(f) => {
-// We must drop copy information for removed file.
-//
-// We need to explicitly record them as dropped to
-// propagate this information when merging two
-// TimeStampedPathCopies object.
-if new_copies.contains_key(f.as_ref()) {
-let ttpc = TimeStampedPathCopy {
-rev: *child,
-path: None,
-};
-new_copies.insert(f.to_owned(), ttpc);
-}
-}
-}
-}
+let new_copies =
+add_from_changes(, , parent, *child);
 
 // Merge has two parents needs to combines their copy information.
 //
@@ -441,6 +403,56 @@
 result
 }
 
+/// Combine ChangedFiles with some existing PathCopies information and return
+/// the result
+fn add_from_changes(
+base_copies: ,
+changes: ,
+parent: Parent,
+current_rev: Revision,
+) -> TimeStampedPathCopies {
+let mut copies = base_copies.clone();
+for action in changes.iter_actions(parent) {
+match action {
+Action::Copied(dest, source) => {
+let entry;
+if let Some(v) = base_copies.get(source) {
+entry = match  {
+Some(path) => Some((*(path)).to_owned()),
+None => Some(source.to_owned()),
+}
+} else {
+entry = Some(source.to_owned());
+}
+// Each new entry is introduced by the children, we
+// record this information as we will need it to take
+// the right decision when merging conflicting copy
+// information. See merge_copies_dict for details.
+let ttpc = TimeStampedPathCopy {
+rev: current_rev,
+path: entry,
+};
+copies.insert(dest.to_owned(), ttpc);
+}
+Action::Removed(f) => {
+// We must drop copy information for removed file.
+//
+// We need to explicitly record them as dropped to
+// propagate this information when merging two
+// TimeStampedPathCopies object.
+if copies.contains_key(f.as_ref()) {
+let ttpc = TimeStampedPathCopy {
+rev: current_rev,
+path: None,
+};
+copies.insert(f.to_owned(), ttpc);
+}
+}
+}
+}
+copies
+}
+
 /// merge two copies-mapping together, minor and major
 ///
 /// In case of conflict, value 

D9420: copies-rust: move the parent token to an enum

2020-11-27 Thread Raphaël Gomès
Alphare created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  We carry around information about which parent of a revision is been dealt
  with. So far this was a `usize` but as we are about to pass it around to more
  function it seems like a good idea to start cleaning this up and use a proper
  enum.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  rust/hg-core/src/copy_tracing.rs

CHANGE DETAILS

diff --git a/rust/hg-core/src/copy_tracing.rs b/rust/hg-core/src/copy_tracing.rs
--- a/rust/hg-core/src/copy_tracing.rs
+++ b/rust/hg-core/src/copy_tracing.rs
@@ -186,7 +186,7 @@
 }
 
 /// Return an iterator over all the `Action` in this instance.
-fn iter_actions(, parent: usize) -> ActionsIterator {
+fn iter_actions(, parent: Parent) -> ActionsIterator {
 ActionsIterator {
 changes: ,
 parent: parent,
@@ -259,7 +259,7 @@
 
 struct ActionsIterator<'a> {
 changes: &'a ChangedFiles<'a>,
-parent: usize,
+parent: Parent,
 current: u32,
 }
 
@@ -267,6 +267,10 @@
 type Item = Action<'a>;
 
 fn next( self) -> Option> {
+let copy_flag = match self.parent {
+Parent::FirstParent => P1_COPY,
+Parent::SecondParent => P2_COPY,
+};
 while self.current < self.changes.nb_items {
 let (flags, file, source) = self.changes.entry(self.current);
 self.current += 1;
@@ -274,10 +278,7 @@
 return Some(Action::Removed(file));
 }
 let copy = flags & COPY_MASK;
-if self.parent == 1 && copy == P1_COPY {
-return Some(Action::Copied(file, source));
-}
-if self.parent == 2 && copy == P2_COPY {
+if copy == copy_flag {
 return Some(Action::Copied(file, source));
 }
 }
@@ -301,6 +302,15 @@
 pub type RevInfoMaker<'a, D> =
 Box Fn(Revision, &'r mut DataHolder) -> RevInfo<'r> + 'a>;
 
+/// enum used to carry information about the parent → child currently processed
+#[derive(Copy, Clone, Debug)]
+enum Parent {
+/// The `p1(x) → x` edge
+FirstParent,
+/// The `p2(x) → x` edge
+SecondParent,
+}
+
 /// Same as mercurial.copies._combine_changeset_copies, but in Rust.
 ///
 /// Arguments are:
@@ -345,10 +355,10 @@
 let (p1, p2, changes) = rev_info(*child,  d);
 
 let parent = if rev == p1 {
-1
+Parent::FirstParent
 } else {
 assert_eq!(rev, p2);
-2
+Parent::SecondParent
 };
 let mut new_copies = copies.clone();
 
@@ -406,9 +416,8 @@
 }
 Some(other_copies) => {
 let (minor, major) = match parent {
-1 => (other_copies, new_copies),
-2 => (new_copies, other_copies),
-_ => unreachable!(),
+Parent::FirstParent => (other_copies, new_copies),
+Parent::SecondParent => (new_copies, other_copies),
 };
 let merged_copies =
 merge_copies_dict(minor, major, ,  oracle);



To: Alphare, #hg-reviewers
Cc: mercurial-patches, mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D9419: copies: properly copies parent dictionary before updating it

2020-11-27 Thread Raphaël Gomès
Alphare created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  This enforces the copy on write logic. Otherwise independant unrelated 
branches
  could affected each other.
  
  More testing of these case are coming, but I need that code landed to unlock
  other performance work in parallel.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  mercurial/copies.py

CHANGE DETAILS

diff --git a/mercurial/copies.py b/mercurial/copies.py
--- a/mercurial/copies.py
+++ b/mercurial/copies.py
@@ -405,9 +405,14 @@
 # changeset based copies. It was made without regards with
 # potential filelog related behavior.
 if parent == 1:
+if newcopies is copies:
+newcopies = copies.copy()
 minor, major = othercopies, newcopies
 else:
-minor, major = newcopies, othercopies
+# we do not know if the other dict is a copy or not, so we
+# need to blindly copy it. Future change should make this
+# unnecessary.
+minor, major = newcopies, othercopies.copy()
 copies = _merge_copies_dict(minor, major, isancestor, changes)
 all_copies[c] = copies
 



To: Alphare, #hg-reviewers
Cc: mercurial-patches, mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D9418: copies: clarify the return of _merge_copies_dict

2020-11-27 Thread Raphaël Gomès
Alphare created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  I misused that function twice in the past few days, so lets clarify the API.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  mercurial/copies.py

CHANGE DETAILS

diff --git a/mercurial/copies.py b/mercurial/copies.py
--- a/mercurial/copies.py
+++ b/mercurial/copies.py
@@ -408,8 +408,8 @@
 minor, major = othercopies, newcopies
 else:
 minor, major = newcopies, othercopies
-_merge_copies_dict(minor, major, isancestor, changes)
-all_copies[c] = minor
+copies = _merge_copies_dict(minor, major, isancestor, changes)
+all_copies[c] = copies
 
 final_copies = {}
 for dest, (tt, source) in all_copies[targetrev].items():
@@ -428,6 +428,8 @@
 
 - `ismerged(path)`: callable return True if `path` have been merged in the
 current revision,
+
+return the resulting dict (in practice, the "minor" object, updated)
 """
 for dest, value in major.items():
 other = minor.get(dest)
@@ -461,6 +463,7 @@
 minor[dest] = value
 elif isancestor(other_tt, new_tt):
 minor[dest] = value
+return minor
 
 
 def _revinfo_getter_extra(repo):



To: Alphare, #hg-reviewers
Cc: mercurial-patches, mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D9417: copies: simplify the call to _merge_copies_dict

2020-11-27 Thread Raphaël Gomès
Alphare created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  Let's get the argument into the right order, then call the function once.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  mercurial/copies.py

CHANGE DETAILS

diff --git a/mercurial/copies.py b/mercurial/copies.py
--- a/mercurial/copies.py
+++ b/mercurial/copies.py
@@ -405,14 +405,11 @@
 # changeset based copies. It was made without regards with
 # potential filelog related behavior.
 if parent == 1:
-_merge_copies_dict(
-othercopies, newcopies, isancestor, changes
-)
+minor, major = othercopies, newcopies
 else:
-_merge_copies_dict(
-newcopies, othercopies, isancestor, changes
-)
-all_copies[c] = newcopies
+minor, major = newcopies, othercopies
+_merge_copies_dict(minor, major, isancestor, changes)
+all_copies[c] = minor
 
 final_copies = {}
 for dest, (tt, source) in all_copies[targetrev].items():



To: Alphare, #hg-reviewers
Cc: mercurial-patches, mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D9416: copies: avoid unwanted side effect from one branch to another

2020-11-27 Thread Raphaël Gomès
Alphare created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  Without this copy, change in a one descendant branch (With "remove" change
  only) could affect computation on another descendant branches.
  
  This was not caugh by the test because the test graph are "too simple". I
  started writing more test in that regards, but I a submitting this changes
  earlier because I want to get more code landed to allow other optimisation 
work
  to happens.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  mercurial/copies.py

CHANGE DETAILS

diff --git a/mercurial/copies.py b/mercurial/copies.py
--- a/mercurial/copies.py
+++ b/mercurial/copies.py
@@ -379,7 +379,9 @@
 source = prev[1]
 newcopies[dest] = (c, source)
 assert newcopies is not copies
-if changes is not None:
+if changes is not None and changes.removed:
+if newcopies is copies:
+newcopies = copies.copy()
 for f in changes.removed:
 if f in newcopies:
 if newcopies is copies:



To: Alphare, #hg-reviewers
Cc: mercurial-patches, mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D9415: copies: fast path no-op merge

2020-11-27 Thread Raphaël Gomès
Alphare created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  If the two sides of the merge are the same (they come an unaltered common
  ancestors) we don't need any merging.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  mercurial/copies.py

CHANGE DETAILS

diff --git a/mercurial/copies.py b/mercurial/copies.py
--- a/mercurial/copies.py
+++ b/mercurial/copies.py
@@ -391,6 +391,9 @@
 othercopies = all_copies.get(c)
 if othercopies is None:
 all_copies[c] = newcopies
+elif newcopies is othercopies:
+# nothing to merge:
+pass
 else:
 # we are the second parent to work on c, we need to merge our
 # work with the other.



To: Alphare, #hg-reviewers
Cc: mercurial-patches, mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D9409: hg-core: add format-bytes dependency

2020-11-26 Thread Raphaël Gomès
Alphare created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  This will be used in the next patch to make error messages that require
  bytestring concatenation clearer.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  rust/Cargo.lock
  rust/hg-core/Cargo.toml

CHANGE DETAILS

diff --git a/rust/hg-core/Cargo.toml b/rust/hg-core/Cargo.toml
--- a/rust/hg-core/Cargo.toml
+++ b/rust/hg-core/Cargo.toml
@@ -26,6 +26,7 @@
 memmap = "0.7.0"
 zstd = "0.5.3"
 rust-crypto = "0.2.36"
+format-bytes = "0.1.2"
 
 # 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.
diff --git a/rust/Cargo.lock b/rust/Cargo.lock
--- a/rust/Cargo.lock
+++ b/rust/Cargo.lock
@@ -7,10 +7,10 @@
 
 [[package]]
 name = "aho-corasick"
-version = "0.7.13"
+version = "0.7.15"
 source = "registry+https://github.com/rust-lang/crates.io-index;
 dependencies = [
- "memchr 2.3.3 (registry+https://github.com/rust-lang/crates.io-index)",
+ "memchr 2.3.4 (registry+https://github.com/rust-lang/crates.io-index)",
 ]
 
 [[package]]
@@ -26,8 +26,8 @@
 version = "0.2.14"
 source = "registry+https://github.com/rust-lang/crates.io-index;
 dependencies = [
- "hermit-abi 0.1.16 (registry+https://github.com/rust-lang/crates.io-index)",
- "libc 0.2.77 (registry+https://github.com/rust-lang/crates.io-index)",
+ "hermit-abi 0.1.17 (registry+https://github.com/rust-lang/crates.io-index)",
+ "libc 0.2.80 (registry+https://github.com/rust-lang/crates.io-index)",
  "winapi 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)",
 ]
 
@@ -48,7 +48,7 @@
 
 [[package]]
 name = "cc"
-version = "1.0.60"
+version = "1.0.65"
 source = "registry+https://github.com/rust-lang/crates.io-index;
 dependencies = [
  "jobserver 0.1.21 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -60,6 +60,11 @@
 source = "registry+https://github.com/rust-lang/crates.io-index;
 
 [[package]]
+name = "cfg-if"
+version = "1.0.0"
+source = "registry+https://github.com/rust-lang/crates.io-index;
+
+[[package]]
 name = "clap"
 version = "2.33.3"
 source = "registry+https://github.com/rust-lang/crates.io-index;
@@ -74,22 +79,27 @@
 ]
 
 [[package]]
+name = "const_fn"
+version = "0.4.3"
+source = "registry+https://github.com/rust-lang/crates.io-index;
+
+[[package]]
 name = "cpython"
 version = "0.4.1"
 source = "registry+https://github.com/rust-lang/crates.io-index;
 dependencies = [
- "libc 0.2.77 (registry+https://github.com/rust-lang/crates.io-index)",
- "num-traits 0.2.12 (registry+https://github.com/rust-lang/crates.io-index)",
+ "libc 0.2.80 (registry+https://github.com/rust-lang/crates.io-index)",
+ "num-traits 0.2.14 (registry+https://github.com/rust-lang/crates.io-index)",
  "python27-sys 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)",
  "python3-sys 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)",
 ]
 
 [[package]]
 name = "crc32fast"
-version = "1.2.0"
+version = "1.2.1"
 source = "registry+https://github.com/rust-lang/crates.io-index;
 dependencies = [
- "cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)",
+ "cfg-if 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
 ]
 
 [[package]]
@@ -115,6 +125,15 @@
 ]
 
 [[package]]
+name = "crossbeam-channel"
+version = "0.5.0"
+source = "registry+https://github.com/rust-lang/crates.io-index;
+dependencies = [
+ "cfg-if 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
+ "crossbeam-utils 0.8.1 
(registry+https://github.com/rust-lang/crates.io-index)",
+]
+
+[[package]]
 name = "crossbeam-deque"
 version = "0.7.3"
 source = "registry+https://github.com/rust-lang/crates.io-index;
@@ -125,6 +144,16 @@
 ]
 
 [[package]]
+name = "crossbeam-deque"
+version = "0.8.0"
+source = "registry+https://github.com/rust-lang/crates.io-index;
+dependencies = [
+ "cfg-if 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
+ "crossbeam-epoch 0.9.1 
(registry+https://github.com/rust-lang/crates.io-index)",
+ "crossbeam-utils 0.8.1 
(registry+https://github.com/rust-lang/crates.io-index)",
+]
+
+[[package]]
 name = "crossbeam-epoch"
 version = "0.8.2"
 source = "registry+https://github.com/rust-lang/crates.io-index;
@@ -139,6 +168,19 @@
 ]
 
 [[package]]
+name = "crossbeam-epoch"
+version = "0.9.1"
+source = "registry+https://github.com/rust-lang/crates.io-index;
+dependencies = [
+ "cfg-if 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
+ "const_fn 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)",
+ "crossbeam-utils 0.8.1 
(registry+https://github.com/rust-lang/crates.io-index)",
+ "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
+ "memoffset 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)",
+ "scopeguard 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
+]

D9408: hg-core: add basic config module

2020-11-26 Thread Raphaël Gomès
Alphare created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  The config module exposes a `Config` struct, unused for now.
  
  It only reads the config file local to the repository, but handles all valid
  patterns and includes/unsets.
  It is structured in layers instead of erasing by reverse order of precedence,
  allowing us to transparently know more about the config for debugging 
purposes,
  and potentially other things I haven't thought about yet.
  
  This change also introduces `format_bytes!` to `hg-core`.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  rust/Cargo.lock
  rust/hg-core/Cargo.toml
  rust/hg-core/src/config.rs
  rust/hg-core/src/config/config.rs
  rust/hg-core/src/config/layer.rs
  rust/hg-core/src/lib.rs
  rust/hg-core/src/utils/files.rs

CHANGE DETAILS

diff --git a/rust/hg-core/src/utils/files.rs b/rust/hg-core/src/utils/files.rs
--- a/rust/hg-core/src/utils/files.rs
+++ b/rust/hg-core/src/utils/files.rs
@@ -18,6 +18,7 @@
 use same_file::is_same_file;
 use std::borrow::{Cow, ToOwned};
 use std::fs::Metadata;
+use std::io::Read;
 use std::iter::FusedIterator;
 use std::ops::Deref;
 use std::path::{Path, PathBuf};
@@ -308,6 +309,17 @@
 }
 }
 
+/// Reads a file in one big chunk instead of doing multiple reads
+pub fn read_whole_file(filepath: ) -> std::io::Result> {
+let mut file = std::fs::File::open(filepath)?;
+let size = file.metadata()?.len();
+
+let mut res = vec![0; size as usize];
+file.read_exact( res)?;
+
+Ok(res)
+}
+
 #[cfg(test)]
 mod tests {
 use super::*;
diff --git a/rust/hg-core/src/lib.rs b/rust/hg-core/src/lib.rs
--- a/rust/hg-core/src/lib.rs
+++ b/rust/hg-core/src/lib.rs
@@ -23,6 +23,7 @@
 pub mod matchers;
 pub mod revlog;
 pub use revlog::*;
+pub mod config;
 pub mod operations;
 pub mod utils;
 
diff --git a/rust/hg-core/src/config/layer.rs b/rust/hg-core/src/config/layer.rs
new file mode 100644
--- /dev/null
+++ b/rust/hg-core/src/config/layer.rs
@@ -0,0 +1,267 @@
+// layer.rs
+//
+// Copyright 2020
+//  Valentin Gatien-Baron,
+//  Raphaël Gomès 
+//
+// This software may be used and distributed according to the terms of the
+// GNU General Public License version 2 or any later version.
+
+//! Layering system for Mercurial config. See [crate::config::Config] for more
+//! details.
+use crate::utils::files::{
+get_bytes_from_path, get_path_from_bytes, read_whole_file,
+};
+use format_bytes::format_bytes;
+use lazy_static::lazy_static;
+use regex::bytes::Regex;
+use std::collections::HashMap;
+use std::io;
+use std::path::{Path, PathBuf};
+
+lazy_static! {
+static ref SECTION_RE: Regex = make_regex(r"^\[([^\[]+)\]");
+static ref ITEM_RE: Regex = make_regex(r"^([^=\s][^=]*?)\s*=\s*((.*\S)?)");
+/// Continuation whitespace
+static ref CONT_RE: Regex = make_regex(r"^\s+(\S|\S.*\S)\s*$");
+static ref EMPTY_RE: Regex = make_regex(r"^(;|#|\s*$)");
+static ref COMMENT_RE: Regex = make_regex(r"^(;|#)");
+/// A directive that allows for removing previous entries
+static ref UNSET_RE: Regex = make_regex(r"^%unset\s+(\S+)");
+/// A directive that allows for including other config files
+static ref INCLUDE_RE: Regex = make_regex(r"^%include\s+(\S|\S.*\S)\s*$");
+}
+
+#[derive(Clone)]
+pub struct ConfigLayer {
+/// Mapping of the sections to their items
+sections: HashMap, ConfigItem>,
+/// All sections (and their items/values) in a layer share the same origin
+pub origin: ConfigOrigin,
+/// Whether this layer comes from a trusted user or group
+pub trusted: bool,
+}
+
+impl ConfigLayer {
+pub fn new(origin: ConfigOrigin) -> Self {
+ConfigLayer {
+sections: HashMap::new(),
+trusted: true, // TODO check
+origin,
+}
+}
+
+/// Add an entry to the config, overwriting the old one if already present.
+pub fn add(
+ self,
+section: Vec,
+item: Vec,
+value: Vec,
+line: Option,
+) {
+self.sections
+.entry(section)
+.or_insert_with(|| HashMap::new())
+.insert(item, ConfigValue { bytes: value, line });
+}
+
+/// Returns the config value in `.` if it exists
+pub fn get(, section: &[u8], item: &[u8]) -> Option<> {
+Some(self.sections.get(section)?.get(item)?)
+}
+
+pub fn is_empty() -> bool {
+self.sections.is_empty()
+}
+
+/// Returns a `Vec` of layers in order of precedence (so, reverse from
+/// the read order), recursively parsing the `%include` directives if any.
+pub fn parse(src: , data: &[u8]) -> Result, ConfigError> {
+let mut layers = vec![];
+
+// Discard byte order mark if any
+

D9407: rhg: use `format_bytes!` for error messages

2020-11-26 Thread Raphaël Gomès
Alphare created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  This change also includes a formatting changing with the new `rustfmt` 
version,
  but I'm expecting it to have already been applied in another patch by the time
  this lands.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  rust/Cargo.lock
  rust/hg-core/src/dirstate/dirstate_tree/node.rs
  rust/rhg/Cargo.toml
  rust/rhg/src/commands/root.rs
  rust/rhg/src/error.rs
  rust/rhg/src/ui.rs

CHANGE DETAILS

diff --git a/rust/rhg/src/ui.rs b/rust/rhg/src/ui.rs
--- a/rust/rhg/src/ui.rs
+++ b/rust/rhg/src/ui.rs
@@ -1,3 +1,4 @@
+use format_bytes::format_bytes;
 use std::borrow::Cow;
 use std::io;
 use std::io::{ErrorKind, Write};
@@ -87,7 +88,10 @@
 let mut stderr = io::stderr();
 
 stderr
-.write_all(&[b"abort: ", error.to_string().as_bytes(), b"\n"].concat())
+.write_all(_bytes!(
+b"abort: {}\n",
+error.to_string().as_bytes()
+))
 .map_err(UiError::StderrError)?;
 
 stderr.flush().map_err(UiError::StderrError)?;
diff --git a/rust/rhg/src/error.rs b/rust/rhg/src/error.rs
--- a/rust/rhg/src/error.rs
+++ b/rust/rhg/src/error.rs
@@ -1,5 +1,6 @@
 use crate::exitcode;
 use crate::ui::UiError;
+use format_bytes::format_bytes;
 use hg::operations::{FindRootError, FindRootErrorKind};
 use hg::utils::files::get_bytes_from_path;
 use std::convert::From;
@@ -37,27 +38,17 @@
 /// Return the message corresponding to the error kind if any
 pub fn get_error_message_bytes() -> Option> {
 match self {
-// TODO use formating macro
 CommandErrorKind::RootNotFound(path) => {
 let bytes = get_bytes_from_path(path);
-Some(
-[
-b"abort: no repository found in '",
-bytes.as_slice(),
-b"' (.hg not found)!\n",
-]
-.concat(),
-)
+Some(format_bytes!(
+b"abort: no repository found in '{}' (.hg not found)!\n",
+bytes.as_slice()
+))
 }
-// TODO use formating macro
-CommandErrorKind::CurrentDirNotFound(e) => Some(
-[
-b"abort: error getting current working directory: ",
-e.to_string().as_bytes(),
-b"\n",
-]
-.concat(),
-),
+CommandErrorKind::CurrentDirNotFound(e) => Some(format_bytes!(
+b"abort: error getting current working directory: {}\n",
+e.to_string().as_bytes(),
+)),
 CommandErrorKind::Abort(message) => message.to_owned(),
 _ => None,
 }
diff --git a/rust/rhg/src/commands/root.rs b/rust/rhg/src/commands/root.rs
--- a/rust/rhg/src/commands/root.rs
+++ b/rust/rhg/src/commands/root.rs
@@ -1,6 +1,7 @@
 use crate::commands::Command;
 use crate::error::CommandError;
 use crate::ui::Ui;
+use format_bytes::format_bytes;
 use hg::operations::FindRoot;
 use hg::utils::files::get_bytes_from_path;
 
@@ -24,8 +25,7 @@
 
 let bytes = get_bytes_from_path(path_buf);
 
-// TODO use formating macro
-ui.write_stdout(&[bytes.as_slice(), b"\n"].concat())?;
+ui.write_stdout(_bytes!(b"{}\n", bytes.as_slice()))?;
 
 Ok(())
 }
diff --git a/rust/rhg/Cargo.toml b/rust/rhg/Cargo.toml
--- a/rust/rhg/Cargo.toml
+++ b/rust/rhg/Cargo.toml
@@ -1,7 +1,10 @@
 [package]
 name = "rhg"
 version = "0.1.0"
-authors = ["Antoine Cezar "]
+authors = [
+"Antoine Cezar ",
+"Raphaël Gomès ",
+]
 edition = "2018"
 
 [dependencies]
@@ -10,3 +13,4 @@
 log = "0.4.11"
 micro-timer = "0.3.1"
 env_logger = "0.7.1"
+format-bytes = "0.1.3"
diff --git a/rust/hg-core/src/dirstate/dirstate_tree/node.rs 
b/rust/hg-core/src/dirstate/dirstate_tree/node.rs
--- a/rust/hg-core/src/dirstate/dirstate_tree/node.rs
+++ b/rust/hg-core/src/dirstate/dirstate_tree/node.rs
@@ -93,11 +93,7 @@
 EntryState::Removed => {
 unreachable!("Removed file turning into a 
directory was dealt with earlier")
 }
-_ => {
-Node::insert_in_file(
-file, new_entry, head, tail,
-)
-}
+_ => Node::insert_in_file(file, new_entry, head, tail),
 }
 }

D9320: rust-status: don't bubble up os errors, translate them to bad matches

2020-11-16 Thread Raphaël Gomès
Alphare created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  In the rare cases when either the OS/filesystem throws an error on an 
otherwise
  valid action, or because a path is not representable on the filesystem, or
  because of concurrent actions in the filesystem, we want to warn the user 
about
  said path instead of bubbling up the error, causing an exception to be raised
  in the Python layer.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  rust/hg-core/src/dirstate/status.rs
  rust/hg-core/src/operations/dirstate_status.rs

CHANGE DETAILS

diff --git a/rust/hg-core/src/operations/dirstate_status.rs 
b/rust/hg-core/src/operations/dirstate_status.rs
--- a/rust/hg-core/src/operations/dirstate_status.rs
+++ b/rust/hg-core/src/operations/dirstate_status.rs
@@ -56,7 +56,7 @@
 .expect("old results should exist"),
  results,
 traversed_sender.clone(),
-)?;
+);
 }
 }
 _ => {
@@ -104,7 +104,7 @@
 _results,
  results,
 traversed_sender.clone(),
-)?;
+);
 }
 }
 _ => {
@@ -116,7 +116,7 @@
 
 if !self.matcher.is_exact() {
 if self.options.list_unknown {
-self.handle_unknowns( results)?;
+self.handle_unknowns( results);
 } else {
 // TODO this is incorrect, see issue6335
 // This requires a fix in both Python and Rust that can happen
diff --git a/rust/hg-core/src/dirstate/status.rs 
b/rust/hg-core/src/dirstate/status.rs
--- a/rust/hg-core/src/dirstate/status.rs
+++ b/rust/hg-core/src/dirstate/status.rs
@@ -109,6 +109,10 @@
 /// A path with its computed ``Dispatch`` information
 type DispatchedPath<'a> = (HgPathCow<'a>, Dispatch);
 
+/// The conversion from `HgPath` to a real fs path failed.
+/// `22` is the error code for "Invalid argument"
+const INVALID_PATH_DISPATCH: Dispatch = Dispatch::Bad(BadMatch::OsError(22));
+
 /// 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
@@ -217,6 +221,12 @@
 }
 }
 
+fn dispatch_os_error(e: ::io::Error) -> Dispatch {
+Dispatch::Bad(BadMatch::OsError(
+e.raw_os_error().expect("expected real OS error"),
+))
+}
+
 lazy_static! {
 static ref DEFAULT_WORK: HashSet<&'static HgPath> = {
 let mut h = HashSet::new();
@@ -372,13 +382,18 @@
 .file_set()
 .unwrap_or(_WORK)
 .par_iter()
-.map(|| -> Option> {
+.flat_map(|| -> Option<_> {
 // TODO normalization
 let normalized = filename;
 
 let buf = match hg_path_to_path_buf(normalized) {
 Ok(x) => x,
-Err(e) => return Some(Err(e.into())),
+Err(_) => {
+return Some((
+Cow::Borrowed(normalized),
+INVALID_PATH_DISPATCH,
+))
+}
 };
 let target = self.root_dir.join(buf);
 let st = target.symlink_metadata();
@@ -389,7 +404,7 @@
 return if file_type.is_file() || file_type.is_symlink()
 {
 if let Some(entry) = in_dmap {
-return Some(Ok((
+return Some((
 Cow::Borrowed(normalized),
 dispatch_found(
 ,
@@ -398,26 +413,26 @@
 _map,
 self.options,
 ),
-)));
+));
 }
-Some(Ok((
+Some((
 Cow::Borrowed(normalized),
 Dispatch::Unknown,
-)))
+))
 } else if file_type.is_dir() {
 if self.options.collect_traversed_dirs {
 traversed_sender
 .send(normalized.to_owned())
 

D9319: rust-status: properly translate OSError to Python

2020-11-16 Thread Raphaël Gomès
Alphare created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  This is probably never going to be called after the next few patches, but we
  might as well make sure this is done correctly for the future rewrite.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  rust/hg-cpython/src/dirstate/status.rs

CHANGE DETAILS

diff --git a/rust/hg-cpython/src/dirstate/status.rs 
b/rust/hg-cpython/src/dirstate/status.rs
--- a/rust/hg-cpython/src/dirstate/status.rs
+++ b/rust/hg-cpython/src/dirstate/status.rs
@@ -10,6 +10,7 @@
 //! `rustext.dirstate.status`.
 
 use crate::{dirstate::DirstateMap, exceptions::FallbackError};
+use cpython::exc::OSError;
 use cpython::{
 exc::ValueError, ObjectProtocol, PyBytes, PyErr, PyList, PyObject,
 PyResult, PyTuple, Python, PythonObject, ToPyObject,
@@ -89,6 +90,7 @@
 
 PyErr::new::(py, _string)
 }
+StatusError::IO(e) => PyErr::new::(py, e.to_string()),
 e => PyErr::new::(py, e.to_string()),
 }
 }



To: Alphare, #hg-reviewers
Cc: mercurial-patches, mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D9170: tests: only diff the `Cargo.lock` in `test-check-cargo-lock.t`

2020-10-08 Thread Raphaël Gomès
Alphare created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  While not perfect (you could be running tests while developing with a 
justified
  modification to `Cargo.lock`), that use-case is small enough that I don't 
think
  it's really going to be an issue.
  
  This stops the test from failing for unrelated changes when running it 
locally.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  tests/test-check-cargo-lock.t

CHANGE DETAILS

diff --git a/tests/test-check-cargo-lock.t b/tests/test-check-cargo-lock.t
--- a/tests/test-check-cargo-lock.t
+++ b/tests/test-check-cargo-lock.t
@@ -8,4 +8,4 @@
 
 However most CIs will run `cargo build` or similar before running the tests, 
so we need to check if it was modified
 
-  $ testrepohg diff
+  $ testrepohg diff Cargo.lock



To: Alphare, #hg-reviewers
Cc: mercurial-patches, mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D9149: py3: use native string when comparing with a function's argspec

2020-10-05 Thread Raphaël Gomès
Alphare created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  I only found two such bugs in `contrib/perf.py`

REPOSITORY
  rHG Mercurial

BRANCH
  stable

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

AFFECTED FILES
  contrib/perf.py

CHANGE DETAILS

diff --git a/contrib/perf.py b/contrib/perf.py
--- a/contrib/perf.py
+++ b/contrib/perf.py
@@ -231,7 +231,7 @@
 command = registrar.command(cmdtable)
 elif safehasattr(cmdutil, 'command'):
 command = cmdutil.command(cmdtable)
-if b'norepo' not in getargspec(command).args:
+if 'norepo' not in getargspec(command).args:
 # for "historical portability":
 # wrap original cmdutil.command, because "norepo" option has
 # been available since 3.1 (or 75a96326cecb)
@@ -805,7 +805,7 @@
 repo.ui.quiet = True
 matcher = scmutil.match(repo[None])
 opts[b'dry_run'] = True
-if b'uipathfn' in getargspec(scmutil.addremove).args:
+if 'uipathfn' in getargspec(scmutil.addremove).args:
 uipathfn = scmutil.getuipathfn(repo)
 timer(lambda: scmutil.addremove(repo, matcher, b"", uipathfn, 
opts))
 else:



To: Alphare, #hg-reviewers
Cc: mercurial-patches, mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D9138: rust: update minimum supported Rust compiler version

2020-10-01 Thread Raphaël Gomès
Alphare created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  Debian stable backported `rustc 1.41.1` for a Firefox release that needed it,
  so we can finally update the compiler version to something that isn't more 
than
  a year old.
  
  This means that (among other things [1]), `async await` syntax is usable!

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  rust/README.rst
  rust/hg-core/Cargo.toml

CHANGE DETAILS

diff --git a/rust/hg-core/Cargo.toml b/rust/hg-core/Cargo.toml
--- a/rust/hg-core/Cargo.toml
+++ b/rust/hg-core/Cargo.toml
@@ -27,10 +27,8 @@
 zstd = "0.5.3"
 rust-crypto = "0.2.36"
 
-# We don't use the `miniz-oxide` backend because its minimum Rust version is
-# `1.36`. However, this PR 
(https://github.com/Frommi/miniz_oxide/pull/84/files)
-# introduces a flag `no_extern_crate_alloc` to bring the requirement back down
-# to `1.34`.
+# 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.
 [dependencies.flate2]
 version = "1.0.16"
 features = ["zlib"]
diff --git a/rust/README.rst b/rust/README.rst
--- a/rust/README.rst
+++ b/rust/README.rst
@@ -52,8 +52,8 @@
 Developing Rust
 ===
 
-The current version of Rust in use is ``1.34.2``, because it's what Debian
-stable has. You can use ``rustup override set 1.34.2`` at the root of the repo
+The current version of Rust in use is ``1.41.1``, because it's what Debian
+stable has. You can use ``rustup override set 1.41.1`` at the root of the repo
 to make it easier on you.
 
 Go to the ``hg-cpython`` folder::



To: Alphare, #hg-reviewers
Cc: mercurial-patches, mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D9137: rust: leverage improved match ergonomics

2020-10-01 Thread Raphaël Gomès
Alphare created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  rust/hg-core/src/dirstate/status.rs

CHANGE DETAILS

diff --git a/rust/hg-core/src/dirstate/status.rs 
b/rust/hg-core/src/dirstate/status.rs
--- a/rust/hg-core/src/dirstate/status.rs
+++ b/rust/hg-core/src/dirstate/status.rs
@@ -730,7 +730,7 @@
 .symlink_metadata();
 
 match meta {
-Ok(ref m)
+Ok(m)
 if !(m.file_type().is_file()
 || m.file_type().is_symlink()) =>
 {
@@ -749,7 +749,7 @@
 );
 Ok((Cow::Owned(filename), dispatch))
 }
-Err(ref e)
+Err(e)
 if e.kind() == ErrorKind::NotFound
 || e.raw_os_error() == Some(20) =>
 {
@@ -783,7 +783,7 @@
 let meta =
 self.root_dir.join(filename_as_path).symlink_metadata();
 match meta {
-Ok(ref m)
+Ok(m)
 if !(m.file_type().is_file()
 || m.file_type().is_symlink()) =>
 {
@@ -802,7 +802,7 @@
 self.options,
 ),
 )),
-Err(ref e)
+Err(e)
 if e.kind() == ErrorKind::NotFound
 || e.raw_os_error() == Some(20) =>
 {



To: Alphare, #hg-reviewers
Cc: mercurial-patches, mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D9136: rust-parsers: use in-place mutation instead of allocating a new `Vec`

2020-10-01 Thread Raphaël Gomès
Alphare created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  This is not done for the `dirstate-tree` feature, since it lacks `iter_mut`.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  rust/hg-core/src/dirstate/parsers.rs

CHANGE DETAILS

diff --git a/rust/hg-core/src/dirstate/parsers.rs 
b/rust/hg-core/src/dirstate/parsers.rs
--- a/rust/hg-core/src/dirstate/parsers.rs
+++ b/rust/hg-core/src/dirstate/parsers.rs
@@ -107,12 +107,11 @@
 let expected_size = expected_size + PARENT_SIZE * 2;
 
 let mut packed = Vec::with_capacity(expected_size);
-let mut new_state_map = vec![];
 
 packed.extend();
 packed.extend();
 
-for (filename, entry) in state_map.iter() {
+for (filename, entry) in state_map.iter_mut() {
 let new_filename = filename.to_owned();
 let mut new_mtime: i32 = entry.mtime;
 if entry.state == EntryState::Normal && entry.mtime == now {
@@ -126,13 +125,10 @@
 // contents of the file if the size is the same. This prevents
 // mistakenly treating such files as clean.
 new_mtime = -1;
-new_state_map.push((
-filename.to_owned(),
-DirstateEntry {
-mtime: new_mtime,
-..*entry
-},
-));
+*entry = DirstateEntry {
+mtime: new_mtime,
+..*entry
+};
 }
 let mut new_filename = new_filename.into_vec();
 if let Some(copy) = copy_map.get(filename) {
@@ -152,8 +148,6 @@
 return Err(DirstatePackError::BadSize(expected_size, packed.len()));
 }
 
-state_map.extend(new_state_map);
-
 Ok(packed)
 }
 /// `now` is the duration in seconds since the Unix epoch



To: Alphare, #hg-reviewers
Cc: mercurial-patches, mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D9133: rust: start plugging the dirstate tree behind a feature gate

2020-09-30 Thread Raphaël Gomès
Alphare created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  The previous patch added the `dirstate-tree` feature gate to enable the two
  dirstate implementations to co-habit while the tree-based one gets better.
  
  This patch copies over the code that differs, be it because the algorithm
  changed or because the borrowing rules are different.
  
  Indeed, `DirstateTree` is not observationally equivalent to the std `HashMap` 
in
  the APIs we use: it does not have the `Entry` API (yet?) and its iterator
  returns owned values instead of references. This last point is because the
  implementation needs to be changed to a more clever and efficient solution.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  rust/hg-core/src/dirstate.rs
  rust/hg-core/src/dirstate/dirs_multiset.rs
  rust/hg-core/src/dirstate/dirstate_map.rs
  rust/hg-core/src/dirstate/parsers.rs
  rust/hg-core/src/dirstate/status.rs
  rust/hg-core/src/operations/dirstate_status.rs
  rust/hg-cpython/src/dirstate/dirstate_map.rs
  rust/hg-cpython/src/dirstate/status.rs
  rust/hg-cpython/src/parsers.rs

CHANGE DETAILS

diff --git a/rust/hg-cpython/src/parsers.rs b/rust/hg-cpython/src/parsers.rs
--- a/rust/hg-cpython/src/parsers.rs
+++ b/rust/hg-cpython/src/parsers.rs
@@ -119,11 +119,11 @@
 Duration::from_secs(now.as_object().extract::(py)?),
 ) {
 Ok(packed) => {
-for (filename, entry) in _map {
+for (filename, entry) in dirstate_map.iter() {
 dmap.set_item(
 py,
 PyBytes::new(py, filename.as_bytes()),
-make_dirstate_tuple(py, entry)?,
+make_dirstate_tuple(py, )?,
 )?;
 }
 Ok(PyBytes::new(py, ))
diff --git a/rust/hg-cpython/src/dirstate/status.rs 
b/rust/hg-cpython/src/dirstate/status.rs
--- a/rust/hg-cpython/src/dirstate/status.rs
+++ b/rust/hg-cpython/src/dirstate/status.rs
@@ -159,7 +159,7 @@
 .collect();
 
 let files = files?;
-let matcher = FileMatcher::new()
+let matcher = FileMatcher::new(files.as_ref())
 .map_err(|e| PyErr::new::(py, e.to_string()))?;
 let ((lookup, status_res), warnings) = status(
 ,
diff --git a/rust/hg-cpython/src/dirstate/dirstate_map.rs 
b/rust/hg-cpython/src/dirstate/dirstate_map.rs
--- a/rust/hg-cpython/src/dirstate/dirstate_map.rs
+++ b/rust/hg-cpython/src/dirstate/dirstate_map.rs
@@ -142,10 +142,10 @@
 })?,
 )
 .and_then(|b| Ok(b.to_py_object(py)))
-.or_else(|_| {
+.or_else(|e| {
 Err(PyErr::new::(
 py,
-"Dirstate error".to_string(),
+format!("Dirstate error: {}", e.to_string()),
 ))
 })
 }
@@ -549,12 +549,14 @@
 ) -> Ref<'a, RustDirstateMap> {
 self.inner(py).borrow()
 }
+#[cfg(not(feature = "dirstate-tree"))]
 fn translate_key(
 py: Python,
 res: (, ),
 ) -> PyResult> {
 Ok(Some(PyBytes::new(py, res.0.as_bytes(
 }
+#[cfg(not(feature = "dirstate-tree"))]
 fn translate_key_value(
 py: Python,
 res: (, ),
@@ -562,7 +564,25 @@
 let (f, entry) = res;
 Ok(Some((
 PyBytes::new(py, f.as_bytes()),
-make_dirstate_tuple(py, entry)?,
+make_dirstate_tuple(py, )?,
+)))
+}
+#[cfg(feature = "dirstate-tree")]
+fn translate_key(
+py: Python,
+res: (HgPathBuf, DirstateEntry),
+) -> PyResult> {
+Ok(Some(PyBytes::new(py, res.0.as_bytes(
+}
+#[cfg(feature = "dirstate-tree")]
+fn translate_key_value(
+py: Python,
+res: (HgPathBuf, DirstateEntry),
+) -> PyResult> {
+let (f, entry) = res;
+Ok(Some((
+PyBytes::new(py, f.as_bytes()),
+make_dirstate_tuple(py, )?,
 )))
 }
 }
diff --git a/rust/hg-core/src/operations/dirstate_status.rs 
b/rust/hg-core/src/operations/dirstate_status.rs
--- a/rust/hg-core/src/operations/dirstate_status.rs
+++ b/rust/hg-core/src/operations/dirstate_status.rs
@@ -14,6 +14,66 @@
 /// files.
 pub type LookupAndStatus<'a> = (Vec>, DirstateStatus<'a>);
 
+#[cfg(feature = "dirstate-tree")]
+impl<'a, M: Matcher + Sync> Status<'a, M> {
+pub(crate) fn run() -> Result, StatusError> {
+let (traversed_sender, traversed_receiver) =
+crossbeam::channel::unbounded();
+
+// Step 1: check the files explicitly mentioned by the user
+let (work, mut results) = self.walk_explicit(traversed_sender.clone());
+
+// Step 2: Check files in the dirstate
+if !self.matcher.is_exact() {
+self.extend_from_dmap( 

D9132: rust: introduce `dirstate-tree` cargo feature

2020-09-30 Thread Raphaël Gomès
Alphare created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  This feature gates (at compile-time) the use of the newly-added dirstate tree.
  
  The motivation for this is that the dirstate tree is currently *very* slow;
  replacing the current hashmap-based dirstate is not a viable solution in terms
  of performance... and why would you be using the Rust implementation if not
  for performance?
  
  The feature will also help reviewers better understand the differences that
  will slowly appear as the dirstate tree gets better.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  Makefile
  contrib/heptapod-ci.yml
  rust/README.rst
  rust/hg-core/Cargo.toml
  rust/hg-core/src/dirstate.rs
  rust/hg-cpython/Cargo.toml

CHANGE DETAILS

diff --git a/rust/hg-cpython/Cargo.toml b/rust/hg-cpython/Cargo.toml
--- a/rust/hg-cpython/Cargo.toml
+++ b/rust/hg-cpython/Cargo.toml
@@ -10,6 +10,7 @@
 
 [features]
 default = ["python27"]
+dirstate-tree = ["hg-core/dirstate-tree"]
 
 # Features to build an extension module:
 python27 = ["cpython/python27-sys", "cpython/extension-module-2-7"]
diff --git a/rust/hg-core/src/dirstate.rs b/rust/hg-core/src/dirstate.rs
--- a/rust/hg-core/src/dirstate.rs
+++ b/rust/hg-core/src/dirstate.rs
@@ -11,6 +11,7 @@
 
 pub mod dirs_multiset;
 pub mod dirstate_map;
+#[cfg(feature = "dirstate-tree")]
 pub mod dirstate_tree;
 pub mod parsers;
 pub mod status;
diff --git a/rust/hg-core/Cargo.toml b/rust/hg-core/Cargo.toml
--- a/rust/hg-core/Cargo.toml
+++ b/rust/hg-core/Cargo.toml
@@ -40,3 +40,9 @@
 clap = "*"
 pretty_assertions = "0.6.1"
 tempfile = "3.1.0"
+
+[features]
+# Use a (still unoptimized) tree for the dirstate instead of the current flat
+# dirstate. This is not yet recommended for performance reasons. A future
+# version might make it the default, or make it a runtime option.
+dirstate-tree = []
diff --git a/rust/README.rst b/rust/README.rst
--- a/rust/README.rst
+++ b/rust/README.rst
@@ -34,6 +34,15 @@
 One day we may use this environment variable to switch to new experimental
 binding crates like a hypothetical ``HGWITHRUSTEXT=hpy``.
 
+Special features
+
+
+You might want to check the `features` section in ``hg-cpython/Cargo.toml``.
+It may contain features that might be interesting to try out.
+
+To use features from the Makefile, use the `HG_RUST_FEATURES` environment 
+variable: for instance `HG_RUST_FEATURES="some-feature other-feature"`
+
 Profiling
 =
 
diff --git a/contrib/heptapod-ci.yml b/contrib/heptapod-ci.yml
--- a/contrib/heptapod-ci.yml
+++ b/contrib/heptapod-ci.yml
@@ -41,6 +41,12 @@
 variables:
 PYTHON: python3
 
+rust-cargo-test-py3-dirstate-tree:
+<<: *rust_cargo_test
+variables:
+PYTHON: python3
+HG_RUST_FEATURES: dirstate-tree
+
 test-py2:
 <<: *runtests
 variables:
@@ -82,6 +88,15 @@
 PYTHON: python3
 TEST_HGMODULEPOLICY: "rust+c"
 
+test-py3-rust-dirstate-tree:
+<<: *runtests
+variables:
+HGWITHRUSTEXT: cpython
+RUNTEST_ARGS: "--rust --blacklist /tmp/check-tests.txt"
+PYTHON: python3
+TEST_HGMODULEPOLICY: "rust+c"
+HG_RUST_FEATURES: "dirstate-tree"
+
 test-py2-chg:
 <<: *runtests
 variables:
diff --git a/Makefile b/Makefile
--- a/Makefile
+++ b/Makefile
@@ -133,7 +133,7 @@
 rust-tests:
cd $(HGROOT)/rust/hg-cpython \
&& $(CARGO) test --quiet --all \
-   --no-default-features --features "$(py_feature)"
+   --no-default-features --features "$(py_feature) 
$(HG_RUST_FEATURES)"
 
 check-code:
hg manifest | xargs python contrib/check-code.py



To: Alphare, #hg-reviewers
Cc: mercurial-patches, mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


Re: Improving the CI experience

2020-09-29 Thread Raphaël Gomès


On 9/28/20 8:12 PM, Augie Fackler wrote:



On Sep 28, 2020, at 10:43, Raphaël Gomès <mailto:raphael.go...@octobus.net>> wrote:


Hi all,

As you may know, we (Octobus) and other Mercurial contributors have 
been using
the Heptapod [1] CI to vet our patches pre-submission against 7 
variants of

Mercurial:
- Python 2 pure
- Python 3 pure
- Python 2 python+c
- Python 3 python+c
- Python 2 rust+c
- Python 3 rust+c
- Python 2 chg
- (also code checks and Rust unit tests, of course)

All variants above are run on x86_64 Debian machines. Our CI does not 
(yet) have

the MacOS, Windows, or FreeBSDoptionsthat the Mercurial Buildbot has, but
does test more variants on Linux.

Nevertheless, it catches a lot of the mistakes that we all make 
sometimes,
before we even send the patches upstream: regressions in Python 3, 
API breakage
with Rust, bad formatting, and other bugs of various nature. It does 
so way

before it touches the `committed` repo, which means that if I screw up my
patch, it only has to bother me.

The value of such a system is highly dependent on it being 
trustworthy: flaky
tests do exist, but they should be addressed and fixed in a timely 
manner and
my CI being red should mean that *I* missed something. Yet, I have 
heard the
phrase "I don't even look at the pipelines anymore, they're always 
broken for

something I haven't done".

Most of the time it's something minor: I've even been guilty of 
breaking the CI
myself in my last patch series (oops) due to bad formatting! However, 
these
issues should be few and far between: the developer experience 
suffers greatly
and we grow to accept that the tests are always broken, don't bother 
to run

them at all, etc.

# Proposal

I thought a start to fixing this situation would be for me to setup
an automation to send a small email to this mailing-list every time 
either the
`stable` or `default` branches (that track `hg-committed`) are 
broken, with a link

to the pipeline results.
This will not catch everything (only a subset of the possible targets 
is tested), but
I think this would be an improvement for all contributors, even those 
that don't

use Heptapod.

What do you all think?


I'm open to it. Do you think the CI that you're running on heptapod is 
faster than the buildbot? Should we keep the buildbot or shut it down?


Faster in terms of latency, almost certainly, at least for now because 
of the number of workers, and probably in terms of the actual speed of 
the runners, though I'm just making a guess.


However, the Buildbot still has value since it covers cases that our CI 
still does not cover and not everyone is using Heptapod, so let's keep 
it around for a while. To further drive the point home, I'm not 
comfortable recommending Heptapod for the project or anything of that 
sort yet, even ruling out personal preferences for workflow. Maybe we 
can have that discussion in a few months, who knows.


The fact that the Buildbot runs *after* the patches have landed makes me 
sad, but that's an issue for another day probably!



Raphaël

[1] https://foss.heptapod.net/octobus/mercurial-devel/-/pipelines
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org 
<mailto:Mercurial-devel@mercurial-scm.org>

https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel



___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


Improving the CI experience

2020-09-28 Thread Raphaël Gomès

Hi all,

As you may know, we (Octobus) and other Mercurial contributors have been 
using

the Heptapod [1] CI to vet our patches pre-submission against 7 variants of
Mercurial:
- Python 2 pure
- Python 3 pure
- Python 2 python+c
- Python 3 python+c
- Python 2 rust+c
- Python 3 rust+c
- Python 2 chg
- (also code checks and Rust unit tests, of course)

All variants above are run on x86_64 Debian machines. Our CI does not 
(yet) have

the MacOS, Windows, or FreeBSDoptionsthat the Mercurial Buildbot has, but
does test more variants on Linux.

Nevertheless, it catches a lot of the mistakes that we all make sometimes,
before we even send the patches upstream: regressions in Python 3, API 
breakage

with Rust, bad formatting, and other bugs of various nature. It does so way
before it touches the `committed` repo, which means that if I screw up my
patch, it only has to bother me.

The value of such a system is highly dependent on it being trustworthy: 
flaky
tests do exist, but they should be addressed and fixed in a timely 
manner and

my CI being red should mean that *I* missed something. Yet, I have heard the
phrase "I don't even look at the pipelines anymore, they're always 
broken for

something I haven't done".

Most of the time it's something minor: I've even been guilty of breaking 
the CI

myself in my last patch series (oops) due to bad formatting! However, these
issues should be few and far between: the developer experience suffers 
greatly

and we grow to accept that the tests are always broken, don't bother to run
them at all, etc.

# Proposal

I thought a start to fixing this situation would be for me to setup
an automation to send a small email to this mailing-list every time 
either the
`stable` or `default` branches (that track `hg-committed`) are broken, 
with a link

to the pipeline results.
This will not catch everything (only a subset of the possible targets is 
tested), but
I think this would be an improvement for all contributors, even those 
that don't

use Heptapod.

What do you all think?
Raphaël

[1] https://foss.heptapod.net/octobus/mercurial-devel/-/pipelines
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D9094: rust: clippy pass

2020-09-28 Thread Raphaël Gomès
Alphare created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  This removes some justified warnings and one hard error that, while 
technically
  not a bug, was an ugly oversight on my part.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  rust/hg-core/src/dirstate/dirstate_tree/iter.rs
  rust/hg-core/src/dirstate/dirstate_tree/node.rs

CHANGE DETAILS

diff --git a/rust/hg-core/src/dirstate/dirstate_tree/node.rs 
b/rust/hg-core/src/dirstate/dirstate_tree/node.rs
--- a/rust/hg-core/src/dirstate/dirstate_tree/node.rs
+++ b/rust/hg-core/src/dirstate/dirstate_tree/node.rs
@@ -91,9 +91,9 @@
 
 match  self.kind {
 NodeKind::Directory(directory) => {
-return Node::insert_in_directory(
+Node::insert_in_directory(
 directory, new_entry, head, tail,
-);
+)
 }
 NodeKind::File(_) => {
 unreachable!("The file case has already been handled")
@@ -227,7 +227,7 @@
 d.children.remove(head);
 }
 res.cleanup =
-d.children.len() == 0 && d.was_file.is_none();
+d.children.is_empty() && d.was_file.is_none();
 res
 } else {
 empty_result
@@ -241,7 +241,7 @@
 if cleanup {
 d.children.remove(head);
 }
-if d.children.len() == 0 && d.was_file.is_none() {
+if d.children.is_empty() && d.was_file.is_none() {
 f.was_directory = None;
 }
 
@@ -288,7 +288,7 @@
 }
 
 RemoveResult {
-cleanup: cleanup,
+cleanup,
 old_entry: Some(entry),
 }
 }
diff --git a/rust/hg-core/src/dirstate/dirstate_tree/iter.rs 
b/rust/hg-core/src/dirstate/dirstate_tree/iter.rs
--- a/rust/hg-core/src/dirstate/dirstate_tree/iter.rs
+++ b/rust/hg-core/src/dirstate/dirstate_tree/iter.rs
@@ -160,7 +160,7 @@
 let meta = self.root_dir.join(filename_as_path).symlink_metadata();
 match meta {
 Ok(ref m) if m.file_type().is_symlink() => true,
-_ => return false,
+_ => false,
 }
 }
 }
@@ -182,7 +182,7 @@
 
 fn next( self) -> Option {
 // If any paths have already been `Dispatch`-ed, return them
-while let Some(res) = self.shortcuts.pop_front() {
+if let Some(res) = self.shortcuts.pop_front() {
 return Some(res);
 }
 
@@ -250,7 +250,7 @@
 ) {
 to_visit.extend(dir.children.iter().map(|(path, child)| {
 let full_path = join_path(_path, );
-(Cow::from(full_path), child)
+(full_path, child)
 }));
 }
 



To: Alphare, #hg-reviewers
Cc: mercurial-patches, mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D9093: rust: format with rustfmt

2020-09-28 Thread Raphaël Gomès
Alphare created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  I suppose I ran the formatter on the tip but not on every patch.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  rust/hg-core/src/dirstate/dirstate_map.rs
  rust/hg-core/src/dirstate/dirstate_tree/iter.rs
  rust/hg-core/src/dirstate/dirstate_tree/node.rs
  rust/hg-core/src/dirstate/dirstate_tree/tree.rs

CHANGE DETAILS

diff --git a/rust/hg-core/src/dirstate/dirstate_tree/tree.rs 
b/rust/hg-core/src/dirstate/dirstate_tree/tree.rs
--- a/rust/hg-core/src/dirstate/dirstate_tree/tree.rs
+++ b/rust/hg-core/src/dirstate/dirstate_tree/tree.rs
@@ -136,7 +136,11 @@
 
 /// Low-level insertion method that returns the previous node (directories
 /// included).
-fn insert_node( self, path: impl AsRef, kind: DirstateEntry) 
-> Option {
+fn insert_node(
+ self,
+path: impl AsRef,
+kind: DirstateEntry,
+) -> Option {
 let InsertResult {
 did_insert,
 old_entry,
@@ -154,7 +158,9 @@
 pub fn get(, path: impl AsRef) -> Option<> {
 if let Some(node) = self.get_node() {
 return match  {
-NodeKind::Directory(d) => d.was_file.as_ref().map(|f| 
),
+NodeKind::Directory(d) => {
+d.was_file.as_ref().map(|f| )
+}
 NodeKind::File(f) => Some(),
 };
 }
@@ -168,10 +174,15 @@
 
 /// Returns a mutable reference to the entry corresponding to `path` if it
 /// exists.
-pub fn get_mut( self, path: impl AsRef) -> Option< 
DirstateEntry> {
+pub fn get_mut(
+ self,
+path: impl AsRef,
+) -> Option< DirstateEntry> {
 if let Some(kind) = self.root.get_mut(path.as_ref().as_bytes()) {
 return match kind {
-NodeKind::Directory(d) => d.was_file.as_mut().map(|f|  
f.entry),
+NodeKind::Directory(d) => {
+d.was_file.as_mut().map(|f|  f.entry)
+}
 NodeKind::File(f) => Some( f.entry),
 };
 }
@@ -192,8 +203,12 @@
 }
 
 /// Remove the entry at `path` and returns it, if it exists.
-pub fn remove( self, path: impl AsRef) -> 
Option {
-let RemoveResult { old_entry, .. } = 
self.root.remove(path.as_ref().as_bytes());
+pub fn remove(
+ self,
+path: impl AsRef,
+) -> Option {
+let RemoveResult { old_entry, .. } =
+self.root.remove(path.as_ref().as_bytes());
 self.files_count = self
 .files_count
 .checked_sub(if old_entry.is_some() { 1 } else { 0 })
@@ -344,7 +359,10 @@
 size: 30,
 };
 assert_eq!(tree.insert_node(HgPath::new(b"foo"), entry), None);
-assert_eq!(tree.insert_node(HgPath::new(b"foo/a"), removed_entry), 
None);
+assert_eq!(
+tree.insert_node(HgPath::new(b"foo/a"), removed_entry),
+None
+);
 // The insert should not turn `foo` into a directory as `foo` is not
 // `Removed`.
 match tree.get_node(HgPath::new(b"foo")).unwrap().kind {
@@ -516,7 +534,10 @@
 ..entry
 };
 assert_eq!(tree.insert(HgPath::new(b"a"), entry), None);
-assert_eq!(tree.insert_node(HgPath::new(b"a/b/x"), removed_entry), 
None);
+assert_eq!(
+tree.insert_node(HgPath::new(b"a/b/x"), removed_entry),
+None
+);
 assert_eq!(tree.files_count, 2);
 dbg!();
 assert_eq!(tree.remove(HgPath::new(b"a")), Some(entry));
diff --git a/rust/hg-core/src/dirstate/dirstate_tree/node.rs 
b/rust/hg-core/src/dirstate/dirstate_tree/node.rs
--- a/rust/hg-core/src/dirstate/dirstate_tree/node.rs
+++ b/rust/hg-core/src/dirstate/dirstate_tree/node.rs
@@ -48,7 +48,11 @@
 }
 
 impl Node {
-pub fn insert( self, path: &[u8], new_entry: DirstateEntry) -> 
InsertResult {
+pub fn insert(
+ self,
+path: &[u8],
+new_entry: DirstateEntry,
+) -> InsertResult {
 let mut split = path.splitn(2, || c == b'/');
 let head = split.next().unwrap_or(b"");
 let tail = split.next().unwrap_or(b"");
@@ -76,16 +80,24 @@
 children: Default::default(),
 })
 }
-_ => return Node::insert_in_file(file, new_entry, head, 
tail),
+_ => {
+return Node::insert_in_file(
+file, new_entry, head, tail,
+)
+}
 }
 }
 }
 
 match  self.kind {
 NodeKind::Directory(directory) => {
-return Node::insert_in_directory(directory, new_entry, head, 
tail);
+return 

D9085: rust: add `dirstate_tree` module

2020-09-25 Thread Raphaël Gomès
Alphare created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  Mercurial needs to represent the filesystem hierarchy on which it operates, 
for
  example in the dirstate. Its current on-disk representation is an unsorted, 
flat
  structure that gets transformed in the current Rust code into a `HashMap`.
  This loses the hierarchical information of the dirstate, leading to some
  unfortunate performance and algorithmic compromises.
  
  This module adds an implementation of a radix tree that is specialized for
  representing the dirstate: its unit is the path component. I have made no
  efforts to optimize either its memory footprint or its insertion speed: 
they're
  pretty bad for now.
  
  Following will be a few patches that modify the dirstate.status logic to use
  that new hierarchical information, fixing issue 6335 in the same swing.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  rust/hg-core/src/dirstate.rs
  rust/hg-core/src/dirstate/dirstate_tree.rs
  rust/hg-core/src/dirstate/dirstate_tree/iter.rs
  rust/hg-core/src/dirstate/dirstate_tree/node.rs
  rust/hg-core/src/dirstate/dirstate_tree/tree.rs

CHANGE DETAILS

diff --git a/rust/hg-core/src/dirstate/dirstate_tree/tree.rs 
b/rust/hg-core/src/dirstate/dirstate_tree/tree.rs
new file mode 100644
--- /dev/null
+++ b/rust/hg-core/src/dirstate/dirstate_tree/tree.rs
@@ -0,0 +1,682 @@
+// tree.rs
+//
+// Copyright 2020, Raphaël Gomès 
+//
+// This software may be used and distributed according to the terms of the
+// GNU General Public License version 2 or any later version.
+
+use super::iter::Iter;
+use super::node::{Directory, Node, NodeKind};
+use crate::dirstate::dirstate_tree::iter::FsIter;
+use crate::dirstate::dirstate_tree::node::{InsertResult, RemoveResult};
+use crate::utils::hg_path::{HgPath, HgPathBuf};
+use crate::DirstateEntry;
+use std::path::PathBuf;
+
+/// A specialized tree to represent the Mercurial dirstate.
+///
+/// # Advantages over a flat structure
+///
+/// The dirstate is inherently hierarchical, since it's a representation of the
+/// file structure of the project. The current dirstate format is flat, and
+/// while that affords us potentially great (unordered) iteration speeds, the
+/// need to retrieve a given path is great enough that you need some kind of
+/// hashmap or tree in a lot of cases anyway.
+///
+/// Going with a tree allows us to be smarter:
+///   - Skipping an ignored directory means we don't visit its entire subtree
+///   - Security auditing does not need to reconstruct paths backwards to check
+/// for symlinked directories, this can be done during the iteration in a
+/// very efficient fashion
+///   - We don't need to build the directory information in another struct,
+/// simplifying the code a lot, reducing the memory footprint and
+/// potentially going faster depending on the implementation.
+///   - We can use it to store a (platform-dependent) caching mechanism [1]
+///   - And probably other types of optimizations.
+///
+/// Only the first two items in this list are implemented as of this commit.
+///
+/// [1]: https://www.mercurial-scm.org/wiki/DirsCachePlan
+///   
+///
+/// # Structure
+///
+/// It's a prefix (radix) tree with no fixed arity, with a granularity of a
+/// folder, allowing it to mimic a filesystem hierarchy:
+///
+/// ```text
+/// foo/bar
+/// foo/baz
+/// test
+/// ```
+/// Will be represented (simplified) by:
+///
+/// ```text
+/// Directory(root):
+///   - File("test")
+///   - Directory("foo"):
+/// - File("bar")
+/// - File("baz")
+/// ```
+///
+/// Moreover, it is special-cased for storing the dirstate and as such handles
+/// cases that a simple `HashMap` would handle, but while preserving the
+/// hierarchy.
+/// For example:
+///
+/// ```shell
+/// $ touch foo
+/// $ hg add foo
+/// $ hg commit -m "foo"
+/// $ hg remove foo
+/// $ rm foo
+/// $ mkdir foo
+/// $ touch foo/a
+/// $ hg add foo/a
+/// $ hg status
+///   R foo
+///   A foo/a
+/// ```
+/// To represent this in a tree, one needs to keep track of whether any given
+/// file was a directory and whether any given directory was a file at the last
+/// dirstate update. This tree stores that information, but only in the right
+/// circumstances by respecting the high-level rules that prevent nonsensical
+/// structures to exist:
+/// - a file can only be added as a child of another file if the latter is
+///   marked as `Removed`
+/// - a file cannot replace a folder unless all its descendents are removed
+///
+/// This second rule is not checked by the tree for performance reasons, and
+/// because high-level logic already prevents that state from happening.
+///
+/// # Ordering
+///
+/// It makes no guarantee of ordering for now.
+#[derive(Debug, Default, Clone, PartialEq)]
+pub s

D9084: rust-dirstatemap: add #[timed] to dirstatemap read for comparison

2020-09-25 Thread Raphaël Gomès
Alphare created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  rust/hg-core/src/dirstate/dirstate_map.rs

CHANGE DETAILS

diff --git a/rust/hg-core/src/dirstate/dirstate_map.rs 
b/rust/hg-core/src/dirstate/dirstate_map.rs
--- a/rust/hg-core/src/dirstate/dirstate_map.rs
+++ b/rust/hg-core/src/dirstate/dirstate_map.rs
@@ -15,6 +15,7 @@
 CopyMap, DirsMultiset, DirstateEntry, DirstateError, DirstateMapError,
 DirstateParents, DirstateParseError, FastHashMap, StateMap,
 };
+use micro_timer::timed;
 use core::borrow::Borrow;
 use std::collections::HashSet;
 use std::convert::TryInto;
@@ -356,6 +357,7 @@
 self.dirty_parents = true;
 }
 
+#[timed]
 pub fn read(
  self,
 file_contents: &[u8],



To: Alphare, #hg-reviewers
Cc: mercurial-patches, mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D9079: rust-tests: add test to check if `Cargo.lock` is up-to-date

2020-09-24 Thread Raphaël Gomès
Alphare created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  An out-of-date `Cargo.lock` is the source of rebase conflicts, prevents a
  reproductible build, introduces desync between the series that introduces a
  change in dependencies and the one that eventually commits the `Cargo.lock`,
  and is just a general annoyance.
  
  This commit demonstrates that the test works, the next one fixes the
  currently out-of-date `Cargo.lock`.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  tests/hghave.py
  tests/test-check-cargo-lock.t

CHANGE DETAILS

diff --git a/tests/test-check-cargo-lock.t b/tests/test-check-cargo-lock.t
new file mode 100644
--- /dev/null
+++ b/tests/test-check-cargo-lock.t
@@ -0,0 +1,11 @@
+#require cargo test-repo
+  $ . "$TESTDIR/helpers-testrepo.sh"
+  $ cd "$TESTDIR"/../rust
+
+Check if Cargo.lock is up-to-date. Will fail with a 101 error code if not.
+
+  $ cargo check --locked --all --quiet
+
+However most CIs will run `cargo build` or similar before running the tests, 
so we need to check if it was modified
+
+  $ testrepohg diff
diff --git a/tests/hghave.py b/tests/hghave.py
--- a/tests/hghave.py
+++ b/tests/hghave.py
@@ -1066,6 +1066,11 @@
 )
 
 
+@check("cargo", "cargo tool")
+def has_cargo():
+return matchoutput('`rustup which cargo` --version', b'cargo')
+
+
 @check("lzma", "python lzma module")
 def has_lzma():
 try:



To: Alphare, #hg-reviewers
Cc: mercurial-patches, mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D9080: rust: update Cargo.lock

2020-09-24 Thread Raphaël Gomès
Alphare created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  rust/Cargo.lock

CHANGE DETAILS

diff --git a/rust/Cargo.lock b/rust/Cargo.lock
--- a/rust/Cargo.lock
+++ b/rust/Cargo.lock
@@ -711,6 +711,16 @@
 ]
 
 [[package]]
+name = "time"
+version = "0.1.44"
+source = "registry+https://github.com/rust-lang/crates.io-index;
+dependencies = [
+ "libc 0.2.77 (registry+https://github.com/rust-lang/crates.io-index)",
+ "wasi 0.10.0+wasi-snapshot-preview1 
(registry+https://github.com/rust-lang/crates.io-index)",
+ "winapi 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)",
+]
+
+[[package]]
 name = "twox-hash"
 version = "1.5.0"
 source = "registry+https://github.com/rust-lang/crates.io-index;
@@ -744,6 +754,11 @@
 source = "registry+https://github.com/rust-lang/crates.io-index;
 
 [[package]]
+name = "wasi"
+version = "0.10.0+wasi-snapshot-preview1"
+source = "registry+https://github.com/rust-lang/crates.io-index;
+
+[[package]]
 name = "winapi"
 version = "0.3.9"
 source = "registry+https://github.com/rust-lang/crates.io-index;
@@ -880,11 +895,13 @@
 "checksum termcolor 1.1.0 
(registry+https://github.com/rust-lang/crates.io-index)" = 
"bb6bfa289a4d7c5766392812c0a1f4c1ba45afa1ad47803c11e1f407d846d75f"
 "checksum textwrap 0.11.0 
(registry+https://github.com/rust-lang/crates.io-index)" = 
"d326610f408c7a4eb6f51c37c330e496b08506c9457c9d34287ecc38809fb060"
 "checksum thread_local 1.0.1 
(registry+https://github.com/rust-lang/crates.io-index)" = 
"d40c6d1b69745a6ec6fb1ca717914848da4b44ae29d9b3080cbee91d72a69b14"
+"checksum time 0.1.44 (registry+https://github.com/rust-lang/crates.io-index)" 
= "6db9e6914ab8b1ae1c260a4ae7a49b6c5611b40328a735b21862567685e73255"
 "checksum twox-hash 1.5.0 
(registry+https://github.com/rust-lang/crates.io-index)" = 
"3bfd5b7557925ce778ff9b9ef90e3ade34c524b5ff10e239c69a42d546d2af56"
 "checksum unicode-width 0.1.8 
(registry+https://github.com/rust-lang/crates.io-index)" = 
"9337591893a19b88d8d87f2cec1e73fad5cdfd10e5a6f349f498ad6ea2ffb1e3"
 "checksum unicode-xid 0.2.1 
(registry+https://github.com/rust-lang/crates.io-index)" = 
"f7fe0bb3479651439c9112f72b6c505038574c9fbb575ed1bf3b797fa39dd564"
 "checksum vcpkg 0.2.10 
(registry+https://github.com/rust-lang/crates.io-index)" = 
"6454029bf181f092ad1b853286f23e2c507d8e8194d01d92da4a55c274a5508c"
 "checksum vec_map 0.8.2 
(registry+https://github.com/rust-lang/crates.io-index)" = 
"f1bddf1187be692e79c5ffeab891132dfb0f236ed36a43c7ed39f1165ee20191"
+"checksum wasi 0.10.0+wasi-snapshot-preview1 
(registry+https://github.com/rust-lang/crates.io-index)" = 
"1a143597ca7c7793eff794def352d41792a93c481eb1042423ff7ff72ba2c31f"
 "checksum wasi 0.9.0+wasi-snapshot-preview1 
(registry+https://github.com/rust-lang/crates.io-index)" = 
"cccddf32554fecc6acb585f82a32a72e28b48f8c4c1883ddfeeeaa96f7d8e519"
 "checksum winapi 0.3.9 
(registry+https://github.com/rust-lang/crates.io-index)" = 
"5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419"
 "checksum winapi-i686-pc-windows-gnu 0.4.0 
(registry+https://github.com/rust-lang/crates.io-index)" = 
"ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6"



To: Alphare, #hg-reviewers
Cc: mercurial-patches, mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D9071: rust-matchers: make `Matcher` trait object-safe

2020-09-23 Thread Raphaël Gomès
Alphare created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  Before this patch, it is not possible to create a `Matcher` trait-object (like
  `Box`), because of the use of a generic parameters in some 
methods,
  namely `impl AsRef`.
  
  While this makes the interface less flexible for callers in theory, it does 
not
  change anything in the current codebase.
  
  Until something like [1] is implemented, this is a "tradeoff" that we need to
  make anyway.
  
  [1] https://internals.rust-lang.org/t/pre-rfc-expand-object-safety/12693

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  rust/hg-core/src/matchers.rs

CHANGE DETAILS

diff --git a/rust/hg-core/src/matchers.rs b/rust/hg-core/src/matchers.rs
--- a/rust/hg-core/src/matchers.rs
+++ b/rust/hg-core/src/matchers.rs
@@ -49,9 +49,9 @@
 /// Explicitly listed files
 fn file_set() -> Option<<>>;
 /// Returns whether `filename` is in `file_set`
-fn exact_match(, filename: impl AsRef) -> bool;
+fn exact_match(, filename: ) -> bool;
 /// Returns whether `filename` is matched by this matcher
-fn matches(, filename: impl AsRef) -> bool;
+fn matches(, filename: ) -> 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
@@ -89,10 +89,7 @@
 /// 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(
-,
-directory: impl AsRef,
-) -> VisitChildrenSet;
+fn visit_children_set(, directory: ) -> VisitChildrenSet;
 /// Matcher will match everything and `files_set()` will be empty:
 /// optimization might be possible.
 fn matches_everything() -> bool;
@@ -119,16 +116,13 @@
 fn file_set() -> Option<<>> {
 None
 }
-fn exact_match(, _filename: impl AsRef) -> bool {
+fn exact_match(, _filename: ) -> bool {
 false
 }
-fn matches(, _filename: impl AsRef) -> bool {
+fn matches(, _filename: ) -> bool {
 true
 }
-fn visit_children_set(
-,
-_directory: impl AsRef,
-) -> VisitChildrenSet {
+fn visit_children_set(, _directory: ) -> VisitChildrenSet {
 VisitChildrenSet::Recursive
 }
 fn matches_everything() -> bool {
@@ -143,9 +137,9 @@
 /// patterns.
 ///
 ///```
-/// use hg::{ matchers::{Matcher, FileMatcher}, utils::hg_path::HgPath };
+/// use hg::{ matchers::{Matcher, FileMatcher}, utils::hg_path::{HgPath, 
HgPathBuf} };
 ///
-/// let files = [HgPath::new(b"a.txt"), HgPath::new(br"re:.*\.c$")];
+/// let files = [HgPathBuf::from_bytes(b"a.txt"), 
HgPathBuf::from_bytes(br"re:.*\.c$")];
 /// let matcher = FileMatcher::new().unwrap();
 ///
 /// assert_eq!(matcher.matches(HgPath::new(b"a.txt")), true);
@@ -160,15 +154,13 @@
 }
 
 impl<'a> FileMatcher<'a> {
-pub fn new(
-files: &'a [impl AsRef],
-) -> Result {
+pub fn new(files: &'a [HgPathBuf]) -> Result {
 Ok(Self {
 files: HashSet::from_iter(files.iter().map(AsRef::as_ref)),
 dirs: DirsMultiset::from_manifest(files)?,
 })
 }
-fn inner_matches(, filename: impl AsRef) -> bool {
+fn inner_matches(, filename: ) -> bool {
 self.files.contains(filename.as_ref())
 }
 }
@@ -177,16 +169,13 @@
 fn file_set() -> Option<<>> {
 Some()
 }
-fn exact_match(, filename: impl AsRef) -> bool {
+fn exact_match(, filename: ) -> bool {
 self.inner_matches(filename)
 }
-fn matches(, filename: impl AsRef) -> bool {
+fn matches(, filename: ) -> bool {
 self.inner_matches(filename)
 }
-fn visit_children_set(
-,
-directory: impl AsRef,
-) -> VisitChildrenSet {
+fn visit_children_set(, directory: ) -> VisitChildrenSet {
 if self.files.is_empty() || !self.dirs.contains() {
 return VisitChildrenSet::Empty;
 }
@@ -270,18 +259,15 @@
 None
 }
 
-fn exact_match(, _filename: impl AsRef) -> bool {
+fn exact_match(, _filename: ) -> bool {
 false
 }
 
-fn matches(, filename: impl AsRef) -> bool {
+fn matches(, filename: ) -> bool {
 (self.match_fn)(filename.as_ref())
 }
 
-fn visit_children_set(
-,
-directory: impl AsRef,
-) -> VisitChildrenSet {
+fn visit_children_set(, directory: ) -> VisitChildrenSet {
 let dir = directory.as_ref();
 if self.prefix && self.roots.contains(dir) {
 return VisitChildrenSet::Recursive;
@@ -725,7 +711,7 @@
 #[test]
 fn test_filematcher_visit_children_set() {
 // Visitchildrenset
-let files = 

Re: Failing To Find Directory

2020-09-14 Thread Raphaël Gomès

What does your config path for phabricator look like?

On 9/11/20 5:39 PM, Jake Mulhern wrote:

Hello,

I used Mercurial to make and submit a patch to Phabricator for Mozilla 
last week for the first time.  I began to make a patch this week for 
Mozilla again and continue to get this message whenever I type in any 
hg command in the terminal on my mac.


*** failed to import extension phabricator from 
~/usr/local/Cellar/mercurial/5.5/lib/python3.8/site-packages/hgext/phabricator.py: 
[Errno 2] No such file or directory: 
'/Users/jacobmulhern/usr/local/Cellar/mercurial/5.5/lib/python3.8/site-packages/hgext/phabricator.py'



I have been looking through files to see where it might have the wrong 
path for this but cannot seem to find it.  Any help would be 
appreciated in this so that I can fix my Mercurial setup and submit 
more patches!



Jake Mulhern


___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D8990: rust-cpython: switch logging facade from `simple_logger` to `env_logger`

2020-09-06 Thread Raphaël Gomès
Alphare created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  `simple_logger` is just too simple. `env_logger` supports logging to `stderr`,
  and logging filtering, for example, which are becoming necessary now. The
  project is nicely active.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  rust/Cargo.lock
  rust/hg-cpython/Cargo.toml
  rust/hg-cpython/src/dirstate.rs

CHANGE DETAILS

diff --git a/rust/hg-cpython/src/dirstate.rs b/rust/hg-cpython/src/dirstate.rs
--- a/rust/hg-cpython/src/dirstate.rs
+++ b/rust/hg-cpython/src/dirstate.rs
@@ -107,7 +107,7 @@
 let dotted_name = !("{}.dirstate", package);
 let m = PyModule::new(py, dotted_name)?;
 
-simple_logger::init_by_env();
+env_logger::init();
 
 m.add(py, "__package__", package)?;
 m.add(py, "__doc__", "Dirstate - Rust implementation")?;
diff --git a/rust/hg-cpython/Cargo.toml b/rust/hg-cpython/Cargo.toml
--- a/rust/hg-cpython/Cargo.toml
+++ b/rust/hg-cpython/Cargo.toml
@@ -24,7 +24,7 @@
 hg-core = { path = "../hg-core"}
 libc = '*'
 log = "0.4.8"
-simple_logger = "1.6.0"
+env_logger = "0.7.1"
 
 [dependencies.cpython]
 version = "0.4.1"
diff --git a/rust/Cargo.lock b/rust/Cargo.lock
--- a/rust/Cargo.lock
+++ b/rust/Cargo.lock
@@ -47,16 +47,6 @@
 source = "registry+https://github.com/rust-lang/crates.io-index;
 
 [[package]]
-name = "chrono"
-version = "0.4.11"
-source = "registry+https://github.com/rust-lang/crates.io-index;
-dependencies = [
- "num-integer 0.1.42 (registry+https://github.com/rust-lang/crates.io-index)",
- "num-traits 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)",
- "time 0.1.42 (registry+https://github.com/rust-lang/crates.io-index)",
-]
-
-[[package]]
 name = "clap"
 version = "2.33.1"
 source = "registry+https://github.com/rust-lang/crates.io-index;
@@ -71,16 +61,6 @@
 ]
 
 [[package]]
-name = "colored"
-version = "1.9.3"
-source = "registry+https://github.com/rust-lang/crates.io-index;
-dependencies = [
- "atty 0.2.14 (registry+https://github.com/rust-lang/crates.io-index)",
- "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
- "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)",
-]
-
-[[package]]
 name = "cpython"
 version = "0.4.1"
 source = "registry+https://github.com/rust-lang/crates.io-index;
@@ -176,6 +156,18 @@
 source = "registry+https://github.com/rust-lang/crates.io-index;
 
 [[package]]
+name = "env_logger"
+version = "0.7.1"
+source = "registry+https://github.com/rust-lang/crates.io-index;
+dependencies = [
+ "atty 0.2.14 (registry+https://github.com/rust-lang/crates.io-index)",
+ "humantime 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
+ "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)",
+ "regex 1.3.9 (registry+https://github.com/rust-lang/crates.io-index)",
+ "termcolor 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
+]
+
+[[package]]
 name = "getrandom"
 version = "0.1.14"
 source = "registry+https://github.com/rust-lang/crates.io-index;
@@ -227,10 +219,18 @@
 version = "0.1.0"
 dependencies = [
  "cpython 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)",
+ "env_logger 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)",
  "hg-core 0.1.0",
  "libc 0.2.67 (registry+https://github.com/rust-lang/crates.io-index)",
  "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)",
- "simple_logger 1.6.0 (registry+https://github.com/rust-lang/crates.io-index)",
+]
+
+[[package]]
+name = "humantime"
+version = "1.3.0"
+source = "registry+https://github.com/rust-lang/crates.io-index;
+dependencies = [
+ "quick-error 1.2.3 (registry+https://github.com/rust-lang/crates.io-index)",
 ]
 
 [[package]]
@@ -299,15 +299,6 @@
 ]
 
 [[package]]
-name = "num-integer"
-version = "0.1.42"
-source = "registry+https://github.com/rust-lang/crates.io-index;
-dependencies = [
- "autocfg 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
- "num-traits 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)",
-]
-
-[[package]]
 name = "num-traits"
 version = "0.2.11"
 source = "registry+https://github.com/rust-lang/crates.io-index;
@@ -375,6 +366,11 @@
 ]
 
 [[package]]
+name = "quick-error"
+version = "1.2.3"
+source = "registry+https://github.com/rust-lang/crates.io-index;
+
+[[package]]
 name = "quote"
 version = "1.0.3"
 source = "registry+https://github.com/rust-lang/crates.io-index;
@@ -529,18 +525,6 @@
 source = "registry+https://github.com/rust-lang/crates.io-index;
 
 [[package]]
-name = "simple_logger"
-version = "1.6.0"
-source = "registry+https://github.com/rust-lang/crates.io-index;
-dependencies = [
- "atty 0.2.14 (registry+https://github.com/rust-lang/crates.io-index)",
- "chrono 0.4.11 (registry+https://github.com/rust-lang/crates.io-index)",
- "colored 1.9.3 

Re: Website: add a blog?

2020-08-03 Thread Raphaël Gomès


On 03/08/2020 17:39, Augie Fackler wrote:

Oh, and if we wanted to take this as an opportunity to try and move to a more 
common static-site-generator rather than a custom flask app, I'd be in favor of 
that too... ;)

+ 1

On Aug 3, 2020, at 11:37, Augie Fackler  wrote:

Howdy folks,

I've been (slowly) working with conservancy on some various things, and one 
thing they suggested that I agree with is that we should probably have some 
kind of dev-blog on mercurial-scm.org where we can talk about neat things in 
Mercurial etc. I'm happy to write for it, but I lack the time to set up a blog 
as part of the website. Can I interest anyone in sending some patches to the 
website[0] to add a blog space, and then we can get 2-3 posts set up for it and 
try to get a post or two a month out?
I'd be up for it, starting with the blog separately from the website 
(which is a bigger undertaking), within the next few weeks seems reasonable.

Thanks,
Augie

0: https://www.mercurial-scm.org/repo/hg-website

___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel

___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D8663: hg-core: define a `dirstate_status` `Operation`

2020-06-25 Thread Raphaël Gomès
Alphare created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  This is 3/3 in a series of patches to improve dirstate status' code.
  
  Following in the footsteps of a46e36b82461 
<https://phab.mercurial-scm.org/rHGa46e36b824612be16b38a1c1cd11160c293d115b>, 
we move the main status
  functionality to an `Operation`. This will most likely be subject to change in
  the future (what function signature, what parameters, etc., but we will see
  when `rhg` gets `hg status` support.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  rust/hg-core/src/dirstate/status.rs
  rust/hg-core/src/operations/dirstate_status.rs
  rust/hg-core/src/operations/mod.rs

CHANGE DETAILS

diff --git a/rust/hg-core/src/operations/mod.rs 
b/rust/hg-core/src/operations/mod.rs
--- a/rust/hg-core/src/operations/mod.rs
+++ b/rust/hg-core/src/operations/mod.rs
@@ -1,3 +1,4 @@
+mod dirstate_status;
 mod find_root;
 pub use find_root::{FindRoot, FindRootError, FindRootErrorKind};
 
diff --git a/rust/hg-core/src/operations/dirstate_status.rs 
b/rust/hg-core/src/operations/dirstate_status.rs
new file mode 100644
--- /dev/null
+++ b/rust/hg-core/src/operations/dirstate_status.rs
@@ -0,0 +1,76 @@
+// dirstate_status.rs
+//
+// Copyright 2019, Raphaël Gomès 
+//
+// 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::dirstate::status::{build_response, Dispatch, HgPathCow, Status};
+use crate::matchers::Matcher;
+use crate::operations::Operation;
+use crate::{DirstateStatus, StatusError};
+
+/// A tuple of the paths that need to be checked in the filelog because it's
+/// ambiguous whether they've changed, and the rest of the already dispatched
+/// files.
+pub type LookupAndStatus<'a> = (Vec>, DirstateStatus<'a>);
+
+impl<'a, M: Matcher + Sync> Operation> for Status<'a, M> {
+type Error = StatusError;
+
+fn run() -> Result, Self::Error> {
+let (traversed_sender, traversed_receiver) =
+crossbeam::channel::unbounded();
+
+// Step 1: check the files explicitly mentioned by the user
+let (work, mut results) = self.walk_explicit(traversed_sender.clone());
+
+if !work.is_empty() {
+// Hashmaps are quite a bit slower to build than vecs, so only
+// build it if needed.
+let old_results = results.iter().cloned().collect();
+
+// Step 2: recursively check the working directory for changes if
+// needed
+for (dir, dispatch) in work {
+match dispatch {
+Dispatch::Directory { was_file } => {
+if was_file {
+results.push((dir.to_owned(), Dispatch::Removed));
+}
+if self.options.list_ignored
+|| self.options.list_unknown
+&& !self.dir_ignore()
+{
+self.traverse(
+,
+_results,
+ results,
+traversed_sender.clone(),
+)?;
+}
+}
+_ => {
+unreachable!("There can only be directories in `work`")
+}
+}
+}
+}
+
+if !self.matcher.is_exact() {
+if self.options.list_unknown {
+self.handle_unknowns( results)?;
+} else {
+// TODO this is incorrect, see issue6335
+// This requires a fix in both Python and Rust that can happen
+// with other pending changes to `status`.
+self.extend_from_dmap( results);
+}
+}
+
+drop(traversed_sender);
+let traversed = traversed_receiver.into_iter().collect();
+
+Ok(build_response(results, traversed))
+}
+}
diff --git a/rust/hg-core/src/dirstate/status.rs 
b/rust/hg-core/src/dirstate/status.rs
--- a/rust/hg-core/src/dirstate/status.rs
+++ b/rust/hg-core/src/dirstate/status.rs
@@ -13,6 +13,7 @@
 dirstate::SIZE_FROM_OTHER_PARENT,
 filepatterns::PatternFileWarning,
 matchers::{get_ignore_function, Matcher, VisitChildrenSet},
+operations::Operation,
 utils::{
 files::{find_dirs, HgMetadata},
 hg_path::{
@@ -101,7 +102,7 @@
 
 /// We have a good mix of owned (from directory traversal) and borrowed (from
 /// the dirstate/explicit) paths, this comes up a lot.
-type HgPathCow<'a> = Cow<'a, HgPath>;
+pub type HgPathCow<'a> = Cow<'a, HgPath>;
 
 /// A path with its compute

D8661: rust-status: refactor status into a struct

2020-06-25 Thread Raphaël Gomès
Alphare created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  The code for `dirstate/status` has grown too large for comfort, this is the
  first of three patches that try to improve maintainability.
  In this patch, refactoring dirstate's status into a struct allows for slimming
  down function signatures drastically, keeping the mental (and maintenance)
  burden lower, since pretty much all of them shared a few common arguments.
  
  This had the pleasant side-effect of simplifying lifetimes a little. This has
  no observable impact on performance.
  
  The next patch will add/improve documentation and refactor some types. I tried
  to keep new code down to a minimum in this patch because it's already pretty
  big.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  rust/hg-core/src/dirstate/status.rs
  rust/hg-cpython/src/dirstate/status.rs

CHANGE DETAILS

diff --git a/rust/hg-cpython/src/dirstate/status.rs 
b/rust/hg-cpython/src/dirstate/status.rs
--- a/rust/hg-cpython/src/dirstate/status.rs
+++ b/rust/hg-cpython/src/dirstate/status.rs
@@ -127,7 +127,7 @@
 let ((lookup, status_res), warnings) = status(
 ,
 ,
-_dir,
+root_dir.to_path_buf(),
 ignore_files,
 StatusOptions {
 check_exec,
@@ -164,7 +164,7 @@
 let ((lookup, status_res), warnings) = status(
 ,
 ,
-_dir,
+root_dir.to_path_buf(),
 ignore_files,
 StatusOptions {
 check_exec,
@@ -219,7 +219,7 @@
 let ((lookup, status_res), warnings) = status(
 ,
 ,
-_dir,
+root_dir.to_path_buf(),
 ignore_files,
 StatusOptions {
 check_exec,
diff --git a/rust/hg-core/src/dirstate/status.rs 
b/rust/hg-core/src/dirstate/status.rs
--- a/rust/hg-core/src/dirstate/status.rs
+++ b/rust/hg-core/src/dirstate/status.rs
@@ -73,7 +73,7 @@
 /// Is similar to `crate::EntryState`, but represents the transient state of
 /// entries during the lifetime of a command.
 #[derive(Debug, Copy, Clone)]
-enum Dispatch {
+pub enum Dispatch {
 Unsure,
 Modified,
 Added,
@@ -214,88 +214,6 @@
 };
 }
 
-/// Get stat data about the files explicitly specified by match.
-/// TODO subrepos
-#[timed]
-fn walk_explicit<'a>(
-files: Option<&'a HashSet<>>,
-dmap: &'a DirstateMap,
-root_dir: impl AsRef + Sync + Send + 'a,
-options: StatusOptions,
-traversed_sender: crossbeam::Sender,
-) -> impl ParallelIterator> {
-files
-.unwrap_or(_WORK)
-.par_iter()
-.map(move || {
-// TODO normalization
-let normalized = filename;
-
-let buf = match hg_path_to_path_buf(normalized) {
-Ok(x) => x,
-Err(e) => return Some(Err(e.into())),
-};
-let target = root_dir.as_ref().join(buf);
-let st = target.symlink_metadata();
-let in_dmap = dmap.get(normalized);
-match st {
-Ok(meta) => {
-let file_type = meta.file_type();
-return if file_type.is_file() || file_type.is_symlink() {
-if let Some(entry) = in_dmap {
-return Some(Ok((
-normalized,
-dispatch_found(
-,
-*entry,
-HgMetadata::from_metadata(meta),
-_map,
-options,
-),
-)));
-}
-Some(Ok((normalized, Dispatch::Unknown)))
-} else if file_type.is_dir() {
-if options.collect_traversed_dirs {
-traversed_sender
-.send(normalized.to_owned())
-.expect("receiver should outlive sender");
-}
-Some(Ok((
-normalized,
-Dispatch::Directory {
-was_file: in_dmap.is_some(),
-},
-)))
-} else {
-Some(Ok((
-normalized,
-Dispatch::Bad(BadMatch::BadType(
-// TODO do more than unknown
-// Support for all `BadType` variant
-

D8662: rust-status: improve documentation and readability

2020-06-25 Thread Raphaël Gomès
Alphare created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  This patch is 2/3 in the series to improve the dirstate status code. It adds a
  number of common type aliases to add more obvious semantics to function
  signatures, improves/adds documentation where necessary and improves one or 
two
  patterns to be more idiomatic.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  rust/hg-core/src/dirstate/status.rs

CHANGE DETAILS

diff --git a/rust/hg-core/src/dirstate/status.rs 
b/rust/hg-core/src/dirstate/status.rs
--- a/rust/hg-core/src/dirstate/status.rs
+++ b/rust/hg-core/src/dirstate/status.rs
@@ -69,7 +69,7 @@
 BadType(BadType),
 }
 
-/// Marker enum used to dispatch new status entries into the right collections.
+/// 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.
 #[derive(Debug, Copy, Clone)]
@@ -94,10 +94,18 @@
 }
 
 type IoResult = std::io::Result;
+
 /// `Box` is syntactic sugar for `Box`, so add
 /// an explicit lifetime here to not fight `'static` bounds "out of nowhere".
 type IgnoreFnType<'a> = Box Fn(&'r HgPath) -> bool + Sync + 'a>;
 
+/// We have a good mix of owned (from directory traversal) and borrowed (from
+/// the dirstate/explicit) paths, this comes up a lot.
+type HgPathCow<'a> = Cow<'a, HgPath>;
+
+/// A path with its computed ``Dispatch`` information
+type DispatchedPath<'a> = (HgPathCow<'a>, Dispatch);
+
 /// 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
@@ -232,22 +240,25 @@
 
 #[derive(Debug)]
 pub struct DirstateStatus<'a> {
-pub modified: Vec>,
-pub added: Vec>,
-pub removed: Vec>,
-pub deleted: Vec>,
-pub clean: Vec>,
-pub ignored: Vec>,
-pub unknown: Vec>,
-pub bad: Vec<(Cow<'a, HgPath>, BadMatch)>,
+pub modified: Vec>,
+pub added: Vec>,
+pub removed: Vec>,
+pub deleted: Vec>,
+pub clean: Vec>,
+pub ignored: Vec>,
+pub unknown: Vec>,
+pub bad: Vec<(HgPathCow<'a>, BadMatch)>,
 /// Only filled if `collect_traversed_dirs` is `true`
 pub traversed: Vec,
 }
 
 #[derive(Debug)]
 pub enum StatusError {
+/// Generic IO error
 IO(std::io::Error),
+/// An invalid path that cannot be represented in Mercurial was found
 Path(HgPathError),
+/// An invalid "ignore" pattern was found
 Pattern(PatternError),
 }
 
@@ -279,6 +290,8 @@
 }
 }
 
+/// Gives information about which files are changed in the working directory
+/// and how, compared to the revision we're based on
 pub struct Status<'a, M: Matcher + Sync> {
 dmap: &'a DirstateMap,
 matcher: &'a M,
@@ -319,6 +332,7 @@
 ))
 }
 
+/// Is the path ignored?
 pub fn is_ignored(, path: impl AsRef) -> bool {
 (self.ignore_fn)(path.as_ref())
 }
@@ -342,16 +356,15 @@
 }
 }
 
-/// Get stat data about the files explicitly specified by match.
+/// Get stat data about the files explicitly specified by the matcher.
+/// Returns a tuple of the directories that need to be traversed and the
+/// files with their corresponding `Dispatch`.
 /// TODO subrepos
 #[timed]
 pub fn walk_explicit(
 ,
 traversed_sender: crossbeam::Sender,
-) -> (
-Vec<(Cow<'a, HgPath>, Dispatch)>,
-Vec<(Cow<'a, HgPath>, Dispatch)>,
-) {
+) -> (Vec>, Vec>) {
 self.matcher
 .file_set()
 .unwrap_or(_WORK)
@@ -443,8 +456,8 @@
 pub fn traverse(
 ,
 path: impl AsRef,
-old_results: , Dispatch>,
-results:  Vec<(Cow<'a, HgPath>, Dispatch)>,
+old_results: , Dispatch>,
+results:  Vec>,
 traversed_sender: crossbeam::Sender,
 ) -> IoResult<()> {
 // The traversal is done in parallel, so use a channel to gather
@@ -637,23 +650,25 @@
 
 let skip_dot_hg = !directory.as_bytes().is_empty();
 let entries = match list_directory(dir_path, skip_dot_hg) {
-Err(e) => match e.kind() {
-ErrorKind::NotFound | ErrorKind::PermissionDenied => {
-files_sender
-.send(Ok((
-directory.to_owned(),
-Dispatch::Bad(BadMatch::OsError(
-// Unwrapping here is OK because the error
-// always is a
-// real os error
-e.raw_os_error().unwrap(),
-)),
-)))
-.unwrap();
-

Re: Virtual sprint? Ideas?

2020-06-22 Thread Raphaël Gomès

Hi there,

I think keeping the global sprint going even if in a new format is a 
good idea, but considering the obvious timezone issues we need to be 
quite organized if we want to do anything real-time.


Here's an idea: let's build up a list of all the main topics we want to 
discuss, estimate roughly how much time we want to allocate to them, 
then try to fit time slots when we can video chat about them in order of 
importance, keeping notes of what's been said. That could be the basis 
for a mailing-list discussion thread for longer-term discussion and 
ideas from people who couldn't join for that topic.
The question remains about how sparse we want these discussions to be. I 
see value in having a dedicated few days/week for kickstarting the 
discussions as opposed to a month-long "let's call each other sometimes" 
to stay in the groove. This will obviously be more sparse than if we 
were to meet IRL, but I think a denser format is better.


I'm afraid that just going for a more free-format discussion will not 
work through earth-wide videoconferencing.


Does that sound like a good idea?
Raphaël

On 5/20/20 1:42 AM, Augie Fackler wrote:

Howdy folks,

Normally we’d have wrapped up a sprint not too long ago and have given some 
thought to a NA location sprint. Given the circumstances around coronavirus and 
the (extremely vague!) guidance most of us have (presumably) gotten from our 
employers and/or governments, I think it’s time to start trying to figure out 
what a virtual sprint might look like. I’ll miss the whiteboard etc time with 
y’all, but I’d really like to get a chance to discuss longer-term projects and 
try to make some decisions about whatever needs deciding as a group.

Thoughts?

Thanks,
Augie
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D8635: rust: do a clippy pass

2020-06-15 Thread Raphaël Gomès
Alphare created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  This is the result of running `cargo clippy` on hg-core/hg-cpython and fixing
  the lints that do not require too much code churn (and would warrant a 
separate
  commit/complete refactor) and only come from our code (a lot of warnings in
  hg-cpython come from `rust-cpython`).
  
  Most of those were good lints, two of them was the linter not being smart
  enough (or compiler to get up to `clippy`'s level depending on how you see 
it).
  
  Maybe in the future we could have `clippy` be part of the CI.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  rust/hg-core/src/ancestors.rs
  rust/hg-core/src/dagops.rs
  rust/hg-core/src/dirstate/dirs_multiset.rs
  rust/hg-core/src/dirstate/dirstate_map.rs
  rust/hg-core/src/dirstate/parsers.rs
  rust/hg-core/src/dirstate/status.rs
  rust/hg-core/src/discovery.rs
  rust/hg-core/src/filepatterns.rs
  rust/hg-core/src/matchers.rs
  rust/hg-core/src/revlog.rs
  rust/hg-core/src/revlog/node.rs
  rust/hg-core/src/revlog/nodemap.rs
  rust/hg-core/src/utils.rs
  rust/hg-core/src/utils/files.rs
  rust/hg-core/src/utils/hg_path.rs
  rust/hg-core/src/utils/path_auditor.rs
  rust/hg-cpython/src/cindex.rs
  rust/hg-cpython/src/dirstate/copymap.rs
  rust/hg-cpython/src/dirstate/dirs_multiset.rs
  rust/hg-cpython/src/dirstate/dirstate_map.rs
  rust/hg-cpython/src/dirstate/non_normal_entries.rs
  rust/hg-cpython/src/dirstate/status.rs
  rust/hg-cpython/src/parsers.rs
  rust/hg-cpython/src/utils.rs

CHANGE DETAILS

diff --git a/rust/hg-cpython/src/utils.rs b/rust/hg-cpython/src/utils.rs
--- a/rust/hg-cpython/src/utils.rs
+++ b/rust/hg-cpython/src/utils.rs
@@ -32,10 +32,7 @@
 
 /// Clone incoming Python bytes given as `PyBytes` as a `Node`,
 /// doing the necessary checks.
-pub fn node_from_py_bytes<'a>(
-py: Python,
-bytes: &'a PyBytes,
-) -> PyResult {
+pub fn node_from_py_bytes(py: Python, bytes: ) -> PyResult {
 ::try_from(bytes.data(py))
 .map_err(|_| {
 PyErr::new::(
@@ -43,5 +40,5 @@
 format!("{}-byte hash required", NODE_BYTES_LENGTH),
 )
 })
-.map(|n| n.into())
+.map(Into::into)
 }
diff --git a/rust/hg-cpython/src/parsers.rs b/rust/hg-cpython/src/parsers.rs
--- a/rust/hg-cpython/src/parsers.rs
+++ b/rust/hg-cpython/src/parsers.rs
@@ -37,15 +37,15 @@
 for (filename, entry) in _map {
 dmap.set_item(
 py,
-PyBytes::new(py, filename.as_ref()),
+PyBytes::new(py, filename.as_bytes()),
 make_dirstate_tuple(py, entry)?,
 )?;
 }
 for (path, copy_path) in copies {
 copymap.set_item(
 py,
-PyBytes::new(py, path.as_ref()),
-PyBytes::new(py, copy_path.as_ref()),
+PyBytes::new(py, path.as_bytes()),
+PyBytes::new(py, copy_path.as_bytes()),
 )?;
 }
 Ok(
@@ -116,7 +116,7 @@
 for (filename, entry) in _map {
 dmap.set_item(
 py,
-PyBytes::new(py, filename.as_ref()),
+PyBytes::new(py, filename.as_bytes()),
 make_dirstate_tuple(py, entry)?,
 )?;
 }
diff --git a/rust/hg-cpython/src/dirstate/status.rs 
b/rust/hg-cpython/src/dirstate/status.rs
--- a/rust/hg-cpython/src/dirstate/status.rs
+++ b/rust/hg-cpython/src/dirstate/status.rs
@@ -236,12 +236,10 @@
 
 build_response(py, lookup, status_res, all_warnings)
 }
-e => {
-return Err(PyErr::new::(
-py,
-format!("Unsupported matcher {}", e),
-));
-}
+e => Err(PyErr::new::(
+py,
+format!("Unsupported matcher {}", e),
+)),
 }
 }
 
diff --git a/rust/hg-cpython/src/dirstate/non_normal_entries.rs 
b/rust/hg-cpython/src/dirstate/non_normal_entries.rs
--- a/rust/hg-cpython/src/dirstate/non_normal_entries.rs
+++ b/rust/hg-cpython/src/dirstate/non_normal_entries.rs
@@ -62,7 +62,7 @@
 py: Python,
 key: ,
 ) -> PyResult> {
-Ok(Some(PyBytes::new(py, key.as_ref(
+Ok(Some(PyBytes::new(py, key.as_bytes(
 }
 }
 
diff --git a/rust/hg-cpython/src/dirstate/dirstate_map.rs 
b/rust/hg-cpython/src/dirstate/dirstate_map.rs
--- a/rust/hg-cpython/src/dirstate/dirstate_map.rs
+++ b/rust/hg-cpython/src/dirstate/dirstate_map.rs
@@ -179,7 +179,7 @@
 "other_parent",
 other_parent
 .iter()
-.map(|v| PyBytes::new(py, v.as_ref()))
+.map(|v| PyBytes::new(py, v.as_bytes()))
 .collect::>()
  

D8634: hg-core: commit forgotten Cargo.lock

2020-06-15 Thread Raphaël Gomès
Alphare created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  This should have been in 2093b2fc70d4 
, 
but I apparently forgot.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  rust/Cargo.lock

CHANGE DETAILS

diff --git a/rust/Cargo.lock b/rust/Cargo.lock
--- a/rust/Cargo.lock
+++ b/rust/Cargo.lock
@@ -210,7 +210,7 @@
  "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)",
  "memchr 2.3.3 (registry+https://github.com/rust-lang/crates.io-index)",
  "memmap 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
- "micro-timer 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
+ "micro-timer 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
  "pretty_assertions 0.6.1 
(registry+https://github.com/rust-lang/crates.io-index)",
  "rand 0.7.3 (registry+https://github.com/rust-lang/crates.io-index)",
  "rand_distr 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -280,16 +280,16 @@
 
 [[package]]
 name = "micro-timer"
-version = "0.2.1"
+version = "0.3.0"
 source = "registry+https://github.com/rust-lang/crates.io-index;
 dependencies = [
- "micro-timer-macros 0.2.0 
(registry+https://github.com/rust-lang/crates.io-index)",
+ "micro-timer-macros 0.3.0 
(registry+https://github.com/rust-lang/crates.io-index)",
  "scopeguard 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
 ]
 
 [[package]]
 name = "micro-timer-macros"
-version = "0.2.0"
+version = "0.3.0"
 source = "registry+https://github.com/rust-lang/crates.io-index;
 dependencies = [
  "proc-macro2 1.0.9 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -672,8 +672,8 @@
 "checksum memchr 2.3.3 
(registry+https://github.com/rust-lang/crates.io-index)" = 
"3728d817d99e5ac407411fa471ff9800a778d88a24685968b36824eaf4bee400"
 "checksum memmap 0.7.0 
(registry+https://github.com/rust-lang/crates.io-index)" = 
"6585fd95e7bb50d6cc31e20d4cf9afb4e2ba16c5846fc76793f11218da9c475b"
 "checksum memoffset 0.5.3 
(registry+https://github.com/rust-lang/crates.io-index)" = 
"75189eb85871ea5c2e2c15abbdd541185f63b408415e5051f5cac122d8c774b9"
-"checksum micro-timer 0.2.1 
(registry+https://github.com/rust-lang/crates.io-index)" = 
"987429cd6162a80ed5ff44fc790f5090b1c6d617ac73a2e272965ed91201d79b"
-"checksum micro-timer-macros 0.2.0 
(registry+https://github.com/rust-lang/crates.io-index)" = 
"43cec5c0b38783eb33ef7bccf4b250b7a085703e11f5f2238fa31969e629388a"
+"checksum micro-timer 0.3.0 
(registry+https://github.com/rust-lang/crates.io-index)" = 
"25b31d6cb9112984323d05d7a353f272ae5d7a307074f9ab9b25c00121b8c947"
+"checksum micro-timer-macros 0.3.0 
(registry+https://github.com/rust-lang/crates.io-index)" = 
"5694085dd384bb9e824207facc040c248d9df653f55e28c3ad0686958b448504"
 "checksum num-integer 0.1.42 
(registry+https://github.com/rust-lang/crates.io-index)" = 
"3f6ea62e9d81a77cd3ee9a2a5b9b609447857f3d358704331e4ef39eb247fcba"
 "checksum num-traits 0.2.11 
(registry+https://github.com/rust-lang/crates.io-index)" = 
"c62be47e61d1842b9170f0fdeec8eba98e60e90e5446449a0545e5152acd7096"
 "checksum num_cpus 1.12.0 
(registry+https://github.com/rust-lang/crates.io-index)" = 
"46203554f085ff89c235cd12f7075f3233af9b11ed7c9e16dfe2560d03313ce6"



To: Alphare, #hg-reviewers
Cc: mercurial-patches, mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D8605: rust-dependencies: upgrade `micro-timer` dependency

2020-06-02 Thread Raphaël Gomès
Alphare created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  I wanted to to a tour of dependencies to upgrade, but only `micro-timer` has a
  new release which does not print when the function panics, which should be 
less
  misleading.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  rust/hg-core/Cargo.toml

CHANGE DETAILS

diff --git a/rust/hg-core/Cargo.toml b/rust/hg-core/Cargo.toml
--- a/rust/hg-core/Cargo.toml
+++ b/rust/hg-core/Cargo.toml
@@ -21,7 +21,7 @@
 twox-hash = "1.5.0"
 same-file = "1.0.6"
 crossbeam = "0.7.3"
-micro-timer = "0.2.1"
+micro-timer = "0.3.0"
 log = "0.4.8"
 
 [dev-dependencies]



To: Alphare, #hg-reviewers
Cc: mercurial-patches, mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D8456: rust: remove duplicate import

2020-05-30 Thread Raphaël Gomès
Closed by commit rHGbe3e85cf8f4d: rust: remove duplicate import (authored by 
Alphare).
This revision was automatically updated to reflect the committed changes.
This revision was not accepted when it landed; it landed in state "Needs 
Revision".

CHANGED PRIOR TO COMMIT
  https://phab.mercurial-scm.org/D8456?vs=21152=21533#toc

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D8456?vs=21152=21533

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

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

AFFECTED FILES


CHANGE DETAILS




To: Alphare, #hg-reviewers, marmoute, indygreg
Cc: indygreg, mercurial-patches, marmoute, mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D8594: rust: remove support for `re2`

2020-05-29 Thread Raphaël Gomès
phase and then investigate
-/// how much work would be needed to use `regex`.
-mod re2;
-pub use re2::Re2;
diff --git a/rust/hg-core/src/matchers.rs b/rust/hg-core/src/matchers.rs
--- a/rust/hg-core/src/matchers.rs
+++ b/rust/hg-core/src/matchers.rs
@@ -7,8 +7,6 @@
 
 //! Structs and types for matching files and directories.
 
-#[cfg(feature = "with-re2")]
-use crate::re2::Re2;
 use crate::{
 dirstate::dirs_multiset::DirsChildrenMultiset,
 filepatterns::{
@@ -239,29 +237,24 @@
 }
 
 /// Matches files that are included in the ignore rules.
-#[cfg_attr(
-feature = "with-re2",
-doc = r##"
-```
-use hg::{
-matchers::{IncludeMatcher, Matcher},
-IgnorePattern,
-PatternSyntax,
-utils::hg_path::HgPath
-};
-use std::path::Path;
-///
-let ignore_patterns =
-vec![IgnorePattern::new(PatternSyntax::RootGlob, b"this*", Path::new(""))];
-let (matcher, _) = IncludeMatcher::new(ignore_patterns, "").unwrap();
-///
-assert_eq!(matcher.matches(HgPath::new(b"testing")), false);
-assert_eq!(matcher.matches(HgPath::new(b"this should work")), true);
-assert_eq!(matcher.matches(HgPath::new(b"this also")), true);
-assert_eq!(matcher.matches(HgPath::new(b"but not this")), false);
-```
-"##
-)]
+/// ```
+/// use hg::{
+/// matchers::{IncludeMatcher, Matcher},
+/// IgnorePattern,
+/// PatternSyntax,
+/// utils::hg_path::HgPath
+/// };
+/// use std::path::Path;
+/// ///
+/// let ignore_patterns =
+/// vec![IgnorePattern::new(PatternSyntax::RootGlob, b"this*", Path::new(""))];
+/// let (matcher, _) = IncludeMatcher::new(ignore_patterns, "").unwrap();
+/// ///
+/// assert_eq!(matcher.matches(HgPath::new(b"testing")), false);
+/// assert_eq!(matcher.matches(HgPath::new(b"this should work")), true);
+/// assert_eq!(matcher.matches(HgPath::new(b"this also")), true);
+/// assert_eq!(matcher.matches(HgPath::new(b"but not this")), false);
+/// ```
 pub struct IncludeMatcher<'a> {
 patterns: Vec,
 match_fn: Box Fn(&'r HgPath) -> bool + 'a + Sync>,
@@ -319,22 +312,6 @@
 }
 }
 
-#[cfg(feature = "with-re2")]
-/// Returns a function that matches an `HgPath` against the given regex
-/// pattern.
-///
-/// This can fail when the pattern is invalid or not supported by the
-/// underlying engine `Re2`, for instance anything with back-references.
-#[timed]
-fn re_matcher(
-pattern: &[u8],
-) -> PatternResult bool + Sync> {
-let regex = Re2::new(pattern);
-let regex = regex.map_err(|e| PatternError::UnsupportedSyntax(e))?;
-Ok(move |path: | regex.is_match(path.as_bytes()))
-}
-
-#[cfg(not(feature = "with-re2"))]
 /// Returns a function that matches an `HgPath` against the given regex
 /// pattern.
 ///
@@ -840,7 +817,6 @@
 );
 }
 
-#[cfg(feature = "with-re2")]
 #[test]
 fn test_includematcher() {
 // VisitchildrensetPrefix
diff --git a/rust/hg-core/src/lib.rs b/rust/hg-core/src/lib.rs
--- a/rust/hg-core/src/lib.rs
+++ b/rust/hg-core/src/lib.rs
@@ -23,8 +23,6 @@
 pub mod matchers;
 pub mod revlog;
 pub use revlog::*;
-#[cfg(feature = "with-re2")]
-pub mod re2;
 pub mod utils;
 
 // Remove this to see (potential) non-artificial compile failures. MacOS
@@ -141,9 +139,6 @@
 /// Needed a pattern that can be turned into a regex but got one that
 /// can't. This should only happen through programmer error.
 NonRegexPattern(IgnorePattern),
-/// This is temporary, see `re2/mod.rs`.
-/// This will cause a fallback to Python.
-Re2NotInstalled,
 }
 
 impl ToString for PatternError {
@@ -166,10 +161,6 @@
 PatternError::NonRegexPattern(pattern) => {
 format!("'{:?}' cannot be turned into a regex", pattern)
 }
-PatternError::Re2NotInstalled => {
-"Re2 is not installed, cannot use regex functionality."
-.to_string()
-}
 }
 }
 }
diff --git a/rust/hg-core/build.rs b/rust/hg-core/build.rs
deleted file mode 100644
--- a/rust/hg-core/build.rs
+++ /dev/null
@@ -1,61 +0,0 @@
-// build.rs
-//
-// Copyright 2020 Raphaël Gomès 
-//
-// This software may be used and distributed according to the terms of the
-// GNU General Public License version 2 or any later version.
-
-#[cfg(feature = "with-re2")]
-use cc;
-
-/// Uses either the system Re2 install as a dynamic library or the provided
-/// build as a static library
-#[cfg(feature = "with-re2")]
-fn compile_re2() {
-use cc;
-use std::path::Path;
-use std::process::exit;
-
-let msg = r"HG_RE2_PATH must be one of `system|`";
-let re2 = match std::env::var_os("HG_RE2_PATH") {
-None => {
-eprintln!("{}", msg);
-exit(1)
-}
-

D8593: rust-dependencies: update `regex` to 1.3.9

2020-05-29 Thread Raphaël Gomès
Alphare created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  Version `1.3.8` introduces support for empty alternations, which makes
  previously disallowed patterns usable in `regex`.
  
  From a user's perspective, this means that glob patterns like `*.py{,c}` will
  no longer generate an "invalid" regex and will use the Rust path.
  
  `1.3.9` is a bugfix release, might as well update to the latest one.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  rust/Cargo.lock
  rust/hg-core/Cargo.toml

CHANGE DETAILS

diff --git a/rust/hg-core/Cargo.toml b/rust/hg-core/Cargo.toml
--- a/rust/hg-core/Cargo.toml
+++ b/rust/hg-core/Cargo.toml
@@ -19,7 +19,7 @@
 rand_pcg = "0.2.1"
 rand_distr = "0.2.2"
 rayon = "1.3.0"
-regex = "1.3.6"
+regex = "1.3.9"
 twox-hash = "1.5.0"
 same-file = "1.0.6"
 crossbeam = "0.7.3"
diff --git a/rust/Cargo.lock b/rust/Cargo.lock
--- a/rust/Cargo.lock
+++ b/rust/Cargo.lock
@@ -223,7 +223,7 @@
  "rand_distr 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
  "rand_pcg 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
  "rayon 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
- "regex 1.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
+ "regex 1.3.9 (registry+https://github.com/rust-lang/crates.io-index)",
  "same-file 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)",
  "tempfile 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
  "twox-hash 1.5.0 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -369,7 +369,7 @@
 source = "registry+https://github.com/rust-lang/crates.io-index;
 dependencies = [
  "libc 0.2.67 (registry+https://github.com/rust-lang/crates.io-index)",
- "regex 1.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
+ "regex 1.3.9 (registry+https://github.com/rust-lang/crates.io-index)",
 ]
 
 [[package]]
@@ -378,7 +378,7 @@
 source = "registry+https://github.com/rust-lang/crates.io-index;
 dependencies = [
  "libc 0.2.67 (registry+https://github.com/rust-lang/crates.io-index)",
- "regex 1.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
+ "regex 1.3.9 (registry+https://github.com/rust-lang/crates.io-index)",
 ]
 
 [[package]]
@@ -471,18 +471,18 @@
 
 [[package]]
 name = "regex"
-version = "1.3.6"
+version = "1.3.9"
 source = "registry+https://github.com/rust-lang/crates.io-index;
 dependencies = [
  "aho-corasick 0.7.10 (registry+https://github.com/rust-lang/crates.io-index)",
  "memchr 2.3.3 (registry+https://github.com/rust-lang/crates.io-index)",
- "regex-syntax 0.6.17 (registry+https://github.com/rust-lang/crates.io-index)",
+ "regex-syntax 0.6.18 (registry+https://github.com/rust-lang/crates.io-index)",
  "thread_local 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)",
 ]
 
 [[package]]
 name = "regex-syntax"
-version = "0.6.17"
+version = "0.6.18"
 source = "registry+https://github.com/rust-lang/crates.io-index;
 
 [[package]]
@@ -701,8 +701,8 @@
 "checksum rayon 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)" 
= "db6ce3297f9c85e16621bb8cca38a06779ffc31bb8184e1be4bed2be4678a098"
 "checksum rayon-core 1.7.0 
(registry+https://github.com/rust-lang/crates.io-index)" = 
"08a89b46efaf957e52b18062fb2f4660f8b8a4dde1807ca002690868ef2c85a9"
 "checksum redox_syscall 0.1.56 
(registry+https://github.com/rust-lang/crates.io-index)" = 
"2439c63f3f6139d1b57529d16bc3b8bb855230c8efcc5d3a896c8bea7c3b1e84"
-"checksum regex 1.3.6 (registry+https://github.com/rust-lang/crates.io-index)" 
= "7f6946991529684867e47d86474e3a6d0c0ab9b82d5821e314b1ede31fa3a4b3"
-"checksum regex-syntax 0.6.17 
(registry+https://github.com/rust-lang/crates.io-index)" = 
"7fe5bd57d1d7414c6b5ed48563a2c855d995ff29dcd91c369ec7fea395ae"
+"checksum regex 1.3.9 (registry+https://github.com/rust-lang/crates.io-index)" 
= "9c3780fcf44b193bc4d09f36d2a3c87b251da4a046c87795a0d35f4f927ad8e6"
+"checksum regex-syntax 0.6.18 
(registry+https://github.com/rust-lang/crates.io-index)" = 
"26412eb97c6b088a6997e05f69403a802a92d520de2f8e63c2b65f9e0f47c4e8"
 "checksum remove_dir_all 0.5.2 
(registry+https://github.com/rust-lang/crates.io-index)" = 
"4a83fa3702a688b9359eccba92d153ac33fd2e8462f9e0e3fdf155239ea7792e"
 "checksum rustc_version 0.2.3 
(registry+https://github.com/rust-lang/crates.io-index)" = 
"138e3e0acb6c9fb258b19b67cb8abd63c00679d2851805ea151465464fe9030a"
 "checksum same-file 1.0.6 
(registry+https://github.com/rust-lang/crates.io-index)" = 
"93fc1dc3aaa9bfed95e02e6eadabb4baf7e3078b0bd1b4d7b6b0b68378900502"



To: Alphare, #hg-reviewers
Cc: mercurial-patches, mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


Re: [PATCH 1 of 2] rust: fix false comment about mpsc::Sender

2020-05-25 Thread Raphaël Gomès

Good catch, patch 2 also looks good, thanks.

On 5/25/20 4:27 PM, Yuya Nishihara wrote:

# HG changeset patch
# User Yuya Nishihara 
# Date 1590415327 -32400
#  Mon May 25 23:02:07 2020 +0900
# Node ID 261fbbdabb261a44c0f82537f10abbcc0d85ace1
# Parent  f3b69aecfdc3f6149a30f87bba43396890c2bee7
rust: fix false comment about mpsc::Sender

We need Sync to share the Sender reference across threads.

diff --git a/rust/hg-core/src/dirstate/status.rs 
b/rust/hg-core/src/dirstate/status.rs
--- a/rust/hg-core/src/dirstate/status.rs
+++ b/rust/hg-core/src/dirstate/status.rs
@@ -560,7 +560,7 @@ fn traverse<'a>(
  let root_dir = root_dir.as_ref();
  
  // The traversal is done in parallel, so use a channel to gather entries.

-// `crossbeam::Sender` is `Send`, while `mpsc::Sender` is not.
+// `crossbeam::Sender` is `Sync`, while `mpsc::Sender` is not.
  let (files_transmitter, files_receiver) = crossbeam::channel::unbounded();
  
  traverse_dir(

@@ -877,7 +877,7 @@ pub fn status<'a: 'c, 'b: 'c, 'c>(
  
  let files = matcher.file_set();
  
-// `crossbeam::Sender` is `Send`, while `mpsc::Sender` is not.

+// `crossbeam::Sender` is `Sync`, while `mpsc::Sender` is not.
  let (traversed_sender, traversed_recv) = crossbeam::channel::unbounded();
  
  // Step 1: check the files explicitly mentioned by the user

___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel

___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


<    1   2   3   4   5   6   7   8   9   10   >