Re: Outdated homepage and repository

2024-05-06 Thread Raphaël Gomès


On 5/4/24 11:08 PM, Mike Hommey wrote:

Hi,

As of writing, thewww.mercurial-scm.org  homepage is still showing
version 6.6.3 as download, while the latest release is 6.7.2, although it's
listed onhttps://www.mercurial-scm.org/downloads  (I guess it could be
related to mac and windows builds not being available?)
This is indeed due to Windows builds lagging behind. Maybe it's time we 
changed the JS that shows the version number to reflect the actual 
latest release, since Windows builds are done by another person that 
does not always have time to catch up.

Similarly, the main repository (https://repo.mercurial-scm.org/hg/) is
outdated. Well, it's not /really/ outdated, but when you `hg clone` it,
your work tree ends up on a changeset from two years ago (290c29df1915)
because that's where the @ bookmark is pointing. You should probably either
update the bookmark, or remove it.
You're actually the second person to mention this recently. The bookmark 
was kept here to make sure we didn't break anyone's workflow too badly 
when migrating our VM and your contribution system, but now it's no 
longer useful.  I've finally removed the bookmarks from the repo, thanks. :)

While I'm here, the mailing list archives are returning 403 Forbidden
errors (they were working a couple days ago).

Ah, I'll send an email to our hosters, thanks again Mike.

Mike

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


Re: Rustext's DirstateItem has no attribute 'v2_data', fsmonitor tries to access it.

2023-10-23 Thread Raphaël Gomès


On 10/23/23 01:16, Sietse Brouwer wrote:

Hello everyone,

I am writing about an AttributeError caused by fsmonitor trying to 
access someDirstateItem.v2_data(), which is not exposed by 
`mercurial.rustext.dirstate.DirstateItem` (but is exposed by 
`mercurial.pure.parsers.DirstateItem`). Steps to reproduce and some 
investigation below this e-mail.
Thanks for reporting this, fsmonitor is untested and not something we 
recommend mixing with Rust (because Rust is tested should give you the 
performance you're looking for without the flakiness). Can I ask why 
you're using fsmonitor?


I'll file a bug and try my hand at a fix, but first I have a question: 
does anybody know which module it is that needs fixing?
- is hgext/fsmonitor/__init__.py wrong to try to access 
DirStateItem.v2_data()?
- Or is rust/hg-cpython/src/dirstate/item.rs:DirstateItem wrong in 
that it lacks a method `v2_data`, when its Python counterpart has it?


I wrote this "fix" when we reworked the dirstate API because people at 
Mozilla use fsmonitor but without the Rust extensions, and we'd broken 
their workflow. I didn't realize we didn't expose the same interface 
from the Rust entry, but I'm not surprised, since it shouldn't be 
exposed past the serialization or FFI layers.


IMO what needs fixing is fsmonitor. It should use the public API until 
we figure out that accessing `not e.has_time or e.has_ambiguous_time` is 
slower than the bitmask hack I used last time.


Do you want to send the fix, or should I do it?

I hope this helps,
Raphaël


Kind regards,
Sietse
Sietse Brouwer

Steps to reproduce:

    hg clone https://www.mercurial-scm.org/repo/hg-stable
    cd hg-stable
    hg up 6.5.2   # latest; but bug exists at least from 6.4.4
    make PURE=--rust local
    HGRCPATH= ./hg --config 'extensions.fsmonitor=' diff "set:tracked()"

    # The above gives a long traceback that ends in
      File 
"/home/sbrouwer/lib/mercurial-main/hgext/fsmonitor/__init__.py", line 
354, in 

        or bool((e.v2_data()[0] & mask) ^ has_mtime)
    AttributeError: 'mercurial.rustext.dirstate.DirstateItem' object 
has no attribute 'v2_data'


Further investigation:

- error goes away when building with `make PURE=--pure local`
- error goes away when the extension fsmonitor is disabled
- error is not affected by turning repo dirstate storage format v2 
on/off (via `hg debugupgrade --config format.use-dirstate-v2=1 --run` 
to turn on, or =0 to turn off.)


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

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


Re: How to contribute?

2023-09-07 Thread Raphaël Gomès

Hi Dan,

Thanks for sending your patch and reaching out.

We've had a massive spam wave recently and it's been tough seeing the 
real requests through it. I've invited you back to the project.


It appears everyone missed your patch... Do you want to try out pushing 
it to Heptapod or should I just take your patch from the ML?


Thanks again,
Raphaël

On 9/6/23 20:08, Dan Rose wrote:
Please help. I want to add Visual Studio as a diff and merge tool. I 
think I followed the process here correctly: 
https://wiki.mercurial-scm.org/ContributingChanges#Sending_patches


I submitted a request to join the heptapod group, still pending.

I submitted a patch to the mailing list 
https://lists.mercurial-scm.org/pipermail/mercurial-devel/2023-August/297739.html


Anything else I should have done/need to do? How can I move this forward?

Thanks, Dan

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

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


Re: [PATCH] httppeer: fix make_peer static - fixed for url-path argument. It has migrated to url-object, but legacy code passed just string

2023-06-26 Thread Raphaël Gomès

Thanks for your patch.

You've left a comment-out line. Is this just forgotten debug code or did 
you mean to do something more there?


Also a small detail, but the `ui.note` was moved from after the call to 
`make_peer`, which makes for a small difference in observed behavior. I 
don't think it matters too much, but it's unrelated to the change.


On a more meta note, sending patches via Heptapod is strongly recommended:
    - it runs the CI on your submissions (which would have caught the 
invalid message title length and improper formatting, just for the 
things  I can see reading this patch)

    - it makes back-and-forth review a lot easier
    - it makes the reviewer's job simpler overall

If you don't want to bother, I understand completely and you can keep 
sending patches via the mailing list if they're not too frequent. 
Otherwise, tell me if you need any help figuring out Heptapod.


Raphaël

On 6/22/23 23:00, alexraynepe...@gmail.com wrote:

# HG changeset patch
# User alexrayne
# Date 1687465008 -10800
#  Thu Jun 22 23:16:48 2023 +0300
# Node ID f0da5dd7a1d6274b62b7852dc05ac56b57381820
# Parent  68c4f8f3c9f43ae3773ed1dcfe7ed8cd0334bb27
httppeer: fix make_peer static - fixed for url-path argument. It has migrated 
to url-object, but legacy code passed just string

diff --git a/mercurial/httppeer.py b/mercurial/httppeer.py
--- a/mercurial/httppeer.py
+++ b/mercurial/httppeer.py
@@ -663,8 +663,10 @@
  return inst
  except error.RepoError as httpexception:
  try:
-r = statichttprepo.make_peer(ui, b"static-" + path.loc, create)
  ui.note(_(b'(falling back to static-http)\n'))
+# path.url.scheme = b"static-" + path.url.scheme;
+spath = urlutil.path(ui, None, rawloc=b"static-"+path.rawloc, 
validate_path=False)
+r = statichttprepo.make_peer(ui, spath, create)
  return r
  except error.RepoError:
  raise httpexception  # use the original http RepoError instead

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


Re: [PATCH 1 of 2] py3: fix for Python 3.12 emitting SyntaxWarning on invalid escape sequences

2023-03-22 Thread Raphaël Gomès
Patch 1 was taken and will land in 6.4, patch 2 doesn't pass CI and is 
just a quality of life improvement for devs, so that'll have to wait for 
later.


I'll still get to answering your email about the review process next 
week, I've been too busy so far.


Raphaël

On 3/21/23 17:51, Mads Kiilerich wrote:

Thanks for landing the previous 3.12 fixes. But I missed one fix ...

The remaining test failures on 3.12 are mostly from the removal 
(asyncore, smtpd and distutils) and deprecation (cgitb) in standard 
library.


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

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


Re: [PATCH 1 of 4 stable] cext: fix for PyLong refactoring in CPython 3.12

2023-03-20 Thread Raphaël Gomès
Queued¹ (by Pierre-Yves, reviewed by me) all except the redundant 
Cargo.toml patch with slightly one modified patch due to formatting.


[1] 
https://foss.heptapod.net/mercurial/mercurial-devel/-/merge_requests/505/


On 3/7/23 19:23, Mads Kiilerich wrote:

# HG changeset patch
# User Mads Kiilerich 
# Date 1678202751 -3600
#  Tue Mar 07 16:25:51 2023 +0100
# Branch stable
# Node ID 1efa4e96f6461bf071b28d66b13bdb67fdc91fc6
# Parent  8a65b43457aba02741bedabe100823d3041af0b5
cext: fix for PyLong refactoring in CPython 3.12

Compiling Mercurial with Python 3.12 a5 would fail with:

mercurial/cext/dirs.c: In function '_addpath':
mercurial/cext/dirs.c:19:44: error: 'PyLongObject' {aka 'struct _longobject'} 
has no member named 'ob_digit'
19 | #define PYLONG_VALUE(o) ((PyLongObject *)o)->ob_digit[0]
   |^~
mercurial/cext/dirs.c:97:25: note: in expansion of macro 'PYLONG_VALUE'
97 | PYLONG_VALUE(val) += 1;
   | ^~~~
mercurial/cext/dirs.c:19:44: error: 'PyLongObject' {aka 'struct _longobject'} 
has no member named 'ob_digit'
19 | #define PYLONG_VALUE(o) ((PyLongObject *)o)->ob_digit[0]
   |^~
mercurial/cext/dirs.c:108:17: note: in expansion of macro 'PYLONG_VALUE'
   108 | PYLONG_VALUE(val) = 1;
   | ^~~~
mercurial/cext/dirs.c: In function '_delpath':
mercurial/cext/dirs.c:19:44: error: 'PyLongObject' {aka 'struct _longobject'} 
has no member named 'ob_digit'
19 | #define PYLONG_VALUE(o) ((PyLongObject *)o)->ob_digit[0]
   |^~
mercurial/cext/dirs.c:145:23: note: in expansion of macro 'PYLONG_VALUE'
   145 | if (--PYLONG_VALUE(val) <= 0) {
   |   ^~~~

This was caused by
https://github.com/python/cpython/commit/c1b1f51cd1632f0b77dacd43092fb44ed5e053a9
 .

diff --git a/mercurial/cext/dirs.c b/mercurial/cext/dirs.c
--- a/mercurial/cext/dirs.c
+++ b/mercurial/cext/dirs.c
@@ -13,7 +13,11 @@
  
  #include "util.h"
  
+#if PY_VERSION_HEX >= 0x030C00A5

+#define PYLONG_VALUE(o) ((PyLongObject *)o)->long_value.ob_digit[0]
+#else
  #define PYLONG_VALUE(o) ((PyLongObject *)o)->ob_digit[0]
+#endif
  
  /*

   * This is a multiset of directory names, built from the files that

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

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


Re: [PATCH 4 of 4 stable] hg-core: upgrade `zstd` dependency to 0.12

2023-03-13 Thread Raphaël Gomès
Scratch that sorry, I didn't look hard enough, I could just take the 
first three patches.


How do you prefer to do it? I see you have an account on Heptapod already.

On 3/13/23 15:44, Raphaël Gomès wrote:
The idea is to have everything run through the CI. Contributions going 
through the repo and thus Heptapod makes it much easier for reviewers.


Email remains as the lowest bar of entry (since you don't need an 
account and two out-of-core extensions) and for people truly allergic 
to the new workflow.


I get so few email patches I forget how to queue patches that need 
amending, heh. Maybe the mbox extension would help, but it's pretty 
low priority for me ATM.


In any case you'd need to send a V2, either via Heptapod or by email, 
since our ZSTD patches overlap.


On 3/10/23 16:08, Mads Kiilerich wrote:

Thanks.

I still maintain my local copy of 
https://www.mercurial-scm.org/wiki/MboxExtension . Something like 
that could be perhaps be patched into heptapod if the goal is to have 
everything running through the web interface.


/Mads


On 09/03/2023 18:33, Augie Fackler wrote:
Series LGTM for stable, but last time I queued something from the ML 
I think I angered the heptapod gods, so I’ll tag a couple of people 
that can hopefully push this on our behalf.


AF


On Mar 7, 2023, at 13:23, Mads Kiilerich  wrote:

# HG changeset patch
# User Mads Kiilerich 
# Date 1678212582 -3600
#  Tue Mar 07 19:09:42 2023 +0100
# Branch stable
# Node ID 98085f80f5b0c786dad342ad1eb9335dda653496
# Parent  6ab12a75c936e0f1bf4305b9fdf9960219d1a39c
hg-core: upgrade `zstd` dependency to 0.12

zstd was recently upgraded from 0.5 to 0.11 . Now, take it one step 
further to

0.12 .

There is no need to stay in the past. And 0.12 is available in 
Fedora - 0.11

isn't.

diff --git a/rust/Cargo.lock b/rust/Cargo.lock
--- a/rust/Cargo.lock
+++ b/rust/Cargo.lock
@@ -1425,18 +1425,18 @@ checksum = "09041cd90cf85f7f8b2df60c646f

[[package]]
name = "zstd"
-version = "0.11.2+zstd.1.5.2"
+version = "0.12.3+zstd.1.5.2"
source = "registry+https://github.com/rust-lang/crates.io-index;
-checksum = 
"20cc960326ece64f010d2d2107537f26dc589a6573a316bd5b1dba685fa5fde4"
+checksum = 
"76eea132fb024e0e13fd9c2f5d5d595d8a967aa72382ac2f9d39fcc95afd0806"

dependencies = [
  "zstd-safe",
]

[[package]]
name = "zstd-safe"
-version = "5.0.2+zstd.1.5.2"
+version = "6.0.4+zstd.1.5.4"
source = "registry+https://github.com/rust-lang/crates.io-index;
-checksum = 
"1d2a5585e04f9eea4b2a3d1eca508c4dee9592a89ef6f450c11719da0726f4db"
+checksum = 
"7afb4b54b8910cf5447638cb54bf4e8a65cbedd783af98b98c62ffe91f185543"

dependencies = [
  "libc",
  "zstd-sys",
@@ -1444,10 +1444,11 @@ dependencies = [

[[package]]
name = "zstd-sys"
-version = "2.0.1+zstd.1.5.2"
+version = "2.0.7+zstd.1.5.4"
source = "registry+https://github.com/rust-lang/crates.io-index;
-checksum = 
"9fd07cbbc53846d9145dbffdf6dd09a7a0aa52be46741825f5c97bdd4f73f12b"
+checksum = 
"94509c3ba2fe55294d752b79842c530ccfab760192521df74a081a78d2b3c7f5"

dependencies = [
  "cc",
  "libc",
+ "pkg-config",
]
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
@@ -34,7 +34,7 @@ thread_local = "1.1.4"
crossbeam-channel = "0.5.6"
log = "0.4.17"
memmap2 = { version = "0.5.8", features = ["stable_deref_trait"] }
-zstd = "0.11.2"
+zstd = "0.12"
format-bytes = "0.3.0"
# once_cell 1.15 uses edition 2021, while the heptapod CI
# uses an old version of Cargo that doesn't support it.

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



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

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


Re: [PATCH 4 of 4 stable] hg-core: upgrade `zstd` dependency to 0.12

2023-03-13 Thread Raphaël Gomès
The idea is to have everything run through the CI. Contributions going 
through the repo and thus Heptapod makes it much easier for reviewers.


Email remains as the lowest bar of entry (since you don't need an 
account and two out-of-core extensions) and for people truly allergic to 
the new workflow.


I get so few email patches I forget how to queue patches that need 
amending, heh. Maybe the mbox extension would help, but it's pretty low 
priority for me ATM.


In any case you'd need to send a V2, either via Heptapod or by email, 
since our ZSTD patches overlap.


On 3/10/23 16:08, Mads Kiilerich wrote:

Thanks.

I still maintain my local copy of 
https://www.mercurial-scm.org/wiki/MboxExtension . Something like that 
could be perhaps be patched into heptapod if the goal is to have 
everything running through the web interface.


/Mads


On 09/03/2023 18:33, Augie Fackler wrote:
Series LGTM for stable, but last time I queued something from the ML 
I think I angered the heptapod gods, so I’ll tag a couple of people 
that can hopefully push this on our behalf.


AF


On Mar 7, 2023, at 13:23, Mads Kiilerich  wrote:

# HG changeset patch
# User Mads Kiilerich 
# Date 1678212582 -3600
#  Tue Mar 07 19:09:42 2023 +0100
# Branch stable
# Node ID 98085f80f5b0c786dad342ad1eb9335dda653496
# Parent  6ab12a75c936e0f1bf4305b9fdf9960219d1a39c
hg-core: upgrade `zstd` dependency to 0.12

zstd was recently upgraded from 0.5 to 0.11 . Now, take it one step 
further to

0.12 .

There is no need to stay in the past. And 0.12 is available in 
Fedora - 0.11

isn't.

diff --git a/rust/Cargo.lock b/rust/Cargo.lock
--- a/rust/Cargo.lock
+++ b/rust/Cargo.lock
@@ -1425,18 +1425,18 @@ checksum = "09041cd90cf85f7f8b2df60c646f

[[package]]
name = "zstd"
-version = "0.11.2+zstd.1.5.2"
+version = "0.12.3+zstd.1.5.2"
source = "registry+https://github.com/rust-lang/crates.io-index;
-checksum = 
"20cc960326ece64f010d2d2107537f26dc589a6573a316bd5b1dba685fa5fde4"
+checksum = 
"76eea132fb024e0e13fd9c2f5d5d595d8a967aa72382ac2f9d39fcc95afd0806"

dependencies = [
  "zstd-safe",
]

[[package]]
name = "zstd-safe"
-version = "5.0.2+zstd.1.5.2"
+version = "6.0.4+zstd.1.5.4"
source = "registry+https://github.com/rust-lang/crates.io-index;
-checksum = 
"1d2a5585e04f9eea4b2a3d1eca508c4dee9592a89ef6f450c11719da0726f4db"
+checksum = 
"7afb4b54b8910cf5447638cb54bf4e8a65cbedd783af98b98c62ffe91f185543"

dependencies = [
  "libc",
  "zstd-sys",
@@ -1444,10 +1444,11 @@ dependencies = [

[[package]]
name = "zstd-sys"
-version = "2.0.1+zstd.1.5.2"
+version = "2.0.7+zstd.1.5.4"
source = "registry+https://github.com/rust-lang/crates.io-index;
-checksum = 
"9fd07cbbc53846d9145dbffdf6dd09a7a0aa52be46741825f5c97bdd4f73f12b"
+checksum = 
"94509c3ba2fe55294d752b79842c530ccfab760192521df74a081a78d2b3c7f5"

dependencies = [
  "cc",
  "libc",
+ "pkg-config",
]
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
@@ -34,7 +34,7 @@ thread_local = "1.1.4"
crossbeam-channel = "0.5.6"
log = "0.4.17"
memmap2 = { version = "0.5.8", features = ["stable_deref_trait"] }
-zstd = "0.11.2"
+zstd = "0.12"
format-bytes = "0.3.0"
# once_cell 1.15 uses edition 2021, while the heptapod CI
# uses an old version of Cargo that doesn't support it.

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



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

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


Re: [PATCH] fastexport: fix data handling

2023-03-07 Thread Raphaël Gomès
Just so it doesn't look like we've ignored this, this series has also 
been sent to Heptapod, which is the preferred method of contribution.


Raphaël

On 3/2/23 21:13, Felipe Contreras wrote:

Commit messages are supposed to end on a newline, and blobs should not
be modified at all.

All data should be written as-is.
---
  hgext/fastexport.py |  8 ++---
  tests/test-fastexport.t | 73 +
  2 files changed, 19 insertions(+), 62 deletions(-)

diff --git a/hgext/fastexport.py b/hgext/fastexport.py
index 738d75259a..a730b2ca7b 100644
--- a/hgext/fastexport.py
+++ b/hgext/fastexport.py
@@ -69,11 +69,9 @@ def convert_to_git_ref(branch):
  return b"refs/heads/" + branch
  
  
-def write_data(buf, data, skip_newline):

+def write_data(buf, data):
  buf.append(b"data %d\n" % len(data))
  buf.append(data)
-if not skip_newline or data[-1:] != b"\n":
-buf.append(b"\n")
  
  
  def export_commit(ui, repo, rev, marks, authormap):

@@ -103,7 +101,7 @@ def export_commit(ui, repo, rev, marks, authormap):
  marks[filerev] = mark
  data = filectx.data()
  buf = [b"blob\n", b"mark :%d\n" % mark]
-write_data(buf, data, False)
+write_data(buf, data)
  ui.write(*buf, keepprogressbar=True)
  del buf
  
@@ -122,7 +120,7 @@ def export_commit(ui, repo, rev, marks, authormap):

  convert_to_git_date(ctx.date()),
  ),
  ]
-write_data(buf, ctx.description(), True)
+write_data(buf, ctx.description() + b"\n")
  if parents:
  buf.append(b"from :%d\n" % marks[parents[0].hex()])
  if len(parents) == 2:
diff --git a/tests/test-fastexport.t b/tests/test-fastexport.t
index 10af6465ed..b6218e651f 100644
--- a/tests/test-fastexport.t
+++ b/tests/test-fastexport.t
@@ -142,16 +142,14 @@
21
22
23
-
blob
mark :2
data 3
r0
-
commit refs/heads/default
mark :3
committer "debugbuilddag"  0 +
-  data 2
+  data 3
r0
M 644 :1 mf
M 644 :2 nf0
@@ -184,21 +182,18 @@
21
22
23
-
blob
mark :5
data 3
r1
-
blob
mark :6
data 3
r1
-
commit refs/heads/default
mark :7
committer "debugbuilddag"  1 +
-  data 2
+  data 3
r1
from :3
M 644 :4 mf
@@ -232,21 +227,18 @@
21
22
23
-
blob
mark :9
data 3
r2
-
blob
mark :10
data 3
r2
-
commit refs/heads/name1
mark :11
committer "debugbuilddag"  2 +
-  data 2
+  data 3
r2
from :7
M 644 :8 mf
@@ -280,21 +272,18 @@
21
22
23
-
blob
mark :13
data 3
r3
-
blob
mark :14
data 3
r3
-
commit refs/heads/name1
mark :15
committer "debugbuilddag"  3 +
-  data 2
+  data 3
r3
from :11
M 644 :12 mf
@@ -328,21 +317,18 @@
21
22
23
-
blob
mark :17
data 3
r4
-
blob
mark :18
data 3
r4
-
commit refs/heads/name1
mark :19
committer "debugbuilddag"  4 +
-  data 2
+  data 3
r4
from :15
M 644 :16 mf
@@ -376,21 +362,18 @@
21
22
23
-
blob
mark :21
data 3
r5
-
blob
mark :22
data 3
r5
-
commit refs/heads/name2
mark :23
committer "debugbuilddag"  5 +
-  data 2
+  data 3
r5
from :7
M 644 :20 mf
@@ -424,21 +407,18 @@
21
22
23
-
blob
mark :25
data 3
r6
-
blob
mark :26
data 3
r6
-
commit refs/heads/name2
mark :27
committer "debugbuilddag"  6 +
-  data 2
+  data 3
r6
from :23
M 644 :24 mf
@@ -472,21 +452,18 @@
21
22
23
-
blob
mark :29
data 3
r7
-
blob
mark :30
data 3
r7
-
commit refs/heads/name2
mark :31
committer "debugbuilddag"  7 +
-  data 2
+  data 3
r7
from :27
M 644 :28 mf
@@ -520,21 +497,18 @@
21
22
23
-
blob
mark :33
data 3
r8
-
blob
mark :34
data 3
r8
-
commit refs/heads/name2
mark :35
committer "debugbuilddag"  8 +
-  data 2
+  data 3
r8
from :31
M 644 :32 mf
@@ -568,21 +542,18 @@
21
22
23
-
blob
mark :37
data 3
r9
-
blob
mark :38
data 3
r9
-
commit refs/heads/both
mark :39
committer "debugbuilddag"  9 +
-  data 2
+  data 3
r9
from :35
merge :19
@@ -620,21 +591,18 @@
21
22
23
-
blob
mark :41
data 4
r10
-
blob
mark :42
data 4
r10
-
commit refs/heads/both
mark :43
committer "debugbuilddag"  10 +
-  data 3
+  data 4
r10
from :39
M 644 :40 mf
@@ -668,21 +636,18 @@
21
22 r11
23
-
blob
mark :45
data 4
r11
-
blob
mark :46
data 4
r11
-
commit refs/heads/both
mark :47
committer "debugbuilddag"  11 +
-  data 3
+  data 4
r11
from :43
M 644 

Re: releasenotes: use re.MULTILINE mode when checking admonitions

2022-10-17 Thread Raphaël Gomès
Sorry, I seemed to have missed (or never received) the email for your 
member submission, I granted you access to Heptapod just now.

Thanks for contributing!
On 10/13/22 06:38, Craig Ozancin wrote:

Thanks for letting me know.

It won't happen again.  I am now setup with mailbomb and waiting on 
heptapod.


Craig

On Wed, Oct 12, 2022 at 9:19 AM Augie Fackler  wrote:

Thanks, queued. Note that your patch suffered pretty bad
whitespace damage in-flight, as though you copied and pasted the
patch into a standard mail client.
https://www.mercurial-scm.org/wiki/ContributingChanges#Emailing_patches is
the golden path (specifically the patchbomb extension) to avoid
that in the future if you want to use email (which I understand!),
otherwise I recommend trying out heptapod.

Sorry for the slow review.


On Sep 30, 2022, at 11:18, Craig Ozancin  wrote:

# HG changeset patch
# User Craig Ozancin 
# Date 1664550348 21600
#      Fri Sep 30 09:05:48 2022 -0600
# Node ID 5083c4a03bad27c7d3353b491516bed93f359d2a
# Parent  4f36738a869a91275c9a2b2f77219cc663199e13
releasenotes: use re.MULTILINE mode when checking admonitions

Release note admonitions must start at the beginning of a line within
the changeset description:

.. admonitions::

The checkadmonitions function search for and validates admonitions.

Unfortunately, since the ctx.description is multi-line, the regex
search
always fails unless the admonition is on the first line.

This changeset adds re.MULTILINE to the re.compile to make the re
opbject
multi-line.

diff --git a/hgext/releasenotes.py b/hgext/releasenotes.py
--- a/hgext/releasenotes.py
+++ b/hgext/releasenotes.py
@@ -70,7 +70,7 @@ DEFAULT_SECTIONS = [
     (b'api', _(b'API Changes')),
 ]

-RE_DIRECTIVE = re.compile(br'^\.\. ([a-zA-Z0-9_]+)::\s*([^$]+)?$')
+RE_DIRECTIVE = re.compile(br'^\.\.
([a-zA-Z0-9_]+)::\s*([^$]+)?$', re.MULTILINE)
 RE_ISSUE = br'\bissue ?[0-9]{4,6}(?![0-9])\b'

 BULLET_SECTION = _(b'Other Changes')
diff --git a/tests/test-releasenotes-formatting.t
b/tests/test-releasenotes-formatting.t
--- a/tests/test-releasenotes-formatting.t
+++ b/tests/test-releasenotes-formatting.t
@@ -387,6 +387,8 @@ Testing output for the --check (-c) flag

   $ touch a
   $ hg -q commit -A -l - << EOF
+  > commit 2
+  >
   > .. asf::
   >
   >    First paragraph under this admonition.
@@ -395,17 +397,19 @@ Testing output for the --check (-c) flag
 Suggest similar admonition in place of the invalid one.

   $ hg releasenotes -r . -c
-  Invalid admonition 'asf' present in changeset 4026fe9e1c20
+  Invalid admonition 'asf' present in changeset 99fa3c800c5e

   $ touch b
   $ hg -q commit -A -l - << EOF
-  > .. fixes::
+  > commit 1
+  >
+  > .. fixed::
   >
   >    First paragraph under this admonition.
   > EOF

   $ hg releasenotes -r . -c
-  Invalid admonition 'fixes' present in changeset 0e7130d2705c
+  Invalid admonition 'fixed' present in changeset 2fbd922a34d6
   (did you mean fix?)

   $ cd ..

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



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


Re: [Bug 6719] New: ttrr

2022-08-29 Thread Raphaël Gomès

This spam is perfect to try out bugzilla email reply

On 6/24/22 20:13, mercurial-b...@mercurial-scm.org wrote:

https://bz.mercurial-scm.org/show_bug.cgi?id=6719

 Bug ID: 6719
Summary: ttrr
Product: Mercurial
Version: 6.1rc0
   Hardware: Other
 OS: Linux
 Status: UNCONFIRMED
   Severity: feature
   Priority: wish
  Component: blackbox
   Assignee: bugzi...@mercurial-scm.org
   Reporter: junaidisto...@gmail.com
 CC: mercurial-de...@mercurial-scm.org
 Python Version: ---

Created attachment 2149
   --> https://bz.mercurial-scm.org/attachment.cgi?id=2149=edit
gg

hh


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


Re: Rust error stratergy in the hg codebase

2022-08-25 Thread Raphaël Gomès

Update,

I've posted the same thing over on Reddit¹ and have gotten advice 
consistent with my discussions with other people (thanks Yuya!). So 
unless someone objects to any of this, I'll have a somewhat difficult 
refactor ahead of my, but at least with a pretty clear plan.


Raphaël

[1] 
https://old.reddit.com/r/rust/comments/wuomjt/help_needed_for_error_stratergy_inside_mercurial/


On 8/22/22 11:06, Raphaël Gomès wrote:

Hi all,

I've been having an ergonomic issue with error handling lately. Error 
handling strategy used to be kind of a rough edge in Rust because of 
the different constraints of both the compiler and the standard 
library. Lately it seems that most projects are happy with using a mix 
of `thiserror`/`anyhow`/`eyere`/`snafu`, however when investigating 
using (a potential combination) of them, they don't appear to allow 
for all the constraints that we have.


Rust errors in the hg codebase:

- need to be matchable at the library layers (basically that 
everything inside `hg-core` exposes enums)
- need to carry enough information for end-users to make sense of the 
issue and/or devs to be able to help end-users with it
- need to match the Python implementation's user-facing behavior 
basically exactly (we can have some leeway for OS errors, I guess, but 
the point is to leave the formatting to us and not a library)
- shouldn't do any formatting inside `hg-core`, that should be left to 
consumers of `hg-core` (though having a default formatting isn't a bad 
idea for debugging)
- shouldn't assume that data is somehow UTF8 (ties in to the last 
point), as we have non-UTF8 data we need to format using 
`format_bytes` or equivalent (no popular crate seems to care since 
it's a pretty niche need)
- need to compose somehow, since not all code can be perfectly 
hierarchical: the `dirstate` module needs to call functions that may 
return a `RevsetError` and the `revset` module needs to call functions 
that may return a `DirstateError`, creating cycles in error enums 
(this is the big one for me that started this refactor and questioning).


So I'm calling to the Rust experts, or at least people that have some 
experience with working in larger Rust codebases about what the 
optimal strategy would be.


Thanks,
Raphaël

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

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


Two-weeks absence and slower review cadance

2022-08-25 Thread Raphaël Gomès

Hi all,

I wanted to warn all contributors that I will be basically out (but not 
unreachable for emergencies) for at least 2 weeks starting on September 
3rd. My own review cadence has already slowed down because of the amount 
of urgent things I need to care of currently, though I'll still take 
time to 6.2.2 next week.


I have patches of my own that have been sitting still for a good while, 
I'd appreciate if we didn't let them bitrot too much. If anyone with 
push access has questions on how to help out, please reach out: this is 
not limited to my patches of course.


Thanks,
Raphaël

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


Re: [PATCH 1 of 4 STABLE] automation: refresh requirements

2022-08-23 Thread Raphaël Gomès
Merged as 
https://foss.heptapod.net/mercurial/mercurial-devel/-/merge_requests/210, 
sorry for the delay


On 7/21/22 05:06, Gregory Szorc wrote:

# HG changeset patch
# User Gregory Szorc 
# Date 1654313106 25200
#  Fri Jun 03 20:25:06 2022 -0700
# Branch stable
# Node ID c6f19972a20a9e834377570786a039db3b07c47b
# Parent  55adff8105464f6247983940ba109684d36b689d
automation: refresh requirements

I'm hitting errors installing the old version of cffi due to an
apparent issue where older versions of cffi aren't compatible with
the modern Clang I'm using. So let's upgrade packages to unbreak
things and to keep things modern.

Differential Revision: https://phab.mercurial-scm.org/D12629

diff --git a/contrib/automation/requirements.txt 
b/contrib/automation/requirements.txt
--- a/contrib/automation/requirements.txt
+++ b/contrib/automation/requirements.txt
@@ -1,193 +1,267 @@
  #
-# This file is autogenerated by pip-compile
+# This file is autogenerated by pip-compile with python 3.10
  # To update, run:
  #
  #pip-compile --generate-hashes 
--output-file=contrib/automation/requirements.txt 
contrib/automation/requirements.txt.in
  #
-asn1crypto==1.0.1 \
-
--hash=sha256:0b199f211ae690df3db4fd6c1c4ff976497fb1da689193e368eedbadc53d9292 \
-
--hash=sha256:bca90060bd995c3f62c4433168eab407e44bdbdb567b3f3a396a676c1a4c4a3f \
-# via cryptography
-bcrypt==3.1.7 \
-
--hash=sha256:0258f143f3de96b7c14f762c770f5fc56ccd72f8a1857a451c1cd9a655d9ac89 \
-
--hash=sha256:0b0069c752ec14172c5f78208f1863d7ad6755a6fae6fe76ec2c80d13be41e42 \
-
--hash=sha256:19a4b72a6ae5bb467fea018b825f0a7d917789bcfe893e53f15c92805d187294 \
-
--hash=sha256:5432dd7b34107ae8ed6c10a71b4397f1c853bd39a4d6ffa7e35f40584cffd161 \
-
--hash=sha256:69361315039878c0680be456640f8705d76cb4a3a3fe1e057e0f261b74be4b31 \
-
--hash=sha256:6fe49a60b25b584e2f4ef175b29d3a83ba63b3a4df1b4c0605b826668d1b6be5 \
-
--hash=sha256:74a015102e877d0ccd02cdeaa18b32aa7273746914a6c5d0456dd442cb65b99c \
-
--hash=sha256:763669a367869786bb4c8fcf731f4175775a5b43f070f50f46f0b59da45375d0 \
-
--hash=sha256:8b10acde4e1919d6015e1df86d4c217d3b5b01bb7744c36113ea43d529e1c3de \
-
--hash=sha256:9fe92406c857409b70a38729dbdf6578caf9228de0aef5bc44f859ffe971a39e \
-
--hash=sha256:a190f2a5dbbdbff4b74e3103cef44344bc30e61255beb27310e2aec407766052 \
-
--hash=sha256:a595c12c618119255c90deb4b046e1ca3bcfad64667c43d1166f2b04bc72db09 \
-
--hash=sha256:c9457fa5c121e94a58d6505cadca8bed1c6b83b3204928a866ca2e599105 \
-
--hash=sha256:cb93f6b2ab0f6853550b74e051d297c27a638719753eb9ff66d1e4072be67133 \
-
--hash=sha256:d7bdc26475679dd073ba0ed2766445bb5b20ca4793ca0db32b399dccc6bc84b7 \
-
--hash=sha256:ff032765bb8716d9387fd5376d987a937254b0619eff0972779515b5c98820bc \
+bcrypt==3.2.2 \
+
--hash=sha256:2b02d6bfc6336d1094276f3f588aa1225a598e27f8e3388f4db9948cb707b521 \
+
--hash=sha256:433c410c2177057705da2a9f2cd01dd157493b2a7ac14c8593a16b3dab6b6bfb \
+
--hash=sha256:4e029cef560967fb0cf4a802bcf4d562d3d6b4b1bf81de5ec1abbe0f1adb027e \
+
--hash=sha256:61bae49580dce88095d669226d5076d0b9d927754cedbdf76c6c9f5099ad6f26 \
+
--hash=sha256:6d2cb9d969bfca5bc08e45864137276e4c3d3d7de2b162171def3d188bf9d34a \
+
--hash=sha256:7180d98a96f00b1050e93f5b0f556e658605dd9f524d0b0e68ae7944673f525e \
+
--hash=sha256:7d9ba2e41e330d2af4af6b1b6ec9e6128e91343d0b4afb9282e54e5508f31baa \
+
--hash=sha256:7ff2069240c6bbe49109fe84ca80508773a904f5a8cb960e02a977f7f519b129 \
+
--hash=sha256:88273d806ab3a50d06bc6a2fc7c87d737dd669b76ad955f449c43095389bc8fb \
+
--hash=sha256:a2c46100e315c3a5b90fdc53e429c006c5f962529bc27e1dfd656292c20ccc40 \
+
--hash=sha256:cd43303d6b8a165c29ec6756afd169faba9396a9472cdff753fe9f19b96ce2fa
  # via paramiko
-bleach==3.1.0 \
-
--hash=sha256:213336e49e102af26d9cde77dd2d0397afabc5a6bf2fed985dc35b5d1e285a16 \
-
--hash=sha256:3fdf7f77adcf649c9911387df51254b813185e32b2c6619f690b593a617e19fa \
+bleach==5.0.0 \
+
--hash=sha256:08a1fe86d253b5c88c92cc3d810fd8048a16d15762e1e5b74d502256e5926aa1 \
+
--hash=sha256:c6d6cc054bdc9c83b48b8083e236e5f00f238428666d2ce2e083eaa5fd568565
  # via readme-renderer
-boto3==1.9.243 \
-
--hash=sha256:404acbecef8f4912f18312fcfaffe7eba7f10b3b7adf7853bdba59cdf2275ebb \
-
--hash=sha256:c6e5a7e4548ce7586c354ff633f2a66ba3c471d15a8ae6a30f873122ab04e1cf
-botocore==1.12.243 \
-
--hash=sha256:397585a7881230274afb8d1877ef69a661b0a311745cd324f14a052fb2a2863a \
-
--hash=sha256:4496f8da89cb496462a831897ad248e13e431d9fa7e41e06d426fd6658ab6e59 \
-# via boto3, s3transfer
-certifi==2021.5.30 \
-
--hash=sha256:2bbf76fd432960138b3ef6dda3dde0544f27cbf8546c458e60baf371917ba9ee \
-
--hash=sha256:50b1e4f8446b06f41be7dd6338db18e0990601dce795c2b1686458aa7e8fa7d8 \
+boto3==1.22.7 \
+
--hash=sha256:4dc0df36c3465ff0d586017da68b0152123695f38f30ad98fed7185e59298d2c \
+
--hash=sha256:de4fa49ca1cbc93313144e93e6d0997cbb61c8cca91f3418b4e3646dc215f441
+# via 

Rust error stratergy in the hg codebase

2022-08-22 Thread Raphaël Gomès

Hi all,

I've been having an ergonomic issue with error handling lately. Error 
handling strategy used to be kind of a rough edge in Rust because of the 
different constraints of both the compiler and the standard library. 
Lately it seems that most projects are happy with using a mix of 
`thiserror`/`anyhow`/`eyere`/`snafu`, however when investigating using 
(a potential combination) of them, they don't appear to allow for all 
the constraints that we have.


Rust errors in the hg codebase:

- need to be matchable at the library layers (basically that everything 
inside `hg-core` exposes enums)
- need to carry enough information for end-users to make sense of the 
issue and/or devs to be able to help end-users with it
- need to match the Python implementation's user-facing behavior 
basically exactly (we can have some leeway for OS errors, I guess, but 
the point is to leave the formatting to us and not a library)
- shouldn't do any formatting inside `hg-core`, that should be left to 
consumers of `hg-core` (though having a default formatting isn't a bad 
idea for debugging)
- shouldn't assume that data is somehow UTF8 (ties in to the last 
point), as we have non-UTF8 data we need to format using `format_bytes` 
or equivalent (no popular crate seems to care since it's a pretty niche 
need)
- need to compose somehow, since not all code can be perfectly 
hierarchical: the `dirstate` module needs to call functions that may 
return a `RevsetError` and the `revset` module needs to call functions 
that may return a `DirstateError`, creating cycles in error enums (this 
is the big one for me that started this refactor and questioning).


So I'm calling to the Rust experts, or at least people that have some 
experience with working in larger Rust codebases about what the optimal 
strategy would be.


Thanks,
Raphaël

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


Re: [PATCH v2] rebase: add boolean config item rebase.norebasesource

2022-08-17 Thread Raphaël Gomès

Hi, sorry for the (very long) delay.

This slipped through the cracks twice, somehow.

Here is the current state of your patch: 
https://foss.heptapod.net/mercurial/mercurial-devel/-/merge_requests/202


I've taken the liberty to amend it for it to go through faster, how does 
that sound?


Raphaël

On 6/16/22 17:03, C. Masloch wrote:
Hi, as specified on the wiki [1] I am hereby "kindly requesting 
someone look at it". "It" being the second version of my patch, in the 
message that I am replying to.


Regards,
ecm

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

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

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


Re: [PATCH 1 of 4 STABLE] automation: refresh requirements

2022-08-17 Thread Raphaël Gomès
If another reviewer better versed than I in email series importing can 
figure out how to import this, that would be nice. I can circle back to 
it later, but my usual tooling fails for now.


On 7/21/22 05:06, Gregory Szorc wrote:


# HG changeset patch
# User Gregory Szorc 
# Date 1654313106 25200
#  Fri Jun 03 20:25:06 2022 -0700
# Branch stable
# Node ID c6f19972a20a9e834377570786a039db3b07c47b
# Parent  55adff8105464f6247983940ba109684d36b689d
automation: refresh requirements

I'm hitting errors installing the old version of cffi due to an
apparent issue where older versions of cffi aren't compatible with
the modern Clang I'm using. So let's upgrade packages to unbreak
things and to keep things modern.

Differential Revision: https://phab.mercurial-scm.org/D12629

diff --git a/contrib/automation/requirements.txt 
b/contrib/automation/requirements.txt
--- a/contrib/automation/requirements.txt
+++ b/contrib/automation/requirements.txt
@@ -1,193 +1,267 @@
  #
-# This file is autogenerated by pip-compile
+# This file is autogenerated by pip-compile with python 3.10
  # To update, run:
  #
  #pip-compile --generate-hashes 
--output-file=contrib/automation/requirements.txt 
contrib/automation/requirements.txt.in
  #
-asn1crypto==1.0.1 \
-
--hash=sha256:0b199f211ae690df3db4fd6c1c4ff976497fb1da689193e368eedbadc53d9292 \
-
--hash=sha256:bca90060bd995c3f62c4433168eab407e44bdbdb567b3f3a396a676c1a4c4a3f \
-# via cryptography
-bcrypt==3.1.7 \
-
--hash=sha256:0258f143f3de96b7c14f762c770f5fc56ccd72f8a1857a451c1cd9a655d9ac89 \
-
--hash=sha256:0b0069c752ec14172c5f78208f1863d7ad6755a6fae6fe76ec2c80d13be41e42 \
-
--hash=sha256:19a4b72a6ae5bb467fea018b825f0a7d917789bcfe893e53f15c92805d187294 \
-
--hash=sha256:5432dd7b34107ae8ed6c10a71b4397f1c853bd39a4d6ffa7e35f40584cffd161 \
-
--hash=sha256:69361315039878c0680be456640f8705d76cb4a3a3fe1e057e0f261b74be4b31 \
-
--hash=sha256:6fe49a60b25b584e2f4ef175b29d3a83ba63b3a4df1b4c0605b826668d1b6be5 \
-
--hash=sha256:74a015102e877d0ccd02cdeaa18b32aa7273746914a6c5d0456dd442cb65b99c \
-
--hash=sha256:763669a367869786bb4c8fcf731f4175775a5b43f070f50f46f0b59da45375d0 \
-
--hash=sha256:8b10acde4e1919d6015e1df86d4c217d3b5b01bb7744c36113ea43d529e1c3de \
-
--hash=sha256:9fe92406c857409b70a38729dbdf6578caf9228de0aef5bc44f859ffe971a39e \
-
--hash=sha256:a190f2a5dbbdbff4b74e3103cef44344bc30e61255beb27310e2aec407766052 \
-
--hash=sha256:a595c12c618119255c90deb4b046e1ca3bcfad64667c43d1166f2b04bc72db09 \
-
--hash=sha256:c9457fa5c121e94a58d6505cadca8bed1c6b83b3204928a866ca2e599105 \
-
--hash=sha256:cb93f6b2ab0f6853550b74e051d297c27a638719753eb9ff66d1e4072be67133 \
-
--hash=sha256:d7bdc26475679dd073ba0ed2766445bb5b20ca4793ca0db32b399dccc6bc84b7 \
-
--hash=sha256:ff032765bb8716d9387fd5376d987a937254b0619eff0972779515b5c98820bc \
+bcrypt==3.2.2 \
+
--hash=sha256:2b02d6bfc6336d1094276f3f588aa1225a598e27f8e3388f4db9948cb707b521 \
+
--hash=sha256:433c410c2177057705da2a9f2cd01dd157493b2a7ac14c8593a16b3dab6b6bfb \
+
--hash=sha256:4e029cef560967fb0cf4a802bcf4d562d3d6b4b1bf81de5ec1abbe0f1adb027e \
+
--hash=sha256:61bae49580dce88095d669226d5076d0b9d927754cedbdf76c6c9f5099ad6f26 \
+
--hash=sha256:6d2cb9d969bfca5bc08e45864137276e4c3d3d7de2b162171def3d188bf9d34a \
+
--hash=sha256:7180d98a96f00b1050e93f5b0f556e658605dd9f524d0b0e68ae7944673f525e \
+
--hash=sha256:7d9ba2e41e330d2af4af6b1b6ec9e6128e91343d0b4afb9282e54e5508f31baa \
+
--hash=sha256:7ff2069240c6bbe49109fe84ca80508773a904f5a8cb960e02a977f7f519b129 \
+
--hash=sha256:88273d806ab3a50d06bc6a2fc7c87d737dd669b76ad955f449c43095389bc8fb \
+
--hash=sha256:a2c46100e315c3a5b90fdc53e429c006c5f962529bc27e1dfd656292c20ccc40 \
+
--hash=sha256:cd43303d6b8a165c29ec6756afd169faba9396a9472cdff753fe9f19b96ce2fa
  # via paramiko
-bleach==3.1.0 \
-
--hash=sha256:213336e49e102af26d9cde77dd2d0397afabc5a6bf2fed985dc35b5d1e285a16 \
-
--hash=sha256:3fdf7f77adcf649c9911387df51254b813185e32b2c6619f690b593a617e19fa \
+bleach==5.0.0 \
+
--hash=sha256:08a1fe86d253b5c88c92cc3d810fd8048a16d15762e1e5b74d502256e5926aa1 \
+
--hash=sha256:c6d6cc054bdc9c83b48b8083e236e5f00f238428666d2ce2e083eaa5fd568565
  # via readme-renderer
-boto3==1.9.243 \
-
--hash=sha256:404acbecef8f4912f18312fcfaffe7eba7f10b3b7adf7853bdba59cdf2275ebb \
-
--hash=sha256:c6e5a7e4548ce7586c354ff633f2a66ba3c471d15a8ae6a30f873122ab04e1cf
-botocore==1.12.243 \
-
--hash=sha256:397585a7881230274afb8d1877ef69a661b0a311745cd324f14a052fb2a2863a \
-
--hash=sha256:4496f8da89cb496462a831897ad248e13e431d9fa7e41e06d426fd6658ab6e59 \
-# via boto3, s3transfer
-certifi==2021.5.30 \
-
--hash=sha256:2bbf76fd432960138b3ef6dda3dde0544f27cbf8546c458e60baf371917ba9ee \
-
--hash=sha256:50b1e4f8446b06f41be7dd6338db18e0990601dce795c2b1686458aa7e8fa7d8 \
+boto3==1.22.7 \
+
--hash=sha256:4dc0df36c3465ff0d586017da68b0152123695f38f30ad98fed7185e59298d2c \
+

Re: [PATCH stable] rust: bump to memmap2 0.5.3, micro-timer 0.4.0, and crossbeam-channel 0.5.0

2022-08-17 Thread Raphaël Gomès

Queued, thanks

On 7/11/22 23:03, Mads Kiilerich wrote:

# HG changeset patch
# User Mads Kiilerich 
# Date 1657572476 -7200
#  Mon Jul 11 22:47:56 2022 +0200
# Branch stable
# Node ID f1713e81437e894fab0658e4f410184e10d35e5e
# Parent  55adff8105464f6247983940ba109684d36b689d
rust: bump to memmap2 0.5.3, micro-timer 0.4.0, and crossbeam-channel 0.5.0

The merge in 12adf8c695ed had conflicts in rust/Cargo.lock and
rust/hg-core/Cargo.toml . Let's ignore rust/Cargo.lock - it is regenerated.

For rust/hg-core/Cargo.toml, stable had dd6b67d5c256 "rust: fix unsound
`OwningDirstateMap`" which introduced ouroboros (and dropped
stable_deref_trait).

Default had ec8d9b5a5e7c "rust-hg-core: upgrade dependencies" which had a lot
of churn bumping minimum versions - also patch versions. It is indeed a good
idea to bump to *allow* use of latest package. That means that major versions
should be bumped for packages after 1.0, and for packages below 1.0 minor
versions should be bumped too. But it doesn't work to try enforce a policy of
using latest patch by bumping versions at arbitrary times.

For good or bad, the merge doesn't seem to have resolved the conflicts
correctly, and many of the minor "upgrade dependencies" were lost again.

Unfortunately, it also lost the bump of memmap2 to 0.5.3, which is needed for
Fedora packaging where 0.4 isn't available. Same with micro-timer bump to 0.4
(which already is used in rhg). crossbeam-channel bump was also lost.

This change fixes that regression by redoing these "important" lines of the
merge "correctly".

I propose this for stable, even though dependency changes on stable branches
are annoying.

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
@@ -29,10 +29,10 @@ sha-1 = "0.10.0"
  twox-hash = "1.6.2"
  same-file = "1.0.6"
  tempfile = "3.1.0"
-crossbeam-channel = "0.4"
-micro-timer = "0.3.0"
+crossbeam-channel = "0.5.0"
+micro-timer = "0.4.0"
  log = "0.4.8"
-memmap2 = {version = "0.4", features = ["stable_deref_trait"]}
+memmap2 = { version = "0.5.3", features = ["stable_deref_trait"] }
  zstd = "0.5.3"
  format-bytes = "0.3.0"
  


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

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


Re: How to submit large series of loosely related changesets in Heptapod

2022-06-07 Thread Raphaël Gomès
Sorry, the mailing daemon broke because Phabricator used up all disk 
space while fighting for its life. I made sure this wouldn't happen 
again, but only just restarted the daemon, so the email got delayed by a 
few days.


On 6/3/22 20:23, Manuel Jacob wrote:
I have a branch with Python 3 cleanups 
(https://foss.heptapod.net/mercurial/mercurial-devel/-/compare/default...py3-cleanups). 
It consists of more than 30 changesets already and will grow larger.



Thanks a lot for this first of all.
Phabricator has a strong focus on single patches. There, I would 
submit each patch shortly after creating them. Each can be reviewed 
and approved individually.


On Heptapod, the focus is more on whole merge request. The Wiki page 
says that review should be done on single changesets, but it seems 
like only the whole merge request can be approved and merged (in the UI).


Review should always happen at the changeset level (though having the 
full diff can be useful to get a global view of all related changes in 
any given MR, something that IMO was lacking in phab's review UI).


While Heptapod's review tool is not the best at "commit-centric" review, 
the review itself is still very much doable.


If I create a single merge request when the series is finished (which 
is whenever I don’t feel to continue), it will be very large and hard 
to review in one pass. Also, it would mean that I would get feedback 
on the first changesets later, increasing the chance of getting merge 
conflicts when changing later changesets (in this case, it hopefully 
wouldn’t be an issue, because the changes are not very complex).


Sure, that's one possibility. As a reviewer I prefer not to get 100 
patches dumped all at once, especially if we can do otherwise.
If I create a single merge request and continue to add changesets to 
it, feedback on the first changesets will possibly be earlier, but CI 
can temporarily break for newer changesets while I keep working on it.
This is something that can be worked around by the reviewer who can take 
an arbitrary subset (most likely always a linear range from the oldest 
changeset), create a separate topic to submit for CI + merging. I think 
I touched about this in the transition email and it was basically "this 
doesn't happen a ton and we may create tooling to help this in the future".


If I create a merge request for each changeset, it will be many and 
each merge request will contain the unmerged ancestors. Also, I think 
it would require that each changeset is in its own topic, which 
complicates matters when working with them locally.


This would be quite expensive in terms of churn (and CI), I would advise 
against it.
I could split them in smaller batches, but it’s not clear how large 
they should be, and it would combine disadvantages of the two other 
approaches (although less pronounced).
I think this is the easiest way of doing this. Just send a series, maybe 
no more than 20 patches, and then the next one, etc.


Thoughts?
___
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


Re: [PATCH stable] rust: relax im-rc dependency to allow minor updates

2022-06-07 Thread Raphaël Gomès

Queued this morning, sorry for the delay.

On 5/24/22 15:04, Mads Kiilerich wrote:

# HG changeset patch
# User Mads Kiilerich 
# Date 1653395384 -7200
#  Tue May 24 14:29:44 2022 +0200
# Branch stable
# Node ID 32de89308ead51d42d631c208ab17c866218e1c5
# Parent  1d257c4c15683ee998edcc7dd6caf5a4cb52c820
rust: relax im-rc dependency to allow minor updates

This "15.0.*" requirement came from 0d99778af68a and is now replaced with plain
"15.0".

AFAICS, it really should allow (but not necessarily require) im-rc 15.1 .

Narrow requirement requirements with wildcard in the version is not used in
other places.

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
@@ -14,7 +14,7 @@ bytes-cast = "0.2"
  byteorder = "1.3.4"
  derive_more = "0.99"
  home = "0.5"
-im-rc = "15.0.*"
+im-rc = "15.0"
  itertools = "0.9"
  lazy_static = "1.4.0"
  libc = "0.2"

___
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


Re: [PATCH 1 of 2 stable] worker: do not suppress EINTR

2022-05-25 Thread Raphaël Gomès
Before I review these (and your previous series), is there a reason why 
you use the ML instead of Heptapod (as per 
https://www.mercurial-scm.org/pipermail/mercurial-devel/2022-May/148466.html 
) considering you're already using it for your pre-submission CI?


On 5/25/22 02:30, Manuel Jacob wrote:

# HG changeset patch
# User Manuel Jacob 
# Date 1653433864 -7200
#  Wed May 25 01:11:04 2022 +0200
# Branch stable
# Node ID d058898bdd462b03c5bff38ad40d1f855ea51c23
# Parent  477b5145e1a02715f846ce017b460858a58e03b1
# EXP-Topic worker-pickle-load-EINTR
worker: do not suppress EINTR

Before this change, when IOError with errno EINTR was raised during
pickle.load(), the error was suppressed and loading from other file descriptors
was continued.

On Python 3, system calls failing with EINTR are retried (PEP 475). Therefore,
the removal of this code should not make any difference.

On Python 2, this is not generally the case. CPickle has no handling of EINTR.
In one place it misinterprets it as EOF. In another place, it will raise
IOError. However, this could happen in the middle of the stream. In this case,
if pickle tries to load from the stream later, it will behave wrongly (usually
it will raise an error, but loading of incorrect data or interpreter crashes
are thinkable).

diff --git a/mercurial/worker.py b/mercurial/worker.py
--- a/mercurial/worker.py
+++ b/mercurial/worker.py
@@ -301,10 +301,6 @@
  selector.unregister(key.fileobj)
  key.fileobj.close()
  openpipes -= 1
-except IOError as e:
-if e.errno == errno.EINTR:
-continue
-raise
  except:  # re-raises
  killworkers()
  cleanup()

___
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


Re: Plan for the migration out of Phabricator

2022-05-12 Thread Raphaël Gomès

Hi all,

There is now a wiki page explaining the new Heptapod contribution workflow.

https://www.mercurial-scm.org/wiki/Heptapod

The previous email contained the complete expected timeline, but I'll 
repeat it here to make it extra obvious for this particular concern:

    - contributions using this workflow will be possible starting May 16th
    - contributions through Phabricator will be deprecated on the same day.
- contributions through Phabricator will not be possible starting June 1st.

We have a couple of things to polish and there (like updating the rest 
of the wiki, etc.), but the base is pretty much ready so I though I'd 
send the email sooner rather than later.


Raphaël

On 5/2/22 21:38, Raphaël Gomès wrote:

Hello all,

It is time to set a flag day for our migration to Heptapod as a review 
tool.


We are currently making very good progress with the team at OSUOSL who 
will - unless a disaster occurs - provide us with infrastructure and 
help with the migration, the details of which are being ironed out 
right now. This is the most confident I have ever been about a smooth 
transition, thanks again to the OSUOSL¹.


Mercurial 6.1.3 should be released on or right after the 1st of June. 
Phabricator will need to be set to read-only mode before the VM goes 
out of support to give us a window between it being deprecated and it 
going out of service entirely.


I think a month is the best we can do for such a migration. More 
clearly (all dates are best-effort and may differ by a couple of days):


- Patches will be accepted to Phabricator until May 30th
- Patches will be accepted to Heptapod starting May 16th (a separate 
email will explain this)
- hg-committed will become deprecated in favor of the Heptapod repo on 
May 16th

- Phabricator will be set to read-only on June 1st
- We will run the scripts that save Phabricator as an archive (I have 
developed them already and have done a successful run)
- The archive will be made public for people to look at and check what 
we've missed before it's too late

- Phabricator will be replaced by its archive on July 1st
- hg-committed will simply redirect to hg at some point after the 
migration


This will be going on while we make the infrastructure migration 
happen and answer to our other obligations whether work-related or 
personal, so please bear with us if anything is sub-optimal.
I am confident that Mercurial as a project will be a lot healthier in 
terms of tooling within the next few months, and while not everything 
will be perfect, we are taking multiple good steps forward IMO.


Feedback is appreciated, as always.
Raphaël

[1] https://osuosl.org

___
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


D12602: test-dirstate: print something when the check is skipped

2022-05-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 makes a programming error obvious in cases when it should not be skipped

REPOSITORY
  rHG Mercurial

BRANCH
  stable

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

AFFECTED FILES
  tests/test-dirstate.t

CHANGE DETAILS

diff --git a/tests/test-dirstate.t b/tests/test-dirstate.t
--- a/tests/test-dirstate.t
+++ b/tests/test-dirstate.t
@@ -136,6 +136,8 @@
   >   # Non-Rust always rewrites the whole dirstate
   >   if [ $# -eq 1 ] || ([ -n "$HGMODULEPOLICY" ] && [ -z 
"${HGMODULEPOLICY##*rust*}" ]) || [ -n "$RHG_INSTALLED_AS_HG" ]; then
   > test $current_uid = $(find_dirstate_uuid)
+  >   else
+  > echo "not testing because using Python implementation"
   >   fi
   > }
 
@@ -156,6 +158,7 @@
   $ dirstate_data_files | wc -l
*1 (re)
   $ dirstate_uuid_has_not_changed
+  not testing because using Python implementation (no-rust no-rhg !)
 
 Trigger an append with a small change
 
@@ -165,6 +168,7 @@
   $ dirstate_data_files | wc -l
*1 (re)
   $ dirstate_uuid_has_not_changed
+  not testing because using Python implementation (no-rust no-rhg !)
 
 Unused bytes counter is non-0 when appending
   $ touch file
@@ -178,6 +182,7 @@
   M dir2/f
   A file
   $ dirstate_uuid_has_not_changed
+  not testing because using Python implementation (no-rust no-rhg !)
 
   $ hg debugstate --docket | grep unused
   number of unused bytes: 0 (no-rust no-rhg !)



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


D12601: test-dirstate: fix detection of Rust environment variable

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

REVISION SUMMARY
  The Rust path never actually worked. This change also improves clarity of the
  comment. The next change will ensure we print something when this check fails.

REPOSITORY
  rHG Mercurial

BRANCH
  stable

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

AFFECTED FILES
  tests/test-dirstate.t

CHANGE DETAILS

diff --git a/tests/test-dirstate.t b/tests/test-dirstate.t
--- a/tests/test-dirstate.t
+++ b/tests/test-dirstate.t
@@ -133,8 +133,8 @@
   > }
 
   $ dirstate_uuid_has_not_changed () {
-  >   # Pure Python always rewrites the whole dirstate
-  >   if [ $# -eq 1 ] || [ "$HGMODULEPOLICY" = *"rust"* ] || [ -n 
"$RHG_INSTALLED_AS_HG" ]; then
+  >   # Non-Rust always rewrites the whole dirstate
+  >   if [ $# -eq 1 ] || ([ -n "$HGMODULEPOLICY" ] && [ -z 
"${HGMODULEPOLICY##*rust*}" ]) || [ -n "$RHG_INSTALLED_AS_HG" ]; then
   > test $current_uid = $(find_dirstate_uuid)
   >   fi
   > }



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


Plan for the migration out of Phabricator

2022-05-02 Thread Raphaël Gomès

Hello all,

It is time to set a flag day for our migration to Heptapod as a review tool.

We are currently making very good progress with the team at OSUOSL who 
will - unless a disaster occurs - provide us with infrastructure and 
help with the migration, the details of which are being ironed out right 
now. This is the most confident I have ever been about a smooth 
transition, thanks again to the OSUOSL¹.


Mercurial 6.1.3 should be released on or right after the 1st of June. 
Phabricator will need to be set to read-only mode before the VM goes out 
of support to give us a window between it being deprecated and it going 
out of service entirely.


I think a month is the best we can do for such a migration. More clearly 
(all dates are best-effort and may differ by a couple of days):


- Patches will be accepted to Phabricator until May 30th
- Patches will be accepted to Heptapod starting May 16th (a separate 
email will explain this)
- hg-committed will become deprecated in favor of the Heptapod repo on 
May 16th

- Phabricator will be set to read-only on June 1st
- We will run the scripts that save Phabricator as an archive (I have 
developed them already and have done a successful run)
- The archive will be made public for people to look at and check what 
we've missed before it's too late

- Phabricator will be replaced by its archive on July 1st
- hg-committed will simply redirect to hg at some point after the migration

This will be going on while we make the infrastructure migration happen 
and answer to our other obligations whether work-related or personal, so 
please bear with us if anything is sub-optimal.
I am confident that Mercurial as a project will be a lot healthier in 
terms of tooling within the next few months, and while not everything 
will be perfect, we are taking multiple good steps forward IMO.


Feedback is appreciated, as always.
Raphaël

[1] https://osuosl.org___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D12591: debugcommands: remove `debugdirstateignorepatternhash`

2022-04-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 is replaced by the more complete `--docket` option to `debugstate`.

REPOSITORY
  rHG Mercurial

BRANCH
  stable

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

AFFECTED FILES
  mercurial/debugcommands.py
  tests/test-completion.t
  tests/test-help.t

CHANGE DETAILS

diff --git a/tests/test-help.t b/tests/test-help.t
--- a/tests/test-help.t
+++ b/tests/test-help.t
@@ -1013,8 +1013,6 @@
  dump information about delta chains in a revlog
debugdirstate
  show the contents of the current dirstate
-   debugdirstateignorepatternshash
- show the hash of ignore patterns stored in dirstate if v2,
debugdiscovery
  runs the changeset discovery protocol in isolation
debugdownload
diff --git a/tests/test-completion.t b/tests/test-completion.t
--- a/tests/test-completion.t
+++ b/tests/test-completion.t
@@ -94,7 +94,6 @@
   debugdate
   debugdeltachain
   debugdirstate
-  debugdirstateignorepatternshash
   debugdiscovery
   debugdownload
   debugextensions
@@ -285,7 +284,6 @@
   debugdata: changelog, manifest, dir
   debugdate: extended
   debugdeltachain: changelog, manifest, dir, template
-  debugdirstateignorepatternshash: 
   debugdirstate: nodates, dates, datesort, docket, all
   debugdiscovery: old, nonheads, rev, seed, local-as-revs, remote-as-revs, 
ssh, remotecmd, insecure, template
   debugdownload: output
diff --git a/mercurial/debugcommands.py b/mercurial/debugcommands.py
--- a/mercurial/debugcommands.py
+++ b/mercurial/debugcommands.py
@@ -1018,22 +1018,6 @@
 
 
 @command(
-b'debugdirstateignorepatternshash',
-[],
-_(b''),
-)
-def debugdirstateignorepatternshash(ui, repo, **opts):
-"""show the hash of ignore patterns stored in dirstate if v2,
-or nothing for dirstate-v2
-"""
-if repo.dirstate._use_dirstate_v2:
-docket = repo.dirstate._map.docket
-hash_len = 20  # 160 bits for SHA-1
-hash_bytes = docket.tree_metadata[-hash_len:]
-ui.write(binascii.hexlify(hash_bytes) + b'\n')
-
-
-@command(
 b'debugdiscovery',
 [
 (b'', b'old', None, _(b'use old-style discovery')),



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


D12590: dirstate-v2: add flag to `debugstate` to print docket information

2022-04-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 is useful information that we don't easily have access to currently,
  unless you speak fluent xxd.
  
  This replaces `debugdirstateignorepatternshash`, which I'll remove in the next
  changeset.

REPOSITORY
  rHG Mercurial

BRANCH
  stable

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

AFFECTED FILES
  mercurial/debugcommands.py
  tests/test-completion.t
  tests/test-hgignore.t

CHANGE DETAILS

diff --git a/tests/test-hgignore.t b/tests/test-hgignore.t
--- a/tests/test-hgignore.t
+++ b/tests/test-hgignore.t
@@ -418,14 +418,14 @@
   $ hg status > /dev/null
   $ cat .hg/testhgignore .hg/testhgignorerel .hgignore dir2/.hgignore 
dir1/.hgignore dir1/.hgignoretwo | $TESTDIR/f --sha1
   sha1=6e315b60f15fb5dfa02be00f3e2c8f923051f5ff
-  $ hg debugdirstateignorepatternshash
-  6e315b60f15fb5dfa02be00f3e2c8f923051f5ff
+  $ hg debugstate --docket | grep ignore
+  ignore pattern hash: 6e315b60f15fb5dfa02be00f3e2c8f923051f5ff
 
   $ echo rel > .hg/testhgignorerel
   $ hg status > /dev/null
   $ cat .hg/testhgignore .hg/testhgignorerel .hgignore dir2/.hgignore 
dir1/.hgignore dir1/.hgignoretwo | $TESTDIR/f --sha1
   sha1=dea19cc7119213f24b6b582a4bae7b0cb063e34e
-  $ hg debugdirstateignorepatternshash
-  dea19cc7119213f24b6b582a4bae7b0cb063e34e
+  $ hg debugstate --docket | grep ignore
+  ignore pattern hash: dea19cc7119213f24b6b582a4bae7b0cb063e34e
 
 #endif
diff --git a/tests/test-completion.t b/tests/test-completion.t
--- a/tests/test-completion.t
+++ b/tests/test-completion.t
@@ -286,7 +286,7 @@
   debugdate: extended
   debugdeltachain: changelog, manifest, dir, template
   debugdirstateignorepatternshash: 
-  debugdirstate: nodates, dates, datesort, all
+  debugdirstate: nodates, dates, datesort, docket, all
   debugdiscovery: old, nonheads, rev, seed, local-as-revs, remote-as-revs, 
ssh, remotecmd, insecure, template
   debugdownload: output
   debugextensions: template
diff --git a/mercurial/debugcommands.py b/mercurial/debugcommands.py
--- a/mercurial/debugcommands.py
+++ b/mercurial/debugcommands.py
@@ -47,6 +47,7 @@
 context,
 copies,
 dagparser,
+dirstateutils,
 encoding,
 error,
 exchange,
@@ -940,6 +941,12 @@
 (b'', b'datesort', None, _(b'sort by saved mtime')),
 (
 b'',
+b'docket',
+False,
+_(b'display the docket (metadata file) instead'),
+),
+(
+b'',
 b'all',
 False,
 _(b'display dirstate-v2 tree nodes that would not exist in v1'),
@@ -950,6 +957,33 @@
 def debugstate(ui, repo, **opts):
 """show the contents of the current dirstate"""
 
+if opts.get("docket"):
+if not repo.dirstate._use_dirstate_v2:
+raise error.Abort(_(b'dirstate v1 does not have a docket'))
+
+docket = repo.dirstate._map.docket
+(
+start_offset,
+root_nodes,
+nodes_with_entry,
+nodes_with_copy,
+unused_bytes,
+_unused,
+ignore_pattern,
+) = dirstateutils.v2.TREE_METADATA.unpack(docket.tree_metadata)
+
+ui.write(_(b"size of dirstate data: %d\n") % docket.data_size)
+ui.write(_(b"data file uuid: %s\n") % docket.uuid)
+ui.write(_(b"start offset of root nodes: %d\n") % start_offset)
+ui.write(_(b"number of root nodes: %d\n") % root_nodes)
+ui.write(_(b"nodes with entries: %d\n") % nodes_with_entry)
+ui.write(_(b"nodes with copies: %d\n") % nodes_with_copy)
+ui.write(_(b"number of unused bytes: %d\n") % unused_bytes)
+ui.write(
+_(b"ignore pattern hash: %s\n") % binascii.hexlify(ignore_pattern)
+)
+return
+
 nodates = not opts['dates']
 if opts.get('nodates') is not None:
 nodates = True



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


D12594: rust-dirstate-v2: fix the unused bytes counter when rewriting the dirstate

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

REVISION SUMMARY
  As per the previous patch, the counter was incorrectly carried over from the
  old docket when it should be reset for a complete rewrite.

REPOSITORY
  rHG Mercurial

BRANCH
  stable

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

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

CHANGE DETAILS

diff --git a/tests/test-dirstate.t b/tests/test-dirstate.t
--- a/tests/test-dirstate.t
+++ b/tests/test-dirstate.t
@@ -193,8 +193,7 @@
 Check that unused bytes counter is reset when creating a new docket
 
   $ hg debugstate --docket | grep unused
-  number of unused bytes: 0 (no-rust !)
-  number of unused bytes: [1-9]\d* (re) (rust known-bad-output !)
+  number of unused bytes: 0
 
 #endif
 
diff --git a/rust/hg-core/src/dirstate_tree/on_disk.rs 
b/rust/hg-core/src/dirstate_tree/on_disk.rs
--- a/rust/hg-core/src/dirstate_tree/on_disk.rs
+++ b/rust/hg-core/src/dirstate_tree/on_disk.rs
@@ -622,13 +622,18 @@
 
 let root_nodes = writer.write_nodes(dirstate_map.root.as_ref())?;
 
+let unreachable_bytes = if append {
+dirstate_map.unreachable_bytes
+} else {
+0
+};
 let meta = TreeMetadata {
 root_nodes,
 nodes_with_entry_count: dirstate_map.nodes_with_entry_count.into(),
 nodes_with_copy_source_count: dirstate_map
 .nodes_with_copy_source_count
 .into(),
-unreachable_bytes: dirstate_map.unreachable_bytes.into(),
+unreachable_bytes: unreachable_bytes.into(),
 unused: [0; 4],
 ignore_patterns_hash: dirstate_map.ignore_patterns_hash,
 };



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


D12593: rust-dirstate-v2: show `unused_bytes` counter is not reset on total rewrite

2022-04-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 was picked up by @aalekseyev when doing unrelated debugging.
  
  The Rust implementation was never resetting this counter, so a brand new file
  would carry over the old counter.
  
  As I write this, my counter is a supposed 7389089 unused bytes for a total of
  170978 bytes in the data file. Feel free to post your own high score.

REPOSITORY
  rHG Mercurial

BRANCH
  stable

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

AFFECTED FILES
  tests/test-dirstate.t

CHANGE DETAILS

diff --git a/tests/test-dirstate.t b/tests/test-dirstate.t
--- a/tests/test-dirstate.t
+++ b/tests/test-dirstate.t
@@ -166,6 +166,23 @@
*1 (re)
   $ dirstate_uuid_has_not_changed
 
+Unused bytes counter is non-0 when appending
+  $ touch file
+  $ hg add file
+  $ current_uid=$(find_dirstate_uuid)
+
+Trigger a rust/rhg run which updates the unused bytes value
+  $ hg st
+  M dir2/f
+  A file
+  $ dirstate_uuid_has_not_changed
+
+  $ hg debugstate --docket | grep unused
+  number of unused bytes: 0 (no-rust no-rhg !)
+  number of unused bytes: [1-9]\d* (re) (rhg no-rust !)
+  number of unused bytes: [1-9]\d* (re) (rust no-rhg !)
+  number of unused bytes: [1-9]\d* (re) (rust rhg !)
+
 Delete most of the dirstate to trigger a non-append
   $ hg rm dir/a dir/b dir/c dir/d
   $ dirstate_data_files | wc -l
@@ -173,5 +190,12 @@
   $ dirstate_uuid_has_not_changed also-if-python
   [1]
 
+Check that unused bytes counter is reset when creating a new docket
+
+  $ hg debugstate --docket | grep unused
+  number of unused bytes: 0 (no-rust !)
+  number of unused bytes: [1-9]\d* (re) (rust known-bad-output !)
+
+#endif
+
   $ cd ..
-#endif



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


D12592: test-dirstate: use new `--docket` flag to get the data uuid

2022-04-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 is more robust.

REPOSITORY
  rHG Mercurial

BRANCH
  stable

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

AFFECTED FILES
  tests/test-dirstate.t

CHANGE DETAILS

diff --git a/tests/test-dirstate.t b/tests/test-dirstate.t
--- a/tests/test-dirstate.t
+++ b/tests/test-dirstate.t
@@ -129,7 +129,7 @@
   > }
 
   $ find_dirstate_uuid () {
-  >   dirstate_data_files | sed 's#.hg/dirstate.##'
+  >   hg debugstate --docket | grep uuid | sed 's/.*uuid: \(.*\)/\1/'
   > }
 
   $ dirstate_uuid_has_not_changed () {



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


D12587: color: support the NO_COLOR environment variable

2022-04-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 https://no-color.org initiative is a good idea, it's easy to support. It
  even explicitly lists Mercurial as one of the programs that don't support it.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  mercurial/color.py
  tests/test-status-color.t

CHANGE DETAILS

diff --git a/tests/test-status-color.t b/tests/test-status-color.t
--- a/tests/test-status-color.t
+++ b/tests/test-status-color.t
@@ -46,6 +46,15 @@
   [status.unknown|? ][status.unknown|b/in_b] (glob)
   [status.unknown|? ][status.unknown|in_root]
 
+NO_COLOR disables color no matter what
+  $ NO_COLOR= HGPLAINEXCEPT=color hg status --color=debug
+  ? a/1/in_a_1 (glob)
+  ? a/in_a (glob)
+  ? b/1/in_b_1 (glob)
+  ? b/2/in_b_2 (glob)
+  ? b/in_b (glob)
+  ? in_root
+
 hg status with template
   $ hg status -T "{label('red', path)}\n" --color=debug
   [red|a/1/in_a_1]
diff --git a/mercurial/color.py b/mercurial/color.py
--- a/mercurial/color.py
+++ b/mercurial/color.py
@@ -211,7 +211,7 @@
 
 
 def _modesetup(ui):
-if ui.plain(b'color'):
+if ui.plain(b'color') or encoding.environ.get(b"NO_COLOR") is not None:
 return None
 config = ui.config(b'ui', b'color')
 if config == b'debug':



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


D12586: rhg: fix dirstate-v2 data file removal system

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

REVISION SUMMARY
  In D12581  I introduced logic to 
remove the previous dirstate-v2 data file
  after a new one is created (and its corresponding docket), but the logic was
  flawed. I fixed it and made it simpler to understand by gather all logic in
  a single expression.

REPOSITORY
  rHG Mercurial

BRANCH
  stable

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

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

CHANGE DETAILS

diff --git a/tests/test-dirstate.t b/tests/test-dirstate.t
--- a/tests/test-dirstate.t
+++ b/tests/test-dirstate.t
@@ -120,4 +120,58 @@
   C hgext3rd/__init__.py
 
   $ cd ..
+
+Check that the old dirstate data file is removed correctly and the new one is
+valid.
+
+  $ number_of_dirstate_data_files () {
+  >   find .hg -maxdepth 1 -name "dirstate.*" | wc -l
+  > } 
+
+  $ find_dirstate_uuid () {
+  >   find .hg -maxdepth 1 -name "dirstate.*" | sed 's#.hg/dirstate.##'
+  > }
+
+  $ dirstate_uuid_has_not_changed () {
+  >   # Python always rewrites the whole dirstate
+  >   if [ -n $1 ] || [ "$HGMODULEPOLICY" = *"rust"* ] || [ -n 
"$RHG_INSTALLED_AS_HG" ]; then
+  > test $current_uid = $(find_dirstate_uuid)
+  >   fi
+  > }
+
+  $ cd ..
+  $ hg init append-mostly
+  $ cd append-mostly
+  $ mkdir dir dir2
+  $ touch dir/a dir/b dir/c dir/d dir/e dir2/f
+  $ hg commit -Aqm initial
+  $ hg st
+  $ number_of_dirstate_data_files
+  1
+  $ current_uid=$(find_dirstate_uuid)
+
+Nothing changes here
+
+  $ hg st
+  $ number_of_dirstate_data_files
+  1
+  $ dirstate_uuid_has_not_changed
+
+Trigger an append with a small change
+
+  $ echo "modified" > dir2/f
+  $ hg st
+  M dir2/f
+  $ number_of_dirstate_data_files
+  1
+  $ dirstate_uuid_has_not_changed
+
+Delete most of the dirstate to trigger a non-append
+  $ hg rm dir/a dir/b dir/c dir/d
+  $ number_of_dirstate_data_files
+  1
+  $ dirstate_uuid_has_not_changed also-if-python
+  [1]
+
+  $ cd ..
 #endif
diff --git a/rust/hg-core/src/repo.rs b/rust/hg-core/src/repo.rs
--- a/rust/hg-core/src/repo.rs
+++ b/rust/hg-core/src/repo.rs
@@ -435,25 +435,32 @@
 // it’s unset
 let parents = self.dirstate_parents()?;
 let (packed_dirstate, old_uuid_to_remove) = if self.has_dirstate_v2() {
-let uuid = self.dirstate_data_file_uuid.get_or_init(self)?;
-let mut uuid = uuid.as_ref();
-let can_append = uuid.is_some();
+let uuid_opt = self.dirstate_data_file_uuid.get_or_init(self)?;
+let uuid_opt = uuid_opt.as_ref();
+let can_append = uuid_opt.is_some();
 let (data, tree_metadata, append, old_data_size) =
 map.pack_v2(can_append)?;
-if !append {
-uuid = None
-}
-let (uuid, old_uuid) = if let Some(uuid) = uuid {
-let as_str = std::str::from_utf8(uuid)
-.map_err(|_| {
-HgError::corrupted("non-UTF-8 dirstate data file ID")
-})?
-.to_owned();
-let old_uuid_to_remove = Some(as_str.to_owned());
-(as_str, old_uuid_to_remove)
-} else {
-(DirstateDocket::new_uid(), None)
+
+// Reuse the uuid, or generate a new one, keeping the old for
+// deletion.
+let (uuid, old_uuid) = match uuid_opt {
+Some(uuid) => {
+let as_str = std::str::from_utf8(uuid)
+.map_err(|_| {
+HgError::corrupted(
+"non-UTF-8 dirstate data file ID",
+)
+})?
+.to_owned();
+if append {
+(as_str, None)
+} else {
+(DirstateDocket::new_uid(), Some(as_str))
+}
+}
+None => (DirstateDocket::new_uid(), None),
 };
+
 let data_filename = format!("dirstate.{}", uuid);
 let data_filename = self.hg_vfs().join(data_filename);
 let mut options = std::fs::OpenOptions::new();



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


D12580: rust-dirstate-v2: save proper data size if no new data on append

2022-04-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 currently only triggered with the tests ran with `--rhg` without
  `--rust`, by "luck", there probably always was something to write, like an
  mtime when also using Rust extensions alongside `rhg`.

REPOSITORY
  rHG Mercurial

BRANCH
  stable

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

AFFECTED FILES
  rust/hg-core/src/dirstate_tree/dirstate_map.rs
  rust/hg-core/src/dirstate_tree/on_disk.rs
  rust/hg-core/src/repo.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
@@ -211,7 +211,7 @@
 let inner = self.inner(py).borrow();
 let result = inner.pack_v2(can_append);
 match result {
-Ok((packed, tree_metadata, append)) => {
+Ok((packed, tree_metadata, append, _old_data_size)) => {
 let packed = PyBytes::new(py, );
 let tree_metadata = PyBytes::new(py, tree_metadata.as_bytes());
 let tuple = (packed, tree_metadata, append);
diff --git a/rust/hg-core/src/repo.rs b/rust/hg-core/src/repo.rs
--- a/rust/hg-core/src/repo.rs
+++ b/rust/hg-core/src/repo.rs
@@ -438,7 +438,8 @@
 let uuid = self.dirstate_data_file_uuid.get_or_init(self)?;
 let mut uuid = uuid.as_ref();
 let can_append = uuid.is_some();
-let (data, tree_metadata, append) = map.pack_v2(can_append)?;
+let (data, tree_metadata, append, old_data_size) =
+map.pack_v2(can_append)?;
 if !append {
 uuid = None
 }
@@ -464,10 +465,19 @@
 // returns `ErrorKind::AlreadyExists`? Collision chance of two
 // random IDs is one in 2**32
 let mut file = options.open(_filename)?;
-file.write_all()?;
-file.flush()?;
-// TODO: use 
https://doc.rust-lang.org/std/io/trait.Seek.html#method.stream_position when we 
require Rust 1.51+
-file.seek(SeekFrom::Current(0))
+if data.is_empty() {
+// If we're not appending anything, the data size is the
+// same as in the previous docket. It is *not* the file
+// length, since it could have garbage at the end.
+// We don't have to worry about it when we do have data
+// to append since we rewrite the root node in this case.
+Ok(old_data_size as u64)
+} else {
+file.write_all()?;
+file.flush()?;
+// TODO: use 
https://doc.rust-lang.org/std/io/trait.Seek.html#method.stream_position when we 
require Rust 1.51+
+file.seek(SeekFrom::Current(0))
+}
 })()
 .when_writing_file(_filename)?;
 DirstateDocket::serialize(
diff --git a/rust/hg-core/src/dirstate_tree/on_disk.rs 
b/rust/hg-core/src/dirstate_tree/on_disk.rs
--- a/rust/hg-core/src/dirstate_tree/on_disk.rs
+++ b/rust/hg-core/src/dirstate_tree/on_disk.rs
@@ -290,6 +290,7 @@
 nodes_with_copy_source_count: meta.nodes_with_copy_source_count.get(),
 ignore_patterns_hash: meta.ignore_patterns_hash,
 unreachable_bytes: meta.unreachable_bytes.get(),
+old_data_size: on_disk.len(),
 };
 Ok(dirstate_map)
 }
@@ -601,11 +602,11 @@
 /// Returns new data and metadata, together with whether that data should be
 /// appended to the existing data file whose content is at
 /// `dirstate_map.on_disk` (true), instead of written to a new data file
-/// (false).
+/// (false), and the previous size of data on disk.
 pub(super) fn write(
 dirstate_map: ,
 can_append: bool,
-) -> Result<(Vec, TreeMetadata, bool), DirstateError> {
+) -> Result<(Vec, TreeMetadata, bool, usize), DirstateError> {
 let append = can_append && dirstate_map.write_should_append();
 
 // This ignores the space for paths, and for nodes without an entry.
@@ -631,7 +632,7 @@
 unused: [0; 4],
 ignore_patterns_hash: dirstate_map.ignore_patterns_hash,
 };
-Ok((writer.out, meta, append))
+Ok((writer.out, meta, append, dirstate_map.old_data_size))
 }
 
 struct Writer<'dmap, 'on_disk> {
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
@@ -49,6 +49,10 @@
 
 /// How many bytes of `on_disk` are not used anymore
 pub(super) unreachable_bytes: u32,
+
+/// Size of the data used to first load this `DirstateMap`. Used in case
+

D12581: rust-dirstate-v2: clean up previous data file after the docket is written

2022-04-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 was overlooked before and caused many data files to keep living forever.
  We could potentially consider adding a random cleanup of them in case they
  slipped through one day.

REPOSITORY
  rHG Mercurial

BRANCH
  stable

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

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

CHANGE DETAILS

diff --git a/rust/hg-core/src/repo.rs b/rust/hg-core/src/repo.rs
--- a/rust/hg-core/src/repo.rs
+++ b/rust/hg-core/src/repo.rs
@@ -434,7 +434,7 @@
 // TODO: Maintain a `DirstateMap::dirty` flag, and return early here if
 // it’s unset
 let parents = self.dirstate_parents()?;
-let packed_dirstate = if self.has_dirstate_v2() {
+let (packed_dirstate, old_uuid_to_remove) = if self.has_dirstate_v2() {
 let uuid = self.dirstate_data_file_uuid.get_or_init(self)?;
 let mut uuid = uuid.as_ref();
 let can_append = uuid.is_some();
@@ -443,14 +443,16 @@
 if !append {
 uuid = None
 }
-let uuid = if let Some(uuid) = uuid {
-std::str::from_utf8(uuid)
+let (uuid, old_uuid) = if let Some(uuid) = uuid {
+let as_str = std::str::from_utf8(uuid)
 .map_err(|_| {
 HgError::corrupted("non-UTF-8 dirstate data file ID")
 })?
-.to_owned()
+.to_owned();
+let old_uuid_to_remove = Some(as_str.to_owned());
+(as_str, old_uuid_to_remove)
 } else {
-DirstateDocket::new_uid()
+(DirstateDocket::new_uid(), None)
 };
 let data_filename = format!("dirstate.{}", uuid);
 let data_filename = self.hg_vfs().join(data_filename);
@@ -480,7 +482,8 @@
 }
 })()
 .when_writing_file(_filename)?;
-DirstateDocket::serialize(
+
+let packed_dirstate = DirstateDocket::serialize(
 parents,
 tree_metadata,
 data_size,
@@ -488,11 +491,20 @@
 )
 .map_err(|_: std::num::TryFromIntError| {
 HgError::corrupted("overflow in dirstate docket serialization")
-})?
+})?;
+
+(packed_dirstate, old_uuid)
 } else {
-map.pack_v1(parents)?
+(map.pack_v1(parents)?, None)
 };
-self.hg_vfs().atomic_write("dirstate", _dirstate)?;
+
+let vfs = self.hg_vfs();
+vfs.atomic_write("dirstate", _dirstate)?;
+if let Some(uuid) = old_uuid_to_remove {
+// Remove the old data file after the new docket pointing to the
+// new data file was written.
+vfs.remove_file(format!("dirstate.{}", uuid))?;
+}
 Ok(())
 }
 }



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


D12578: rhg: use `Command::exec` instead of `Command::status`

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


  Pending CI refresh

REVISION SUMMARY
  `rhg` is supposed to be a transparent executable, using a subprocess defeats
  that purpose. See inline comments for more details.
  
  This also introduces the `which` crate to check if the fallback executable
  actually exists to help debugging (plain `execve` doesn't give much
  information).
  
  The error code 253 is used to signify that the fallback is not found, but may
  mean in the future that it is otherwise invalid if we start being more
  specific.

REPOSITORY
  rHG Mercurial

BRANCH
  stable

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

AFFECTED FILES
  rust/Cargo.lock
  rust/hg-core/src/exit_codes.rs
  rust/rhg/Cargo.toml
  rust/rhg/src/error.rs
  rust/rhg/src/main.rs
  tests/test-rhg.t

CHANGE DETAILS

diff --git a/tests/test-rhg.t b/tests/test-rhg.t
--- a/tests/test-rhg.t
+++ b/tests/test-rhg.t
@@ -179,15 +179,8 @@
   [1]
 
   $ rhg cat original --exclude="*.rs" --config 
rhg.fallback-executable=hg-non-existent
-  tried to fall back to a 'hg-non-existent' sub-process but got error $ENOENT$
-  unsupported feature: error: Found argument '--exclude' which wasn't 
expected, or isn't valid in this context
-  
-  USAGE:
-  rhg cat [OPTIONS] ...
-  
-  For more information try --help
-  
-  [252]
+  abort: fallback path does not exist: 'hg-non-existent'
+  [253]
 
   $ rhg cat original --exclude="*.rs" --config rhg.fallback-executable=rhg
   Blocking recursive fallback. The 'rhg.fallback-executable = rhg' config 
points to `rhg` itself.
diff --git a/rust/rhg/src/main.rs b/rust/rhg/src/main.rs
--- a/rust/rhg/src/main.rs
+++ b/rust/rhg/src/main.rs
@@ -13,6 +13,7 @@
 use hg::utils::SliceExt;
 use std::collections::HashSet;
 use std::ffi::OsString;
+use std::os::unix::prelude::CommandExt;
 use std::path::PathBuf;
 use std::process::Command;
 
@@ -365,12 +366,14 @@
 }
 }
 Err(CommandError::Unsuccessful) => exit_codes::UNSUCCESSFUL,
-
 // Exit with a specific code and no error message to let a potential
 // wrapper script fallback to Python-based Mercurial.
 Err(CommandError::UnsupportedFeature { .. }) => {
 exit_codes::UNIMPLEMENTED
 }
+Err(CommandError::InvalidFallback { .. }) => {
+exit_codes::INVALID_FALLBACK
+}
 }
 }
 
@@ -415,6 +418,16 @@
 } else {
 log::debug!("falling back (see trace-level log)");
 log::trace!("{}", local_to_utf8(message));
+if !which::which(executable_path).is_ok() {
+exit_no_fallback(
+ui,
+OnUnsupported::Abort,
+Err(CommandError::InvalidFallback {
+path: executable.to_owned(),
+}),
+use_detailed_exit_code,
+)
+}
 // `args` is now `argv[1..]` since we’ve already consumed
 // `argv[0]`
 let mut command = Command::new(executable_path);
@@ -422,19 +435,19 @@
 if let Some(initial) = initial_current_dir {
 command.current_dir(initial);
 }
-let result = command.status();
-match result {
-Ok(status) => std::process::exit(
-status.code().unwrap_or(exit_codes::ABORT),
-),
-Err(error) => {
-let _ = ui.write_stderr(_bytes!(
-b"tried to fall back to a '{}' sub-process but got 
error {}\n",
-executable, format_bytes::Utf8(error)
-));
-on_unsupported = OnUnsupported::Abort
-}
-}
+// We don't use subprocess because proper signal handling is harder
+// and we don't want to keep `rhg` around after a fallback anyway.
+// For example, if `rhg` is ran in the background and falls back to
+// `hg` which, in turn, waits for a signal, we'll get stuck if
+// we're doing plain subprocess.
+//
+// If `exec` returns, we can only assume our process is very broken
+// (see its documentation), so only try to forward the error code
+// when exiting.
+let err = command.exec();
+std::process::exit(
+err.raw_os_error().unwrap_or(exit_codes::ABORT),
+);
 }
 }
 exit_no_fallback(ui, on_unsupported, result, use_detailed_exit_code)
@@ -471,6 +484,12 @@
 OnUnsupported::Fallback { .. } => unreachable!(),
 }
 }
+Err(CommandError::InvalidFallback { path }) => {
+let _ = ui.write_stderr(_bytes!(
+b"abort: fallback path does not exist: '{}'\n",
+path
+   

D12575: actions: fix formatting issue

2022-04-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 was triggered by a new change in the file in cb21c9c1a480.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  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
@@ -33,6 +33,7 @@
 requirements.CHANGELOGV2_REQUIREMENT,
 }
 
+
 def preservedrequirements(repo):
 preserved = {
 requirements.SHARED_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


D12574: rust: fix formatting

2022-04-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 slipped through.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  rust/rhg/src/main.rs

CHANGE DETAILS

diff --git a/rust/rhg/src/main.rs b/rust/rhg/src/main.rs
--- a/rust/rhg/src/main.rs
+++ b/rust/rhg/src/main.rs
@@ -126,14 +126,17 @@
 blackbox::Blackbox::new(, process_start_time)?;
 blackbox.log_command_start(argv.iter());
 let result = run();
-blackbox.log_command_end(argv.iter(), exit_code(
-,
-// TODO: show a warning or combine with original error if
-// `get_bool` returns an error
-config
-.get_bool(b"ui", b"detailed-exit-code")
-.unwrap_or(false),
-));
+blackbox.log_command_end(
+argv.iter(),
+exit_code(
+,
+// TODO: show a warning or combine with original error if
+// `get_bool` returns an error
+config
+.get_bool(b"ui", b"detailed-exit-code")
+.unwrap_or(false),
+),
+);
 result
 } else {
 run()



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: Moving away from Phabricator

2022-04-14 Thread Raphaël Gomès

On 4/13/22 22:24, Augie Fackler wrote:



On Apr 13, 2022, at 12:06 PM, Raphaël Gomès 
 wrote:


Hi everyone,

It has now been more than a month and our window to migrate out of 
our VM is closing down.




Thanks for keeping track of this!


Thanks for answering quickly!


I am happy to report that the new versions of Heptapod and the evolve 
extension have brought the expected speedups and the push/pull times 
on Heptapod are now much better. There still remains a lot to be 
desired with regards to exchange, but that is for another discussion.


It's time to make an inventory of the project and make some decisions 
about what stays the same, what changes and what disappears. We also 
need to discuss the contribution and review process.


# Inventory

We still don't have a clear path for VM hosting, but maybe the OSUOSL 
can help us, seeing as a good amount of the foss.heptapod.net 
<http://foss.heptapod.net> CI there. See 
https://osuosl.org/services/hosting/details.


## The mailing lists

They're not going anywhere, of course. Additionally, the ability to 
send patches to the devel mailing list will stay, but will not be the 
preferred way proposed.


They are currently managed by a mailman on the VM, which will need to 
be migrated out. The OSUOSL people have already agreed to manage our 
mailing lists for us. This could be a good solution to further reduce 
sysadmin burden.




If we finish off the lists and phabricator, that reduces our footprint 
a _lot_ FWIW. That removes all (I think?) the reasons we have to send 
mail, so you’re really down to hosting the wiki and the repos.



That would reduce the load significantly, yes. :)



## Phabricator

Phabricator will be turned off and be replaced as a means of 
contribution by Heptapod.


The `phab.mercurial-scm.org <http://phab.mercurial-scm.org>` 
differential URLs will be kept around as a static archive: I have 
already started the relatively painful (basically because of AJAX) 
endeavor of creating the scripts to save the valuable history of our 
review discussions, and hope to have enough free time to have it done 
before the VM dies.


## mercurial-scm.org <http://mercurial-scm.org>

The website will need to be migrated out. I don't expect this to be a 
major hassle.


On a related but technically independent front, I've started some 
very simple patches to improve its contents (like not advertising 
that we use Python 2...).


## Wiki

The wiki needs to be migrated out. I'm not exactly sure what the 
story of MoinMoin is currently, but this should also be a relatively 
simple process.


## Repos

I think the project should still use hgweb to advertise at least its 
main (read-only) repository and any other repo that doesn't have a 
better home. See the part about the contribution process for more 
discussion about the hg-committed repo.




These all sound right.


## Patchwork

What should we do about patchwork? I've only been reminded of its 
existence by looking around the VM. Maybe my `getpatches` alias uses 
it underneath for queuing from the mailing list?




If your getpatches alias is the one I think it is, that probably hits 
https://hgpatches.durin42.com/? Which, as the URL suggests, is 
actually running on a machine I own. It’s been zero-maintenance for 
years, but if y’all care about it long-term we should probably 
transition it eventually. Though it’s not as pressing.


Sure, we'll need to figure out something not too long after. Thanks for 
keeping it running.


## Buildbot

This has been functionally dead for a long while and will not be 
carried over now that we have the Heptapod CI.


## Bugzilla

We will want to - of course - keep our bug tracking. We're using 
Bugzilla with MySQL, but we could use PostgreSQL in the target 
machine if that makes it easier, I don't think this particular aspect 
would be too hard to migrate on its own.


The migration from bugzilla to another tool (like Heptapod/Gitlab 
issues) should probably be another discussion to simplify the transition.




Agreed. Bugzilla has been a pretty minor pain point compared to 
phabricator.


The spam issue has been pretty annoying (same problem as with phab), but 
it's still not as urgent. We only have so many things we can do at once 
single time.


## Other things?

Have I forgotten an important piece of the project?



hgbot runs on mercurial-scm.org <http://mercurial-scm.org>. It uses a 
sqlite database and is pretty minimal in terms of overhead, so as long 
as wherever we put the VM can handle the irc connection, seems fine.



Ah, right. This will also probably be fine.



# Review process



I’m inactive enough I’ll defer to the opinions of others here. Others: 
if you have opinions, _please_ speak up! This is your chance to make a 
difference before we EOL phabricator and your choices are (by default) 
heptapod and `hg email`.


[snip review process options]



# Conclusion

The hope of this migration is to remove a lo

Re: Moving away from Phabricator

2022-04-13 Thread Raphaël Gomès
 to the hg-committed repo
    - A separate accepter marks those changesets as accepted after a 
separate review

    - A cron job makes all accepted changesets public.

This allows us to be agile with regards to new changes (i.e. they can be 
queued faster), while still being given the option of amending/pruning 
changesets that are still not public.


This is not without its issues though. It integrates poorly with 
tooling, confuses the contributors (honestly reviewers as well, speaking 
for myself) and makes the release process harder. With regards to 
tooling, once changesets are on hg-committed they are in a weird phase 
of "draft but you can't touch them" where none of the commands will 
prevent you from making changes to them (rebase, amend, fold, prune, 
etc.) and we still lack some kind of "local prune" in case they get 
rejected from hg-committed and need to be rolled back without affecting 
the original contributor. Bonus issues: the accept script gets confused 
and sometimes publishes changesets anyway in certain conditions, and the 
`@` bookmarks gets stuck on an obsolete changeset and needs to be pushed 
explicitly. Urgh.


Thinking back over my time contributing to Mercurial, the vast majority 
of after-the-fact amends and prunes have been done because of test 
failures. This two-phase publication workflow has rarely caught some 
*other* cause for removal before it was too late and we needed a 
backout/follow-up anyway.


## Proposals for the new process

### Default Heptapod workflow

The most radical of my proposals is that we should adopt the default 
Heptapod workflow.


We now have pre-landing CI and a more obvious way of knowing if all 
feedback has been taken into account (we can even tell Heptapod to 
refuse to "merge" if there are unresolved comments).


Reviewers can still make the decision that they want to wait on the 
approval of someone else before merging, and we will still be basically 
relying on the good intentions of people with push access to not push 
garbage to the repo, just as we are now. Note that this would imply that 
contributions coming from the mailing-list need to be sent to Heptapod 
by the reviewer (or anybody else, really) in a topic to run the CI first 
if we want to be coherent (though we rarely get patches this way nowadays).


### Keeping hg-committed

If the previous proposal to just use the Heptapod default workflow is a 
bit too strong and I'm in the minority, we could still have the 
two-phase publishing system. It would require some development on 
Heptapod's side to allow for that workflow, but Georges assured me it 
would be on the easier side.


### A middleground

An in-between solution is to supplement the default Heptapod workflow 
with the use of a bot (think Rust's bors). The bot would make sure that 
the necessary approval has been given before merging. Such a bot would 
need to be one that speaks Mercurial or be simple enough to only need 
the GitLab API for rebasing. In any case, a bot solution will need at 
least some amount of development as well.


Speaking of development, work in underway to define topic namespaces to 
allow for drive-by contributors to more easily get access and to prevent 
new users from stepping on each-other's toes when they make mistakes.


# Conclusion

The hope of this migration is to remove a lot of the sysadmin burden, 
simplify, strengthen and modernize the contribution and review process 
and leave the project in a healthier, more maintainable state. I hope to 
see my mental load reduced by a lot after this transition, and I'm 
pretty sure I'm not the only one.


On 3/10/22 14:28, Raphaël Gomès wrote:


Hi again,

We will have to start making a decision soon-ish. I'd expect us to 
start figuring out the migration process by early April to have a 
solid 3 months before the VM becomes out of support at the end of June 
(or I get tired of responding to low-disk issues on the machine ;) ).


Does anyone have any thoughts or questions on the matter? I know (from 
IRC discussion about Heptapod) that Matt Harbison was planning to at 
least respond to that email but didn't have time to get to it yet, he 
might not be the only one.


To reiterate, we'll need to wait until Heptapod 0.30 (coming to 
foss.heptapod.net at the latest on March 22nd) to try out anything for 
real, but we might as well get ahead of things to plan the work needed.


Raphaël

On 2/23/22 18:25, Raphaël Gomès wrote:

Hi all,

The VM that hosts our Phabricator instance¹ is going out of support 
in June of this year², and this has prompted a discussion in the 
infrastructure mailing-list that has been a long time coming.


Phabricator has been unmaintained for all intents and purposes for a 
few months now, and while its per-commit review tool is actually not 
too bad, it's lacking in basically all other aspects. To say that it 
would be a relief to drop it would be an understatement, sysadmin 
burden being on

D12541: rust-dirstatemap: remove unused helper from the old API

2022-04-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/D12541

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
@@ -22,7 +22,6 @@
 use crate::DirstateMapError;
 use crate::DirstateParents;
 use crate::DirstateStatus;
-use crate::EntryState;
 use crate::FastHashbrownMap as FastHashMap;
 use crate::PatternFileWarning;
 use crate::StatusError;
@@ -346,18 +345,6 @@
 }
 }
 
-pub(super) fn state(
-,
-) -> Result, DirstateV2ParseError> {
-Ok(self.entry()?.and_then(|e| {
-if e.any_tracked() {
-Some(e.state())
-} else {
-None
-}
-}))
-}
-
 pub(super) fn cached_directory_mtime(
 ,
 ) -> Result, DirstateV2ParseError> {



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


D12540: rust-status: stop using `state()` in the dispatch logic

2022-04-12 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 use the new API.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

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

CHANGE DETAILS

diff --git a/rust/hg-core/src/dirstate_tree/status.rs 
b/rust/hg-core/src/dirstate_tree/status.rs
--- a/rust/hg-core/src/dirstate_tree/status.rs
+++ b/rust/hg-core/src/dirstate_tree/status.rs
@@ -13,7 +13,6 @@
 use crate::utils::hg_path::HgPath;
 use crate::BadMatch;
 use crate::DirstateStatus;
-use crate::EntryState;
 use crate::HgPathBuf;
 use crate::HgPathCow;
 use crate::PatternFileWarning;
@@ -459,17 +458,23 @@
 )?
 } else {
 if file_or_symlink && self.matcher.matches(hg_path) {
-if let Some(state) = dirstate_node.state()? {
-match state {
-EntryState::Added => {
-self.push_outcome(Outcome::Added, _node)?
-}
-EntryState::Removed => self
-.push_outcome(Outcome::Removed, _node)?,
-EntryState::Merged => self
-.push_outcome(Outcome::Modified, _node)?,
-EntryState::Normal => self
-.handle_normal_file(_node, fs_metadata)?,
+if let Some(entry) = dirstate_node.entry()? {
+if !entry.any_tracked() {
+// Forward-compat if we start tracking unknown/ignored
+// files for caching reasons
+self.mark_unknown_or_ignored(
+has_ignored_ancestor,
+hg_path,
+);
+}
+if entry.added() {
+self.push_outcome(Outcome::Added, _node)?;
+} else if entry.removed() {
+self.push_outcome(Outcome::Removed, _node)?;
+} else if entry.modified() {
+self.push_outcome(Outcome::Modified, _node)?;
+} else {
+self.handle_normal_file(_node, fs_metadata)?;
 }
 } else {
 // `node.entry.is_none()` indicates a "directory"
@@ -579,8 +584,7 @@
 Ok(())
 }
 
-/// A file with `EntryState::Normal` in the dirstate was found in the
-/// filesystem
+/// A file that is clean in the dirstate was found in the filesystem
 fn handle_normal_file(
 ,
 dirstate_node: <'tree, 'on_disk>,



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


D12539: rust-status: stop using `state()` in `handle_normal_file`

2022-04-12 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 use the new API

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

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

CHANGE DETAILS

diff --git a/rust/hg-core/src/dirstate_tree/status.rs 
b/rust/hg-core/src/dirstate_tree/status.rs
--- a/rust/hg-core/src/dirstate_tree/status.rs
+++ b/rust/hg-core/src/dirstate_tree/status.rs
@@ -653,10 +653,15 @@
 ,
 dirstate_node: <'tree, 'on_disk>,
 ) -> Result<(), DirstateV2ParseError> {
-if let Some(state) = dirstate_node.state()? {
+if let Some(entry) = dirstate_node.entry()? {
+if !entry.any_tracked() {
+// Future-compat for when we start storing ignored and unknown
+// files for caching reasons
+return Ok(())
+}
 let path = dirstate_node.full_path(self.dmap.on_disk)?;
 if self.matcher.matches(path) {
-if let EntryState::Removed = state {
+if entry.removed() {
 self.push_outcome(Outcome::Removed, dirstate_node)?
 } else {
 self.push_outcome(Outcome::Deleted, _node)?



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


D12538: rust-dirstatemap: stop using `state()` in the cache logic

2022-04-12 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 use the new API

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

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
@@ -1182,8 +1182,8 @@
 if let Some(node) = map.get_node(directory)? {
 // A node without a `DirstateEntry` was created to hold child
 // nodes, and is therefore a directory.
-let state = node.state()?;
-Ok(state.is_none() && node.tracked_descendants_count() > 0)
+let is_dir = node.entry()?.is_none();
+Ok(is_dir && node.tracked_descendants_count() > 0)
 } else {
 Ok(false)
 }
@@ -1198,8 +1198,8 @@
 if let Some(node) = map.get_node(directory)? {
 // A node without a `DirstateEntry` was created to hold child
 // nodes, and is therefore a directory.
-let state = node.state()?;
-Ok(state.is_none() && node.descendants_with_entry_count() > 0)
+let is_dir = node.entry()?.is_none();
+Ok(is_dir && node.descendants_with_entry_count() > 0)
 } else {
 Ok(false)
 }



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


D12537: rust-dirstatemap: stop using `.state` in `is_from_other_parent`

2022-04-12 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 deprecated API and will be removed one day.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

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

CHANGE DETAILS

diff --git a/rust/hg-core/src/dirstate/entry.rs 
b/rust/hg-core/src/dirstate/entry.rs
--- a/rust/hg-core/src/dirstate/entry.rs
+++ b/rust/hg-core/src/dirstate/entry.rs
@@ -655,8 +655,7 @@
 }
 
 pub(crate) fn is_from_other_parent() -> bool {
-self.state() == EntryState::Normal
-&& self.size() == SIZE_FROM_OTHER_PARENT
+self.flags.contains(Flags::WDIR_TRACKED | Flags::P2_INFO)
 }
 
 // TODO: other platforms



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


D12534: rust: use `entry.tracked()` directly

2022-04-12 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 new API

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  rust/hg-core/src/dirstate_tree/dirstate_map.rs
  rust/hg-core/src/dirstate_tree/on_disk.rs
  rust/hg-core/src/operations/list_tracked_files.rs
  rust/hg-core/src/repo.rs

CHANGE DETAILS

diff --git a/rust/hg-core/src/repo.rs b/rust/hg-core/src/repo.rs
--- a/rust/hg-core/src/repo.rs
+++ b/rust/hg-core/src/repo.rs
@@ -388,7 +388,7 @@
 
 pub fn has_subrepos() -> Result {
 if let Some(entry) = self.dirstate_map()?.get(HgPath::new(".hgsub"))? {
-Ok(entry.state().is_tracked())
+Ok(entry.tracked())
 } else {
 Ok(false)
 }
diff --git a/rust/hg-core/src/operations/list_tracked_files.rs 
b/rust/hg-core/src/operations/list_tracked_files.rs
--- a/rust/hg-core/src/operations/list_tracked_files.rs
+++ b/rust/hg-core/src/operations/list_tracked_files.rs
@@ -51,7 +51,7 @@
 let _parents = parse_dirstate_entries(
 ,
 |path, entry, _copy_source| {
-if entry.state().is_tracked() {
+if entry.tracked() {
 files.push(path)
 }
 Ok(())
diff --git a/rust/hg-core/src/dirstate_tree/on_disk.rs 
b/rust/hg-core/src/dirstate_tree/on_disk.rs
--- a/rust/hg-core/src/dirstate_tree/on_disk.rs
+++ b/rust/hg-core/src/dirstate_tree/on_disk.rs
@@ -587,7 +587,7 @@
 ) -> Result<(), DirstateV2ParseError> {
 for node in read_nodes(on_disk, nodes)? {
 if let Some(entry) = node.entry()? {
-if entry.state().is_tracked() {
+if entry.tracked() {
 f(node.full_path(on_disk)?)
 }
 }
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
@@ -477,7 +477,7 @@
 let parents = parse_dirstate_entries(
 map.on_disk,
 |path, entry, copy_source| {
-let tracked = entry.state().is_tracked();
+let tracked = entry.tracked();
 let node = Self::get_or_insert_node_inner(
 map.on_disk,
  map.unreachable_bytes,



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


D12536: rust-dirstate-entry: add `modified` method

2022-04-12 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 also be used in other places later in the series.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

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

CHANGE DETAILS

diff --git a/rust/hg-core/src/dirstate/entry.rs 
b/rust/hg-core/src/dirstate/entry.rs
--- a/rust/hg-core/src/dirstate/entry.rs
+++ b/rust/hg-core/src/dirstate/entry.rs
@@ -417,6 +417,11 @@
 self.flags.contains(Flags::WDIR_TRACKED) && !self.in_either_parent()
 }
 
+pub fn modified() -> bool {
+self.flags
+.contains(Flags::WDIR_TRACKED | Flags::P1_TRACKED | Flags::P2_INFO)
+}
+
 pub fn maybe_clean() -> bool {
 if !self.flags.contains(Flags::WDIR_TRACKED) {
 false
@@ -463,10 +468,7 @@
 }
 if self.removed() {
 EntryState::Removed
-} else if self
-.flags
-.contains(Flags::WDIR_TRACKED | Flags::P1_TRACKED | Flags::P2_INFO)
-{
+} else if self.modified() {
 EntryState::Merged
 } else if self.added() {
 EntryState::Added



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


D12535: rust: remove use of `EntryState` in `DirsMultiset`

2022-04-12 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 use the new API.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

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

CHANGE DETAILS

diff --git a/rust/hg-core/src/dirstate/dirs_multiset.rs 
b/rust/hg-core/src/dirstate/dirs_multiset.rs
--- a/rust/hg-core/src/dirstate/dirs_multiset.rs
+++ b/rust/hg-core/src/dirstate/dirs_multiset.rs
@@ -10,7 +10,6 @@
 //! Used to counts the references to directories in a manifest or dirstate.
 use crate::dirstate_tree::on_disk::DirstateV2ParseError;
 use crate::{
-dirstate::EntryState,
 utils::{
 files,
 hg_path::{HgPath, HgPathBuf, HgPathError},
@@ -49,7 +48,7 @@
 let filename = filename.as_ref();
 // This `if` is optimized out of the loop
 if only_tracked {
-if entry.state() != EntryState::Removed {
+if !entry.removed() {
 multiset.add_path(filename)?;
 }
 } else {
@@ -215,6 +214,8 @@
 
 #[cfg(test)]
 mod tests {
+use crate::EntryState;
+
 use super::*;
 
 #[test]



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


D12533: rust-hg-cpython: remove use of `EntryState`

2022-04-12 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 use the new API

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  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
@@ -26,7 +26,7 @@
 dirstate::StateMapIter, dirstate_tree::on_disk::DirstateV2ParseError,
 dirstate_tree::owning::OwningDirstateMap, revlog::Node,
 utils::files::normalize_case, utils::hg_path::HgPath, DirstateEntry,
-DirstateError, DirstateParents, EntryState,
+DirstateError, DirstateParents,
 };
 
 // TODO
@@ -269,7 +269,7 @@
 let dict = PyDict::new(py);
 for item in self.inner(py).borrow_mut().iter() {
 let (path, entry) = item.map_err(|e| v2_error(py, e))?;
-if entry.state() != EntryState::Removed {
+if !entry.removed() {
 let key = normalize_case(path);
 let value = path;
 dict.set_item(



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


D12532: rust-dirstatemap: use a checked sub instead of a potentially underflowing one

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

REVISION SUMMARY
  This was missed in 2593873cda0f 


REPOSITORY
  rHG Mercurial

BRANCH
  default

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

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
@@ -1337,7 +1337,9 @@
 )?
 .and_then(|node| {
 if let Some(source) = _source {
-*count -= 1;
+*count = count
+.checked_sub(1)
+.expect("nodes_with_copy_source_count should be >= 0");
 DirstateMap::count_dropped_path(unreachable_bytes, source);
 }
 node.copy_source.take().map(Cow::into_owned)



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


D12531: rust-dirstatemap: add simpler version of `get_node_mut`

2022-04-12 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 help reduce code and footgun potential for simpler callers.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

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
@@ -545,13 +545,32 @@
 
 /// Returns a mutable reference to the node at `path` if it exists
 ///
+/// `each_ancestor` is a callback that is called for each ancestor node
+/// when descending the tree. It is used to keep the different counters
+/// of the `DirstateMap` up-to-date.
+fn get_node_mut<'tree>(
+&'tree mut self,
+path: ,
+each_ancestor: impl FnMut( Node),
+) -> Result>, DirstateV2ParseError> {
+Self::get_node_mut_inner(
+self.on_disk,
+ self.unreachable_bytes,
+ self.root,
+path,
+each_ancestor,
+)
+}
+
+/// Lower-level version of `get_node_mut`.
+///
 /// This takes `root` instead of ` self` so that callers can mutate
 /// other fields while the returned borrow is still valid.
 ///
 /// `each_ancestor` is a callback that is called for each ancestor node
 /// when descending the tree. It is used to keep the different counters
 /// of the `DirstateMap` up-to-date.
-fn get_node_mut<'tree>(
+fn get_node_mut_inner<'tree>(
 on_disk: &'on_disk [u8],
 unreachable_bytes:  u32,
 root: &'tree mut ChildNodes<'on_disk>,
@@ -746,19 +765,14 @@
 filename: ,
 old_entry: DirstateEntry,
 ) -> Result<(), DirstateV2ParseError> {
-let node = DirstateMap::get_node_mut(
-self.on_disk,
- self.unreachable_bytes,
- self.root,
-filename,
-|ancestor| {
+let node = self
+.get_node_mut(filename, |ancestor| {
 ancestor.tracked_descendants_count = ancestor
 .tracked_descendants_count
 .checked_sub(1)
 .expect("tracked_descendants_count should be >= 0");
-},
-)?
-.expect("node should exist");
+})?
+.expect("node should exist");
 let mut new_entry = old_entry.clone();
 new_entry.set_untracked();
 node.data = NodeData::Entry(new_entry);
@@ -780,18 +794,13 @@
 size: u32,
 mtime: TruncatedTimestamp,
 ) -> Result<(), DirstateError> {
-let node = DirstateMap::get_node_mut(
-self.on_disk,
- self.unreachable_bytes,
- self.root,
-filename,
-|ancestor| {
+let node = self
+.get_node_mut(filename, |ancestor| {
 if !old_entry.tracked() {
 ancestor.tracked_descendants_count += 1;
 }
-},
-)?
-.expect("node should exist");
+})?
+.expect("node should exist");
 let mut new_entry = old_entry.clone();
 new_entry.set_clean(mode, size, mtime);
 node.data = NodeData::Entry(new_entry);
@@ -807,14 +816,9 @@
  self,
 filename: ,
 ) -> Result<(), DirstateError> {
-let node = DirstateMap::get_node_mut(
-self.on_disk,
- self.unreachable_bytes,
- self.root,
-filename,
-|_ancestor| {},
-)?
-.expect("node should exist");
+let node = self
+.get_node_mut(filename, |_ancestor| {})?
+.expect("node should exist");
 let entry = node.data.as_entry_mut().expect("entry should exist");
 entry.set_possibly_dirty();
 node.data = NodeData::Entry(*entry);
@@ -826,13 +830,7 @@
  self,
 path: ,
 ) -> Result<(), DirstateV2ParseError> {
-let node = match DirstateMap::get_node_mut(
-self.on_disk,
- self.unreachable_bytes,
- self.root,
-path,
-|_ancestor| {},
-)? {
+let node = match self.get_node_mut(path, |_ancestor| {})? {
 Some(node) => node,
 None => return Ok(()),
 };
@@ -848,13 +846,7 @@
 path: ,
 mtime: TruncatedTimestamp,
 ) -> Result<(), DirstateV2ParseError> {
-let node = match DirstateMap::get_node_mut(
-self.on_disk,
- self.unreachable_bytes,
- self.root,
-path,
-|_ancestor| {},
-)? {
+let node = match self.get_node_mut(path, |_ancestor| {})? {
 Some(node) => node,
 None => 

D12530: rust-dirstatemap: use `get_node_mut` instead or `get_or_insert_node`

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

REVISION SUMMARY
  This (along with the docstring), makes it more obvious that we're not 
expecting
  to insert a node here. This is less prone to bugs in later refactorings.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

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
@@ -733,25 +733,45 @@
 Ok(new)
 }
 
-/// It is the responsibility of the caller to know that there was an entry
-/// there before. Does not handle the removal of copy source
+/// Set a node as untracked in the dirstate.
+///
+/// It is the responsibility of the caller to remove the copy source and/or
+/// the entry itself if appropriate.
+///
+/// # Panics
+///
+/// Panics if the node does not exist.
 fn set_untracked(
  self,
 filename: ,
 old_entry: DirstateEntry,
 ) -> Result<(), DirstateV2ParseError> {
-let node = self.get_or_insert_node(filename, |ancestor| {
-ancestor.tracked_descendants_count = ancestor
-.tracked_descendants_count
-.checked_sub(1)
-.expect("tracked_descendants_count should be >= 0");
-})?;
+let node = DirstateMap::get_node_mut(
+self.on_disk,
+ self.unreachable_bytes,
+ self.root,
+filename,
+|ancestor| {
+ancestor.tracked_descendants_count = ancestor
+.tracked_descendants_count
+.checked_sub(1)
+.expect("tracked_descendants_count should be >= 0");
+},
+)?
+.expect("node should exist");
 let mut new_entry = old_entry.clone();
 new_entry.set_untracked();
 node.data = NodeData::Entry(new_entry);
 Ok(())
 }
 
+/// Set a node as clean in the dirstate.
+///
+/// It is the responsibility of the caller to remove the copy source.
+///
+/// # Panics
+///
+/// Panics if the node does not exist.
 fn set_clean(
  self,
 filename: ,
@@ -760,22 +780,41 @@
 size: u32,
 mtime: TruncatedTimestamp,
 ) -> Result<(), DirstateError> {
-let node = self.get_or_insert_node(filename, |ancestor| {
-if !old_entry.tracked() {
-ancestor.tracked_descendants_count += 1;
-}
-})?;
+let node = DirstateMap::get_node_mut(
+self.on_disk,
+ self.unreachable_bytes,
+ self.root,
+filename,
+|ancestor| {
+if !old_entry.tracked() {
+ancestor.tracked_descendants_count += 1;
+}
+},
+)?
+.expect("node should exist");
 let mut new_entry = old_entry.clone();
 new_entry.set_clean(mode, size, mtime);
 node.data = NodeData::Entry(new_entry);
 Ok(())
 }
 
+/// Set a node as possibly dirty in the dirstate.
+///
+/// # Panics
+///
+/// Panics if the node does not exist.
 fn set_possibly_dirty(
  self,
 filename: ,
 ) -> Result<(), DirstateError> {
-let node = self.get_or_insert_node(filename, |_ancestor| {})?;
+let node = DirstateMap::get_node_mut(
+self.on_disk,
+ self.unreachable_bytes,
+ self.root,
+filename,
+|_ancestor| {},
+)?
+.expect("node should exist");
 let entry = node.data.as_entry_mut().expect("entry should exist");
 entry.set_possibly_dirty();
 node.data = NodeData::Entry(*entry);



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


D12529: rust-dirstatemap: add `each_ancestor` argument to `get_node_mut`

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

REVISION SUMMARY
  This forces the callers to think about if the counters in the ancestors
  need to be adjusted.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

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
@@ -546,12 +546,17 @@
 /// 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
+/// other fields while the returned borrow is still valid.
+///
+/// `each_ancestor` is a callback that is called for each ancestor node
+/// when descending the tree. It is used to keep the different counters
+/// of the `DirstateMap` up-to-date.
 fn get_node_mut<'tree>(
 on_disk: &'on_disk [u8],
 unreachable_bytes:  u32,
 root: &'tree mut ChildNodes<'on_disk>,
 path: ,
+mut each_ancestor: impl FnMut( Node),
 ) -> Result>, DirstateV2ParseError> {
 let mut children = root;
 let mut components = path.components();
@@ -563,6 +568,7 @@
 .get_mut(component)
 {
 if let Some(next_component) = components.next() {
+each_ancestor(child);
 component = next_component;
 children =  child.children;
 } else {
@@ -786,6 +792,7 @@
  self.unreachable_bytes,
  self.root,
 path,
+|_ancestor| {},
 )? {
 Some(node) => node,
 None => return Ok(()),
@@ -807,6 +814,7 @@
  self.unreachable_bytes,
  self.root,
 path,
+|_ancestor| {},
 )? {
 Some(node) => node,
 None => return Ok(()),
@@ -1294,6 +1302,7 @@
 unreachable_bytes,
  map.root,
 key,
+|_ancestor| {},
 )?
 .and_then(|node| {
 if let Some(source) = _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


D12528: rust-dirstatemap: add a simpler method `get_or_insert_node` for the common case

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

REVISION SUMMARY
  All but one case use the exact same input for most arguments, this simplifies
  code and reduces footgun potential.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

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
@@ -478,7 +478,7 @@
 map.on_disk,
 |path, entry, copy_source| {
 let tracked = entry.state().is_tracked();
-let node = Self::get_or_insert_node(
+let node = Self::get_or_insert_node_inner(
 map.on_disk,
  map.unreachable_bytes,
  map.root,
@@ -574,7 +574,30 @@
 }
 }
 
+/// Get a mutable reference to the node at `path`, creating it if it does
+/// not exist.
+///
+/// `each_ancestor` is a callback that is called for each ancestor node
+/// when descending the tree. It is used to keep the different counters
+/// of the `DirstateMap` up-to-date.
 fn get_or_insert_node<'tree, 'path>(
+&'tree mut self,
+path: &'path HgPath,
+each_ancestor: impl FnMut( Node),
+) -> Result<&'tree mut Node<'on_disk>, DirstateV2ParseError> {
+Self::get_or_insert_node_inner(
+self.on_disk,
+ self.unreachable_bytes,
+ self.root,
+path,
+WithBasename::to_cow_owned,
+each_ancestor,
+)
+}
+
+/// Lower-level version of `get_or_insert_node_inner`, which is used when
+/// parsing disk data to remove allocations for new nodes.
+fn get_or_insert_node_inner<'tree, 'path>(
 on_disk: &'on_disk [u8],
 unreachable_bytes:  u32,
 root: &'tree mut ChildNodes<'on_disk>,
@@ -620,30 +643,23 @@
 Some(old_entry) => (true, old_entry.tracked()),
 None => (false, false),
 };
-let node = Self::get_or_insert_node(
-self.on_disk,
- self.unreachable_bytes,
- self.root,
-filename,
-WithBasename::to_cow_owned,
-|ancestor| {
-if !had_entry {
-ancestor.descendants_with_entry_count += 1;
+let node = self.get_or_insert_node(filename, |ancestor| {
+if !had_entry {
+ancestor.descendants_with_entry_count += 1;
+}
+if was_tracked {
+if !wc_tracked {
+ancestor.tracked_descendants_count = ancestor
+.tracked_descendants_count
+.checked_sub(1)
+.expect("tracked count to be >= 0");
 }
-if was_tracked {
-if !wc_tracked {
-ancestor.tracked_descendants_count = ancestor
-.tracked_descendants_count
-.checked_sub(1)
-.expect("tracked count to be >= 0");
-}
-} else {
-if wc_tracked {
-ancestor.tracked_descendants_count += 1;
-}
+} else {
+if wc_tracked {
+ancestor.tracked_descendants_count += 1;
 }
-},
-)?;
+}
+})?;
 
 let v2_data = if let Some(parent_file_data) = parent_file_data_opt {
 DirstateV2Data {
@@ -666,10 +682,10 @@
 ..Default::default()
 }
 };
+node.data = NodeData::Entry(DirstateEntry::from_v2_data(v2_data));
 if !had_entry {
 self.nodes_with_entry_count += 1;
 }
-node.data = NodeData::Entry(DirstateEntry::from_v2_data(v2_data));
 Ok(())
 }
 
@@ -683,21 +699,14 @@
 let tracked_count_increment = if was_tracked { 0 } else { 1 };
 let mut new = false;
 
-let node = Self::get_or_insert_node(
-self.on_disk,
- self.unreachable_bytes,
- self.root,
-filename,
-WithBasename::to_cow_owned,
-|ancestor| {
-if !had_entry {
-ancestor.descendants_with_entry_count += 1;
-}
+let node = self.get_or_insert_node(filename, |ancestor| {
+if !had_entry {
+ancestor.descendants_with_entry_count += 1;
+}
 
-ancestor.tracked_descendants_count += tracked_count_increment;
-},
-)?;
-let new_entry = if let Some(old_entry) = 

D12527: rust-dirstatemap: inline the last `get_or_insert` call

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

REVISION SUMMARY
  The `get_or_insert` method was dangerous because it did not take the
  `DirstateMap` counters into account. This particular instance does not need
  to update the counters.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

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
@@ -574,20 +574,6 @@
 }
 }
 
-pub(super) fn get_or_insert<'tree, 'path>(
-&'tree mut self,
-path: ,
-) -> Result<&'tree mut Node<'on_disk>, DirstateV2ParseError> {
-Self::get_or_insert_node(
-self.on_disk,
- self.unreachable_bytes,
- self.root,
-path,
-WithBasename::to_cow_owned,
-|_| {},
-)
-}
-
 fn get_or_insert_node<'tree, 'path>(
 on_disk: &'on_disk [u8],
 unreachable_bytes:  u32,
@@ -1438,7 +1424,14 @@
 }
 self.with_dmap_mut(|map| {
 for path in files_with_p2_info.iter() {
-let node = map.get_or_insert(path)?;
+let node = DirstateMap::get_or_insert_node(
+map.on_disk,
+ map.unreachable_bytes,
+ map.root,
+path,
+WithBasename::to_cow_owned,
+|_| {},
+)?;
 let entry =
 node.data.as_entry_mut().expect("entry should exist");
 entry.drop_merge_data();



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


D12526: rust-dirstatemap: add `set_cached_mtime` helper method

2022-04-12 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 help remove the `get_or_insert` method, which is dangerous because 
it
  does not take the `DirstateMap` counters into account

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

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

CHANGE DETAILS

diff --git a/rust/hg-core/src/dirstate_tree/status.rs 
b/rust/hg-core/src/dirstate_tree/status.rs
--- a/rust/hg-core/src/dirstate_tree/status.rs
+++ b/rust/hg-core/src/dirstate_tree/status.rs
@@ -4,7 +4,6 @@
 use crate::dirstate_tree::dirstate_map::BorrowedPath;
 use crate::dirstate_tree::dirstate_map::ChildNodesRef;
 use crate::dirstate_tree::dirstate_map::DirstateMap;
-use crate::dirstate_tree::dirstate_map::NodeData;
 use crate::dirstate_tree::dirstate_map::NodeRef;
 use crate::dirstate_tree::on_disk::DirstateV2ParseError;
 use crate::matchers::get_ignore_function;
@@ -143,13 +142,7 @@
 dmap.clear_cached_mtime(path)?;
 }
 for (path, mtime) in _cachable {
-let node = dmap.get_or_insert(path)?;
-match  {
-NodeData::Entry(_) => {} // Don’t overwrite an entry
-NodeData::CachedDirectory { .. } | NodeData::None => {
-node.data = NodeData::CachedDirectory { mtime: *mtime }
-}
-}
+dmap.set_cached_mtime(path, *mtime)?;
 }
 
 Ok((outcome, warnings))
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
@@ -823,6 +823,30 @@
 Ok(())
 }
 
+/// Sets the cached mtime for the (potential) folder at `path`.
+pub(super) fn set_cached_mtime(
+ self,
+path: ,
+mtime: TruncatedTimestamp,
+) -> Result<(), DirstateV2ParseError> {
+let node = match DirstateMap::get_node_mut(
+self.on_disk,
+ self.unreachable_bytes,
+ self.root,
+path,
+)? {
+Some(node) => node,
+None => return Ok(()),
+};
+match  {
+NodeData::Entry(_) => {} // Don’t overwrite an entry
+NodeData::CachedDirectory { .. } | NodeData::None => {
+node.data = NodeData::CachedDirectory { mtime }
+}
+}
+Ok(())
+}
+
 fn iter_nodes<'tree>(
 &'tree self,
 ) -> impl Iterator<



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


D12525: rust-dirstatemap: add `clear_cached_mtime` helper method

2022-04-12 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 help remove the `get_or_insert` method, which is dangerous because 
it
  does not take the `DirstateMap` counters into account.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

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

CHANGE DETAILS

diff --git a/rust/hg-core/src/dirstate_tree/status.rs 
b/rust/hg-core/src/dirstate_tree/status.rs
--- a/rust/hg-core/src/dirstate_tree/status.rs
+++ b/rust/hg-core/src/dirstate_tree/status.rs
@@ -140,10 +140,7 @@
 // Remove outdated mtimes before adding new mtimes, in case a given
 // directory is both
 for path in  {
-let node = dmap.get_or_insert(path)?;
-if let NodeData::CachedDirectory { .. } =  {
-node.data = NodeData::None
-}
+dmap.clear_cached_mtime(path)?;
 }
 for (path, mtime) in _cachable {
 let node = dmap.get_or_insert(path)?;
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
@@ -803,6 +803,26 @@
 Ok(())
 }
 
+/// Clears the cached mtime for the (potential) folder at `path`.
+pub(super) fn clear_cached_mtime(
+ self,
+path: ,
+) -> Result<(), DirstateV2ParseError> {
+let node = match DirstateMap::get_node_mut(
+self.on_disk,
+ self.unreachable_bytes,
+ self.root,
+path,
+)? {
+Some(node) => node,
+None => return Ok(()),
+};
+if let NodeData::CachedDirectory { .. } =  {
+node.data = NodeData::None
+}
+Ok(())
+}
+
 fn iter_nodes<'tree>(
 &'tree self,
 ) -> impl Iterator<



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


D12524: rust-dirstatemap: add unit tests

2022-04-12 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 missing and have already proven valuable since they have found
  two bugs (fixed in previous patches).
  
  There may be other behavior to test, but this gives us a decent coverage.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

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
@@ -1433,3 +1433,417 @@
 }))
 }
 }
+#[cfg(test)]
+mod tests {
+use super::*;
+
+/// Shortcut to return tracked descendants of a path.
+/// Panics if the path does not exist.
+fn tracked_descendants(map: , path: &[u8]) -> u32 {
+let path = dbg!(HgPath::new(path));
+let node = map.get_map().get_node(path);
+node.unwrap().unwrap().tracked_descendants_count()
+}
+
+/// Shortcut to return descendants with an entry.
+/// Panics if the path does not exist.
+fn descendants_with_an_entry(map: , path: &[u8]) -> u32 {
+let path = dbg!(HgPath::new(path));
+let node = map.get_map().get_node(path);
+node.unwrap().unwrap().descendants_with_entry_count()
+}
+
+fn assert_does_not_exist(map: , path: &[u8]) {
+let path = dbg!(HgPath::new(path));
+let node = map.get_map().get_node(path);
+assert!(node.unwrap().is_none());
+}
+
+/// Shortcut for path creation in tests
+fn p(b: &[u8]) ->  {
+HgPath::new(b)
+}
+
+/// Test the very simple case a single tracked file
+#[test]
+fn test_tracked_descendants_simple() -> Result<(), DirstateError> {
+let mut map = OwningDirstateMap::new_empty(vec![]);
+assert_eq!(map.len(), 0);
+
+map.set_tracked(p(b"some/nested/path"))?;
+
+assert_eq!(map.len(), 1);
+assert_eq!(tracked_descendants(, b"some"), 1);
+assert_eq!(tracked_descendants(, b"some/nested"), 1);
+assert_eq!(tracked_descendants(, b"some/nested/path"), 0);
+
+map.set_untracked(p(b"some/nested/path"))?;
+assert_eq!(map.len(), 0);
+assert!(map.get_map().get_node(p(b"some"))?.is_none());
+
+Ok(())
+}
+
+/// Test the simple case of all tracked, but multiple files
+#[test]
+fn test_tracked_descendants_multiple() -> Result<(), DirstateError> {
+let mut map = OwningDirstateMap::new_empty(vec![]);
+
+map.set_tracked(p(b"some/nested/path"))?;
+map.set_tracked(p(b"some/nested/file"))?;
+// one layer without any files to test deletion cascade
+map.set_tracked(p(b"some/other/nested/path"))?;
+map.set_tracked(p(b"root_file"))?;
+map.set_tracked(p(b"some/file"))?;
+map.set_tracked(p(b"some/file2"))?;
+map.set_tracked(p(b"some/file3"))?;
+
+assert_eq!(map.len(), 7);
+assert_eq!(tracked_descendants(, b"some"), 6);
+assert_eq!(tracked_descendants(, b"some/nested"), 2);
+assert_eq!(tracked_descendants(, b"some/other"), 1);
+assert_eq!(tracked_descendants(, b"some/other/nested"), 1);
+assert_eq!(tracked_descendants(, b"some/nested/path"), 0);
+
+map.set_untracked(p(b"some/nested/path"))?;
+assert_eq!(map.len(), 6);
+assert_eq!(tracked_descendants(, b"some"), 5);
+assert_eq!(tracked_descendants(, b"some/nested"), 1);
+assert_eq!(tracked_descendants(, b"some/other"), 1);
+assert_eq!(tracked_descendants(, b"some/other/nested"), 1);
+
+map.set_untracked(p(b"some/nested/file"))?;
+assert_eq!(map.len(), 5);
+assert_eq!(tracked_descendants(, b"some"), 4);
+assert_eq!(tracked_descendants(, b"some/other"), 1);
+assert_eq!(tracked_descendants(, b"some/other/nested"), 1);
+assert_does_not_exist(, b"some_nested");
+
+map.set_untracked(p(b"some/other/nested/path"))?;
+assert_eq!(map.len(), 4);
+assert_eq!(tracked_descendants(, b"some"), 3);
+assert_does_not_exist(, b"some/other");
+
+map.set_untracked(p(b"root_file"))?;
+assert_eq!(map.len(), 3);
+assert_eq!(tracked_descendants(, b"some"), 3);
+assert_does_not_exist(, b"root_file");
+
+map.set_untracked(p(b"some/file"))?;
+assert_eq!(map.len(), 2);
+assert_eq!(tracked_descendants(, b"some"), 2);
+assert_does_not_exist(, b"some/file");
+
+map.set_untracked(p(b"some/file2"))?;
+assert_eq!(map.len(), 1);
+assert_eq!(tracked_descendants(, b"some"), 1);
+assert_does_not_exist(, b"some/file2");
+
+map.set_untracked(p(b"some/file3"))?;
+assert_eq!(map.len(), 0);
+

D12523: rust: add `Debug` trait to a bunch of structs

2022-04-12 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 useful when... debugging. Right now the output is not in the most
  readable state it could be, but this is very low effort and is good enough
  for now. We may want to write a nicer custom debug formatter for some of those
  structs in the future.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

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

CHANGE DETAILS

diff --git a/rust/hg-core/src/dirstate_tree/on_disk.rs 
b/rust/hg-core/src/dirstate_tree/on_disk.rs
--- a/rust/hg-core/src/dirstate_tree/on_disk.rs
+++ b/rust/hg-core/src/dirstate_tree/on_disk.rs
@@ -84,7 +84,7 @@
 
 /// Fields are documented in the *The data file format*
 /// section of `mercurial/helptext/internals/dirstate-v2.txt`
-#[derive(BytesCast)]
+#[derive(BytesCast, Debug)]
 #[repr(C)]
 pub(super) struct Node {
 full_path: PathSlice,
@@ -124,7 +124,7 @@
 }
 
 /// Duration since the Unix epoch
-#[derive(BytesCast, Copy, Clone)]
+#[derive(BytesCast, Copy, Clone, Debug)]
 #[repr(C)]
 struct PackedTruncatedTimestamp {
 truncated_seconds: U32Be,
@@ -152,7 +152,7 @@
 /// Always sorted by ascending `full_path`, to allow binary search.
 /// Since nodes with the same parent nodes also have the same parent path,
 /// only the `base_name`s need to be compared during binary search.
-#[derive(BytesCast, Copy, Clone)]
+#[derive(BytesCast, Copy, Clone, Debug)]
 #[repr(C)]
 struct ChildNodes {
 start: Offset,
@@ -160,7 +160,7 @@
 }
 
 /// A `HgPath` of `len` bytes
-#[derive(BytesCast, Copy, Clone)]
+#[derive(BytesCast, Copy, Clone, Debug)]
 #[repr(C)]
 struct PathSlice {
 start: Offset,
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
@@ -32,6 +32,7 @@
 /// anymore) is less than this fraction of the total amount of existing data.
 const ACCEPTABLE_UNREACHABLE_BYTES_RATIO: f32 = 0.5;
 
+#[derive(Debug)]
 pub struct DirstateMap<'on_disk> {
 /// Contents of the `.hg/dirstate` file
 pub(super) on_disk: &'on_disk [u8],
@@ -61,21 +62,25 @@
 
 /// Similar to `&'tree Cow<'on_disk, HgPath>`, but can also be returned
 /// for on-disk nodes that don’t actually have a `Cow` to borrow.
+#[derive(Debug)]
 pub(super) enum BorrowedPath<'tree, 'on_disk> {
 InMemory(&'tree HgPathBuf),
 OnDisk(&'on_disk HgPath),
 }
 
+#[derive(Debug)]
 pub(super) enum ChildNodes<'on_disk> {
 InMemory(FastHashMap, Node<'on_disk>>),
 OnDisk(&'on_disk [on_disk::Node]),
 }
 
+#[derive(Debug)]
 pub(super) enum ChildNodesRef<'tree, 'on_disk> {
 InMemory(&'tree FastHashMap, Node<'on_disk>>),
 OnDisk(&'on_disk [on_disk::Node]),
 }
 
+#[derive(Debug)]
 pub(super) enum NodeRef<'tree, 'on_disk> {
 InMemory(&'tree NodeKey<'on_disk>, &'tree Node<'on_disk>),
 OnDisk(&'on_disk on_disk::Node),
@@ -383,7 +388,7 @@
 }
 
 /// Represents a file or a directory
-#[derive(Default)]
+#[derive(Default, Debug)]
 pub(super) struct Node<'on_disk> {
 pub(super) data: NodeData,
 
@@ -399,6 +404,7 @@
 pub(super) tracked_descendants_count: u32,
 }
 
+#[derive(Debug)]
 pub(super) enum NodeData {
 Entry(DirstateEntry),
 CachedDirectory { mtime: TruncatedTimestamp },



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


D12522: rust-dirstatemap: use `` instead of `HgPathBuf` in `copy_map_insert`

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

REVISION SUMMARY
  No reason to require an owned path here.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  rust/hg-core/src/dirstate_tree/dirstate_map.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
@@ -23,13 +23,10 @@
 pybytes_deref::PyBytesDeref,
 };
 use hg::{
-dirstate::StateMapIter,
-dirstate_tree::on_disk::DirstateV2ParseError,
-dirstate_tree::owning::OwningDirstateMap,
-revlog::Node,
-utils::files::normalize_case,
-utils::hg_path::{HgPath, HgPathBuf},
-DirstateEntry, DirstateError, DirstateParents, EntryState,
+dirstate::StateMapIter, dirstate_tree::on_disk::DirstateV2ParseError,
+dirstate_tree::owning::OwningDirstateMap, revlog::Node,
+utils::files::normalize_case, utils::hg_path::HgPath, DirstateEntry,
+DirstateError, DirstateParents, EntryState,
 };
 
 // TODO
@@ -411,8 +408,8 @@
 self.inner(py)
 .borrow_mut()
 .copy_map_insert(
-HgPathBuf::from_bytes(key.data(py)),
-HgPathBuf::from_bytes(value.data(py)),
+HgPath::new(key.data(py)),
+HgPath::new(value.data(py)),
 )
 .map_err(|e| v2_error(py, e))?;
 Ok(py.None())
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
@@ -1284,8 +1284,8 @@
 
 pub fn copy_map_insert(
  self,
-key: HgPathBuf,
-value: HgPathBuf,
+key: ,
+value: ,
 ) -> Result, DirstateV2ParseError> {
 self.with_dmap_mut(|map| {
 let node = DirstateMap::get_or_insert_node(
@@ -1299,7 +1299,10 @@
 if node.copy_source.is_none() {
 map.nodes_with_copy_source_count += 1
 }
-Ok(node.copy_source.replace(value.into()).map(Cow::into_owned))
+Ok(node
+.copy_source
+.replace(value.to_owned().into())
+.map(Cow::into_owned))
 })
 }
 



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


D12521: rust-dirstatemap: use `DirstateEntry::tracked` directly

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

REVISION SUMMARY
  `state()` is a legacy API that will be removed at some point, let's use the
  newer API.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

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
@@ -988,9 +988,7 @@
  self,
 filename: ,
 ) -> Result<(), DirstateError> {
-let was_tracked = self
-.get(filename)?
-.map_or(false, |e| e.state().is_tracked());
+let was_tracked = self.get(filename)?.map_or(false, |e| e.tracked());
 struct Dropped {
 was_tracked: bool,
 had_entry: bool,



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


D12519: rust-dirstatemap: remove `set_dirstate_entry`/`set_entry` methods

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

REVISION SUMMARY
  These methods were needed crutches before the Rust implementation caught up
  to Python. Calling `set_entry` (whether from Python or Rust) was dangerous
  since it didn't update any of the counters of the DirstateMap data structure,
  while having no real way of knowing when to use it "correctly" except it you
  were one of the 3 people who looked deep enough into the soul of this code.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  rust/hg-core/src/dirstate_tree/dirstate_map.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
@@ -104,20 +104,6 @@
 }
 }
 
-def set_dirstate_item(
-,
-path: PyObject,
-item: DirstateItem
-) -> PyResult {
-let f = path.extract::(py)?;
-let filename = HgPath::new(f.data(py));
-self.inner(py)
-.borrow_mut()
-.set_entry(filename, item.get_entry(py))
-.map_err(|e| v2_error(py, e))?;
-Ok(py.None())
-}
-
 def set_tracked(, f: PyObject) -> PyResult {
 let bytes = f.extract::(py)?;
 let path = HgPath::new(bytes.data(py));
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
@@ -884,17 +884,6 @@
 });
 }
 
-pub fn set_entry(
- self,
-filename: ,
-entry: DirstateEntry,
-) -> Result<(), DirstateV2ParseError> {
-self.with_dmap_mut(|map| {
-map.get_or_insert()?.data = NodeData::Entry(entry);
-Ok(())
-})
-}
-
 pub fn set_tracked(
  self,
 filename: ,



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


D12520: rust-cpython: remove unused API to `drop_entry_and_copy_source`

2022-04-12 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 used anywhere anymore and its use cases are covered by the new API

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  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
@@ -205,17 +205,6 @@
 Ok(PyNone)
 }
 
-def drop_item_and_copy_source(
-,
-f: PyBytes,
-) -> PyResult {
-self.inner(py)
-.borrow_mut()
-.drop_entry_and_copy_source(HgPath::new(f.data(py)))
-.map_err(|e |dirstate_error(py, e))?;
-Ok(PyNone)
-}
-
 def hastrackeddir(, d: PyObject) -> PyResult {
 let d = d.extract::(py)?;
 Ok(self.inner(py).borrow_mut()



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


D12518: rust-dirstatemap: implement part of the `setparents` logic

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

REVISION SUMMARY
  The Python code does many round-trip calls to the Rust dirstatemap when copy
  information needs to be dropped in `setparents`.
  
  This may result in improved performance on `commit`, `update` and other such
  commands, but was mostly done to drop the last use of `set_dirstate_item`.
  See inline comments for an asterisk about performance, and see next patch for
  why `set_dirstate_item` has to go.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  mercurial/dirstatemap.py
  rust/hg-core/src/dirstate_tree/dirstate_map.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
@@ -489,6 +489,19 @@
 Ok(dirs)
 }
 
+def setparents_fixup() -> PyResult {
+let dict = PyDict::new(py);
+let copies = self.inner(py).borrow_mut().setparents_fixup();
+for (key, value) in copies.map_err(|e| v2_error(py, e))? {
+dict.set_item(
+py,
+PyBytes::new(py, key.as_bytes()),
+PyBytes::new(py, value.as_bytes()),
+)?;
+}
+Ok(dict)
+}
+
 def debug_iter(, all: bool) -> PyResult {
 let dirs = PyList::new(py, &[]);
 for item in self.inner(py).borrow().debug_iter(all) {
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
@@ -1375,6 +1375,41 @@
 )))
 }
 
+/// Only public because it needs to be exposed to the Python layer.
+/// It is not the full `setparents` logic, only the parts that mutate the
+/// entries.
+pub fn setparents_fixup(
+ self,
+) -> Result, DirstateV2ParseError> {
+// XXX
+// All the copying and re-querying is quite inefficient, but this is
+// still a lot better than doing it from Python.
+//
+// The better solution is to develop a mechanism for `iter_mut`,
+// which will be a lot more involved: we're dealing with a lazy,
+// append-mostly, tree-like data structure. This will do for now.
+let mut copies = vec![];
+let mut files_with_p2_info = vec![];
+for res in self.iter() {
+let (path, entry) = res?;
+if entry.p2_info() {
+files_with_p2_info.push(path.to_owned())
+}
+}
+self.with_dmap_mut(|map| {
+for path in files_with_p2_info.iter() {
+let node = map.get_or_insert(path)?;
+let entry =
+node.data.as_entry_mut().expect("entry should exist");
+entry.drop_merge_data();
+if let Some(source) = node.copy_source.take().as_deref() {
+copies.push((path.to_owned(), source.to_owned()));
+}
+}
+Ok(copies)
+})
+}
+
 pub fn debug_iter(
 ,
 all: bool,
diff --git a/mercurial/dirstatemap.py b/mercurial/dirstatemap.py
--- a/mercurial/dirstatemap.py
+++ b/mercurial/dirstatemap.py
@@ -593,22 +593,7 @@
 self._dirtyparents = True
 copies = {}
 if fold_p2:
-# Collect into an intermediate list to avoid a `RuntimeError`
-# exception due to mutation during iteration.
-# TODO: move this the whole loop to Rust where `iter_mut`
-# enables in-place mutation of elements of a collection while
-# iterating it, without mutating the collection itself.
-files_with_p2_info = [
-f for f, s in self._map.items() if s.p2_info
-]
-rust_map = self._map
-for f in files_with_p2_info:
-e = rust_map.get(f)
-source = self.copymap.pop(f, None)
-if source:
-copies[f] = source
-e.drop_merge_data()
-rust_map.set_dirstate_item(f, e)
+copies = self._map.setparents_fixup()
 return copies
 
 ### disk interaction



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


D12517: dirstate-item: add missing bit of docstring

2022-04-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/D12517

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
@@ -278,7 +278,7 @@
 self._mtime_ns = None
 
 def drop_merge_data(self):
-"""remove all "merge-only" from a DirstateItem
+"""remove all "merge-only" information from a DirstateItem
 
 This is to be call by the dirstatemap code when the second parent is 
dropped
 """



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


D12516: dirstatemap: move `_dirs_incr` and `_dirs_decr` methods out of the common

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

REVISION SUMMARY
  They are only used by the Python implementation now

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  mercurial/dirstatemap.py

CHANGE DETAILS

diff --git a/mercurial/dirstatemap.py b/mercurial/dirstatemap.py
--- a/mercurial/dirstatemap.py
+++ b/mercurial/dirstatemap.py
@@ -79,25 +79,6 @@
 def __getitem__(self, item):
 return self._map[item]
 
-### sub-class utility method
-#
-# Use to allow for generic implementation of some method while still coping
-# with minor difference between implementation.
-
-def _dirs_incr(self, filename, old_entry=None):
-"""increment the dirstate counter if applicable
-
-This might be a no-op for some subclasses who deal with directory
-tracking in a different way.
-"""
-
-def _dirs_decr(self, filename, old_entry=None, remove_variant=False):
-"""decrement the dirstate counter if applicable
-
-This might be a no-op for some subclasses who deal with directory
-tracking in a different way.
-"""
-
 ### disk interaction
 
 def _opendirstatefile(self):
@@ -354,7 +335,7 @@
 # (e.g. "has_dir")
 
 def _dirs_incr(self, filename, old_entry=None):
-"""incremente the dirstate counter if applicable"""
+"""increment the dirstate counter if applicable"""
 if (
 old_entry is None or old_entry.removed
 ) and "_dirs" in self.__dict__:
@@ -363,7 +344,7 @@
 self._alldirs.addpath(filename)
 
 def _dirs_decr(self, filename, old_entry=None, remove_variant=False):
-"""decremente the dirstate counter if applicable"""
+"""decrement the dirstate counter if applicable"""
 if old_entry is not None:
 if "_dirs" in self.__dict__ and not old_entry.removed:
 self._dirs.delpath(filename)



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


D12515: dirstatemap: move `_refresh_entry` out of the common methods

2022-04-12 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 only used in the Python implementation now

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  mercurial/dirstatemap.py

CHANGE DETAILS

diff --git a/mercurial/dirstatemap.py b/mercurial/dirstatemap.py
--- a/mercurial/dirstatemap.py
+++ b/mercurial/dirstatemap.py
@@ -98,9 +98,6 @@
 tracking in a different way.
 """
 
-def _refresh_entry(self, f, entry):
-"""record updated state of an entry"""
-
 ### disk interaction
 
 def _opendirstatefile(self):
@@ -523,6 +520,7 @@
 self._refresh_entry(filename, entry)
 
 def _refresh_entry(self, f, entry):
+"""record updated state of an entry"""
 if not entry.any_tracked:
 self._map.pop(f, 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


D12514: dirstatemap: move `_drop_entry` out of the common methods

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

REVISION SUMMARY
  Only the Python implementation uses it.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  mercurial/dirstatemap.py

CHANGE DETAILS

diff --git a/mercurial/dirstatemap.py b/mercurial/dirstatemap.py
--- a/mercurial/dirstatemap.py
+++ b/mercurial/dirstatemap.py
@@ -101,13 +101,6 @@
 def _refresh_entry(self, f, entry):
 """record updated state of an entry"""
 
-def _drop_entry(self, f):
-"""remove any entry for file f
-
-This should also drop associated copy information
-
-The fact we actually need to drop it is the responsability of the 
caller"""
-
 ### disk interaction
 
 def _opendirstatefile(self):
@@ -534,6 +527,11 @@
 self._map.pop(f, None)
 
 def _drop_entry(self, f):
+"""remove any entry for file f
+
+This should also drop associated copy information
+
+The fact we actually need to drop it is the responsability of the 
caller"""
 self._map.pop(f, None)
 self.copymap.pop(f, 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


D12513: rust-dirstatemap: remove `_drop_entry`

2022-04-12 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 used anywhere anymore

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  mercurial/dirstatemap.py

CHANGE DETAILS

diff --git a/mercurial/dirstatemap.py b/mercurial/dirstatemap.py
--- a/mercurial/dirstatemap.py
+++ b/mercurial/dirstatemap.py
@@ -730,6 +730,3 @@
 has_meaningful_mtime,
 parentfiledata,
 )
-
-def _drop_entry(self, f):
-self._map.drop_item_and_copy_source(f)



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


D12512: rust-dirstatemap: remove `__settitem__`

2022-04-12 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 used anywhere now.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  mercurial/dirstatemap.py

CHANGE DETAILS

diff --git a/mercurial/dirstatemap.py b/mercurial/dirstatemap.py
--- a/mercurial/dirstatemap.py
+++ b/mercurial/dirstatemap.py
@@ -733,7 +733,3 @@
 
 def _drop_entry(self, f):
 self._map.drop_item_and_copy_source(f)
-
-def __setitem__(self, key, value):
-assert isinstance(value, DirstateItem)
-self._map.set_dirstate_item(key, value)



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


D12511: rust-dirstatemap: remove unused `_refresh_entry` implementation

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

REVISION SUMMARY
  This was only used in the newer APIs, all of which have been rewritten in Rust

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  mercurial/dirstatemap.py

CHANGE DETAILS

diff --git a/mercurial/dirstatemap.py b/mercurial/dirstatemap.py
--- a/mercurial/dirstatemap.py
+++ b/mercurial/dirstatemap.py
@@ -701,12 +701,6 @@
 
 ### code related to manipulation of entries and copy-sources
 
-def _refresh_entry(self, f, entry):
-if not entry.any_tracked:
-self._map.drop_item_and_copy_source(f)
-else:
-self._map.addfile(f, entry)
-
 def set_tracked(self, f):
 return self._map.set_tracked(f)
 



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


D12510: rust-distatemap: remove `addfile` API

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

REVISION SUMMARY
  All of its users have been migrated to the new API

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  rust/hg-core/src/dirstate_tree/dirstate_map.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
@@ -118,20 +118,6 @@
 Ok(py.None())
 }
 
-def addfile(
-,
-f: PyBytes,
-item: DirstateItem,
-) -> PyResult {
-let filename = HgPath::new(f.data(py));
-let entry = item.get_entry(py);
-self.inner(py)
-.borrow_mut()
-.add_file(filename, entry)
-.map_err(|e |dirstate_error(py, e))?;
-Ok(PyNone)
-}
-
 def set_tracked(, f: PyObject) -> PyResult {
 let bytes = f.extract::(py)?;
 let path = HgPath::new(bytes.data(py));
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
@@ -727,49 +727,6 @@
 Ok(new)
 }
 
-fn add_or_remove_file(
- self,
-path: ,
-old_state: Option,
-new_entry: DirstateEntry,
-) -> Result<(), DirstateV2ParseError> {
-let had_entry = old_state.is_some();
-let was_tracked = old_state.map_or(false, |s| s.is_tracked());
-let tracked_count_increment =
-match (was_tracked, new_entry.state().is_tracked()) {
-(false, true) => 1,
-(true, false) => -1,
-_ => 0,
-};
-
-let node = Self::get_or_insert_node(
-self.on_disk,
- self.unreachable_bytes,
- self.root,
-path,
-WithBasename::to_cow_owned,
-|ancestor| {
-if !had_entry {
-ancestor.descendants_with_entry_count += 1;
-}
-
-// We can’t use `+= increment` because the counter is unsigned,
-// and we want debug builds to detect accidental underflow
-// through zero
-match tracked_count_increment {
-1 => ancestor.tracked_descendants_count += 1,
--1 => ancestor.tracked_descendants_count -= 1,
-_ => {}
-}
-},
-)?;
-if !had_entry {
-self.nodes_with_entry_count += 1
-}
-node.data = NodeData::Entry(new_entry);
-Ok(())
-}
-
 /// It is the responsibility of the caller to know that there was an entry
 /// there before. Does not handle the removal of copy source
 fn set_untracked(
@@ -938,17 +895,6 @@
 })
 }
 
-pub fn add_file(
- self,
-filename: ,
-entry: DirstateEntry,
-) -> Result<(), DirstateError> {
-let old_state = self.get(filename)?.map(|e| e.state());
-self.with_dmap_mut(|map| {
-Ok(map.add_or_remove_file(filename, old_state, entry)?)
-})
-}
-
 pub fn set_tracked(
  self,
 filename: ,



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


D12509: rust-dirstatemap: remove `removefile` API

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

REVISION SUMMARY
  Its callers have been migrated to the newer dirstate API.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  rust/hg-core/src/dirstate_tree/dirstate_map.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
@@ -233,25 +233,6 @@
 Ok(PyNone)
 }
 
-def removefile(
-,
-f: PyObject,
-in_merge: PyObject
-) -> PyResult {
-self.inner(py).borrow_mut()
-.remove_file(
-HgPath::new(f.extract::(py)?.data(py)),
-in_merge.extract::(py)?.is_true(),
-)
-.or_else(|_| {
-Err(PyErr::new::(
-py,
-"Dirstate error".to_string(),
-))
-})?;
-Ok(py.None())
-}
-
 def drop_item_and_copy_source(
 ,
 f: PyBytes,
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
@@ -15,8 +15,6 @@
 use crate::dirstate::ParentFileData;
 use crate::dirstate::StateMapIter;
 use crate::dirstate::TruncatedTimestamp;
-use crate::dirstate::SIZE_FROM_OTHER_PARENT;
-use crate::dirstate::SIZE_NON_NORMAL;
 use crate::matchers::Matcher;
 use crate::utils::hg_path::{HgPath, HgPathBuf};
 use crate::DirstateEntry;
@@ -1051,40 +1049,6 @@
 })
 }
 
-pub fn remove_file(
- self,
-filename: ,
-in_merge: bool,
-) -> Result<(), DirstateError> {
-let old_entry_opt = self.get(filename)?;
-let old_state = old_entry_opt.map(|e| e.state());
-let mut size = 0;
-if in_merge {
-// XXX we should not be able to have 'm' state and 'FROM_P2' if not
-// during a merge. So I (marmoute) am not sure we need the
-// conditionnal at all. Adding double checking this with assert
-// would be nice.
-if let Some(old_entry) = old_entry_opt {
-// backup the previous state
-if old_entry.state() == EntryState::Merged {
-size = SIZE_NON_NORMAL;
-} else if old_entry.state() == EntryState::Normal
-&& old_entry.size() == SIZE_FROM_OTHER_PARENT
-{
-// other parent
-size = SIZE_FROM_OTHER_PARENT;
-}
-}
-}
-if size == 0 {
-self.copy_map_remove(filename)?;
-}
-self.with_dmap_mut(|map| {
-let entry = DirstateEntry::new_removed(size);
-Ok(map.add_or_remove_file(filename, old_state, entry)?)
-})
-}
-
 pub fn drop_entry_and_copy_source(
  self,
 filename: ,



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


D12508: rhg: use the new `set_clean` API

2022-04-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/D12508

AFFECTED FILES
  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
@@ -15,7 +15,6 @@
 use hg::dirstate::has_exec_bit;
 use hg::dirstate::status::StatusPath;
 use hg::dirstate::TruncatedTimestamp;
-use hg::dirstate::RANGE_MASK_31BIT;
 use hg::errors::{HgError, IoResultExt};
 use hg::lock::LockError;
 use hg::manifest::Manifest;
@@ -390,12 +389,8 @@
 .when_reading_file(_path)?
 {
 let mode = fs_metadata.mode();
-let size = fs_metadata.len() as u32 & RANGE_MASK_31BIT;
-let mut entry = dmap
-.get(_path)?
-.expect("ambiguous file not in dirstate");
-entry.set_clean(mode, size, mtime);
-dmap.add_file(_path, entry)?;
+let size = fs_metadata.len();
+dmap.set_clean(_path, mode, size as u32, mtime)?;
 dirstate_write_needed = true
 }
 }



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


D12506: rust-dirstatemap: add `set_untracked` method

2022-04-12 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 new API that Python has already migrated to

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  rust/hg-core/src/dirstate_tree/dirstate_map.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
@@ -142,6 +142,16 @@
 Ok(was_tracked.to_py_object(py))
 }
 
+def set_untracked(, f: PyObject) -> PyResult {
+let bytes = f.extract::(py)?;
+let path = HgPath::new(bytes.data(py));
+let res = self.inner(py).borrow_mut().set_untracked(path);
+let was_tracked = res.or_else(|_| {
+Err(PyErr::new::(py, "Dirstate 
error".to_string()))
+})?;
+Ok(was_tracked.to_py_object(py))
+}
+
 def set_clean(
 ,
 f: PyObject,
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
@@ -772,6 +772,32 @@
 Ok(())
 }
 
+/// It is the responsibility of the caller to know that there was an entry
+/// there before. Does not handle the removal of copy source
+fn set_untracked(
+ self,
+filename: ,
+old_entry: DirstateEntry,
+) -> Result<(), DirstateV2ParseError> {
+let node = Self::get_or_insert_node(
+self.on_disk,
+ self.unreachable_bytes,
+ self.root,
+filename,
+WithBasename::to_cow_owned,
+|ancestor| {
+ancestor.tracked_descendants_count = ancestor
+.tracked_descendants_count
+.checked_sub(1)
+.expect("tracked_descendants_count should be >= 0");
+},
+)?;
+let mut new_entry = old_entry.clone();
+new_entry.set_untracked();
+node.data = NodeData::Entry(new_entry);
+Ok(())
+}
+
 fn set_clean(
  self,
 filename: ,
@@ -933,6 +959,39 @@
 self.with_dmap_mut(|map| map.set_tracked(filename, old_entry_opt))
 }
 
+pub fn set_untracked(
+ self,
+filename: ,
+) -> Result {
+let old_entry_opt = self.get(filename)?;
+match old_entry_opt {
+None => Ok(false),
+Some(old_entry) => {
+if !old_entry.tracked() {
+// `DirstateMap::set_untracked` is not a noop if
+// already not tracked as it will decrement the
+// tracked counters while going down.
+return Ok(true);
+}
+if old_entry.added() {
+// Untracking an "added" entry will just result in a
+// worthless entry (and other parts of the code will
+// complain about it), just drop it entirely.
+self.drop_entry_and_copy_source(filename)?;
+return Ok(true);
+}
+if !old_entry.p2_info() {
+self.copy_map_remove(filename)?;
+}
+
+self.with_dmap_mut(|map| {
+map.set_untracked(filename, old_entry)?;
+Ok(true)
+})
+}
+}
+}
+
 pub fn set_clean(
  self,
 filename: ,



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


D12507: dirstatemap: move `set_untracked` out of the common methods

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

REVISION SUMMARY
  There is a dedicated Rust implementation now

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  mercurial/dirstatemap.py

CHANGE DETAILS

diff --git a/mercurial/dirstatemap.py b/mercurial/dirstatemap.py
--- a/mercurial/dirstatemap.py
+++ b/mercurial/dirstatemap.py
@@ -108,21 +108,6 @@
 
 The fact we actually need to drop it is the responsability of the 
caller"""
 
-### method to manipulate the entries
-
-def set_untracked(self, f):
-"""Mark a file as no longer tracked in the dirstate map"""
-entry = self.get(f)
-if entry is None:
-return False
-else:
-self._dirs_decr(f, old_entry=entry, remove_variant=not entry.added)
-if not entry.p2_info:
-self.copymap.pop(f, None)
-entry.set_untracked()
-self._refresh_entry(f, entry)
-return True
-
 ### disk interaction
 
 def _opendirstatefile(self):
@@ -517,6 +502,19 @@
 self._refresh_entry(filename, entry)
 return new
 
+def set_untracked(self, f):
+"""Mark a file as no longer tracked in the dirstate map"""
+entry = self.get(f)
+if entry is None:
+return False
+else:
+self._dirs_decr(f, old_entry=entry, remove_variant=not entry.added)
+if not entry.p2_info:
+self.copymap.pop(f, None)
+entry.set_untracked()
+self._refresh_entry(f, entry)
+return True
+
 def set_clean(self, filename, mode, size, mtime):
 """mark a file as back to a clean state"""
 entry = self[filename]
@@ -712,6 +710,9 @@
 def set_tracked(self, f):
 return self._map.set_tracked(f)
 
+def set_untracked(self, f):
+return self._map.set_untracked(f)
+
 def set_clean(self, filename, mode, size, mtime):
 self._map.set_clean(filename, mode, size, mtime)
 



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


D12505: dirstatemap: move `set_possibly_dirty` out of the common methods

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

REVISION SUMMARY
  There exists now a dedicated Rust implementation

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  mercurial/dirstatemap.py

CHANGE DETAILS

diff --git a/mercurial/dirstatemap.py b/mercurial/dirstatemap.py
--- a/mercurial/dirstatemap.py
+++ b/mercurial/dirstatemap.py
@@ -110,12 +110,6 @@
 
 ### method to manipulate the entries
 
-def set_possibly_dirty(self, filename):
-"""record that the current state of the file on disk is unknown"""
-entry = self[filename]
-entry.set_possibly_dirty()
-self._refresh_entry(filename, entry)
-
 def set_untracked(self, f):
 """Mark a file as no longer tracked in the dirstate map"""
 entry = self.get(f)
@@ -531,6 +525,12 @@
 self._refresh_entry(filename, entry)
 self.copymap.pop(filename, None)
 
+def set_possibly_dirty(self, filename):
+"""record that the current state of the file on disk is unknown"""
+entry = self[filename]
+entry.set_possibly_dirty()
+self._refresh_entry(filename, entry)
+
 def _refresh_entry(self, f, entry):
 if not entry.any_tracked:
 self._map.pop(f, None)
@@ -715,6 +715,9 @@
 def set_clean(self, filename, mode, size, mtime):
 self._map.set_clean(filename, mode, size, mtime)
 
+def set_possibly_dirty(self, f):
+self._map.set_possibly_dirty(f)
+
 def reset_state(
 self,
 filename,



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


D12504: rust-dirstatemap: add `set_possibly_dirty` method

2022-04-12 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 new API that Python has already migrated to.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  rust/hg-core/src/dirstate_tree/dirstate_map.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
@@ -164,6 +164,16 @@
 Ok(PyNone)
 }
 
+def set_possibly_dirty(, f: PyObject) -> PyResult {
+let bytes = f.extract::(py)?;
+let path = HgPath::new(bytes.data(py));
+let res = self.inner(py).borrow_mut().set_possibly_dirty(path);
+res.or_else(|_| {
+Err(PyErr::new::(py, "Dirstate 
error".to_string()))
+})?;
+Ok(PyNone)
+}
+
 def reset_state(
 ,
 f: PyObject,
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
@@ -427,6 +427,13 @@
 _ => None,
 }
 }
+
+fn as_entry_mut( self) -> Option< DirstateEntry> {
+match self {
+NodeData::Entry(entry) => Some(entry),
+_ => None,
+}
+}
 }
 
 impl<'on_disk> DirstateMap<'on_disk> {
@@ -791,6 +798,24 @@
 Ok(())
 }
 
+fn set_possibly_dirty(
+ self,
+filename: ,
+) -> Result<(), DirstateError> {
+let node = Self::get_or_insert_node(
+self.on_disk,
+ self.unreachable_bytes,
+ self.root,
+filename,
+WithBasename::to_cow_owned,
+|_ancestor| {},
+)?;
+let entry = node.data.as_entry_mut().expect("entry should exist");
+entry.set_possibly_dirty();
+node.data = NodeData::Entry(*entry);
+Ok(())
+}
+
 fn iter_nodes<'tree>(
 &'tree self,
 ) -> impl Iterator<
@@ -929,6 +954,16 @@
 })
 }
 
+pub fn set_possibly_dirty(
+ self,
+filename: ,
+) -> Result<(), DirstateError> {
+if self.get(filename)?.is_none() {
+return Err(DirstateMapError::PathNotFound(filename.into()).into());
+}
+self.with_dmap_mut(|map| map.set_possibly_dirty(filename))
+}
+
 pub fn reset_state(
  self,
 filename: ,



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


D12502: rust-dirstatemap: add `set_clean` method

2022-04-12 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 new dirstate API that has already been moved to in Python.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  rust/hg-core/src/dirstate_tree/dirstate_map.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
@@ -142,6 +142,28 @@
 Ok(was_tracked.to_py_object(py))
 }
 
+def set_clean(
+,
+f: PyObject,
+mode: u32,
+size: u32,
+mtime: (i64, u32, bool)
+) -> PyResult {
+let (mtime_s, mtime_ns, second_ambiguous) = mtime;
+let timestamp = TruncatedTimestamp::new_truncate(
+mtime_s, mtime_ns, second_ambiguous
+);
+let bytes = f.extract::(py)?;
+let path = HgPath::new(bytes.data(py));
+let res = self.inner(py).borrow_mut().set_clean(
+path, mode, size, timestamp,
+);
+res.or_else(|_| {
+Err(PyErr::new::(py, "Dirstate 
error".to_string()))
+})?;
+Ok(PyNone)
+}
+
 def reset_state(
 ,
 f: PyObject,
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
@@ -21,6 +21,7 @@
 use crate::utils::hg_path::{HgPath, HgPathBuf};
 use crate::DirstateEntry;
 use crate::DirstateError;
+use crate::DirstateMapError;
 use crate::DirstateParents;
 use crate::DirstateStatus;
 use crate::EntryState;
@@ -764,6 +765,32 @@
 Ok(())
 }
 
+fn set_clean(
+ self,
+filename: ,
+old_entry: DirstateEntry,
+mode: u32,
+size: u32,
+mtime: TruncatedTimestamp,
+) -> Result<(), DirstateError> {
+let node = Self::get_or_insert_node(
+self.on_disk,
+ self.unreachable_bytes,
+ self.root,
+filename,
+WithBasename::to_cow_owned,
+|ancestor| {
+if !old_entry.tracked() {
+ancestor.tracked_descendants_count += 1;
+}
+},
+)?;
+let mut new_entry = old_entry.clone();
+new_entry.set_clean(mode, size, mtime);
+node.data = NodeData::Entry(new_entry);
+Ok(())
+}
+
 fn iter_nodes<'tree>(
 &'tree self,
 ) -> impl Iterator<
@@ -881,6 +908,27 @@
 self.with_dmap_mut(|map| map.set_tracked(filename, old_entry_opt))
 }
 
+pub fn set_clean(
+ self,
+filename: ,
+mode: u32,
+size: u32,
+mtime: TruncatedTimestamp,
+) -> Result<(), DirstateError> {
+let old_entry = match self.get(filename)? {
+None => {
+return Err(
+DirstateMapError::PathNotFound(filename.into()).into()
+)
+}
+Some(e) => e,
+};
+self.copy_map_remove(filename)?;
+self.with_dmap_mut(|map| {
+map.set_clean(filename, old_entry, mode, size, mtime)
+})
+}
+
 pub fn reset_state(
  self,
 filename: ,



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


D12503: dirstatemap: move `set_clean` out of common methods

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

REVISION SUMMARY
  This now has a dedicated Rust implementation

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  mercurial/dirstatemap.py

CHANGE DETAILS

diff --git a/mercurial/dirstatemap.py b/mercurial/dirstatemap.py
--- a/mercurial/dirstatemap.py
+++ b/mercurial/dirstatemap.py
@@ -116,14 +116,6 @@
 entry.set_possibly_dirty()
 self._refresh_entry(filename, entry)
 
-def set_clean(self, filename, mode, size, mtime):
-"""mark a file as back to a clean state"""
-entry = self[filename]
-size = size & rangemask
-entry.set_clean(mode, size, mtime)
-self._refresh_entry(filename, entry)
-self.copymap.pop(filename, None)
-
 def set_untracked(self, f):
 """Mark a file as no longer tracked in the dirstate map"""
 entry = self.get(f)
@@ -531,6 +523,14 @@
 self._refresh_entry(filename, entry)
 return new
 
+def set_clean(self, filename, mode, size, mtime):
+"""mark a file as back to a clean state"""
+entry = self[filename]
+size = size & rangemask
+entry.set_clean(mode, size, mtime)
+self._refresh_entry(filename, entry)
+self.copymap.pop(filename, None)
+
 def _refresh_entry(self, f, entry):
 if not entry.any_tracked:
 self._map.pop(f, None)
@@ -712,6 +712,9 @@
 def set_tracked(self, f):
 return self._map.set_tracked(f)
 
+def set_clean(self, filename, mode, size, mtime):
+self._map.set_clean(filename, mode, size, mtime)
+
 def reset_state(
 self,
 filename,



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


D12499: rust-dirstatemap: add Rust implementation of `reset_state`

2022-04-12 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 new API which has already been defined in Python

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  rust/hg-core/src/dirstate/entry.rs
  rust/hg-core/src/dirstate_tree/dirstate_map.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
@@ -15,6 +15,7 @@
 exc, PyBool, PyBytes, PyClone, PyDict, PyErr, PyList, PyNone, PyObject,
 PyResult, Python, PythonObject, ToPyObject, UnsafePyLeaked,
 };
+use hg::dirstate::{ParentFileData, TruncatedTimestamp};
 
 use crate::{
 dirstate::copymap::{CopyMap, CopyMapItemsIterator, CopyMapKeysIterator},
@@ -141,6 +142,55 @@
 Ok(was_tracked.to_py_object(py))
 }
 
+def reset_state(
+,
+f: PyObject,
+wc_tracked: bool,
+p1_tracked: bool,
+p2_info: bool,
+has_meaningful_mtime: bool,
+parentfiledata: Option<(u32, u32, Option<(i64, u32, bool)>)>,
+) -> PyResult {
+let mut has_meaningful_mtime = has_meaningful_mtime;
+let parent_file_data = match parentfiledata {
+None => {
+has_meaningful_mtime = false;
+None
+},
+Some(data) => {
+let (mode, size, mtime_info) = data;
+let mtime = if let Some(mtime_info) = mtime_info {
+let (mtime_s, mtime_ns, second_ambiguous) = mtime_info;
+let timestamp = TruncatedTimestamp::new_truncate(
+mtime_s, mtime_ns, second_ambiguous
+);
+Some(timestamp)
+} else {
+has_meaningful_mtime = false;
+None
+};
+Some(ParentFileData {
+mode_size: Some((mode, size)),
+mtime,
+})
+}
+};
+let bytes = f.extract::(py)?;
+let path = HgPath::new(bytes.data(py));
+let res = self.inner(py).borrow_mut().reset_state(
+path,
+wc_tracked,
+p1_tracked,
+p2_info,
+has_meaningful_mtime,
+parent_file_data,
+);
+res.or_else(|_| {
+Err(PyErr::new::(py, "Dirstate 
error".to_string()))
+})?;
+Ok(PyNone)
+}
+
 def removefile(
 ,
 f: PyObject,
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
@@ -11,6 +11,8 @@
 use crate::dirstate::parsers::packed_entry_size;
 use crate::dirstate::parsers::parse_dirstate_entries;
 use crate::dirstate::CopyMapIter;
+use crate::dirstate::DirstateV2Data;
+use crate::dirstate::ParentFileData;
 use crate::dirstate::StateMapIter;
 use crate::dirstate::TruncatedTimestamp;
 use crate::dirstate::SIZE_FROM_OTHER_PARENT;
@@ -606,6 +608,73 @@
 }
 }
 
+fn reset_state(
+ self,
+filename: ,
+old_entry_opt: Option,
+wc_tracked: bool,
+p1_tracked: bool,
+p2_info: bool,
+has_meaningful_mtime: bool,
+parent_file_data_opt: Option,
+) -> Result<(), DirstateError> {
+let (had_entry, was_tracked) = match old_entry_opt {
+Some(old_entry) => (true, old_entry.tracked()),
+None => (false, false),
+};
+let node = Self::get_or_insert_node(
+self.on_disk,
+ self.unreachable_bytes,
+ self.root,
+filename,
+WithBasename::to_cow_owned,
+|ancestor| {
+if !had_entry {
+ancestor.descendants_with_entry_count += 1;
+}
+if was_tracked {
+if !wc_tracked {
+ancestor.tracked_descendants_count = ancestor
+.tracked_descendants_count
+.checked_sub(1)
+.expect("tracked count to be >= 0");
+}
+} else {
+if wc_tracked {
+ancestor.tracked_descendants_count += 1;
+}
+}
+},
+)?;
+
+let v2_data = if let Some(parent_file_data) = parent_file_data_opt {
+DirstateV2Data {
+wc_tracked,
+p1_tracked,
+p2_info,
+mode_size: parent_file_data.mode_size,
+mtime: if 

D12501: dirstatemap: remove `_insert_entry`

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

REVISION SUMMARY
  This was needed as a compatibility layer for the Python and Rust
  implementations, but it is not called from anywhere in Rust anymore.
  
  The two remaining calls have been inlined.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  mercurial/dirstatemap.py

CHANGE DETAILS

diff --git a/mercurial/dirstatemap.py b/mercurial/dirstatemap.py
--- a/mercurial/dirstatemap.py
+++ b/mercurial/dirstatemap.py
@@ -101,12 +101,6 @@
 def _refresh_entry(self, f, entry):
 """record updated state of an entry"""
 
-def _insert_entry(self, f, entry):
-"""add a new dirstate entry (or replace an unrelated one)
-
-The fact it is actually new is the responsability of the caller
-"""
-
 def _drop_entry(self, f):
 """remove any entry for file f
 
@@ -511,7 +505,7 @@
 has_meaningful_mtime=has_meaningful_mtime,
 parentfiledata=parentfiledata,
 )
-self._insert_entry(filename, entry)
+self._map[filename] = entry
 
 def set_tracked(self, filename):
 new = False
@@ -522,7 +516,7 @@
 wc_tracked=True,
 )
 
-self._insert_entry(filename, entry)
+self._map[filename] = entry
 new = True
 elif not entry.tracked:
 self._dirs_incr(filename, entry)
@@ -541,9 +535,6 @@
 if not entry.any_tracked:
 self._map.pop(f, None)
 
-def _insert_entry(self, f, entry):
-self._map[f] = entry
-
 def _drop_entry(self, f):
 self._map.pop(f, None)
 self.copymap.pop(f, None)
@@ -718,9 +709,6 @@
 else:
 self._map.addfile(f, entry)
 
-def _insert_entry(self, f, entry):
-self._map.addfile(f, entry)
-
 def set_tracked(self, f):
 return self._map.set_tracked(f)
 



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


D12500: dirstatemap: move `reset_state` out of common methods

2022-04-12 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 we have a Rust implementation, we defer to that accordingly.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  mercurial/dirstatemap.py

CHANGE DETAILS

diff --git a/mercurial/dirstatemap.py b/mercurial/dirstatemap.py
--- a/mercurial/dirstatemap.py
+++ b/mercurial/dirstatemap.py
@@ -143,45 +143,6 @@
 self._refresh_entry(f, entry)
 return True
 
-def reset_state(
-self,
-filename,
-wc_tracked=False,
-p1_tracked=False,
-p2_info=False,
-has_meaningful_mtime=True,
-parentfiledata=None,
-):
-"""Set a entry to a given state, diregarding all previous state
-
-This is to be used by the part of the dirstate API dedicated to
-adjusting the dirstate after a update/merge.
-
-note: calling this might result to no entry existing at all if the
-dirstate map does not see any point at having one for this file
-anymore.
-"""
-# copy information are now outdated
-# (maybe new information should be in directly passed to this function)
-self.copymap.pop(filename, None)
-
-if not (p1_tracked or p2_info or wc_tracked):
-old_entry = self._map.get(filename)
-self._drop_entry(filename)
-self._dirs_decr(filename, old_entry=old_entry)
-return
-
-old_entry = self._map.get(filename)
-self._dirs_incr(filename, old_entry)
-entry = DirstateItem(
-wc_tracked=wc_tracked,
-p1_tracked=p1_tracked,
-p2_info=p2_info,
-has_meaningful_mtime=has_meaningful_mtime,
-parentfiledata=parentfiledata,
-)
-self._insert_entry(filename, entry)
-
 ### disk interaction
 
 def _opendirstatefile(self):
@@ -513,6 +474,45 @@
 
 ### code related to manipulation of entries and copy-sources
 
+def reset_state(
+self,
+filename,
+wc_tracked=False,
+p1_tracked=False,
+p2_info=False,
+has_meaningful_mtime=True,
+parentfiledata=None,
+):
+"""Set a entry to a given state, diregarding all previous state
+
+This is to be used by the part of the dirstate API dedicated to
+adjusting the dirstate after a update/merge.
+
+note: calling this might result to no entry existing at all if the
+dirstate map does not see any point at having one for this file
+anymore.
+"""
+# copy information are now outdated
+# (maybe new information should be in directly passed to this function)
+self.copymap.pop(filename, None)
+
+if not (p1_tracked or p2_info or wc_tracked):
+old_entry = self._map.get(filename)
+self._drop_entry(filename)
+self._dirs_decr(filename, old_entry=old_entry)
+return
+
+old_entry = self._map.get(filename)
+self._dirs_incr(filename, old_entry)
+entry = DirstateItem(
+wc_tracked=wc_tracked,
+p1_tracked=p1_tracked,
+p2_info=p2_info,
+has_meaningful_mtime=has_meaningful_mtime,
+parentfiledata=parentfiledata,
+)
+self._insert_entry(filename, entry)
+
 def set_tracked(self, filename):
 new = False
 entry = self.get(filename)
@@ -724,6 +724,24 @@
 def set_tracked(self, f):
 return self._map.set_tracked(f)
 
+def reset_state(
+self,
+filename,
+wc_tracked=False,
+p1_tracked=False,
+p2_info=False,
+has_meaningful_mtime=True,
+parentfiledata=None,
+):
+return self._map.reset_state(
+filename,
+wc_tracked,
+p1_tracked,
+p2_info,
+has_meaningful_mtime,
+parentfiledata,
+)
+
 def _drop_entry(self, f):
 self._map.drop_item_and_copy_source(f)
 



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


D12498: rust-dirstate: introduce intermediate struct for dirstate-v2 data

2022-04-12 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 passed often as a long tuple that is not easy to know the form of, so
  we refactor everything in this struct.
  
  This also renames `wdir_tracked` to follow the Python `wc_tracked`, even 
though
  the on-disk format uses `WDIR_TRACKED`.
  I think a single naming scheme is better, but we can't easily break the Python
  impl now because of extensions, so this is low-effort enough and facilitates
  grepping.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  rust/hg-core/src/dirstate/entry.rs
  rust/hg-core/src/dirstate_tree/on_disk.rs
  rust/hg-cpython/src/dirstate/item.rs

CHANGE DETAILS

diff --git a/rust/hg-cpython/src/dirstate/item.rs 
b/rust/hg-cpython/src/dirstate/item.rs
--- a/rust/hg-cpython/src/dirstate/item.rs
+++ b/rust/hg-cpython/src/dirstate/item.rs
@@ -8,6 +8,7 @@
 use cpython::Python;
 use cpython::PythonObject;
 use hg::dirstate::DirstateEntry;
+use hg::dirstate::DirstateV2Data;
 use hg::dirstate::TruncatedTimestamp;
 use std::cell::Cell;
 
@@ -38,15 +39,15 @@
 }
 }
 }
-let entry = DirstateEntry::from_v2_data(
-wc_tracked,
+let entry = DirstateEntry::from_v2_data(DirstateV2Data {
+wc_tracked: wc_tracked,
 p1_tracked,
 p2_info,
-mode_size_opt,
-mtime_opt,
+mode_size: mode_size_opt,
+mtime: mtime_opt,
 fallback_exec,
 fallback_symlink,
-);
+});
 DirstateItem::create_instance(py, Cell::new(entry))
 }
 
diff --git a/rust/hg-core/src/dirstate_tree/on_disk.rs 
b/rust/hg-core/src/dirstate_tree/on_disk.rs
--- a/rust/hg-core/src/dirstate_tree/on_disk.rs
+++ b/rust/hg-core/src/dirstate_tree/on_disk.rs
@@ -2,7 +2,7 @@
 //!
 //! See `mercurial/helptext/internals/dirstate-v2.txt`
 
-use crate::dirstate::TruncatedTimestamp;
+use crate::dirstate::{DirstateV2Data, TruncatedTimestamp};
 use crate::dirstate_tree::dirstate_map::{self, DirstateMap, NodeRef};
 use crate::dirstate_tree::path_with_basename::WithBasename;
 use crate::errors::HgError;
@@ -412,7 +412,7 @@
 
 fn assume_entry() -> Result {
 // TODO: convert through raw bits instead?
-let wdir_tracked = self.flags().contains(Flags::WDIR_TRACKED);
+let wc_tracked = self.flags().contains(Flags::WDIR_TRACKED);
 let p1_tracked = self.flags().contains(Flags::P1_TRACKED);
 let p2_info = self.flags().contains(Flags::P2_INFO);
 let mode_size = if self.flags().contains(Flags::HAS_MODE_AND_SIZE)
@@ -442,15 +442,15 @@
 } else {
 None
 };
-Ok(DirstateEntry::from_v2_data(
-wdir_tracked,
+Ok(DirstateEntry::from_v2_data(DirstateV2Data {
+wc_tracked,
 p1_tracked,
 p2_info,
 mode_size,
 mtime,
 fallback_exec,
 fallback_symlink,
-))
+}))
 }
 
 pub(super) fn entry(
@@ -490,18 +490,18 @@
 fn from_dirstate_entry(
 entry: ,
 ) -> (Flags, U32Be, PackedTruncatedTimestamp) {
-let (
-wdir_tracked,
+let DirstateV2Data {
+wc_tracked,
 p1_tracked,
 p2_info,
-mode_size_opt,
-mtime_opt,
+mode_size: mode_size_opt,
+mtime: mtime_opt,
 fallback_exec,
 fallback_symlink,
-) = entry.v2_data();
-// TODO: convert throug raw flag bits instead?
+} = entry.v2_data();
+// TODO: convert through raw flag bits instead?
 let mut flags = Flags::empty();
-flags.set(Flags::WDIR_TRACKED, wdir_tracked);
+flags.set(Flags::WDIR_TRACKED, wc_tracked);
 flags.set(Flags::P1_TRACKED, p1_tracked);
 flags.set(Flags::P2_INFO, p2_info);
 let size = if let Some((m, s)) = mode_size_opt {
diff --git a/rust/hg-core/src/dirstate/entry.rs 
b/rust/hg-core/src/dirstate/entry.rs
--- a/rust/hg-core/src/dirstate/entry.rs
+++ b/rust/hg-core/src/dirstate/entry.rs
@@ -248,23 +248,35 @@
 /// dirstate v1 format.
 pub const SIZE_NON_NORMAL: i32 = -1;
 
+#[derive(Debug, Default, Copy, Clone)]
+pub struct DirstateV2Data {
+pub wc_tracked: bool,
+pub p1_tracked: bool,
+pub p2_info: bool,
+pub mode_size: Option<(u32, u32)>,
+pub mtime: Option,
+pub fallback_exec: Option,
+pub fallback_symlink: Option,
+}
+
 impl DirstateEntry {
-pub fn from_v2_data(
-wdir_tracked: bool,
-p1_tracked: bool,
-p2_info: bool,
-mode_size: Option<(u32, u32)>,
-mtime: Option,
-fallback_exec: Option,
-fallback_symlink: Option,
-) -> Self {
+pub fn from_v2_data(v2_data: DirstateV2Data) -> Self {
+let 

D12497: dirstatemap: remove unused parameter from `reset_state`

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

REVISION SUMMARY
  This has no callers using it and is not used inside the method itself.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  mercurial/dirstatemap.py

CHANGE DETAILS

diff --git a/mercurial/dirstatemap.py b/mercurial/dirstatemap.py
--- a/mercurial/dirstatemap.py
+++ b/mercurial/dirstatemap.py
@@ -150,7 +150,6 @@
 p1_tracked=False,
 p2_info=False,
 has_meaningful_mtime=True,
-has_meaningful_data=True,
 parentfiledata=None,
 ):
 """Set a entry to a given state, diregarding all previous state



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


D12496: dirstatemap: move `set_tracked` out of common methods and plug in Rust

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

REVISION SUMMARY
  We now have a Rust-specific implementation of this method, it is no longer
  shared between both implementations.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  mercurial/dirstatemap.py
  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
@@ -131,6 +131,16 @@
 Ok(PyNone)
 }
 
+def set_tracked(, f: PyObject) -> PyResult {
+let bytes = f.extract::(py)?;
+let path = HgPath::new(bytes.data(py));
+let res = self.inner(py).borrow_mut().set_tracked(path);
+let was_tracked = res.or_else(|_| {
+Err(PyErr::new::(py, "Dirstate 
error".to_string()))
+})?;
+Ok(was_tracked.to_py_object(py))
+}
+
 def removefile(
 ,
 f: PyObject,
diff --git a/mercurial/dirstatemap.py b/mercurial/dirstatemap.py
--- a/mercurial/dirstatemap.py
+++ b/mercurial/dirstatemap.py
@@ -130,30 +130,6 @@
 self._refresh_entry(filename, entry)
 self.copymap.pop(filename, None)
 
-def set_tracked(self, filename):
-new = False
-entry = self.get(filename)
-if entry is None:
-self._dirs_incr(filename)
-entry = DirstateItem(
-wc_tracked=True,
-)
-
-self._insert_entry(filename, entry)
-new = True
-elif not entry.tracked:
-self._dirs_incr(filename, entry)
-entry.set_tracked()
-self._refresh_entry(filename, entry)
-new = True
-else:
-# XXX This is probably overkill for more case, but we need this to
-# fully replace the `normallookup` call with `set_tracked` one.
-# Consider smoothing this in the future.
-entry.set_possibly_dirty()
-self._refresh_entry(filename, entry)
-return new
-
 def set_untracked(self, f):
 """Mark a file as no longer tracked in the dirstate map"""
 entry = self.get(f)
@@ -538,6 +514,30 @@
 
 ### code related to manipulation of entries and copy-sources
 
+def set_tracked(self, filename):
+new = False
+entry = self.get(filename)
+if entry is None:
+self._dirs_incr(filename)
+entry = DirstateItem(
+wc_tracked=True,
+)
+
+self._insert_entry(filename, entry)
+new = True
+elif not entry.tracked:
+self._dirs_incr(filename, entry)
+entry.set_tracked()
+self._refresh_entry(filename, entry)
+new = True
+else:
+# XXX This is probably overkill for more case, but we need this to
+# fully replace the `normallookup` call with `set_tracked` one.
+# Consider smoothing this in the future.
+entry.set_possibly_dirty()
+self._refresh_entry(filename, entry)
+return new
+
 def _refresh_entry(self, f, entry):
 if not entry.any_tracked:
 self._map.pop(f, None)
@@ -722,6 +722,9 @@
 def _insert_entry(self, f, entry):
 self._map.addfile(f, entry)
 
+def set_tracked(self, f):
+return self._map.set_tracked(f)
+
 def _drop_entry(self, f):
 self._map.drop_item_and_copy_source(f)
 



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


D12495: rust-dirstatemap: add `set_tracked` method

2022-04-12 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 new dirstate API that has already been moved to in Python.
  It will be used in place of the old `addfile`/`removefile` one.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  rust/hg-core/src/dirstate/entry.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
@@ -606,6 +606,52 @@
 }
 }
 
+fn set_tracked(
+ self,
+filename: ,
+old_entry_opt: Option,
+) -> Result {
+let was_tracked = old_entry_opt.map_or(false, |e| e.tracked());
+let had_entry = old_entry_opt.is_some();
+let tracked_count_increment = if was_tracked { 0 } else { 1 };
+let mut new = false;
+
+let node = Self::get_or_insert_node(
+self.on_disk,
+ self.unreachable_bytes,
+ self.root,
+filename,
+WithBasename::to_cow_owned,
+|ancestor| {
+if !had_entry {
+ancestor.descendants_with_entry_count += 1;
+}
+
+ancestor.tracked_descendants_count += tracked_count_increment;
+},
+)?;
+let new_entry = if let Some(old_entry) = old_entry_opt {
+let mut e = old_entry.clone();
+if e.tracked() {
+// XXX
+// This is probably overkill for more case, but we need this to
+// fully replace the `normallookup` call with `set_tracked`
+// one. Consider smoothing this in the future.
+e.set_possibly_dirty();
+} else {
+new = true;
+e.set_tracked();
+}
+e
+} else {
+self.nodes_with_entry_count += 1;
+new = true;
+DirstateEntry::new_tracked()
+};
+node.data = NodeData::Entry(new_entry);
+Ok(new)
+}
+
 fn add_or_remove_file(
  self,
 path: ,
@@ -758,6 +804,14 @@
 })
 }
 
+pub fn set_tracked(
+ self,
+filename: ,
+) -> Result {
+let old_entry_opt = self.get(filename)?;
+self.with_dmap_mut(|map| map.set_tracked(filename, old_entry_opt))
+}
+
 pub fn remove_file(
  self,
 filename: ,
diff --git a/rust/hg-core/src/dirstate/entry.rs 
b/rust/hg-core/src/dirstate/entry.rs
--- a/rust/hg-core/src/dirstate/entry.rs
+++ b/rust/hg-core/src/dirstate/entry.rs
@@ -367,6 +367,10 @@
 Self::from_v1_data(EntryState::Removed, 0, size, 0)
 }
 
+pub fn new_tracked() -> Self {
+Self::from_v2_data(true, false, false, None, None, None, None)
+}
+
 pub fn tracked() -> bool {
 self.flags.contains(Flags::WDIR_TRACKED)
 }



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


D7542: mail: don't complain about a multi-word email.method

2022-04-12 Thread Raphaël Gomès
This revision is now accepted and ready to land.
Alphare added a comment.
Alphare accepted this revision.


  That's an oldie

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

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

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


D12482: setup: fix incomplete implementation of Command

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


  Pending CI refresh

REVISION SUMMARY
  `test-install.t` fails without the `get_outputs` method being implemented,
  which is used when, `self.report` is `True`.
  
  When 8d7eaff92f9c 
 
introduced this change, they probably ran `test-install.t`
  without `HGTESTS_ALLOW_NETIO=1`, which does not trigger this codepath.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  setup.py

CHANGE DETAILS

diff --git a/setup.py b/setup.py
--- a/setup.py
+++ b/setup.py
@@ -1110,12 +1110,16 @@
 
 def initialize_options(self):
 self.install_dir = None
+self.outputs = []
 
 def finalize_options(self):
 self.set_undefined_options(
 'install_data', ('install_dir', 'install_dir')
 )
 
+def get_outputs(self):
+return self.outputs
+
 def run(self):
 for src, dir_path, dest in (
 (
@@ -1127,9 +1131,10 @@
 ):
 dir = os.path.join(self.install_dir, *dir_path)
 self.mkpath(dir)
-self.copy_file(
-os.path.join('contrib', src), os.path.join(dir, dest)
-)
+
+dest = os.path.join(dir, dest)
+self.outputs.append(dest)
+self.copy_file(os.path.join('contrib', src), dest)
 
 
 # virtualenv installs custom distutils/__init__.py and



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


D12478: rust-dirstatemap: add unit tests

2022-04-06 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 missing and have already proven valuable since they have found
  two bugs (fixed in previous patches).
  
  There may be other behavior to test, but this gives us a decent coverage.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

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
@@ -1427,3 +1427,417 @@
 }))
 }
 }
+#[cfg(test)]
+mod tests {
+use super::*;
+
+/// Shortcut to return tracked descendants of a path.
+/// Panics if the path does not exist.
+fn tracked_descendants(map: , path: &[u8]) -> u32 {
+let path = dbg!(HgPath::new(path));
+let node = map.get_map().get_node(path);
+node.unwrap().unwrap().tracked_descendants_count()
+}
+
+/// Shortcut to return descendants with an entry.
+/// Panics if the path does not exist.
+fn descendants_with_an_entry(map: , path: &[u8]) -> u32 {
+let path = dbg!(HgPath::new(path));
+let node = map.get_map().get_node(path);
+node.unwrap().unwrap().descendants_with_entry_count()
+}
+
+fn assert_does_not_exist(map: , path: &[u8]) {
+let path = dbg!(HgPath::new(path));
+let node = map.get_map().get_node(path);
+assert!(node.unwrap().is_none());
+}
+
+/// Shortcut for path creation in tests
+fn p(b: &[u8]) ->  {
+HgPath::new(b)
+}
+
+/// Test the very simple case a single tracked file
+#[test]
+fn test_tracked_descendants_simple() -> Result<(), DirstateError> {
+let mut map = OwningDirstateMap::new_empty(vec![]);
+assert_eq!(map.len(), 0);
+
+map.set_tracked(p(b"some/nested/path"))?;
+
+assert_eq!(map.len(), 1);
+assert_eq!(tracked_descendants(, b"some"), 1);
+assert_eq!(tracked_descendants(, b"some/nested"), 1);
+assert_eq!(tracked_descendants(, b"some/nested/path"), 0);
+
+map.set_untracked(p(b"some/nested/path"))?;
+assert_eq!(map.len(), 0);
+assert!(map.get_map().get_node(p(b"some"))?.is_none());
+
+Ok(())
+}
+
+/// Test the simple case of all tracked, but multiple files
+#[test]
+fn test_tracked_descendants_multiple() -> Result<(), DirstateError> {
+let mut map = OwningDirstateMap::new_empty(vec![]);
+
+map.set_tracked(p(b"some/nested/path"))?;
+map.set_tracked(p(b"some/nested/file"))?;
+// one layer without any files to test deletion cascade
+map.set_tracked(p(b"some/other/nested/path"))?;
+map.set_tracked(p(b"root_file"))?;
+map.set_tracked(p(b"some/file"))?;
+map.set_tracked(p(b"some/file2"))?;
+map.set_tracked(p(b"some/file3"))?;
+
+assert_eq!(map.len(), 7);
+assert_eq!(tracked_descendants(, b"some"), 6);
+assert_eq!(tracked_descendants(, b"some/nested"), 2);
+assert_eq!(tracked_descendants(, b"some/other"), 1);
+assert_eq!(tracked_descendants(, b"some/other/nested"), 1);
+assert_eq!(tracked_descendants(, b"some/nested/path"), 0);
+
+map.set_untracked(p(b"some/nested/path"))?;
+assert_eq!(map.len(), 6);
+assert_eq!(tracked_descendants(, b"some"), 5);
+assert_eq!(tracked_descendants(, b"some/nested"), 1);
+assert_eq!(tracked_descendants(, b"some/other"), 1);
+assert_eq!(tracked_descendants(, b"some/other/nested"), 1);
+
+map.set_untracked(p(b"some/nested/file"))?;
+assert_eq!(map.len(), 5);
+assert_eq!(tracked_descendants(, b"some"), 4);
+assert_eq!(tracked_descendants(, b"some/other"), 1);
+assert_eq!(tracked_descendants(, b"some/other/nested"), 1);
+assert_does_not_exist(, b"some_nested");
+
+map.set_untracked(p(b"some/other/nested/path"))?;
+assert_eq!(map.len(), 4);
+assert_eq!(tracked_descendants(, b"some"), 3);
+assert_does_not_exist(, b"some/other");
+
+map.set_untracked(p(b"root_file"))?;
+assert_eq!(map.len(), 3);
+assert_eq!(tracked_descendants(, b"some"), 3);
+assert_does_not_exist(, b"root_file");
+
+map.set_untracked(p(b"some/file"))?;
+assert_eq!(map.len(), 2);
+assert_eq!(tracked_descendants(, b"some"), 2);
+assert_does_not_exist(, b"some/file");
+
+map.set_untracked(p(b"some/file2"))?;
+assert_eq!(map.len(), 1);
+assert_eq!(tracked_descendants(, b"some"), 1);
+assert_does_not_exist(, b"some/file2");
+
+map.set_untracked(p(b"some/file3"))?;
+assert_eq!(map.len(), 0);
+

D12477: rust: add `Debug` trait to a bunch of structs

2022-04-06 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 useful when... debugging. Right now the output is not in the most
  readable state it could be, but this is very low effort and is good enough
  for now. We may want to write a nicer custom debug formatter for some of those
  structs in the future.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

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

CHANGE DETAILS

diff --git a/rust/hg-core/src/dirstate_tree/on_disk.rs 
b/rust/hg-core/src/dirstate_tree/on_disk.rs
--- a/rust/hg-core/src/dirstate_tree/on_disk.rs
+++ b/rust/hg-core/src/dirstate_tree/on_disk.rs
@@ -84,7 +84,7 @@
 
 /// Fields are documented in the *The data file format*
 /// section of `mercurial/helptext/internals/dirstate-v2.txt`
-#[derive(BytesCast)]
+#[derive(BytesCast, Debug)]
 #[repr(C)]
 pub(super) struct Node {
 full_path: PathSlice,
@@ -124,7 +124,7 @@
 }
 
 /// Duration since the Unix epoch
-#[derive(BytesCast, Copy, Clone)]
+#[derive(BytesCast, Copy, Clone, Debug)]
 #[repr(C)]
 struct PackedTruncatedTimestamp {
 truncated_seconds: U32Be,
@@ -152,7 +152,7 @@
 /// Always sorted by ascending `full_path`, to allow binary search.
 /// Since nodes with the same parent nodes also have the same parent path,
 /// only the `base_name`s need to be compared during binary search.
-#[derive(BytesCast, Copy, Clone)]
+#[derive(BytesCast, Copy, Clone, Debug)]
 #[repr(C)]
 struct ChildNodes {
 start: Offset,
@@ -160,7 +160,7 @@
 }
 
 /// A `HgPath` of `len` bytes
-#[derive(BytesCast, Copy, Clone)]
+#[derive(BytesCast, Copy, Clone, Debug)]
 #[repr(C)]
 struct PathSlice {
 start: Offset,
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
@@ -32,6 +32,7 @@
 /// anymore) is less than this fraction of the total amount of existing data.
 const ACCEPTABLE_UNREACHABLE_BYTES_RATIO: f32 = 0.5;
 
+#[derive(Debug)]
 pub struct DirstateMap<'on_disk> {
 /// Contents of the `.hg/dirstate` file
 pub(super) on_disk: &'on_disk [u8],
@@ -61,21 +62,25 @@
 
 /// Similar to `&'tree Cow<'on_disk, HgPath>`, but can also be returned
 /// for on-disk nodes that don’t actually have a `Cow` to borrow.
+#[derive(Debug)]
 pub(super) enum BorrowedPath<'tree, 'on_disk> {
 InMemory(&'tree HgPathBuf),
 OnDisk(&'on_disk HgPath),
 }
 
+#[derive(Debug)]
 pub(super) enum ChildNodes<'on_disk> {
 InMemory(FastHashMap, Node<'on_disk>>),
 OnDisk(&'on_disk [on_disk::Node]),
 }
 
+#[derive(Debug)]
 pub(super) enum ChildNodesRef<'tree, 'on_disk> {
 InMemory(&'tree FastHashMap, Node<'on_disk>>),
 OnDisk(&'on_disk [on_disk::Node]),
 }
 
+#[derive(Debug)]
 pub(super) enum NodeRef<'tree, 'on_disk> {
 InMemory(&'tree NodeKey<'on_disk>, &'tree Node<'on_disk>),
 OnDisk(&'on_disk on_disk::Node),
@@ -383,7 +388,7 @@
 }
 
 /// Represents a file or a directory
-#[derive(Default)]
+#[derive(Default, Debug)]
 pub(super) struct Node<'on_disk> {
 pub(super) data: NodeData,
 
@@ -399,6 +404,7 @@
 pub(super) tracked_descendants_count: u32,
 }
 
+#[derive(Debug)]
 pub(super) enum NodeData {
 Entry(DirstateEntry),
 CachedDirectory { mtime: TruncatedTimestamp },



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


D12476: rust-dirstatemap: use `` instead of `HgPathBuf` in `copy_map_insert`

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

REVISION SUMMARY
  No reason to require an owned path here.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  rust/hg-core/src/dirstate_tree/dirstate_map.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
@@ -23,13 +23,10 @@
 pybytes_deref::PyBytesDeref,
 };
 use hg::{
-dirstate::StateMapIter,
-dirstate_tree::on_disk::DirstateV2ParseError,
-dirstate_tree::owning::OwningDirstateMap,
-revlog::Node,
-utils::files::normalize_case,
-utils::hg_path::{HgPath, HgPathBuf},
-DirstateEntry, DirstateError, DirstateParents, EntryState,
+dirstate::StateMapIter, dirstate_tree::on_disk::DirstateV2ParseError,
+dirstate_tree::owning::OwningDirstateMap, revlog::Node,
+utils::files::normalize_case, utils::hg_path::HgPath, DirstateEntry,
+DirstateError, DirstateParents, EntryState,
 };
 
 // TODO
@@ -428,8 +425,8 @@
 self.inner(py)
 .borrow_mut()
 .copy_map_insert(
-HgPathBuf::from_bytes(key.data(py)),
-HgPathBuf::from_bytes(value.data(py)),
+HgPath::new(key.data(py)),
+HgPath::new(value.data(py)),
 )
 .map_err(|e| v2_error(py, e))?;
 Ok(py.None())
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
@@ -1278,8 +1278,8 @@
 
 pub fn copy_map_insert(
  self,
-key: HgPathBuf,
-value: HgPathBuf,
+key: ,
+value: ,
 ) -> Result, DirstateV2ParseError> {
 self.with_dmap_mut(|map| {
 let node = DirstateMap::get_or_insert_node(
@@ -1293,7 +1293,10 @@
 if node.copy_source.is_none() {
 map.nodes_with_copy_source_count += 1
 }
-Ok(node.copy_source.replace(value.into()).map(Cow::into_owned))
+Ok(node
+.copy_source
+.replace(value.to_owned().into())
+.map(Cow::into_owned))
 })
 }
 



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


D12475: rust-dirstatemap: use `DirstateEntry::tracked` directly

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

REVISION SUMMARY
  `state()` is a legacy API that will be removed at some point, let's use the
  newer API.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

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
@@ -982,9 +982,7 @@
  self,
 filename: ,
 ) -> Result<(), DirstateError> {
-let was_tracked = self
-.get(filename)?
-.map_or(false, |e| e.state().is_tracked());
+let was_tracked = self.get(filename)?.map_or(false, |e| e.tracked());
 struct Dropped {
 was_tracked: bool,
 had_entry: bool,



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


D12473: rust-dirstatemap: remove `set_dirstate_entry`/`set_entry` methods

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

REVISION SUMMARY
  These methods were needed crutches before the Rust implementation caught up
  to Python. Calling `set_entry` (whether from Python or Rust) was dangerous
  since it didn't update any of the counters of the DirstateMap data structure,
  while having no real way of knowing when to use it "correctly" except it you
  were one of the 3 people who looked deep enough into the soul of this code.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  rust/hg-core/src/dirstate_tree/dirstate_map.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
@@ -104,20 +104,6 @@
 }
 }
 
-def set_dirstate_item(
-,
-path: PyObject,
-item: DirstateItem
-) -> PyResult {
-let f = path.extract::(py)?;
-let filename = HgPath::new(f.data(py));
-self.inner(py)
-.borrow_mut()
-.set_entry(filename, item.get_entry(py))
-.map_err(|e| v2_error(py, e))?;
-Ok(py.None())
-}
-
 def set_tracked(, f: PyObject) -> PyResult {
 Ok(self.inner(py).borrow_mut()
 .set_tracked(
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
@@ -878,17 +878,6 @@
 });
 }
 
-pub fn set_entry(
- self,
-filename: ,
-entry: DirstateEntry,
-) -> Result<(), DirstateV2ParseError> {
-self.with_dmap_mut(|map| {
-map.get_or_insert()?.data = NodeData::Entry(entry);
-Ok(())
-})
-}
-
 pub fn set_tracked(
  self,
 filename: ,



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


D12474: rust-cpython: remove unused API to `drop_entry_and_copy_source`

2022-04-06 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 used anywhere anymore and its use cases are covered by the new API

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  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
@@ -222,17 +222,6 @@
 Ok(PyNone)
 }
 
-def drop_item_and_copy_source(
-,
-f: PyBytes,
-) -> PyResult {
-self.inner(py)
-.borrow_mut()
-.drop_entry_and_copy_source(HgPath::new(f.data(py)))
-.map_err(|e |dirstate_error(py, e))?;
-Ok(PyNone)
-}
-
 def hastrackeddir(, d: PyObject) -> PyResult {
 let d = d.extract::(py)?;
 Ok(self.inner(py).borrow_mut()



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


D12472: rust-dirstatemap: implement part of the `setparents` logic

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

REVISION SUMMARY
  The Python code does many round-trip calls to the Rust dirstatemap when copy
  information needs to be dropped in `setparents`.
  
  This may result in improved performance on `commit`, `update` and other such
  commands, but was mostly done to drop the last use of `set_dirstate_item`.
  See inline comments for an asterisk about performance, and see next patch for
  why `set_dirstate_item` has to go.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  mercurial/dirstatemap.py
  rust/hg-core/src/dirstate_tree/dirstate_map.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
@@ -506,6 +506,19 @@
 Ok(dirs)
 }
 
+def setparents_fixup() -> PyResult {
+let dict = PyDict::new(py);
+let copies = self.inner(py).borrow_mut().setparents_fixup();
+for (key, value) in copies.map_err(|e| v2_error(py, e))? {
+dict.set_item(
+py,
+PyBytes::new(py, key.as_bytes()),
+PyBytes::new(py, value.as_bytes()),
+)?;
+}
+Ok(dict)
+}
+
 def debug_iter(, all: bool) -> PyResult {
 let dirs = PyList::new(py, &[]);
 for item in self.inner(py).borrow().debug_iter(all) {
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
@@ -1369,6 +1369,41 @@
 )))
 }
 
+/// Only public because it needs to be exposed to the Python layer.
+/// It is not the full `setparents` logic, only the parts that mutate the
+/// entries.
+pub fn setparents_fixup(
+ self,
+) -> Result, DirstateV2ParseError> {
+// XXX
+// All the copying and re-querying is quite inefficient, but this is
+// still a lot better than doing it from Python.
+//
+// The better solution is to develop a mechanism for `iter_mut`,
+// which will be a lot more involved: we're dealing with a lazy,
+// append-mostly, tree-like data structure. This will do for now.
+let mut copies = vec![];
+let mut files_with_p2_info = vec![];
+for res in self.iter() {
+let (path, entry) = res?;
+if entry.p2_info() {
+files_with_p2_info.push(path.to_owned())
+}
+}
+self.with_dmap_mut(|map| {
+for path in files_with_p2_info.iter() {
+let node = map.get_or_insert(path)?;
+let entry =
+node.data.as_entry_mut().expect("entry should exist");
+entry.drop_merge_data();
+if let Some(source) = node.copy_source.take().as_deref() {
+copies.push((path.to_owned(), source.to_owned()));
+}
+}
+Ok(copies)
+})
+}
+
 pub fn debug_iter(
 ,
 all: bool,
diff --git a/mercurial/dirstatemap.py b/mercurial/dirstatemap.py
--- a/mercurial/dirstatemap.py
+++ b/mercurial/dirstatemap.py
@@ -593,22 +593,7 @@
 self._dirtyparents = True
 copies = {}
 if fold_p2:
-# Collect into an intermediate list to avoid a `RuntimeError`
-# exception due to mutation during iteration.
-# TODO: move this the whole loop to Rust where `iter_mut`
-# enables in-place mutation of elements of a collection while
-# iterating it, without mutating the collection itself.
-files_with_p2_info = [
-f for f, s in self._map.items() if s.p2_info
-]
-rust_map = self._map
-for f in files_with_p2_info:
-e = rust_map.get(f)
-source = self.copymap.pop(f, None)
-if source:
-copies[f] = source
-e.drop_merge_data()
-rust_map.set_dirstate_item(f, e)
+copies = self._map.setparents_fixup()
 return copies
 
 ### disk interaction



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


D12471: dirstate-item: add missing bit of docstring

2022-04-06 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/D12471

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
@@ -278,7 +278,7 @@
 self._mtime_ns = None
 
 def drop_merge_data(self):
-"""remove all "merge-only" from a DirstateItem
+"""remove all "merge-only" information from a DirstateItem
 
 This is to be call by the dirstatemap code when the second parent is 
dropped
 """



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


D12470: dirstatemap: move `_dirs_incr` and `_dirs_decr` methods out of the common

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

REVISION SUMMARY
  They are only used by the Python implementation now

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  mercurial/dirstatemap.py

CHANGE DETAILS

diff --git a/mercurial/dirstatemap.py b/mercurial/dirstatemap.py
--- a/mercurial/dirstatemap.py
+++ b/mercurial/dirstatemap.py
@@ -79,25 +79,6 @@
 def __getitem__(self, item):
 return self._map[item]
 
-### sub-class utility method
-#
-# Use to allow for generic implementation of some method while still coping
-# with minor difference between implementation.
-
-def _dirs_incr(self, filename, old_entry=None):
-"""increment the dirstate counter if applicable
-
-This might be a no-op for some subclasses who deal with directory
-tracking in a different way.
-"""
-
-def _dirs_decr(self, filename, old_entry=None, remove_variant=False):
-"""decrement the dirstate counter if applicable
-
-This might be a no-op for some subclasses who deal with directory
-tracking in a different way.
-"""
-
 ### disk interaction
 
 def _opendirstatefile(self):
@@ -354,7 +335,7 @@
 # (e.g. "has_dir")
 
 def _dirs_incr(self, filename, old_entry=None):
-"""incremente the dirstate counter if applicable"""
+"""increment the dirstate counter if applicable"""
 if (
 old_entry is None or old_entry.removed
 ) and "_dirs" in self.__dict__:
@@ -363,7 +344,7 @@
 self._alldirs.addpath(filename)
 
 def _dirs_decr(self, filename, old_entry=None, remove_variant=False):
-"""decremente the dirstate counter if applicable"""
+"""decrement the dirstate counter if applicable"""
 if old_entry is not None:
 if "_dirs" in self.__dict__ and not old_entry.removed:
 self._dirs.delpath(filename)



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


D12469: dirstatemap: move `_refresh_entry` out of the common methods

2022-04-06 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 only used in the Python implementation now

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  mercurial/dirstatemap.py

CHANGE DETAILS

diff --git a/mercurial/dirstatemap.py b/mercurial/dirstatemap.py
--- a/mercurial/dirstatemap.py
+++ b/mercurial/dirstatemap.py
@@ -98,9 +98,6 @@
 tracking in a different way.
 """
 
-def _refresh_entry(self, f, entry):
-"""record updated state of an entry"""
-
 ### disk interaction
 
 def _opendirstatefile(self):
@@ -523,6 +520,7 @@
 self._refresh_entry(filename, entry)
 
 def _refresh_entry(self, f, entry):
+"""record updated state of an entry"""
 if not entry.any_tracked:
 self._map.pop(f, 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


D12468: dirstatemap: move `_drop_entry` out of the common methods

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

REVISION SUMMARY
  Only the Python implementation uses it.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  mercurial/dirstatemap.py

CHANGE DETAILS

diff --git a/mercurial/dirstatemap.py b/mercurial/dirstatemap.py
--- a/mercurial/dirstatemap.py
+++ b/mercurial/dirstatemap.py
@@ -101,13 +101,6 @@
 def _refresh_entry(self, f, entry):
 """record updated state of an entry"""
 
-def _drop_entry(self, f):
-"""remove any entry for file f
-
-This should also drop associated copy information
-
-The fact we actually need to drop it is the responsability of the 
caller"""
-
 ### disk interaction
 
 def _opendirstatefile(self):
@@ -534,6 +527,11 @@
 self._map.pop(f, None)
 
 def _drop_entry(self, f):
+"""remove any entry for file f
+
+This should also drop associated copy information
+
+The fact we actually need to drop it is the responsability of the 
caller"""
 self._map.pop(f, None)
 self.copymap.pop(f, 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


D12467: rust-dirstatemap: remove `_drop_entry`

2022-04-06 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 used anywhere anymore

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  mercurial/dirstatemap.py

CHANGE DETAILS

diff --git a/mercurial/dirstatemap.py b/mercurial/dirstatemap.py
--- a/mercurial/dirstatemap.py
+++ b/mercurial/dirstatemap.py
@@ -730,6 +730,3 @@
 has_meaningful_mtime,
 parentfiledata,
 )
-
-def _drop_entry(self, f):
-self._map.drop_item_and_copy_source(f)



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


  1   2   3   4   5   6   7   8   9   10   >