D10505: mail: add a TODO about proper mbox locking

2021-04-20 Thread mharbison72 (Matt Harbison)
mharbison72 created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  Per @nbjoerg in IRC, the mbox isn't locked correctly.

REPOSITORY
  rHG Mercurial

BRANCH
  stable

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

AFFECTED FILES
  mercurial/mail.py

CHANGE DETAILS

diff --git a/mercurial/mail.py b/mercurial/mail.py
--- a/mercurial/mail.py
+++ b/mercurial/mail.py
@@ -220,6 +220,7 @@
 
 def _mbox(mbox, sender, recipients, msg):
 '''write mails to mbox'''
+# TODO: use python mbox library for proper locking
 with open(mbox, b'ab+') as fp:
 # Should be time.asctime(), but Windows prints 2-characters day
 # of month instead of one. Make them print the same thing.



To: mharbison72, #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


D10504: dirstateguard: use mktemp-like functionality to generate the backup filenames

2021-04-20 Thread spectral (Kyle Lippincott)
spectral created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  Previously these were generated with names like:
  `dirstate.backup.commit.`
  
  This could cause problems if two hg commands ran at the same time that used 
the
  same memory address, (which is apparently not uncommon if chg is involved), as
  memory addresses are not unique across processes.
  
  This issue was reported in the post-review comments on
  http://phab.mercurial-scm.org/D9952.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  mercurial/dirstateguard.py

CHANGE DETAILS

diff --git a/mercurial/dirstateguard.py b/mercurial/dirstateguard.py
--- a/mercurial/dirstateguard.py
+++ b/mercurial/dirstateguard.py
@@ -7,6 +7,7 @@
 
 from __future__ import absolute_import
 
+import os
 from .i18n import _
 
 from . import (
@@ -34,11 +35,12 @@
 self._repo = repo
 self._active = False
 self._closed = False
-self._backupname = b'dirstate.backup.%s.%d' % (name, id(self))
-self._narrowspecbackupname = b'narrowspec.backup.%s.%d' % (
-name,
-id(self),
-)
+def getname(prefix):
+fd, fname = repo.vfs.mkstemp(prefix=prefix)
+os.close(fd)
+return fname
+self._backupname = getname(b'dirstate.backup.%s.' % name)
+self._narrowspecbackupname = getname(b'narrowspec.backup.%s.' % name)
 repo.dirstate.savebackup(repo.currenttransaction(), self._backupname)
 narrowspec.savewcbackup(repo, self._narrowspecbackupname)
 self._active = True



To: spectral, #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


D10503: narrow: add more status messages when narrowing

2021-04-20 Thread martinvonz (Martin von Zweigbergk)
martinvonz created this revision.
Herald added a reviewer: durin42.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  Each of the steps I added status messages for in this patch frequently
  take minutes or tens of minutes for our internal users.
  
  It would be nice to also have a progress bar but that will have to
  come later.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  hgext/narrow/narrowcommands.py
  tests/test-narrow-clone-non-narrow-server.t
  tests/test-narrow-patterns.t
  tests/test-narrow-share.t
  tests/test-narrow-trackedcmd.t
  tests/test-narrow.t

CHANGE DETAILS

diff --git a/tests/test-narrow.t b/tests/test-narrow.t
--- a/tests/test-narrow.t
+++ b/tests/test-narrow.t
@@ -132,12 +132,14 @@
   looking for local changes to affected paths
   The following changeset(s) or their ancestors have local changes not on the 
remote:
   * (glob)
+  moving unwanted changesets to backup
   saved backup bundle to 
$TESTTMP/narrow-local-changes/.hg/strip-backup/*-narrow.hg (glob)
   deleting data/d0/f.i (reporevlogstore !)
   deleting meta/d0/00manifest.i (tree !)
   deleting data/d0/f/362fef284ce2ca02aecc8de6d5e8a1c3af0556fe (reposimplestore 
!)
   deleting data/d0/f/4374b5650fc5ae54ac857c0f0381971fdde376f7 (reposimplestore 
!)
   deleting data/d0/f/index (reposimplestore !)
+  deleting unwanted files from working copy
 
   $ hg log -T "{rev}: {desc} {outsidenarrow}\n"
   7: local change to d3 
@@ -164,12 +166,14 @@
   comparing with ssh://user@dummy/master
   searching for changes
   looking for local changes to affected paths
+  moving unwanted changesets to backup
   saved backup bundle to 
$TESTTMP/narrow-local-changes/.hg/strip-backup/*-narrow.hg (glob)
   deleting data/d0/f.i (reporevlogstore !)
   deleting meta/d0/00manifest.i (tree !)
   deleting data/d0/f/362fef284ce2ca02aecc8de6d5e8a1c3af0556fe (reposimplestore 
!)
   deleting data/d0/f/4374b5650fc5ae54ac857c0f0381971fdde376f7 (reposimplestore 
!)
   deleting data/d0/f/index (reposimplestore !)
+  deleting unwanted files from working copy
 
 Updates off of stripped commit if necessary
   $ hg co -r 'desc("local change to d3")' -q
@@ -183,12 +187,14 @@
   * (glob)
   * (glob)
   2 files updated, 0 files merged, 0 files removed, 0 files unresolved
+  moving unwanted changesets to backup
   saved backup bundle to 
$TESTTMP/narrow-local-changes/.hg/strip-backup/*-narrow.hg (glob)
   deleting data/d3/f.i (reporevlogstore !)
   deleting meta/d3/00manifest.i (tree !)
   deleting data/d3/f/2661d26c649684b482d10f91960cc3db683c38b4 (reposimplestore 
!)
   deleting data/d3/f/99fa7136105a15e2045ce3d9152e4837c5349e4d (reposimplestore 
!)
   deleting data/d3/f/index (reposimplestore !)
+  deleting unwanted files from working copy
   $ hg log -T '{desc}\n' -r .
   add d10/f
 Updates to nullid if necessary
@@ -206,12 +212,14 @@
   The following changeset(s) or their ancestors have local changes not on the 
remote:
   * (glob)
   0 files updated, 0 files merged, 1 files removed, 0 files unresolved
+  moving unwanted changesets to backup
   saved backup bundle to 
$TESTTMP/narrow-local-changes/.hg/strip-backup/*-narrow.hg (glob)
   deleting data/d3/f.i (reporevlogstore !)
   deleting meta/d3/00manifest.i (tree !)
   deleting data/d3/f/2661d26c649684b482d10f91960cc3db683c38b4 (reposimplestore 
!)
   deleting data/d3/f/5ce0767945cbdbca3b924bb9fbf5143f72ab40ac (reposimplestore 
!)
   deleting data/d3/f/index (reposimplestore !)
+  deleting unwanted files from working copy
   $ hg id
   
   $ cd ..
@@ -272,6 +280,7 @@
   deleting meta/d0/00manifest.i (tree !)
   deleting data/d0/f/362fef284ce2ca02aecc8de6d5e8a1c3af0556fe (reposimplestore 
!)
   deleting data/d0/f/index (reposimplestore !)
+  deleting unwanted files from working copy
   $ hg tracked
   $ hg files
   [1]
@@ -332,6 +341,7 @@
   deleting meta/d6/00manifest.i (tree !)
   deleting data/d6/f/7339d30678f451ac8c3f38753beeb4cf2e1655c7 (reposimplestore 
!)
   deleting data/d6/f/index (reposimplestore !)
+  deleting unwanted files from working copy
   $ hg tracked
   I path:d0
   I path:d3
@@ -355,6 +365,7 @@
   deleting data/d3/f.i (reporevlogstore !)
   deleting data/d3/f/2661d26c649684b482d10f91960cc3db683c38b4 (reposimplestore 
!)
   deleting data/d3/f/index (reposimplestore !)
+  deleting unwanted files from working copy
   $ hg tracked
   I path:d0
   I path:d3
@@ -378,6 +389,7 @@
   deleting meta/d0/00manifest.i (tree !)
   deleting data/d0/f/362fef284ce2ca02aecc8de6d5e8a1c3af0556fe (reposimplestore 
!)
   deleting data/d0/f/index (reposimplestore !)
+  deleting unwanted files from working copy
   $ hg tracked
   I path:d3
   I path:d9
@@ -478,11 +490,13 @@
   path:d2
   remove these unused includes (yn)? y
   looking for local changes to affected paths
+  moving unwanted changesets to backup
   saved backup bundle to 

D10502: packaging: extract pre-computed version when running from plain tarball

2021-04-20 Thread joerg.sonnenberger (Joerg Sonnenberger)
joerg.sonnenberger created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  The tarballs created by setup.py are not including the usual archive
  markers as `hg export` leaves, so the rewrite of the version number
  computation actually left the empty version string around. This meant
  that installations from PyPI would use 0.0.0 as version string.

REPOSITORY
  rHG Mercurial

BRANCH
  stable

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

AFFECTED FILES
  setup.py

CHANGE DETAILS

diff --git a/setup.py b/setup.py
--- a/setup.py
+++ b/setup.py
@@ -437,6 +437,9 @@
 version = '%(latesttag)s+hg%(latesttagdistance)s.%(node).12s' % kw
 else:
 version = '0+hg' + kw.get('node', '')[:12]
+elif os.path.exists('mercurial/__version__.py'):
+data = open('mercurial/__version__.py').read()
+version = re.search('version = b"(.*)"', data).group(1)
 
 if version:
 versionb = version



To: joerg.sonnenberger, #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


D10501: narrow: add progress-reporting when looking for local changes in `hg tracked`

2021-04-20 Thread martinvonz (Martin von Zweigbergk)
martinvonz created this revision.
Herald added a reviewer: durin42.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  Looking for local changes (changes not on the given remote) can take a
  long time, so we should have progress-reporting for it.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  hgext/narrow/narrowcommands.py

CHANGE DETAILS

diff --git a/hgext/narrow/narrowcommands.py b/hgext/narrow/narrowcommands.py
--- a/hgext/narrow/narrowcommands.py
+++ b/hgext/narrow/narrowcommands.py
@@ -228,10 +228,17 @@
 unfi = repo.unfiltered()
 outgoing = discovery.findcommonoutgoing(unfi, remote, commoninc=commoninc)
 ui.status(_(b'looking for local changes to affected paths\n'))
+progress = ui.makeprogress(
+topic=_(b'changesets'),
+unit=_(b'changesets'),
+total=len(outgoing.missing) + len(outgoing.excluded),
+)
 localnodes = []
-for n in itertools.chain(outgoing.missing, outgoing.excluded):
-if any(oldmatch(f) and not newmatch(f) for f in unfi[n].files()):
-localnodes.append(n)
+with progress:
+for n in itertools.chain(outgoing.missing, outgoing.excluded):
+if any(oldmatch(f) and not newmatch(f) for f in unfi[n].files()):
+localnodes.append(n)
+progress.increment()
 revstostrip = unfi.revs(b'descendants(%ln)', localnodes)
 hiddenrevs = repoview.filterrevs(repo, b'visible')
 visibletostrip = list(



To: martinvonz, 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


Failed pipeline for branch/default | mercurial-devel | 9fbe3670

2021-04-20 Thread Heptapod


Pipeline #20909 has failed!

Project: mercurial-devel ( https://foss.heptapod.net/octobus/mercurial-devel )
Branch: branch/default ( 
https://foss.heptapod.net/octobus/mercurial-devel/-/commits/branch/default )

Commit: 9fbe3670 ( 
https://foss.heptapod.net/octobus/mercurial-devel/-/commit/9fbe367092b20fcbb063cc5227321db2470f0646
 )
Commit Message: node: replace nullid and friends with nodeconst...
Commit Author: Jörg Sonnenberger ( https://foss.heptapod.net/joerg )

Pipeline #20909 ( 
https://foss.heptapod.net/octobus/mercurial-devel/-/pipelines/20909 ) triggered 
by Administrator ( https://foss.heptapod.net/root )
had 1 failed build.

Job #188185 ( 
https://foss.heptapod.net/octobus/mercurial-devel/-/jobs/188185/raw )

Stage: phabricator
Name: phabricator-refresh

-- 
You're receiving this email because of your account on foss.heptapod.net.



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


Failed pipeline for branch/stable | mercurial-devel | 0f014579

2021-04-20 Thread Heptapod


Pipeline #20906 has failed!

Project: mercurial-devel ( https://foss.heptapod.net/octobus/mercurial-devel )
Branch: branch/stable ( 
https://foss.heptapod.net/octobus/mercurial-devel/-/commits/branch/stable )

Commit: 0f014579 ( 
https://foss.heptapod.net/octobus/mercurial-devel/-/commit/0f014579668a4aa6c8e9a8d2fe2424715d7c9742
 )
Commit Message: Added signature for changeset f67b8946bb1b

--H...
Commit Author: durin42 ( https://foss.heptapod.net/durin42 )

Pipeline #20906 ( 
https://foss.heptapod.net/octobus/mercurial-devel/-/pipelines/20906 ) triggered 
by Administrator ( https://foss.heptapod.net/root )
had 3 failed builds.

Job #188139 ( 
https://foss.heptapod.net/octobus/mercurial-devel/-/jobs/188139/raw )

Stage: tests
Name: test-py2-chg
Job #188132 ( 
https://foss.heptapod.net/octobus/mercurial-devel/-/jobs/188132/raw )

Stage: tests
Name: test-py2
Job #188138 ( 
https://foss.heptapod.net/octobus/mercurial-devel/-/jobs/188138/raw )

Stage: tests
Name: test-py3-rhg

-- 
You're receiving this email because of your account on foss.heptapod.net.



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


mercurial@46995: 3 new changesets (3 on stable)

2021-04-20 Thread Mercurial Commits
3 new changesets (3 on stable) in mercurial:

https://www.mercurial-scm.org/repo/hg/rev/f67b8946bb1b
changeset:   46993:f67b8946bb1b
branch:  stable
tag: 5.8rc0
parent:  46810:bc268ea9f984
parent:  46992:5fa019ceb499
user:Augie Fackler 
date:Tue Apr 20 11:01:06 2021 -0400
summary: merge: default into stable for 5.8 rc

https://www.mercurial-scm.org/repo/hg/rev/e846261413d0
changeset:   46994:e846261413d0
branch:  stable
user:Augie Fackler 
date:Tue Apr 20 11:12:19 2021 -0400
summary: Added tag 5.8rc0 for changeset f67b8946bb1b

https://www.mercurial-scm.org/repo/hg/rev/01264552a1dc
changeset:   46995:01264552a1dc
branch:  stable
bookmark:@
tag: tip
user:Augie Fackler 
date:Tue Apr 20 11:12:20 2021 -0400
summary: Added signature for changeset f67b8946bb1b

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


D10500: relnotes: copy "next" to "5.8" and clear "next"

2021-04-20 Thread martinvonz (Martin von Zweigbergk)
martinvonz created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  The same procedure as every year^Wcycle.

REPOSITORY
  rHG Mercurial

BRANCH
  stable

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

AFFECTED FILES
  relnotes/5.8
  relnotes/next

CHANGE DETAILS

diff --git a/relnotes/next b/relnotes/next
--- a/relnotes/next
+++ b/relnotes/next
@@ -1,24 +1,8 @@
 == New Features ==
  
- * `hg purge` is now a core command using `--confirm` by default.
- 
- * The `rev-branch-cache` is now updated incrementally whenever changesets
-   are added.
-
- * The new options `experimental.bundlecompthreads` and
-   `experimental.bundlecompthreads.` can be used to instruct
-   the compression engines for bundle operations to use multiple threads
-   for compression. The default is single threaded operation. Currently
-   only supported for zstd.
 
 == New Experimental Features ==
 
- * There's a new `diff.merge` config option to show the changes
-relative to an automerge for merge changesets. This makes it
-easier to detect and review manual changes performed in merge
-changesets. It is supported by `hg diff --change`, `hg log -p`
-`hg incoming -p`, and `hg outgoing -p` so far.
-
 
 == Bug Fixes ==
 
@@ -26,24 +10,6 @@
 
 == Backwards Compatibility Changes ==
 
- * In normal repositories, the first parent of a changeset is not null,
-   unless both parents are null (like the first changeset). Some legacy
-   repositories violate this condition. The revlog code will now
-   silentely swap the parents if this condition is tested. This can
-   change the output of `hg log` when explicitly asking for first or
-   second parent.
-
 
 == Internal API Changes ==
 
- * `changelog.branchinfo` is deprecated and will be removed after 5.8.
-   It is superseded by `changelogrevision.branchinfo`.
-
- * Callbacks for revlog.addgroup and the changelog._nodeduplicatecallback hook
-   now get a revision number as argument instead of a node.
-
- * revlog.addrevision returns the revision number instead of the node.
-
- * `nodes.nullid` and related constants are being phased out as part of
-   the deprecation of SHA1. Repository instances and related classes
-   provide access via `nodeconstants` and in some cases `nullid` attributes.
diff --git a/relnotes/next b/relnotes/5.8
copy from relnotes/next
copy to relnotes/5.8



To: martinvonz, #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


mercurial@46992: 89 new changesets

2021-04-20 Thread Mercurial Commits
89 new changesets in mercurial:

https://www.mercurial-scm.org/repo/hg/rev/ede52e19c752
changeset:   46904:ede52e19c752
user:Pierre-Yves David 
date:Sat Apr 10 15:28:10 2021 +0200
summary: help: point to `hg help urls` in `hg help config.paths`

https://www.mercurial-scm.org/repo/hg/rev/95a5ed7db9ca
changeset:   46905:95a5ed7db9ca
user:Pierre-Yves David 
date:Sat Apr 10 15:30:32 2021 +0200
summary: help: document the `path://` url scheme

https://www.mercurial-scm.org/repo/hg/rev/33524c46a092
changeset:   46906:33524c46a092
user:Pierre-Yves David 
date:Sun Apr 11 23:54:35 2021 +0200
summary: urlutil: extract `path` related code into a new module

https://www.mercurial-scm.org/repo/hg/rev/ffd3e823a7e5
changeset:   46907:ffd3e823a7e5
user:Pierre-Yves David 
date:Mon Apr 12 03:01:04 2021 +0200
summary: urlutil: extract `url` related code from `util` into the new module

https://www.mercurial-scm.org/repo/hg/rev/4452cb788404
changeset:   46908:4452cb788404
user:Pierre-Yves David 
date:Mon Apr 12 06:34:54 2021 +0200
summary: urlutil: extract `parseurl` from `hg` into the new module

https://www.mercurial-scm.org/repo/hg/rev/067840864f37
changeset:   46909:067840864f37
user:Pierre-Yves David 
date:Mon Apr 12 22:22:56 2021 +0200
summary: urlutil: add a `get_push_paths` to perform the push destination 
logic

https://www.mercurial-scm.org/repo/hg/rev/df7439cc6806
changeset:   46910:df7439cc6806
user:Pierre-Yves David 
date:Tue Apr 13 12:28:44 2021 +0200
summary: urlutil: add a `get_pull_paths` to perform the pull destination 
logic

https://www.mercurial-scm.org/repo/hg/rev/6071bfab6292
changeset:   46911:6071bfab6292
user:Pierre-Yves David 
date:Sat Apr 10 21:55:01 2021 +0200
summary: infinitepush: use the new function to determine push destination

https://www.mercurial-scm.org/repo/hg/rev/627bb1875fee
changeset:   46912:627bb1875fee
user:Pierre-Yves David 
date:Sun Apr 11 19:20:14 2021 +0200
summary: outgoing: remove some early return

https://www.mercurial-scm.org/repo/hg/rev/b2740c547243
changeset:   46913:b2740c547243
user:Pierre-Yves David 
date:Sun Apr 11 19:31:03 2021 +0200
summary: outgoing: make `recurse` a real function

https://www.mercurial-scm.org/repo/hg/rev/50b79f8b802d
changeset:   46914:50b79f8b802d
user:Pierre-Yves David 
date:Tue Apr 13 15:13:20 2021 +0200
summary: outgoing: move filtering logic in its own function

https://www.mercurial-scm.org/repo/hg/rev/efc6f6a794bd
changeset:   46915:efc6f6a794bd
user:Pierre-Yves David 
date:Sun Apr 11 20:00:46 2021 +0200
summary: outgoing: merge the code handling --graph with the main one

https://www.mercurial-scm.org/repo/hg/rev/7061eee84151
changeset:   46916:7061eee84151
user:Pierre-Yves David 
date:Tue Apr 13 15:32:59 2021 +0200
summary: push-dests: rework the handling of default value

https://www.mercurial-scm.org/repo/hg/rev/efadec3ea8e2
changeset:   46917:efadec3ea8e2
user:Pierre-Yves David 
date:Tue Apr 13 15:30:32 2021 +0200
summary: push-dests: move the code around missing default dest inside 
`get_push_paths`

https://www.mercurial-scm.org/repo/hg/rev/248cbe173203
changeset:   46918:248cbe173203
user:Pierre-Yves David 
date:Wed Apr 14 15:53:43 2021 +0200
summary: run-test: make it clearer  why we terminating process

https://www.mercurial-scm.org/repo/hg/rev/9799ba0abb12
changeset:   46919:9799ba0abb12
user:Pierre-Yves David 
date:Wed Apr 14 15:54:32 2021 +0200
summary: test-lfs: avoid pagination

https://www.mercurial-scm.org/repo/hg/rev/7a9b74e98240
changeset:   46920:7a9b74e98240
user:Pierre-Yves David 
date:Wed Apr 14 15:56:21 2021 +0200
summary: test-lfs: avoid a bashism when spawning the server

https://www.mercurial-scm.org/repo/hg/rev/8f7b1bf3c540
changeset:   46921:8f7b1bf3c540
user:Pierre-Yves David 
date:Wed Apr 14 16:09:12 2021 +0200
summary: test-lfs: fix expected output

https://www.mercurial-scm.org/repo/hg/rev/17368844f786
changeset:   46922:17368844f786
user:Kyle Lippincott 
date:Mon Apr 12 17:51:56 2021 -0700
summary: split: add test demonstrating issue with empty splits adjusting 
phases

https://www.mercurial-scm.org/repo/hg/rev/8ee1ac083ee7
changeset:   46923:8ee1ac083ee7
user:Kyle Lippincott 
date:Mon Apr 12 17:52:46 2021 -0700
summary: split: fix issue with empty splits adjusting phases

https://www.mercurial-scm.org/repo/hg/rev/ca0049946e9a
changeset:   46924:ca0049946e9a
user:Kyle Lippincott 
date:Mon Apr 12 19:25:34 2021 -0700
summary: split: avoid strip if split is a no-op (identical to original)

https://www.mercurial-scm.org/repo/hg/rev/b5e8bf10436e
changeset:   46925:b5e8bf10436e
user:Simon 

D10499: relnote: mention a nodemap bug fixes

2021-04-20 Thread marmoute (Pierre-Yves David)
marmoute created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  The fix was in a3720569a43f 
.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  relnotes/next

CHANGE DETAILS

diff --git a/relnotes/next b/relnotes/next
--- a/relnotes/next
+++ b/relnotes/next
@@ -40,6 +40,7 @@
 
 == Bug Fixes ==
 
+ * gracefully recover from inconsistent persistent-nodemap data from disk.
 
 
 == Backwards Compatibility Changes ==



To: marmoute, #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


D10498: relnote: document the use of persistent-nodemap by default for Rust build

2021-04-20 Thread marmoute (Pierre-Yves David)
marmoute 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/D10498

AFFECTED FILES
  relnotes/next

CHANGE DETAILS

diff --git a/relnotes/next b/relnotes/next
--- a/relnotes/next
+++ b/relnotes/next
@@ -21,6 +21,14 @@
 released in May 2019. See `hg help config.format.revlog-compression` for
 details.
 
+  * Mercurial installation built with the Rust parts will now use the
+"persistent nodemap" feature by default. This feature was introduced in
+Mercurial 5.4 (May 2020). However Mercurial instalation built without the
+fast Rust implementation will refuse to interract with them by default.
+This restriction can be lifted through configuration.
+
+See `hg help config.format.use-persistent-nodemap` for details
+
 == New Experimental Features ==
 
  * There's a new `diff.merge` config option to show the changes



To: marmoute, #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


D10497: relnode: document the move to `zstd` as default compression

2021-04-20 Thread marmoute (Pierre-Yves David)
marmoute 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/D10497

AFFECTED FILES
  relnotes/next

CHANGE DETAILS

diff --git a/relnotes/next b/relnotes/next
--- a/relnotes/next
+++ b/relnotes/next
@@ -11,6 +11,16 @@
for compression. The default is single threaded operation. Currently
only supported for zstd.
 
+== Default Format Change ==
+
+These changes affects newly created repositories (or new clone) done with
+Mercurial 5.8.
+
+  * The `ZSTD` compression will now be used by default for new repositories
+when available. This compression format was introduced in Mercurial 5.0,
+released in May 2019. See `hg help config.format.revlog-compression` for
+details.
+
 == New Experimental Features ==
 
  * There's a new `diff.merge` config option to show the changes



To: marmoute, #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


D10496: relnote: clarify the backward compatibility entry about p1/p2 swap

2021-04-20 Thread marmoute (Pierre-Yves David)
marmoute created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  The previous message might read a bit scary. So we clarify that the nodeid are
  not affected.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  relnotes/next

CHANGE DETAILS

diff --git a/relnotes/next b/relnotes/next
--- a/relnotes/next
+++ b/relnotes/next
@@ -31,7 +31,7 @@
repositories violate this condition. The revlog code will now
silentely swap the parents if this condition is tested. This can
change the output of `hg log` when explicitly asking for first or
-   second parent.
+   second parent. The changesets "nodeid" are not affected.
 
 
 == Internal API Changes ==



To: marmoute, #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


D10490: dirstate-tree: Add has_dir and has_tracked_dir

2021-04-20 Thread SimonSapin
SimonSapin created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  A node without a `DirstateMap` entry represents a directory.
  
  Only some values of `EntryState` represent tracked files.
  A directory is considered "tracked" if it contains any descendant file that
  is tracked. To avoid a sub-tree traversal in `has_tracked_dir` we add a
  counter for this. A boolean flag would become insufficent when we implement
  remove_file and drop_file.
  
  `add_file_node` is more general than needed here, in anticipation of adding
  the `add_file` and `remove_file` methods.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

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

CHANGE DETAILS

diff --git a/rust/hg-core/src/dirstate_tree/dirstate_map.rs 
b/rust/hg-core/src/dirstate_tree/dirstate_map.rs
--- a/rust/hg-core/src/dirstate_tree/dirstate_map.rs
+++ b/rust/hg-core/src/dirstate_tree/dirstate_map.rs
@@ -46,11 +46,30 @@
 /// string prefix.
 type ChildNodes = BTreeMap, Node>;
 
+/// Represents a file or a directory
 #[derive(Default)]
 struct Node {
+/// `None` for directories
 entry: Option,
+
 copy_source: Option,
+
+/// Empty for files
 children: ChildNodes,
+
+/// How many (non-inclusive) descendants of this node are tracked files
+tracked_descendants_count: usize,
+}
+
+impl Node {
+/// Whether this node has a `DirstateEntry` with `.state.is_tracked()`
+fn is_tracked_file() -> bool {
+if let Some(entry) =  {
+entry.state.is_tracked()
+} else {
+false
+}
+}
 }
 
 /// `(full_path, entry, copy_source)`
@@ -87,18 +106,48 @@
 }
 }
 
+/// Returns a mutable reference to the node at `path` if it exists
+///
 /// This takes `root` instead of ` self` so that callers can mutate
 /// other fields while the returned borrow is still valid
 fn get_node_mut<'tree>(
 root: &'tree mut ChildNodes,
 path: ,
 ) -> Option<&'tree mut Node> {
+Self::each_and_get(root, path, |_| {})
+}
+
+/// Call `each` for each ancestor node of the one at `path` (not including
+/// that node itself), starting from nearest the root.
+///
+/// Panics (possibly after some calls to `each`) if there is no node at
+/// `path`.
+fn for_each_ancestor_node<'tree>(
+ self,
+path: ,
+each: impl FnMut( Node),
+) {
+let parent = path.parent();
+if !parent.is_empty() {
+Self::each_and_get( self.root, parent, each)
+.expect("missing dirstate node");
+}
+}
+
+/// Common implementation detail of `get_node_mut` and
+/// `for_each_ancestor_node`
+fn each_and_get<'tree>(
+root: &'tree mut ChildNodes,
+path: ,
+mut each: impl FnMut( Node),
+) -> Option<&'tree mut Node> {
 let mut children = root;
 let mut components = path.components();
 let mut component =
 components.next().expect("expected at least one components");
 loop {
 let child = children.get_mut(component)?;
+each(child);
 if let Some(next_component) = components.next() {
 component = next_component;
 children =  child.children;
@@ -162,10 +211,29 @@
 self.nodes_with_copy_source_count -= 1
 }
 }
+let tracked_count_increment =
+match (node.is_tracked_file(), new_entry.state.is_tracked()) {
+(false, true) => 1,
+(true, false) => -1,
+_ => 0,
+};
+
 node.entry = Some(new_entry);
 if let Some(source) = new_copy_source {
 node.copy_source = source
 }
+// Borrow of `self.root` through `node` ends here
+
+match tracked_count_increment {
+1 => self.for_each_ancestor_node(path, |node| {
+node.tracked_descendants_count += 1
+}),
+// We can’t use `+= -1` because the counter is unsigned
+-1 => self.for_each_ancestor_node(path, |node| {
+node.tracked_descendants_count -= 1
+}),
+_ => {}
+}
 }
 
 fn iter_nodes<'a>(
@@ -335,16 +403,28 @@
 
 fn has_tracked_dir(
  self,
-_directory: ,
+directory: ,
 ) -> Result {
-todo!()
+if let Some(node) = self.get_node(directory) {
+// A node without a `DirstateEntry` was created to hold child
+// nodes, and is therefore a directory.
+Ok(node.entry.is_none() && node.tracked_descendants_count > 0)
+} else {
+Ok(false)
+}
 }
 
 fn has_dir(
  self,
-_directory: ,
+directory: ,
 ) -> Result 

D10492: dirstate-tree: Add "non normal" and "from other parent" sets

2021-04-20 Thread SimonSapin
SimonSapin created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  Unlike the other DirstateMap implementation, these sets are not materialized
  separately in memory. Instead we traverse the main tree.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

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

CHANGE DETAILS

diff --git a/rust/hg-core/src/dirstate_tree/dispatch.rs 
b/rust/hg-core/src/dirstate_tree/dispatch.rs
--- a/rust/hg-core/src/dirstate_tree/dispatch.rs
+++ b/rust/hg-core/src/dirstate_tree/dispatch.rs
@@ -45,7 +45,7 @@
 
 fn non_normal_entries_contains( self, key: ) -> bool;
 
-fn non_normal_entries_remove( self, key: ) -> bool;
+fn non_normal_entries_remove( self, key: );
 
 fn non_normal_or_other_parent_paths(
  self,
@@ -179,7 +179,7 @@
 non_normal.contains(key)
 }
 
-fn non_normal_entries_remove( self, key: ) -> bool {
+fn non_normal_entries_remove( self, key: ) {
 self.non_normal_entries_remove(key)
 }
 
diff --git a/rust/hg-core/src/dirstate_tree/dirstate_map.rs 
b/rust/hg-core/src/dirstate_tree/dirstate_map.rs
--- a/rust/hg-core/src/dirstate_tree/dirstate_map.rs
+++ b/rust/hg-core/src/dirstate_tree/dirstate_map.rs
@@ -398,40 +398,61 @@
 }
 }
 
-fn non_normal_entries_contains( self, _key: ) -> bool {
-todo!()
+fn non_normal_entries_contains( self, key: ) -> bool {
+self.get_node(key)
+.and_then(|node| node.entry.as_ref())
+.map_or(false, DirstateEntry::is_non_normal)
 }
 
-fn non_normal_entries_remove( self, _key: ) -> bool {
-todo!()
+fn non_normal_entries_remove( self, _key: ) {
+// Do nothing, this `DirstateMap` does not have a separate "non normal
+// entries" set that need to be kept up to date
 }
 
 fn non_normal_or_other_parent_paths(
  self,
 ) -> Box + '_> {
-todo!()
+Box::new(self.iter_nodes().filter_map(|(path, node)| {
+node.entry
+.as_ref()
+.filter(|entry| {
+entry.is_non_normal() || entry.is_from_other_parent()
+})
+.map(|_| path.full_path())
+}))
 }
 
 fn set_non_normal_other_parent_entries( self, _force: bool) {
-todo!()
+// Do nothing, this `DirstateMap` does not have a separate "non normal
+// entries" and "from other parent" sets that need to be recomputed
 }
 
 fn iter_non_normal_paths(
  self,
 ) -> Box + Send + '_> {
-todo!()
+self.iter_non_normal_paths_panic()
 }
 
 fn iter_non_normal_paths_panic(
 ,
 ) -> Box + Send + '_> {
-todo!()
+Box::new(self.iter_nodes().filter_map(|(path, node)| {
+node.entry
+.as_ref()
+.filter(|entry| entry.is_non_normal())
+.map(|_| path.full_path())
+}))
 }
 
 fn iter_other_parent_paths(
  self,
 ) -> Box + Send + '_> {
-todo!()
+Box::new(self.iter_nodes().filter_map(|(path, node)| {
+node.entry
+.as_ref()
+.filter(|entry| entry.is_from_other_parent())
+.map(|_| path.full_path())
+}))
 }
 
 fn has_tracked_dir(
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
@@ -10,7 +10,7 @@
 use crate::errors::HgError;
 use crate::revlog::node::NULL_NODE;
 use crate::{
-dirstate::{parsers::PARENT_SIZE, EntryState, SIZE_FROM_OTHER_PARENT},
+dirstate::{parsers::PARENT_SIZE, EntryState},
 pack_dirstate, parse_dirstate,
 utils::{
 files::normalize_case,
@@ -27,8 +27,6 @@
 
 pub type FileFoldMap = FastHashMap;
 
-const MTIME_UNSET: i32 = -1;
-
 #[derive(Default)]
 pub struct DirstateMap {
 state_map: StateMap,
@@ -99,13 +97,13 @@
 }
 self.state_map.insert(filename.to_owned(), entry.to_owned());
 
-if entry.state != EntryState::Normal || entry.mtime == MTIME_UNSET {
+if entry.is_non_normal() {
 self.get_non_normal_other_parent_entries()
 .0
 .insert(filename.to_owned());
 }
 
-if entry.size == SIZE_FROM_OTHER_PARENT {
+if entry.is_from_other_parent() {
 self.get_non_normal_other_parent_entries()
 .1
 .insert(filename.to_owned());
@@ -199,14 +197,12 @@
 }
 }
 
-pub fn non_normal_entries_remove(
- self,
-key: impl AsRef,
-) -> bool {
+pub fn non_normal_entries_remove( self, key: impl 

D10494: rust: Move "lookup" a.k.a. "unsure" paths into `DirstateStatus` struct

2021-04-20 Thread SimonSapin
SimonSapin created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  Instead of having `status()` returning a tuple of those paths and
  `DirstateStatus`.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  rust/hg-core/src/dirstate/status.rs
  rust/hg-core/src/dirstate_tree/dirstate_map.rs
  rust/hg-core/src/dirstate_tree/dispatch.rs
  rust/hg-core/src/operations/dirstate_status.rs
  rust/hg-cpython/src/dirstate/status.rs
  rust/rhg/src/commands/status.rs

CHANGE DETAILS

diff --git a/rust/rhg/src/commands/status.rs b/rust/rhg/src/commands/status.rs
--- a/rust/rhg/src/commands/status.rs
+++ b/rust/rhg/src/commands/status.rs
@@ -181,7 +181,7 @@
 collect_traversed_dirs: false,
 };
 let ignore_file = repo.working_directory_vfs().join(".hgignore"); // TODO 
hardcoded
-let ((lookup, ds_status), pattern_warnings) = hg::status(
+let (ds_status, pattern_warnings) = hg::status(
 ,
 ,
 repo.working_directory_path().to_owned(),
@@ -195,10 +195,10 @@
 if !ds_status.bad.is_empty() {
 warn!("Bad matches {:?}", &(ds_status.bad))
 }
-if !lookup.is_empty() {
+if !ds_status.unsure.is_empty() {
 info!(
 "Files to be rechecked by retrieval from filelog: {:?}",
-
+_status.unsure
 );
 }
 // TODO check ordering to match `hg status` output.
@@ -206,7 +206,7 @@
 if display_states.modified {
 display_status_paths(ui, &(ds_status.modified), b"M")?;
 }
-if !lookup.is_empty() {
+if !ds_status.unsure.is_empty() {
 let p1: Node = parents
 .expect(
 "Dirstate with no parents should not list any file to
@@ -217,7 +217,7 @@
 let p1_hex = format!("{:x}", p1);
 let mut rechecked_modified: Vec = Vec::new();
 let mut rechecked_clean: Vec = Vec::new();
-for to_check in lookup {
+for to_check in ds_status.unsure {
 if cat_file_is_modified(repo, _check, _hex)? {
 rechecked_modified.push(to_check);
 } else {
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
@@ -25,7 +25,7 @@
 BadMatch, DirstateStatus, IgnorePattern, PatternFileWarning, StatusError,
 StatusOptions,
 };
-use std::borrow::{Borrow, Cow};
+use std::borrow::Borrow;
 
 /// This will be useless once trait impls for collection are added to `PyBytes`
 /// upstream.
@@ -126,7 +126,7 @@
 match matcher.get_type(py).name(py).borrow() {
 "alwaysmatcher" => {
 let matcher = AlwaysMatcher;
-let ((lookup, status_res), warnings) = dmap
+let (status_res, warnings) = dmap
 .status(
 ,
 root_dir.to_path_buf(),
@@ -141,7 +141,7 @@
 },
 )
 .map_err(|e| handle_fallback(py, e))?;
-build_response(py, lookup, status_res, warnings)
+build_response(py, status_res, warnings)
 }
 "exactmatcher" => {
 let files = matcher.call_method(
@@ -163,7 +163,7 @@
 let files = files?;
 let matcher = FileMatcher::new(files.as_ref())
 .map_err(|e| PyErr::new::(py, e.to_string()))?;
-let ((lookup, status_res), warnings) = dmap
+let (status_res, warnings) = dmap
 .status(
 ,
 root_dir.to_path_buf(),
@@ -178,7 +178,7 @@
 },
 )
 .map_err(|e| handle_fallback(py, e))?;
-build_response(py, lookup, status_res, warnings)
+build_response(py, status_res, warnings)
 }
 "includematcher" => {
 // Get the patterns from Python even though most of them are
@@ -218,7 +218,7 @@
 .map_err(|e| handle_fallback(py, e.into()))?;
 all_warnings.extend(warnings);
 
-let ((lookup, status_res), warnings) = dmap
+let (status_res, warnings) = dmap
 .status(
 ,
 root_dir.to_path_buf(),
@@ -236,7 +236,7 @@
 
 all_warnings.extend(warnings);
 
-build_response(py, lookup, status_res, all_warnings)
+build_response(py, status_res, all_warnings)
 }
 e => Err(PyErr::new::(
 py,
@@ -247,7 +247,6 @@
 
 fn build_response(
 py: Python,
-lookup: Vec>,
 status_res: DirstateStatus,
 warnings: Vec,
 ) -> PyResult {
@@ -258,7 +257,7 @@
 let clean = collect_pybytes_list(py, status_res.clean.as_ref());
 let ignored = collect_pybytes_list(py, status_res.ignored.as_ref());
 let unknown = 

D10493: rust: Remove DirstateMap::file_fold_map

2021-04-20 Thread SimonSapin
SimonSapin created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  This was a HashMap constructed on demand and then cached in the DirstateMap
  struct to avoid reconstructing at the next access. However the only use is
  in Python bindings converting it to a PyDict. That method in turn is wrapped
  in a @cachedproperty in Python code.
  
  This was two redudant layers of caching. This changeset removes the Rust-level
  one to keep the Python dict cache, and have bindings create a PyDict by
  iterating.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

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

CHANGE DETAILS

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
@@ -30,6 +30,7 @@
 dirstate_tree::dispatch::DirstateMapMethods,
 errors::HgError,
 revlog::Node,
+utils::files::normalize_case,
 utils::hg_path::{HgPath, HgPathBuf},
 DirsMultiset, DirstateEntry, DirstateMap as RustDirstateMap,
 DirstateMapError, DirstateParents, EntryState, StateMapIter,
@@ -329,14 +330,16 @@
 
 def filefoldmapasdict() -> PyResult {
 let dict = PyDict::new(py);
-for (key, value) in
-self.inner(py).borrow_mut().build_file_fold_map().iter()
-{
-dict.set_item(
-py,
-PyBytes::new(py, key.as_bytes()).into_object(),
-PyBytes::new(py, value.as_bytes()).into_object(),
-)?;
+for (path, entry) in self.inner(py).borrow_mut().iter() {
+if entry.state != EntryState::Removed {
+let key = normalize_case(path);
+let value = path;
+dict.set_item(
+py,
+PyBytes::new(py, key.as_bytes()).into_object(),
+PyBytes::new(py, value.as_bytes()).into_object(),
+)?;
+}
 }
 Ok(dict)
 }
diff --git a/rust/hg-core/src/dirstate_tree/dispatch.rs 
b/rust/hg-core/src/dirstate_tree/dispatch.rs
--- a/rust/hg-core/src/dirstate_tree/dispatch.rs
+++ b/rust/hg-core/src/dirstate_tree/dispatch.rs
@@ -11,7 +11,6 @@
 use crate::DirstateParents;
 use crate::DirstateStatus;
 use crate::EntryState;
-use crate::FastHashMap;
 use crate::HgPathCow;
 use crate::PatternFileWarning;
 use crate::StateMapIter;
@@ -93,8 +92,6 @@
 now: Timestamp,
 ) -> Result, DirstateError>;
 
-fn build_file_fold_map( self) -> ;
-
 fn set_all_dirs( self) -> Result<(), DirstateMapError>;
 
 fn set_dirs( self) -> Result<(), DirstateMapError>;
@@ -259,10 +256,6 @@
 self.pack(parents, now)
 }
 
-fn build_file_fold_map( self) ->  {
-self.build_file_fold_map()
-}
-
 fn set_all_dirs( self) -> Result<(), DirstateMapError> {
 self.set_all_dirs()
 }
diff --git a/rust/hg-core/src/dirstate_tree/dirstate_map.rs 
b/rust/hg-core/src/dirstate_tree/dirstate_map.rs
--- a/rust/hg-core/src/dirstate_tree/dirstate_map.rs
+++ b/rust/hg-core/src/dirstate_tree/dirstate_map.rs
@@ -19,7 +19,6 @@
 use crate::DirstateParents;
 use crate::DirstateStatus;
 use crate::EntryState;
-use crate::FastHashMap;
 use crate::HgPathCow;
 use crate::PatternFileWarning;
 use crate::StateMapIter;
@@ -566,10 +565,6 @@
 Ok(packed)
 }
 
-fn build_file_fold_map( self) ->  {
-todo!()
-}
-
 fn set_all_dirs( self) -> Result<(), DirstateMapError> {
 // Do nothing, this `DirstateMap` does not a separate `all_dirs` that
 // needs to be recomputed
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
@@ -12,12 +12,9 @@
 use crate::{
 dirstate::{parsers::PARENT_SIZE, EntryState},
 pack_dirstate, parse_dirstate,
-utils::{
-files::normalize_case,
-hg_path::{HgPath, HgPathBuf},
-},
+utils::hg_path::{HgPath, HgPathBuf},
 CopyMap, DirsMultiset, DirstateEntry, DirstateError, DirstateMapError,
-DirstateParents, FastHashMap, StateMap,
+DirstateParents, StateMap,
 };
 use micro_timer::timed;
 use std::collections::HashSet;
@@ -25,13 +22,10 @@
 use std::iter::FromIterator;
 use std::ops::Deref;
 
-pub type FileFoldMap = FastHashMap;
-
 #[derive(Default)]
 pub struct DirstateMap {
 state_map: StateMap,
 pub copy_map: CopyMap,
-file_fold_map: Option,
 pub dirs: Option,
 pub all_dirs: Option,
 non_normal_set: Option>,
@@ -68,7 +62,6 @@
 pub fn clear( self) {
 self.state_map = StateMap::default();
 

D10495: rust: Add doc-comments to DirstateStatus fields

2021-04-20 Thread SimonSapin
SimonSapin 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/D10495

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
@@ -256,18 +256,39 @@
 
 #[derive(Debug)]
 pub struct DirstateStatus<'a> {
+/// Tracked files whose contents have changed since the parent revision
 pub modified: Vec>,
+
+/// Newly-tracked files that were not present in the parent
 pub added: Vec>,
+
+/// Previously-tracked files that have been (re)moved with an hg command
 pub removed: Vec>,
+
+/// (Still) tracked files that are missing, (re)moved with an non-hg
+/// command
 pub deleted: Vec>,
+
+/// Tracked files that are up to date with the parent.
+/// Only pupulated if `StatusOptions::list_clean` is true.
 pub clean: Vec>,
+
+/// Files in the working directory that are ignored with `.hgignore`.
+/// Only pupulated if `StatusOptions::list_ignored` is true.
 pub ignored: Vec>,
+
+/// Files in the working directory that are neither tracked nor ignored.
+/// Only pupulated if `StatusOptions::list_unknown` is true.
 pub unknown: Vec>,
+
+/// Was explicitly matched but cannot be found/accessed
 pub bad: Vec<(HgPathCow<'a>, BadMatch)>,
+
 /// Either clean or modified, but we can’t tell from filesystem metadata
 /// alone. The file contents need to be read and compared with that in
 /// the parent.
 pub unsure: Vec>,
+
 /// Only filled if `collect_traversed_dirs` is `true`
 pub traversed: Vec,
 }



To: SimonSapin, #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


D10485: rust: Add a Timestamp struct instead of abusing Duration

2021-04-20 Thread SimonSapin
SimonSapin created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  `SystemTime` would be the standard library type semantically appropriate
  instead of `Duration`.
  
  But since the value is coming from Python as a plain integer and used in
  dirstate packing code as an integer, let’s make a type that contains a single
  integer instead of using one with sub-second precision.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  rust/hg-core/src/dirstate/dirstate_map.rs
  rust/hg-core/src/dirstate/parsers.rs
  rust/hg-core/src/dirstate_tree/dirstate_map.rs
  rust/hg-core/src/dirstate_tree/dispatch.rs
  rust/hg-core/src/lib.rs
  rust/hg-cpython/src/dirstate/dirstate_map.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
@@ -14,13 +14,13 @@
 PythonObject, ToPyObject,
 };
 use hg::{
-pack_dirstate, parse_dirstate, utils::hg_path::HgPathBuf, DirstateEntry,
-DirstateParents, FastHashMap, PARENT_SIZE,
+dirstate::parsers::Timestamp, pack_dirstate, parse_dirstate,
+utils::hg_path::HgPathBuf, DirstateEntry, DirstateParents, FastHashMap,
+PARENT_SIZE,
 };
 use std::convert::TryInto;
 
 use crate::dirstate::{extract_dirstate, make_dirstate_tuple};
-use std::time::Duration;
 
 fn parse_dirstate_wrapper(
 py: Python,
@@ -98,7 +98,7 @@
 p1: p1.try_into().unwrap(),
 p2: p2.try_into().unwrap(),
 },
-Duration::from_secs(now.as_object().extract::(py)?),
+Timestamp(now.as_object().extract::(py)?),
 ) {
 Ok(packed) => {
 for (filename, entry) in dirstate_map.iter() {
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
@@ -10,7 +10,6 @@
 
 use std::cell::{Ref, RefCell};
 use std::convert::TryInto;
-use std::time::Duration;
 
 use cpython::{
 exc, ObjectProtocol, PyBool, PyBytes, PyClone, PyDict, PyErr, PyList,
@@ -27,6 +26,7 @@
 parsers::dirstate_parents_to_pytuple,
 };
 use hg::{
+dirstate::parsers::Timestamp,
 dirstate_tree::dispatch::DirstateMapMethods,
 errors::HgError,
 revlog::Node,
@@ -312,7 +312,7 @@
 p2: PyObject,
 now: PyObject
 ) -> PyResult {
-let now = Duration::new(now.extract(py)?, 0);
+let now = Timestamp(now.extract(py)?);
 let parents = DirstateParents {
 p1: extract_node_id(py, )?,
 p2: extract_node_id(py, )?,
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
@@ -8,7 +8,7 @@
 pub mod dagops;
 pub mod errors;
 pub use ancestors::{AncestorsIterator, LazyAncestors, MissingAncestors};
-mod dirstate;
+pub mod dirstate;
 pub mod dirstate_tree;
 pub mod discovery;
 pub mod requirements;
diff --git a/rust/hg-core/src/dirstate_tree/dispatch.rs 
b/rust/hg-core/src/dirstate_tree/dispatch.rs
--- a/rust/hg-core/src/dirstate_tree/dispatch.rs
+++ b/rust/hg-core/src/dirstate_tree/dispatch.rs
@@ -1,6 +1,6 @@
 use std::path::PathBuf;
-use std::time::Duration;
 
+use crate::dirstate::parsers::Timestamp;
 use crate::matchers::Matcher;
 use crate::utils::hg_path::{HgPath, HgPathBuf};
 use crate::CopyMapIter;
@@ -90,7 +90,7 @@
 fn pack(
  self,
 parents: DirstateParents,
-now: Duration,
+now: Timestamp,
 ) -> Result, DirstateError>;
 
 fn build_file_fold_map( self) -> ;
@@ -254,7 +254,7 @@
 fn pack(
  self,
 parents: DirstateParents,
-now: Duration,
+now: Timestamp,
 ) -> Result, DirstateError> {
 self.pack(parents, now)
 }
diff --git a/rust/hg-core/src/dirstate_tree/dirstate_map.rs 
b/rust/hg-core/src/dirstate_tree/dirstate_map.rs
--- a/rust/hg-core/src/dirstate_tree/dirstate_map.rs
+++ b/rust/hg-core/src/dirstate_tree/dirstate_map.rs
@@ -1,10 +1,10 @@
 use std::collections::BTreeMap;
 use std::path::PathBuf;
-use std::time::Duration;
 
 use super::path_with_basename::WithBasename;
 use crate::dirstate::parsers::parse_dirstate_entries;
 use crate::dirstate::parsers::parse_dirstate_parents;
+use crate::dirstate::parsers::Timestamp;
 
 use crate::matchers::Matcher;
 use crate::revlog::node::NULL_NODE;
@@ -328,7 +328,7 @@
 fn pack(
  self,
 _parents: DirstateParents,
-_now: Duration,
+_now: Timestamp,
 ) -> Result, DirstateError> {
 let _ = self.iter_node_data_mut();
 todo!()
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
@@ -13,7 +13,6 @@
 use 

D10491: dirstate-tree: Add add_file, remove_file, and drop_file

2021-04-20 Thread SimonSapin
SimonSapin created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  Again, various counters need to be kept up to date.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

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

CHANGE DETAILS

diff --git a/rust/hg-core/src/dirstate_tree/dirstate_map.rs 
b/rust/hg-core/src/dirstate_tree/dirstate_map.rs
--- a/rust/hg-core/src/dirstate_tree/dirstate_map.rs
+++ b/rust/hg-core/src/dirstate_tree/dirstate_map.rs
@@ -331,28 +331,61 @@
 
 fn add_file(
  self,
-_filename: ,
+filename: ,
 _old_state: EntryState,
-_entry: DirstateEntry,
+entry: DirstateEntry,
 ) -> Result<(), DirstateMapError> {
-todo!()
+self.add_file_node(filename, entry, None);
+Ok(())
 }
 
 fn remove_file(
  self,
-_filename: ,
+filename: ,
 _old_state: EntryState,
-_size: i32,
+size: i32,
 ) -> Result<(), DirstateMapError> {
-todo!()
+let entry = DirstateEntry {
+state: EntryState::Removed,
+mode: 0,
+size,
+mtime: 0,
+};
+self.add_file_node(filename, entry, None);
+Ok(())
 }
 
 fn drop_file(
  self,
-_filename: ,
+filename: ,
 _old_state: EntryState,
 ) -> Result {
-todo!()
+if let Some(node) = Self::get_node_mut( self.root, filename) {
+let was_tracked = node.is_tracked_file();
+let had_entry = node.entry.is_some();
+let had_copy_source = node.copy_source.is_some();
+
+// TODO: this leaves in the tree a "non-file" node. Should we
+// remove the node instead, together with ancestor nodes for
+// directories that become empty?
+node.entry = None;
+node.copy_source = None;
+
+if had_entry {
+self.nodes_with_entry_count -= 1
+}
+if had_copy_source {
+self.nodes_with_copy_source_count -= 1
+}
+if was_tracked {
+self.for_each_ancestor_node(filename, |node| {
+node.tracked_descendants_count -= 1
+})
+}
+Ok(had_entry)
+} else {
+Ok(false)
+}
 }
 
 fn clear_ambiguous_times( self, filenames: Vec, now: i32) {



To: SimonSapin, #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


D10489: dirstate-tree: Add clear_ambiguous_times in the new DirstateMap

2021-04-20 Thread SimonSapin
SimonSapin created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  Also drive-by refactor it in the other DirstateMap

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

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

CHANGE DETAILS

diff --git a/rust/hg-core/src/dirstate_tree/dirstate_map.rs 
b/rust/hg-core/src/dirstate_tree/dirstate_map.rs
--- a/rust/hg-core/src/dirstate_tree/dirstate_map.rs
+++ b/rust/hg-core/src/dirstate_tree/dirstate_map.rs
@@ -287,12 +287,14 @@
 todo!()
 }
 
-fn clear_ambiguous_times(
- self,
-_filenames: Vec,
-_now: i32,
-) {
-todo!()
+fn clear_ambiguous_times( self, filenames: Vec, now: i32) {
+for filename in filenames {
+if let Some(node) = Self::get_node_mut( self.root, ) {
+if let Some(entry) = node.entry.as_mut() {
+clear_ambiguous_mtime(entry, now);
+}
+}
+}
 }
 
 fn non_normal_entries_contains( self, _key: ) -> bool {
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
@@ -5,6 +5,7 @@
 // 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::parsers::clear_ambiguous_mtime;
 use crate::dirstate::parsers::Timestamp;
 use crate::errors::HgError;
 use crate::revlog::node::NULL_NODE;
@@ -188,21 +189,13 @@
 now: i32,
 ) {
 for filename in filenames {
-let mut changed = false;
 if let Some(entry) = self.state_map.get_mut() {
-if entry.state == EntryState::Normal && entry.mtime == now {
-changed = true;
-*entry = DirstateEntry {
-mtime: MTIME_UNSET,
-..*entry
-};
+if clear_ambiguous_mtime(entry, now) {
+self.get_non_normal_other_parent_entries()
+.0
+.insert(filename.to_owned());
 }
 }
-if changed {
-self.get_non_normal_other_parent_entries()
-.0
-.insert(filename.to_owned());
-}
 }
 }
 



To: SimonSapin, #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


D10486: dirstate-tree: Serialize to disk

2021-04-20 Thread SimonSapin
SimonSapin created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  The existing `pack_dirstate` function relies on implementation details
  of `DirstateMap`, so extract some parts of it as separate functions
  for us in the tree-based `DirstateMap`.
  
  Drive-by refactor `clear_ambiguous_times` which does part of the same thing.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  rust/Cargo.lock
  rust/hg-core/Cargo.toml
  rust/hg-core/src/dirstate/parsers.rs
  rust/hg-core/src/dirstate_tree/dirstate_map.rs

CHANGE DETAILS

diff --git a/rust/hg-core/src/dirstate_tree/dirstate_map.rs 
b/rust/hg-core/src/dirstate_tree/dirstate_map.rs
--- a/rust/hg-core/src/dirstate_tree/dirstate_map.rs
+++ b/rust/hg-core/src/dirstate_tree/dirstate_map.rs
@@ -1,11 +1,14 @@
-use std::collections::BTreeMap;
+use bytes_cast::BytesCast;
 use std::path::PathBuf;
+use std::{collections::BTreeMap, convert::TryInto};
 
 use super::path_with_basename::WithBasename;
+use crate::dirstate::parsers::clear_ambiguous_mtime;
+use crate::dirstate::parsers::pack_entry;
+use crate::dirstate::parsers::packed_entry_size;
 use crate::dirstate::parsers::parse_dirstate_entries;
 use crate::dirstate::parsers::parse_dirstate_parents;
 use crate::dirstate::parsers::Timestamp;
-
 use crate::matchers::Matcher;
 use crate::revlog::node::NULL_NODE;
 use crate::utils::hg_path::{HgPath, HgPathBuf};
@@ -327,11 +330,38 @@
 
 fn pack(
  self,
-_parents: DirstateParents,
-_now: Timestamp,
+parents: DirstateParents,
+now: Timestamp,
 ) -> Result, DirstateError> {
-let _ = self.iter_node_data_mut();
-todo!()
+// Optizimation (to be measured?): pre-compute size to avoid `Vec`
+// reallocations
+let mut size = parents.as_bytes().len();
+for (path, node) in self.iter_nodes() {
+if node.entry.is_some() {
+size += packed_entry_size(
+path.full_path(),
+node.copy_source.as_ref(),
+)
+}
+}
+
+let mut packed = Vec::with_capacity(size);
+packed.extend(parents.as_bytes());
+
+let now: i32 = now.0.try_into().expect("time overflow");
+for (path, opt_entry, copy_source) in self.iter_node_data_mut() {
+if let Some(entry) = opt_entry {
+clear_ambiguous_mtime(entry, now);
+pack_entry(
+path.full_path(),
+entry,
+copy_source.as_ref(),
+ packed,
+);
+}
+}
+self.dirty_parents = false;
+Ok(packed)
 }
 
 fn build_file_fold_map( self) ->  {
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
@@ -4,7 +4,7 @@
 // GNU General Public License version 2 or any later version.
 
 use crate::errors::HgError;
-use crate::utils::hg_path::HgPath;
+use crate::utils::hg_path::{HgPath, HgPathBuf};
 use crate::{
 dirstate::{CopyMap, EntryState, RawEntry, StateMap},
 DirstateEntry, DirstateParents,
@@ -82,9 +82,71 @@
 Ok(parents)
 }
 
+fn packed_filename_and_copy_source_size(
+filename: ,
+copy_source: Option<>,
+) -> usize {
+filename.len()
++ if let Some(source) = copy_source {
+b"\0".len() + source.len()
+} else {
+0
+}
+}
+
+pub fn packed_entry_size(
+filename: ,
+copy_source: Option<>,
+) -> usize {
+MIN_ENTRY_SIZE
++ packed_filename_and_copy_source_size(filename, copy_source)
+}
+
+pub fn pack_entry(
+filename: ,
+entry: ,
+copy_source: Option<>,
+packed:  Vec,
+) {
+let length = packed_filename_and_copy_source_size(filename, copy_source);
+
+// Unwrapping because `impl std::io::Write for Vec` never errors
+packed.write_u8(entry.state.into()).unwrap();
+packed.write_i32::(entry.mode).unwrap();
+packed.write_i32::(entry.size).unwrap();
+packed.write_i32::(entry.mtime).unwrap();
+packed.write_i32::(length as i32).unwrap();
+packed.extend(filename.as_bytes());
+if let Some(source) = copy_source {
+packed.push(b'\0');
+packed.extend(source.as_bytes());
+}
+}
+
 /// Seconds since the Unix epoch
 pub struct Timestamp(pub u64);
 
+pub fn clear_ambiguous_mtime(
+entry:  DirstateEntry,
+mtime_now: i32,
+) -> bool {
+let ambiguous =
+entry.state == EntryState::Normal && entry.mtime == mtime_now;
+if ambiguous {
+// The file was last modified "simultaneously" with the current
+// write to dirstate (i.e. within the same second for file-
+// systems with a granularity of 1 sec). This commonly happens
+// for at least a 

D10488: dirstate-tree: Add copy_map_insert and copy_map_remove

2021-04-20 Thread SimonSapin
SimonSapin 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/D10488

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

CHANGE DETAILS

diff --git a/rust/hg-core/src/dirstate_tree/dirstate_map.rs 
b/rust/hg-core/src/dirstate_tree/dirstate_map.rs
--- a/rust/hg-core/src/dirstate_tree/dirstate_map.rs
+++ b/rust/hg-core/src/dirstate_tree/dirstate_map.rs
@@ -89,6 +89,25 @@
 
 /// This takes `root` instead of ` self` so that callers can mutate
 /// other fields while the returned borrow is still valid
+fn get_node_mut<'tree>(
+root: &'tree mut ChildNodes,
+path: ,
+) -> Option<&'tree mut Node> {
+let mut children = root;
+let mut components = path.components();
+let mut component =
+components.next().expect("expected at least one components");
+loop {
+let child = children.get_mut(component)?;
+if let Some(next_component) = components.next() {
+component = next_component;
+children =  child.children;
+} else {
+return Some(child);
+}
+}
+}
+
 fn get_or_insert_node<'tree>(
 root: &'tree mut ChildNodes,
 path: ,
@@ -463,16 +482,26 @@
 self.get_node(key)?.copy_source.as_ref()
 }
 
-fn copy_map_remove( self, _key: ) -> Option {
-todo!()
+fn copy_map_remove( self, key: ) -> Option {
+let count =  self.nodes_with_copy_source_count;
+Self::get_node_mut( self.root, key).and_then(|node| {
+if node.copy_source.is_some() {
+*count -= 1
+}
+node.copy_source.take()
+})
 }
 
 fn copy_map_insert(
  self,
-_key: HgPathBuf,
-_value: HgPathBuf,
+key: HgPathBuf,
+value: HgPathBuf,
 ) -> Option {
-todo!()
+let node = Self::get_or_insert_node( self.root, );
+if node.copy_source.is_none() {
+self.nodes_with_copy_source_count += 1
+}
+node.copy_source.replace(value)
 }
 
 fn len() -> usize {



To: SimonSapin, #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


D10487: dirstate-tree: Maintain a counter of DirstateEntry’s and copy sources

2021-04-20 Thread SimonSapin
SimonSapin created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  This allows implementing __len__ for DirstateMap and CopyMap efficiently,
  without traversing the tree.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

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

CHANGE DETAILS

diff --git a/rust/hg-core/src/dirstate_tree/dirstate_map.rs 
b/rust/hg-core/src/dirstate_tree/dirstate_map.rs
--- a/rust/hg-core/src/dirstate_tree/dirstate_map.rs
+++ b/rust/hg-core/src/dirstate_tree/dirstate_map.rs
@@ -30,6 +30,13 @@
 parents: Option,
 dirty_parents: bool,
 root: ChildNodes,
+
+/// Number of nodes anywhere in the tree that have `.entry.is_some()`.
+nodes_with_entry_count: usize,
+
+/// Number of nodes anywhere in the tree that have
+/// `.copy_source.is_some()`.
+nodes_with_copy_source_count: usize,
 }
 
 /// Using a plain `HgPathBuf` of the full path from the repository root as a
@@ -59,6 +66,8 @@
 parents: None,
 dirty_parents: false,
 root: ChildNodes::new(),
+nodes_with_entry_count: 0,
+nodes_with_copy_source_count: 0,
 }
 }
 
@@ -78,8 +87,13 @@
 }
 }
 
-fn get_or_insert_node( self, path: ) ->  Node {
-let mut child_nodes =  self.root;
+/// This takes `root` instead of ` self` so that callers can mutate
+/// other fields while the returned borrow is still valid
+fn get_or_insert_node<'tree>(
+root: &'tree mut ChildNodes,
+path: ,
+) -> &'tree mut Node {
+let mut child_nodes = root;
 let mut inclusive_ancestor_paths =
 WithBasename::inclusive_ancestors_of(path);
 let mut ancestor_path = inclusive_ancestor_paths
@@ -106,6 +120,35 @@
 }
 }
 
+/// The meaning of `new_copy_source` is:
+///
+/// * `Some(Some(x))`: set `Node::copy_source` to `Some(x)`
+/// * `Some(None)`: set `Node::copy_source` to `None`
+/// * `None`: leave `Node::copy_source` unchanged
+fn add_file_node(
+ self,
+path: ,
+new_entry: DirstateEntry,
+new_copy_source: Option>,
+) {
+let node = Self::get_or_insert_node( self.root, path);
+if node.entry.is_none() {
+self.nodes_with_entry_count += 1
+}
+if let Some(source) = _copy_source {
+if node.copy_source.is_none() && source.is_some() {
+self.nodes_with_copy_source_count += 1
+}
+if node.copy_source.is_some() && source.is_none() {
+self.nodes_with_copy_source_count -= 1
+}
+}
+node.entry = Some(new_entry);
+if let Some(source) = new_copy_source {
+node.copy_source = source
+}
+}
+
 fn iter_nodes<'a>(
 &'a self,
 ) -> impl Iterator, &'a Node)> + 'a
@@ -194,7 +237,9 @@
 p1: NULL_NODE,
 p2: NULL_NODE,
 });
-self.root.clear()
+self.root.clear();
+self.nodes_with_entry_count = 0;
+self.nodes_with_copy_source_count = 0;
 }
 
 fn add_file(
@@ -315,9 +360,11 @@
 let parents = parse_dirstate_entries(
 file_contents,
 |path, entry, copy_source| {
-let node = self.get_or_insert_node(path);
-node.entry = Some(*entry);
-node.copy_source = copy_source.map(HgPath::to_owned);
+self.add_file_node(
+path,
+*entry,
+Some(copy_source.map(HgPath::to_owned)),
+)
 },
 )?;
 
@@ -393,7 +440,7 @@
 }
 
 fn copy_map_len() -> usize {
-todo!()
+self.nodes_with_copy_source_count
 }
 
 fn copy_map_iter() -> CopyMapIter<'_> {
@@ -429,7 +476,7 @@
 }
 
 fn len() -> usize {
-todo!()
+self.nodes_with_entry_count
 }
 
 fn contains_key(, key: ) -> bool {



To: SimonSapin, #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


[Bug 6509] New: Mercurial rust extensions crash

2021-04-20 Thread mercurial-bugs
https://bz.mercurial-scm.org/show_bug.cgi?id=6509

Bug ID: 6509
   Summary: Mercurial rust extensions crash
   Product: Mercurial
   Version: 5.6.1
  Hardware: PC
OS: Windows
Status: UNCONFIRMED
  Severity: feature
  Priority: wish
 Component: Mercurial
  Assignee: bugzi...@mercurial-scm.org
  Reporter: mathias.dem...@gmail.com
CC: mercurial-devel@mercurial-scm.org
Python Version: ---

We're inconsistently seeing this crash in our builds, which run in a CentOS 7
container (host OS is also CentOS 7).

Command that runs (inside make): /bin/hg --config ui.ssh='ssh
-oStrictHostKeyChecking=no -oUserKnownHostsFile=/dev/null' --config
ui.clonebundlefallback=True --config extensions.hgext.purge= -R
 purge --all

Error:
*** Error in `/usr/bin/python3': double free or corruption (fasttop):
0x0219ec10 ***
*** Error in `/usr/bin/python3': double free or corruption (fasttop):
0x0219ec10 ***
*** Error in `/usr/bin/python3': double free or corruption (fasttop):
0x0219ec10 ***
*** Error in `/usr/bin/python3': double free or corruption (fasttop):
0x0219ec10 ***

Decoded backtrace:
Program terminated with signal 6, Aborted.
#0  0x7f897eb6b3d7 in raise () from /lib64/libc.so.6
#0  0x7f897eb6b3d7 in raise () from /lib64/libc.so.6
#1  0x7f897eb6cac8 in abort () from /lib64/libc.so.6
#2  0x7f897ebadf67 in __libc_message () from /lib64/libc.so.6
#3  0x7f897ebb4474 in malloc_printerr () from /lib64/libc.so.6
#4  0x7f897ebb9770 in _int_realloc () from /lib64/libc.so.6
#5  0x7f897ebbae12 in realloc () from /lib64/libc.so.6
#6  0x7f897fd53e51 in store_fd (file=0x7f895400dee0, fd=14) at ../path.c:39
#7  0x7f897fd5195f in opendir (name=0x7f8954005e30
"/repo/builder/repo/vobs/esam/build/reborn/buildroot-isam-reborn-x86-qemu-unit-m32/boot/afboot-stm32")
at ../libaccess.c:332
#8  0x7f897868c053 in std::sys::unix::fs::readdir::h72e024f03cced67b ()
from
/usr/lib64/python3.6/site-packages/mercurial/rustext.cpython-36m-x86_64-linux-gnu.so
#9  0x7f897855a3eb in
hg::dirstate::status::list_directory::h0d0649bfa6ff4dfc () from
/usr/lib64/python3.6/site-packages/mercurial/rustext.cpython-36m-x86_64-linux-gnu.so
#10 0x7f897855ae49 in
hg::dirstate::status::Status$LT$M$GT$::traverse_dir::h4c41d7d5b67110c4 () from
/usr/lib64/python3.6/site-packages/mercurial/rustext.cpython-36m-x86_64-linux-gnu.so
#11 0x7f89784f82da in
_$LT$std..panic..AssertUnwindSafe$LT$F$GT$$u20$as$u20$core..ops..function..FnOnce$LT$$LP$$RP$$GT$$GT$::call_once::h24ed0e9c68e77ee4
() from
/usr/lib64/python3.6/site-packages/mercurial/rustext.cpython-36m-x86_64-linux-gnu.so
#12 0x7f897852227f in
_$LT$rayon_core..job..HeapJob$LT$BODY$GT$$u20$as$u20$rayon_core..job..Job$GT$::execute::h41abbd7b1792dfc2
() from
/usr/lib64/python3.6/site-packages/mercurial/rustext.cpython-36m-x86_64-linux-gnu.so
#13 0x7f897865bdd1 in
rayon_core::registry::WorkerThread::wait_until_cold::h3c79165e986a165a () from
/usr/lib64/python3.6/site-packages/mercurial/rustext.cpython-36m-x86_64-linux-gnu.so
#14 0x7f897865a539 in
rayon_core::registry::ThreadBuilder::run::h6af6dd34d0625309 () from
/usr/lib64/python3.6/site-packages/mercurial/rustext.cpython-36m-x86_64-linux-gnu.so
#15 0x7f897865d8a5 in
std::sys_common::backtrace::__rust_begin_short_backtrace::h338dfc6ea17569fd ()
from
/usr/lib64/python3.6/site-packages/mercurial/rustext.cpython-36m-x86_64-linux-gnu.so
#16 0x7f897865dfc3 in
core::ops::function::FnOnce::call_once$u7b$$u7b$vtable.shim$u7d$$u7d$::ha610835416cffb73
() from
/usr/lib64/python3.6/site-packages/mercurial/rustext.cpython-36m-x86_64-linux-gnu.so
#17 0x7f897868d24a in
std::sys::unix::thread::Thread::new::thread_start::h69f54c4a59452ed6 () from
/usr/lib64/python3.6/site-packages/mercurial/rustext.cpython-36m-x86_64-linux-gnu.so
#18 0x7f897f613ea5 in start_thread () from /lib64/libpthread.so.0
#19 0x7f897ec339fd in clone () from /lib64/libc.so.6

=== Backtrace: =
/lib64/libc.so.6(+0x7f474)[0x7f897ebb4474]
/lib64/libc.so.6(+0x84770)[0x7f897ebb9770]
/lib64/libc.so.6(realloc+0x1d2)[0x7f897ebbae12]
/repo/tools/lin86/make/V3.82_a1.6_7/bin/../lib64/libaccess.so(+0x3e51)[0x7f897fd53e51]
/repo/tools/lin86/make/V3.82_a1.6_7/bin/../lib64/libaccess.so(opendir+0x6f)[0x7f897fd5195f]
/usr/lib64/python3.6/site-packages/mercurial/rustext.cpython-36m-x86_64-linux-gnu.so(+0x1f9053)[0x7f897868c053]
/usr/lib64/python3.6/site-packages/mercurial/rustext.cpython-36m-x86_64-linux-gnu.so(+0xc73eb)[0x7f897855a3eb]
/usr/lib64/python3.6/site-packages/mercurial/rustext.cpython-36m-x86_64-linux-gnu.so(+0xc7e49)[0x7f897855ae49]
/usr/lib64/python3.6/site-packages/mercurial/rustext.cpython-36m-x86_64-linux-gnu.so(+0x652da)[0x7f89784f82da]
/usr/lib64/python3.6/site-packages/mercurial/rustext.cpython-36m-x86_64-linux-gnu.so(+0x8f27f)[0x7f897852227f]

Failed pipeline for branch/default | mercurial-devel | 502de799

2021-04-20 Thread Heptapod


Pipeline #20885 has failed!

Project: mercurial-devel ( https://foss.heptapod.net/octobus/mercurial-devel )
Branch: branch/default ( 
https://foss.heptapod.net/octobus/mercurial-devel/-/commits/branch/default )

Commit: 502de799 ( 
https://foss.heptapod.net/octobus/mercurial-devel/-/commit/502de7996f89db5048dda5ec3ae8b72131104e21
 )
Commit Message: mail: use a context manager when writing to mbo...
Commit Author: Matt Harbison

Pipeline #20885 ( 
https://foss.heptapod.net/octobus/mercurial-devel/-/pipelines/20885 ) triggered 
by Administrator ( https://foss.heptapod.net/root )
had 1 failed build.

Job #187901 ( 
https://foss.heptapod.net/octobus/mercurial-devel/-/jobs/187901/raw )

Stage: tests
Name: test-py2-chg

-- 
You're receiving this email because of your account on foss.heptapod.net.



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


Failed pipeline for branch/default | mercurial-devel | f758cd7e

2021-04-20 Thread Heptapod


Pipeline #20884 has failed!

Project: mercurial-devel ( https://foss.heptapod.net/octobus/mercurial-devel )
Branch: branch/default ( 
https://foss.heptapod.net/octobus/mercurial-devel/-/commits/branch/default )

Commit: f758cd7e ( 
https://foss.heptapod.net/octobus/mercurial-devel/-/commit/f758cd7ecf0c84fe5ee9401597470a1705508b4b
 )
Commit Message: errors: remove unnecessary varargs handling fro...
Commit Author: Martin von Zweigbergk ( https://foss.heptapod.net/martinvonz )

Pipeline #20884 ( 
https://foss.heptapod.net/octobus/mercurial-devel/-/pipelines/20884 ) triggered 
by Administrator ( https://foss.heptapod.net/root )
had 1 failed build.

Job #187882 ( 
https://foss.heptapod.net/octobus/mercurial-devel/-/jobs/187882/raw )

Stage: tests
Name: test-py2-pure

-- 
You're receiving this email because of your account on foss.heptapod.net.



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