Re: [PATCH] hgrc: search XDG_CONFIG_HOME on Mac

2024-04-25 Thread Pierre-Yves David
Your patch mostly fell into the cracks. We seldomly have email 
contribution these days and it arrive a week were the bulk of reviewer 
where busy IRL.


The code you change seems to be been introduced in 354020079723 ¹ with 
the idea that Mac Os X won't respect this env variable. However it does 
not seems to hurt to comply to it if present and have seen multiple 
other project doing the same.


A test was introduced allow side the original change, with Os X 
exclusion. I have modified this patch in the version of you patch that I 
send into our usual review-pipeline:


https://foss.heptapod.net/mercurial/mercurial-devel/-/merge_requests/848

[1] https://repo.mercurial-scm.org/hg/rev/354020079723

On 4/22/24 23:33, Hraban Luyat via Mercurial-devel wrote:

Hi, did anything happen regarding this patch? Was it rejected / accepted / 
ignored?

On Tuesday, March 26th, 2024 at 1:36 AM, Hraban  wrote:



# HG changeset patch
# User Hraban luyathra...@0brg.net

# Date 1711430847 14400
# Tue Mar 26 01:27:27 2024 -0400
# Node ID 8bc5a4e12666c85e246f175f6bd3136678f8a5ba
# Parent 4a8bb136ee779b9763a6dfcdb707ba5894f5e36d
hgrc: search XDG_CONFIG_HOME on mac

Searching for hgrc was special cased not to look through ~/.config/hg on
Mac,
but that’s unnecessary: Macs support it as do other unix based systems.
There
are plenty tools that use it there, e.g. git, and people expect it to work,
e.g.
"https://stackoverflow.com/questions/72499837/mercurial-on-macos-doesnt-read-config-hg-hgrc;.

diff -r 4a8bb136ee77 -r 8bc5a4e12666 mercurial/scmposix.py
--- a/mercurial/scmposix.py Thu Mar 07 10:57:16 2024 +0100
+++ b/mercurial/scmposix.py Tue Mar 26 01:27:27 2024 -0400
@@ -60,8 +60,6 @@
def userrcpath() -> List[bytes]:

if pycompat.sysplatform == b'plan9':
return [encoding.environ[b'home'] + b'/lib/hgrc']
- elif pycompat.isdarwin:
- return [os.path.expanduser(b'~/.hgrc')]
else:
confighome = encoding.environ.get(b'XDG_CONFIG_HOME')
if confighome is None or not os.path.isabs(confighome):

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


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


Re: Accidental modification of mercurial.changelog._defaultextra

2024-02-01 Thread Pierre-Yves David


On 2/1/24 10:08, Manuel Jacob wrote:
When the raw extra field on a changeset is missing, the 
mercurial.changelog.changelogrevision.extra property returns the 
_defaultextra dictionary as-is. Method 
mercurial.context.changectx.extra() returns that property as-is. The 
problem is that if someone changes the return value in this case, all 
later calls to mercurial.context.changectx.extra() on changesets 
without the raw extra field will return a dictionary containing these 
changes.


To check whether the problem results in bugs in practice, I changed 
the mercurial.changelog.changelogrevision.extra property to return a 
read-only proxy to _defaultextra. Three tests fail because of this: 
https://foss.heptapod.net/mercurial/mercurial-devel/-/jobs/2253663


We could change the mercurial.changelog.changelogrevision.extra 
property to always return a new dictionary. This is already the case 
if a changeset has the raw extra field.


If we don’t want to return a copied dictionary when a changeset has no 
raw extra field, we would need to fix all callers that modify the 
dictionary to copy it first instead of modifying the returned 
dictionary. In the cases when the returned dictionary is already a 
copied dictionary (i.e. if the changeset has the raw extra field), it 
would be redundant.


If we make it part of the contract that the returned extra dictionary 
should not be modified, should that contract be enforced somehow? We 
could return types.MappingProxyType (1) never, (2) always or (3) only 
when _defaultextra is returned.


What do you think?



I think this is a pretty good catch, thanks you.

I don't believe this is reasonable to assume or enforce that caller will 
not modify the returned dictionnary, and we should return a new 
dictionnary in all cases. I don't expect any significant performance 
impact from this.


Would you send a patch in that direction ?

--

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


Re: Configurable resource usage profile and repository role

2023-10-09 Thread Pierre-Yves David
I create a MR to create such option, not fully convinced with the naming 
yet, but that is a starting point.



https://foss.heptapod.net/mercurial/mercurial-devel/-/merge_requests/682

On 9/13/23 16:45, Mathias De Mare (Nokia) wrote:



-Original Message-
From: Pierre-Yves David 
Sent: Wednesday, September 13, 2023 12:36 PM
To: mercurial-devel 
Cc: Joerg Sonnenberger ; Mathias De Mare (Nokia)

Subject: Configurable resource usage profile and repository role


CAUTION: This is an external email. Please be very careful when clicking links 
or
opening attachments. See the URL nok.it/ext for additional information.



Hello everyone,

I would like to submit some development though and possible directions for
Mercurial performance-behavior in the future.


One of the key principle of Mercurial since its conception is "versatility".
Mercurial is built to be as suitable for small repositories, large repositories,
small teams, large teams, small hardware, large hardware. This approach is
pretty nice and have been working reasonably well so far.

However, when it comes to performance optimization, this approach reach
some limitation. For example, using more memory for caches can have a big
impact on some operation, but could cripples them on smaller hardware. In
the same ways, some expensive computation are necessary for smooth server
operation, but would signicantly slow down operation on developer machine.

So I think it would make sense to introduce two sets of configuration:

- the first one for finer control about resource profiles, (that would adjust 
the
default setting for some configuration),

- the second one to clearer declaration of the repository intended usage, (that
would adjust the default setting for some configuration),

Having resource profiles and usage profiles looks like it would have a few nice 
benefits:
- It would make a lot of configuration easier (I think we still have some 
settings behind flags, or indeed caches set to relatively low values).
- It would help have less 'missed configuration': every so often, I notice an 
interesting performance-related flag that we simply did not have set.
- It would perhaps introduce new settings to at least a subset of users sooner (by 
enabling them for the "high" level, for example).

I'm definitely in favour of this.

Both for resource profile and usage profile, I think it would be also be useful 
to print some kind of warning message when doing a new clone if no resource or 
usage profile is set.

One thing that worries me a bit: do we let "low", "medium" and "high" evolve in 
the future? I know we have backwards-compatibility to keep in mind, so maybe we should clearly define this as 
something that is not set in stone (and never will be)?



# About resource profile

I can see about three areas were resource usage could be adjusted:
memory, cpu and storage.

Having three levels would be a good start, "low", "medium" (the default) and
"high". (maybe with a fourth option that control all other at the same time)

  From this configuration, we could adjust some of the current value (especially
cache size) and some behavior. For example if the storage is marked as "low"
and the "cpu" is marked as "high", more time can be spent optimizing the
storage.

I could go into more example of what we could adjust here, but I did not want
this initial email to grow too large.


# About usage profile :

The way a repository is used can change the tradeoff that works best for it. For
example, if you make a disposable clone for a CI runner, we really don't care
about optimizing the storage information received from the server, that clone
will be dead in a couple of minutes, on the other hand, if you are the server
holding the main copy of a repository, it make sense to carefully validate and
optimize the small content you receive from your client pushes.

We would definitely be interested in profiles like this, especially for the two 
use cases you mention. Anything that makes our CI runners faster is welcome 

Greetings,
Mathias

I can think of the following role we could declare (with different level of
precision).

- server
- main
- mirror
- client
- developer
- read-only
- ci
  - temporary
  - persistent


(again, I am not going into too much details to keep this email short.

I guess I am not the only one to think about these problems, so I am curious to
hear your though.

--
Pierre-Yves David

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


--
Pierre-Yves David

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


Configurable resource usage profile and repository role

2023-09-13 Thread Pierre-Yves David

Hello everyone,

I would like to submit some development though and possible directions 
for Mercurial performance-behavior in the future.



One of the key principle of Mercurial since its conception is 
"versatility". Mercurial is built to be as suitable for small 
repositories, large repositories, small teams, large teams, small 
hardware, large hardware. This approach is pretty nice and have been 
working reasonably well so far.


However, when it comes to performance optimization, this approach reach 
some limitation. For example, using more memory for caches can have a 
big impact on some operation, but could cripples them on smaller 
hardware. In the same ways, some expensive computation are necessary for 
smooth server operation, but would signicantly slow down operation on 
developer machine.


So I think it would make sense to introduce two sets of configuration:

- the first one for finer control about resource profiles, (that would 
adjust the default setting for some configuration),


- the second one to clearer declaration of the repository intended 
usage, (that would adjust the default setting for some configuration),



# About resource profile

I can see about three areas were resource usage could be adjusted: 
memory, cpu and storage.


Having three levels would be a good start, "low", "medium" (the default) 
and "high". (maybe with a fourth option that control all other at the 
same time)


From this configuration, we could adjust some of the current value 
(especially cache size) and some behavior. For example if the storage is 
marked as "low" and the "cpu" is marked as "high", more time can be 
spent optimizing the storage.


I could go into more example of what we could adjust here, but I did not 
want this initial email to grow too large.



# About usage profile :

The way a repository is used can change the tradeoff that works best for 
it. For example, if you make a disposable clone for a CI runner, we 
really don't care about optimizing the storage information received from 
the server, that clone will be dead in a couple of minutes, on the other 
hand, if you are the server holding the main copy of a repository, it 
make sense to carefully validate and optimize the small content you 
receive from your client pushes.


I can think of the following role we could declare (with different level 
of precision).


- server
  - main
  - mirror
- client
  - developer
  - read-only
  - ci
    - temporary
    - persistent


(again, I am not going into too much details to keep this email short.

I guess I am not the only one to think about these problems, so I am 
curious to hear your though.


--
Pierre-Yves David

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


Re: [PATCH] histedit: fix diff colors

2023-03-20 Thread Pierre-Yves David

pushed on stable though heptapod. Thanks

On 3/15/23 19:55, Jordi Gutiérrez Hermoso wrote:

# HG changeset patch
# User Jordi Gutiérrez Hermoso 
# Date 1666906442 14400
#  Thu Oct 27 17:34:02 2022 -0400
# Node ID 28cad0a7eb26a3bb0edd4623d1ec1c9169eb49e2
# Parent  dd42156b6441f6b8356100b4228fa16fbf95f669
histedit: fix diff colors

The problem here is that indexing a bytestring gives you integers, not
chars, so the comparison to b'+' ends up being wrong.

We don't really have a way to test curses output, so no tests to
verify the correctness of this behaviour.

diff --git a/hgext/histedit.py b/hgext/histedit.py
--- a/hgext/histedit.py
+++ b/hgext/histedit.py
@@ -1427,11 +1427,11 @@ pgup/K: move patch up, pgdn/J: move patc
  for y in range(0, length):
  line = output[y]
  if diffcolors:
-if line and line[0] == b'+':
+if line.startswith(b'+'):
  win.addstr(
  y, 0, line, curses.color_pair(COLOR_DIFF_ADD_LINE)
  )
-elif line and line[0] == b'-':
+elif line.startswith(b'-'):
  win.addstr(
  y, 0, line, curses.color_pair(COLOR_DIFF_DEL_LINE)
  )
___
Mercurial-devel mailing list
Mercurial-devel@lists.mercurial-scm.org
https://lists.mercurial-scm.org/mailman/listinfo/mercurial-devel


--
Pierre-Yves David

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


resuming the command namespacing effort

2023-03-13 Thread Pierre-Yves David

Hi everyone,

A while back (at the last online sprint) we discussed the idea of 
introducing some command namespacing to clarify the command space a bit. 
The initial motivation is to clarify the currently implicit "debug" 
namespace that mixes all sort of commands, from massive foot-guns to 
quite reasonable routine administration commands. There are no plan to 
move command used in normal operations of "standard users" in namespace. 
"moving to a namespace" always mean a command "rename", keeping the 
previous name as a deprecated alias.


I am planning to resume working on command name-spacing this cycle. 
Introducing new command in namespace when applicable and moving some of 
the existing one when it make sense.


The currently planned namespaces are:

*# admin*
Commands that a server/site administrator might have to run as part of 
server/user management. For example:


- cache warming,
- repository format inspection and upgrade
- clone bundle management
- history stripping
- lock management ?

*# debug
*Nobody should need to run this command but Mercurial developers and 
people instructed to do so by mercurial developer, this should cover
- command that extract debug information about the repository raw 
content, statistic, encoding and efficiency,

- foot-guns (why do we have foot-guns ?)

*# script*
Command useful for scripting, their behavior and output should be script 
friendly (instead of user friendly) and they should help common 
operation needed during scripting. For example:


- checking working copy status (is the dirstate clean)
- checking if a revset match anything
- locking utility ?

*# perf*

performance command from the perf extension,. this namespace actually 
already exists for a handful of versions


Cheers

--
Pierre-Yves David

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


Re: emacs vc-region-history: uses git log -L, is there a HG equivalent?

2022-10-16 Thread Pierre-Yves David

hg log has a similar option:


 -L --line-range FILE,RANGE [+] follow line range of specified file
    (EXPERIMENTAL)

On 10/16/22 14:22, Uwe Brauer wrote:

Hi

I tried out, in a small git repository, emacs's
vc-region-history

It quite nice and useful but supports only git where it relies on
«git log -L»

I am not aware of any hg equivalent, but may be there is, or it is planned?


Regards

Uwe Brauer

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


--
Pierre-Yves David

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


D12619: auto-upgrade: skip the operation if the repository cannot be locked

2022-05-06 Thread marmoute (Pierre-Yves David)
marmoute created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  This seems like a fine default behavior for now. If some users wants something
  more aggressive we can make the behavior configurable in the future.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  mercurial/helptext/config.txt
  mercurial/upgrade_utils/auto_upgrade.py
  tests/test-upgrade-repo.t

CHANGE DETAILS

diff --git a/tests/test-upgrade-repo.t b/tests/test-upgrade-repo.t
--- a/tests/test-upgrade-repo.t
+++ b/tests/test-upgrade-repo.t
@@ -2069,8 +2069,6 @@
   $ hg status -R auto-upgrade \
   > --config 
format.use-dirstate-v2.automatic-upgrade-of-mismatching-repositories=yes \
   > --config format.use-dirstate-v2=no
-  abort: could not lock working directory of auto-upgrade: Permission denied
-  [20]
   $ hg debugformat -R auto-upgrade | grep dirstate-v2
   dirstate-v2:yes
 
@@ -2085,8 +2083,6 @@
   $ hg status -R auto-upgrade \
   > --config 
format.use-dirstate-v2.automatic-upgrade-of-mismatching-repositories=yes \
   > --config format.use-dirstate-v2=no
-  abort: repository auto-upgrade: timed out waiting for lock held by 
'brunhoff/effc:1215708'
-  [20]
   $ hg debugformat -R auto-upgrade | grep dirstate-v2
   dirstate-v2:yes
 
diff --git a/mercurial/upgrade_utils/auto_upgrade.py 
b/mercurial/upgrade_utils/auto_upgrade.py
--- a/mercurial/upgrade_utils/auto_upgrade.py
+++ b/mercurial/upgrade_utils/auto_upgrade.py
@@ -217,19 +217,26 @@
 
 loop = 0
 
-while not clear:
-loop += 1
-if loop > 100:
-# XXX basic protection against infinite loop, make it better.
-raise error.ProgrammingError("Too many auto upgrade loops")
-clear = True
-for get_action in AUTO_UPGRADE_ACTIONS:
-action = get_action(repo)
-if action is not None:
-clear = False
-with repo.wlock(wait=False), repo.lock(wait=False):
-action = get_action(repo)
-if action is not None:
-action()
-repo = maker_func()
+try:
+while not clear:
+loop += 1
+if loop > 100:
+# XXX basic protection against infinite loop, make it better.
+raise error.ProgrammingError("Too many auto upgrade loops")
+clear = True
+for get_action in AUTO_UPGRADE_ACTIONS:
+action = get_action(repo)
+if action is not None:
+clear = False
+with repo.wlock(wait=False), repo.lock(wait=False):
+action = get_action(repo)
+if action is not None:
+action()
+repo = maker_func()
+except error.LockError:
+# if we cannot get the lock, ignore the auto-upgrade attemps and
+# proceed. We might want to make this behavior configurable in the
+# future.
+pass
+
 return repo
diff --git a/mercurial/helptext/config.txt b/mercurial/helptext/config.txt
--- a/mercurial/helptext/config.txt
+++ b/mercurial/helptext/config.txt
@@ -957,6 +957,9 @@
needed. This also apply to operation that would have been read-only (like hg
status).
 
+   If the repository cannot be locked, the automatic-upgrade operation will be
+   skipped. The next operation will attemps it again.
+
This configuration will apply for move in any direction, either adding the
`dirstate-v2` format if `format.use-dirstate-v2=yes` or removing the
`dirstate-v2` requirement if `format.use-dirstate-v2=no`. So we recommand
@@ -1008,6 +1011,9 @@
change is needed. This also apply to operation that would have been 
read-only
(like hg status).
 
+   If the repository cannot be locked, the automatic-upgrade operation will be
+   skipped. The next operation will attemps it again.
+
This configuration will apply for move in any direction, either adding the
`dirstate-tracked-hint` format if `format.use-dirstate-tracked-hint=yes` or
removing the `dirstate-tracked-hint` requirement if
@@ -1084,6 +1090,9 @@
change is needed. This also apply to operation that would have been
read-only (like hg status).
 
+   If the repository cannot be locked, the automatic-upgrade operation will be
+   skipped. The next operation will attemps it again.
+
This configuration will apply for move in any direction, either adding the
`share-safe` format if `format.use-share-safe=yes` or removing the
`share-safe` requirement if `format.use-share-safe=no`. So we recommand



To: marmoute, #hg-reviewers
Cc: mercurial-patches, mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org

D12616: debuglock: make the command more useful in non-interactive mode

2022-05-06 Thread marmoute (Pierre-Yves David)
marmoute created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  The existing prompt mode simply release the lock immediately in 
non-interactive.
  That is quite useless in the test so now the non-interactive mode simply wait
  for a signal.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  mercurial/debugcommands.py

CHANGE DETAILS

diff --git a/mercurial/debugcommands.py b/mercurial/debugcommands.py
--- a/mercurial/debugcommands.py
+++ b/mercurial/debugcommands.py
@@ -2185,7 +2185,19 @@
 except error.LockHeld:
 raise error.Abort(_(b'lock is already held'))
 if len(locks):
-ui.promptchoice(_(b"ready to release the lock (y)? $$ "))
+try:
+if ui.interactive():
+prompt = _(b"ready to release the lock (y)? $$ ")
+ui.promptchoice(prompt)
+else:
+msg = b"%d locks held, waiting for signal\n"
+msg %= len(locks)
+ui.status(msg)
+while True:  # XXX wait for a signal
+time.sleep(0.1)
+except KeyboardInterrupt:
+msg = b"signal-received releasing locks\n"
+ui.status(msg)
 return 0
 finally:
 release(*locks)



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


D12618: auto-upgrade: add a test case where the repository is already locked

2022-05-06 Thread marmoute (Pierre-Yves David)
marmoute created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  This show the current behavior is the repository to auto-upgrade is already
  locked.
  
  The current behavior is to abort, which is probably not great. Now that we 
have
  a proper test, we can think about the behavior we wants in a later tests.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  tests/test-upgrade-repo.t

CHANGE DETAILS

diff --git a/tests/test-upgrade-repo.t b/tests/test-upgrade-repo.t
--- a/tests/test-upgrade-repo.t
+++ b/tests/test-upgrade-repo.t
@@ -2076,3 +2076,18 @@
 
   $ chmod -R u+w auto-upgrade
 
+Attempting Auto-upgrade on a locked repository
+--
+
+  $ hg -R auto-upgrade debuglock --set-lock --quiet &
+  $ echo $! >> $DAEMON_PIDS
+  $ $RUNTESTDIR/testlib/wait-on-file 10 auto-upgrade/.hg/store/lock
+  $ hg status -R auto-upgrade \
+  > --config 
format.use-dirstate-v2.automatic-upgrade-of-mismatching-repositories=yes \
+  > --config format.use-dirstate-v2=no
+  abort: repository auto-upgrade: timed out waiting for lock held by 
'brunhoff/effc:1215708'
+  [20]
+  $ hg debugformat -R auto-upgrade | grep dirstate-v2
+  dirstate-v2:yes
+
+  $ killdaemons.py



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


D12617: wait-on-file: properly wait on any file and symlink

2022-05-06 Thread marmoute (Pierre-Yves David)
marmoute created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  This make the utility more useful, for example to wait on a lock file.
  We also an explicit -L check since the lock are "weird" symlink.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  tests/testlib/wait-on-file

CHANGE DETAILS

diff --git a/tests/testlib/wait-on-file b/tests/testlib/wait-on-file
--- a/tests/testlib/wait-on-file
+++ b/tests/testlib/wait-on-file
@@ -29,7 +29,7 @@
 touch "$create"
 create=""
 fi
-while [ "$timer" -gt 0 ] && [ ! -f "$wait_on" ]; do
+while [ "$timer" -gt 0 ] && !([ -e "$wait_on" ] || [ -L "$wait_on" ]) ; do
 timer=$(( $timer - 1))
 sleep 0.02
 done



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


D12613: auto-upgrade: introduce a way to auto-upgrade to/from tracked-hint

2022-05-06 Thread marmoute (Pierre-Yves David)
marmoute created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  This is similar to what we introduce for `share-safe`, but apply tot he 
tracked-hint feature.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  mercurial/configitems.py
  mercurial/helptext/config.txt
  mercurial/upgrade_utils/auto_upgrade.py
  rust/hg-core/src/requirements.rs
  rust/rhg/src/main.rs
  tests/test-help.t
  tests/test-share-safe.t
  tests/test-status-tracked-key.t

CHANGE DETAILS

diff --git a/tests/test-status-tracked-key.t b/tests/test-status-tracked-key.t
--- a/tests/test-status-tracked-key.t
+++ b/tests/test-status-tracked-key.t
@@ -202,3 +202,37 @@
   .hg/dirstate-tracked-hint
   $ hg debugrequires | grep 'tracked'
   dirstate-tracked-key-v1
+  $ cd ..
+
+Test automatic upgrade and downgrade
+
+
+create an initial repository
+
+  $ hg init auto-upgrade \
+  > --config format.use-dirstate-tracked-hint=no
+  $ hg debugbuilddag -R auto-upgrade --new-file .+5
+  $ hg -R auto-upgrade update
+  6 files updated, 0 files merged, 0 files removed, 0 files unresolved
+  $ hg debugformat -R auto-upgrade | grep tracked
+  tracked-hint:no
+
+upgrade it to dirstate-tracked-hint automatically
+
+  $ hg status -R auto-upgrade \
+  > --config 
format.use-dirstate-tracked-hint.automatic-upgrade-of-mismatching-repositories=yes
 \
+  > --config format.use-dirstate-tracked-hint=yes
+  automatically upgrading repository to the `tracked-hint` feature
+  (see `hg help config.format.use-dirstate-tracked-hint` for details)
+  $ hg debugformat -R auto-upgrade | grep tracked
+  tracked-hint:   yes
+
+downgrade it from dirstate-tracked-hint automatically
+
+  $ hg status -R auto-upgrade \
+  > --config 
format.use-dirstate-tracked-hint.automatic-upgrade-of-mismatching-repositories=yes
 \
+  > --config format.use-dirstate-tracked-hint=no
+  automatically downgrading repository from the `tracked-hint` feature
+  (see `hg help config.format.use-dirstate-tracked-hint` for details)
+  $ hg debugformat -R auto-upgrade | grep tracked
+  tracked-hint:no
diff --git a/tests/test-share-safe.t b/tests/test-share-safe.t
--- a/tests/test-share-safe.t
+++ b/tests/test-share-safe.t
@@ -603,3 +603,36 @@
   |
   o  f3ba8b99bb6f897c87bbc1c07b75c6ddf43a4f77: added foo
   
+
+Test automatique upgrade/downgrade of main-repository
+--
+
+create an initial repository
+
+  $ hg init auto-upgrade \
+  > --config format.use-share-safe=no
+  $ hg debugbuilddag -R auto-upgrade --new-file .+5
+  $ hg -R auto-upgrade update
+  6 files updated, 0 files merged, 0 files removed, 0 files unresolved
+  $ hg debugformat -R auto-upgrade | grep share-safe
+  share-safe:  no
+
+upgrade it to share-safe automatically
+
+  $ hg status -R auto-upgrade \
+  > --config 
format.use-share-safe.automatic-upgrade-of-mismatching-repositories=yes \
+  > --config format.use-share-safe=yes
+  automatically upgrading repository to the `share-safe` feature
+  (see `hg help config.format.use-share-safe` for details)
+  $ hg debugformat -R auto-upgrade | grep share-safe
+  share-safe: yes
+
+downgrade it from share-safe automatically
+
+  $ hg status -R auto-upgrade \
+  > --config 
format.use-share-safe.automatic-upgrade-of-mismatching-repositories=yes \
+  > --config format.use-share-safe=no
+  automatically downgrading repository from the `share-safe` feature
+  (see `hg help config.format.use-share-safe` for details)
+  $ hg debugformat -R auto-upgrade | grep share-safe
+  share-safe:  no
diff --git a/tests/test-help.t b/tests/test-help.t
--- a/tests/test-help.t
+++ b/tests/test-help.t
@@ -1599,6 +1599,8 @@
   
   "use-dirstate-tracked-hint"
   
+  "use-dirstate-tracked-hint.automatic-upgrade-of-mismatching-repositories"
+  
   "use-persistent-nodemap"
   
   "use-share-safe"
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
@@ -731,6 +731,11 @@
 ("format", "use-share-safe"),
 requirements::SHARESAFE_REQUIREMENT,
 ),
+(
+("format", 
"use-dirstate-tracked-hint.automatic-upgrade-of-mismatching-repositories"),
+("format", "use-dirstate-tracked-hint"),
+requirements::DIRSTATE_TRACKED_HINT_V1,
+),
 ];
 
 /// Mercurial allows users to automatically upgrade their repository.
diff --git a/rust/hg-core/src/requirements.rs b/rust/hg-core/src/requirements.rs
--- a/rust/hg-core/src/requirements.rs
+++ b/rust/hg-core/src/requirements.rs
@@ -100,6 +100,10 @@
 
 pub const DIRSTATE_V2_REQUIREMENT:  = "dirstate-v2";
 
+/// A repository that uses the tracked hint dirstate file
+#[allow(unused)]
+pub const DIRSTATE_TRACKED_HINT_V1:  = "dirstate-tracked-key-v1";
+
 /// When narrowing is finalized and no longer 

D12614: auto-upgrade: introduce a way to auto-upgrade to/from dirstate-v2

2022-05-06 Thread marmoute (Pierre-Yves David)
marmoute created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  This is similar to what we introduce for `share-safe`, but apply tot he
  tracked-hint feature.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  mercurial/configitems.py
  mercurial/helptext/config.txt
  mercurial/upgrade_utils/auto_upgrade.py
  rust/rhg/src/main.rs
  tests/test-help.t
  tests/test-upgrade-repo.t

CHANGE DETAILS

diff --git a/tests/test-upgrade-repo.t b/tests/test-upgrade-repo.t
--- a/tests/test-upgrade-repo.t
+++ b/tests/test-upgrade-repo.t
@@ -1994,3 +1994,70 @@
   dirstate-v2: no
 
   $ cd ..
+
+Test automatic upgrade/downgrade
+
+
+
+For dirstate v2
+---
+
+create an initial repository
+
+  $ hg init auto-upgrade \
+  > --config format.use-dirstate-v2=no \
+  > --config format.use-dirstate-tracked-hint=yes \
+  > --config format.use-share-safe=no
+  $ hg debugbuilddag -R auto-upgrade --new-file .+5
+  $ hg -R auto-upgrade update
+  6 files updated, 0 files merged, 0 files removed, 0 files unresolved
+  $ hg debugformat -R auto-upgrade | grep dirstate-v2
+  dirstate-v2: no
+
+upgrade it to dirstate-v2 automatically
+
+  $ hg status -R auto-upgrade \
+  > --config 
format.use-dirstate-v2.automatic-upgrade-of-mismatching-repositories=yes \
+  > --config format.use-dirstate-v2=yes
+  automatically upgrading repository to the `dirstate-v2` feature
+  (see `hg help config.format.use-dirstate-v2` for details)
+  $ hg debugformat -R auto-upgrade | grep dirstate-v2
+  dirstate-v2:yes
+
+downgrade it from dirstate-v2 automatically
+
+  $ hg status -R auto-upgrade \
+  > --config 
format.use-dirstate-v2.automatic-upgrade-of-mismatching-repositories=yes \
+  > --config format.use-dirstate-v2=no
+  automatically downgrading repository from the `dirstate-v2` feature
+  (see `hg help config.format.use-dirstate-v2` for details)
+  $ hg debugformat -R auto-upgrade | grep dirstate-v2
+  dirstate-v2: no
+
+
+For multiple change at the same time
+
+
+  $ hg debugformat -R auto-upgrade | egrep '(dirstate-v2|tracked|share-safe)'
+  dirstate-v2: no
+  tracked-hint:   yes
+  share-safe:  no
+
+  $ hg status -R auto-upgrade \
+  > --config 
format.use-dirstate-v2.automatic-upgrade-of-mismatching-repositories=yes \
+  > --config format.use-dirstate-v2=yes \
+  > --config 
format.use-dirstate-tracked-hint.automatic-upgrade-of-mismatching-repositories=yes
 \
+  > --config format.use-dirstate-tracked-hint=no\
+  > --config 
format.use-share-safe.automatic-upgrade-of-mismatching-repositories=yes \
+  > --config format.use-share-safe=yes
+  automatically upgrading repository to the `dirstate-v2` feature
+  (see `hg help config.format.use-dirstate-v2` for details)
+  automatically upgrading repository to the `share-safe` feature
+  (see `hg help config.format.use-share-safe` for details)
+  automatically downgrading repository from the `tracked-hint` feature
+  (see `hg help config.format.use-dirstate-tracked-hint` for details)
+  $ hg debugformat -R auto-upgrade | egrep '(dirstate-v2|tracked|share-safe)'
+  dirstate-v2:yes
+  tracked-hint:no
+  share-safe: yes
+
diff --git a/tests/test-help.t b/tests/test-help.t
--- a/tests/test-help.t
+++ b/tests/test-help.t
@@ -1597,6 +1597,8 @@
   
   "use-dirstate-v2"
   
+  "use-dirstate-v2.automatic-upgrade-of-mismatching-repositories"
+  
   "use-dirstate-tracked-hint"
   
   "use-dirstate-tracked-hint.automatic-upgrade-of-mismatching-repositories"
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
@@ -736,6 +736,11 @@
 ("format", "use-dirstate-tracked-hint"),
 requirements::DIRSTATE_TRACKED_HINT_V1,
 ),
+(
+("use-dirstate-v2", "automatic-upgrade-of-mismatching-repositories"),
+("format", "use-dirstate-v2"),
+requirements::DIRSTATE_V2_REQUIREMENT,
+),
 ];
 
 /// Mercurial allows users to automatically upgrade their repository.
diff --git a/mercurial/upgrade_utils/auto_upgrade.py 
b/mercurial/upgrade_utils/auto_upgrade.py
--- a/mercurial/upgrade_utils/auto_upgrade.py
+++ b/mercurial/upgrade_utils/auto_upgrade.py
@@ -136,7 +136,64 @@
 return action
 
 
+def get_dirstate_v2_action(repo):
+"""return an automatic-upgrade action for `dirstate-v2` if applicable
+
+If no action is needed, return None, otherwise return a callback to upgrade
+or downgrade the repository according the configuration and repository
+format.
+"""
+ui = repo.ui
+requirements = set(repo.requirements)
+auto_upgrade_tracked_hint = ui.configbool(
+b'format',
+b'use-dirstate-v2.automatic-upgrade-of-mismatching-repositories',

D12611: auto-upgrade: introduce a way to auto-upgrade to/from share-safe

2022-05-06 Thread marmoute (Pierre-Yves David)
marmoute created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  This is the first "automatic-upgrade" capabilities. In the following commits,
  similar features are coming for other "fast to upgrade" format.
  
  This is different from the `safe-mismatch.source-not-safe` and
  `safe-mismatch.source-safe` configuration that deal with mismatch between a
  share and its share-source. Here we are dealing with mismatch between 
repository
  configuration and its actual format.
  
  We will need further work for cases were the repository cannot be locked. A
  basic protection is in place to avoid infinite loop for now, but it will get
  proper attention in a later changesets.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  mercurial/configitems.py
  mercurial/helptext/config.txt
  mercurial/localrepo.py
  mercurial/upgrade.py
  mercurial/upgrade_utils/auto_upgrade.py
  rust/rhg/src/main.rs
  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
@@ -1603,6 +1603,8 @@
   
   "use-share-safe"
   
+  "use-share-safe.automatic-upgrade-of-mismatching-repositories"
+  
   "usestore"
   
   "sparse-revlog"
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
@@ -7,10 +7,10 @@
 use clap::ArgMatches;
 use format_bytes::{format_bytes, join};
 use hg::config::{Config, ConfigSource};
-use hg::exit_codes;
 use hg::repo::{Repo, RepoError};
 use hg::utils::files::{get_bytes_from_os_str, get_path_from_bytes};
 use hg::utils::SliceExt;
+use hg::{exit_codes, requirements};
 use std::collections::HashSet;
 use std::ffi::OsString;
 use std::os::unix::prelude::CommandExt;
@@ -724,6 +724,50 @@
 }
 }
 
+/// Array of tuples of (auto upgrade conf, feature conf, local requirement)
+const AUTO_UPGRADES: &[((, ), (, ), )] = &[
+(
+("format", 
"use-share-safe.automatic-upgrade-of-mismatching-repositories"),
+("format", "use-share-safe"),
+requirements::SHARESAFE_REQUIREMENT,
+),
+];
+
+/// Mercurial allows users to automatically upgrade their repository.
+/// `rhg` does not have the ability to upgrade yet, so fallback if an upgrade
+/// is needed.
+fn check_auto_upgrade(
+config: ,
+reqs: ,
+) -> Result<(), CommandError> {
+for (upgrade_conf, feature_conf, local_req) in AUTO_UPGRADES.iter() {
+let auto_upgrade = config
+.get_bool(upgrade_conf.0.as_bytes(), upgrade_conf.1.as_bytes())?;
+
+if auto_upgrade {
+let want_it = config.get_bool(
+feature_conf.0.as_bytes(),
+feature_conf.1.as_bytes(),
+)?;
+let have_it = reqs.contains(*local_req);
+
+let action = match (want_it, have_it) {
+(true, false) => Some("upgrade"),
+(false, true) => Some("downgrade"),
+_ => None,
+};
+if let Some(action) = action {
+let message = format!(
+"automatic {} {}.{}",
+action, upgrade_conf.0, upgrade_conf.1
+);
+return Err(CommandError::unsupported(message));
+}
+}
+}
+Ok(())
+}
+
 fn check_unsupported(
 config: ,
 repo: Result<, >,
@@ -740,6 +784,7 @@
 if repo.has_subrepos()? {
 Err(CommandError::unsupported("sub-repositories"))?
 }
+check_auto_upgrade(config, repo.requirements())?;
 }
 
 if config.has_non_empty_section(b"encode") {
diff --git a/mercurial/upgrade_utils/auto_upgrade.py 
b/mercurial/upgrade_utils/auto_upgrade.py
new file mode 100644
--- /dev/null
+++ b/mercurial/upgrade_utils/auto_upgrade.py
@@ -0,0 +1,107 @@
+# upgrade.py - functions for automatic upgrade of Mercurial repository
+#
+# Copyright (c) 2022-present, Pierre-Yves David
+#
+# This software may be used and distributed according to the terms of the
+# GNU General Public License version 2 or any later version.
+from ..i18n import _
+
+from .. import (
+error,
+requirements as requirementsmod,
+scmutil,
+)
+
+
+def get_share_safe_action(repo):
+"""return an automatic-upgrade action for `share-safe` if applicable
+
+If no action is needed, return None, otherwise return a callback to upgrade
+or downgrade the repository according the configuration and repository
+format.
+"""
+ui = repo.ui
+requirements = repo.requirements
+auto_upgrade_share_source = ui.configbool(
+b'format',
+b'use-share-safe.automatic-upgrade-of-mismatching-repositories',
+

D12615: auto-upgrade: add a test case with no permission to lock the repository

2022-05-06 Thread marmoute (Pierre-Yves David)
marmoute created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  This show the current behavior is the repository is unlockable.
  
  The current behavior is to abort, which is probably not great. Now that we 
have
  a proper test, we can think about the behavior we wants in a later tests.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  tests/test-upgrade-repo.t

CHANGE DETAILS

diff --git a/tests/test-upgrade-repo.t b/tests/test-upgrade-repo.t
--- a/tests/test-upgrade-repo.t
+++ b/tests/test-upgrade-repo.t
@@ -2061,3 +2061,18 @@
   tracked-hint:no
   share-safe: yes
 
+Attempting Auto-upgrade on a read-only repository
+-
+
+  $ chmod -R a-w auto-upgrade
+
+  $ hg status -R auto-upgrade \
+  > --config 
format.use-dirstate-v2.automatic-upgrade-of-mismatching-repositories=yes \
+  > --config format.use-dirstate-v2=no
+  abort: could not lock working directory of auto-upgrade: Permission denied
+  [20]
+  $ hg debugformat -R auto-upgrade | grep dirstate-v2
+  dirstate-v2:yes
+
+  $ chmod -R u+w auto-upgrade
+



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


D12612: upgrade: split some logic from UpgradeOperation

2022-05-06 Thread marmoute (Pierre-Yves David)
marmoute created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  The automatic-upgrade and the upgrade-repo code path should be able to use the
  same code. However that code often need an UpgradeOperation object to 
function.
  So we start spliting the Operation into a minimal component that we will be
  able to reuse outside of the "classic" upgrade path.
  
  We will put the base-class to use in the next changesets.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

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
@@ -685,7 +685,24 @@
 return newactions
 
 
-class UpgradeOperation:
+class BaseOperation:
+"""base class that contains the minimum for an upgrade to work
+
+(this might need to be extended as the usage for subclass alternative to
+UpgradeOperation extends)
+"""
+
+def __init__(
+self,
+new_requirements,
+backup_store,
+):
+self.new_requirements = new_requirements
+# should this operation create a backup of the store
+self.backup_store = backup_store
+
+
+class UpgradeOperation(BaseOperation):
 """represent the work to be done during an upgrade"""
 
 def __init__(
@@ -698,8 +715,11 @@
 revlogs_to_process,
 backup_store,
 ):
+super().__init__(
+new_requirements,
+backup_store,
+)
 self.ui = ui
-self.new_requirements = new_requirements
 self.current_requirements = current_requirements
 # list of upgrade actions the operation will perform
 self.upgrade_actions = upgrade_actions
@@ -741,9 +761,6 @@
 b're-delta-multibase' in upgrade_actions_names
 )
 
-# should this operation create a backup of the store
-self.backup_store = backup_store
-
 @property
 def upgrade_actions_names(self):
 return set([a.name for a in self.upgrade_actions])



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


D12610: rust: make requirements public

2022-05-06 Thread marmoute (Pierre-Yves David)
marmoute created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  These can be used by any client crates (including `rhg`), no need to make them
  private to the crate.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

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

CHANGE DETAILS

diff --git a/rust/hg-core/src/requirements.rs b/rust/hg-core/src/requirements.rs
--- a/rust/hg-core/src/requirements.rs
+++ b/rust/hg-core/src/requirements.rs
@@ -98,35 +98,35 @@
 
 // Copied from mercurial/requirements.py:
 
-pub(crate) const DIRSTATE_V2_REQUIREMENT:  = "dirstate-v2";
+pub const DIRSTATE_V2_REQUIREMENT:  = "dirstate-v2";
 
 /// When narrowing is finalized and no longer subject to format changes,
 /// we should move this to just "narrow" or similar.
 #[allow(unused)]
-pub(crate) const NARROW_REQUIREMENT:  = "narrowhg-experimental";
+pub const NARROW_REQUIREMENT:  = "narrowhg-experimental";
 
 /// Bookmarks must be stored in the `store` part of the repository and will be
 /// share accross shares
 #[allow(unused)]
-pub(crate) const BOOKMARKS_IN_STORE_REQUIREMENT:  = "bookmarksinstore";
+pub const BOOKMARKS_IN_STORE_REQUIREMENT:  = "bookmarksinstore";
 
 /// Enables sparse working directory usage
 #[allow(unused)]
-pub(crate) const SPARSE_REQUIREMENT:  = "exp-sparse";
+pub const SPARSE_REQUIREMENT:  = "exp-sparse";
 
 /// Enables the internal phase which is used to hide changesets instead
 /// of stripping them
 #[allow(unused)]
-pub(crate) const INTERNAL_PHASE_REQUIREMENT:  = "internal-phase";
+pub const INTERNAL_PHASE_REQUIREMENT:  = "internal-phase";
 
 /// Stores manifest in Tree structure
 #[allow(unused)]
-pub(crate) const TREEMANIFEST_REQUIREMENT:  = "treemanifest";
+pub const TREEMANIFEST_REQUIREMENT:  = "treemanifest";
 
 /// Increment the sub-version when the revlog v2 format changes to lock out old
 /// clients.
 #[allow(unused)]
-pub(crate) const REVLOGV2_REQUIREMENT:  = "exp-revlogv2.1";
+pub const REVLOGV2_REQUIREMENT:  = "exp-revlogv2.1";
 
 /// A repository with the sparserevlog feature will have delta chains that
 /// can spread over a larger span. Sparse reading cuts these large spans into
@@ -137,32 +137,32 @@
 /// chain. This is why once a repository has enabled sparse-read, it becomes
 /// required.
 #[allow(unused)]
-pub(crate) const SPARSEREVLOG_REQUIREMENT:  = "sparserevlog";
+pub const SPARSEREVLOG_REQUIREMENT:  = "sparserevlog";
 
 /// A repository with the the copies-sidedata-changeset requirement will store
 /// copies related information in changeset's sidedata.
 #[allow(unused)]
-pub(crate) const COPIESSDC_REQUIREMENT:  = "exp-copies-sidedata-changeset";
+pub const COPIESSDC_REQUIREMENT:  = "exp-copies-sidedata-changeset";
 
 /// The repository use persistent nodemap for the changelog and the manifest.
 #[allow(unused)]
-pub(crate) const NODEMAP_REQUIREMENT:  = "persistent-nodemap";
+pub const NODEMAP_REQUIREMENT:  = "persistent-nodemap";
 
 /// Denotes that the current repository is a share
 #[allow(unused)]
-pub(crate) const SHARED_REQUIREMENT:  = "shared";
+pub const SHARED_REQUIREMENT:  = "shared";
 
 /// Denotes that current repository is a share and the shared source path is
 /// relative to the current repository root path
 #[allow(unused)]
-pub(crate) const RELATIVE_SHARED_REQUIREMENT:  = "relshared";
+pub const RELATIVE_SHARED_REQUIREMENT:  = "relshared";
 
 /// A repository with share implemented safely. The repository has different
 /// store and working copy requirements i.e. both `.hg/requires` and
 /// `.hg/store/requires` are present.
 #[allow(unused)]
-pub(crate) const SHARESAFE_REQUIREMENT:  = "share-safe";
+pub const SHARESAFE_REQUIREMENT:  = "share-safe";
 
 /// A repository that use zstd compression inside its revlog
 #[allow(unused)]
-pub(crate) const REVLOG_COMPRESSION_ZSTD:  = "revlog-compression-zstd";
+pub const REVLOG_COMPRESSION_ZSTD:  = "revlog-compression-zstd";



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


D12484: help: set the large-file-limit to 10MB

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

REVISION SUMMARY
  This is a minor increase (5%) and makes the doc much clearer.

REPOSITORY
  rHG Mercurial

BRANCH
  stable

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

AFFECTED FILES
  mercurial/configitems.py
  mercurial/helptext/config.txt

CHANGE DETAILS

diff --git a/mercurial/helptext/config.txt b/mercurial/helptext/config.txt
--- a/mercurial/helptext/config.txt
+++ b/mercurial/helptext/config.txt
@@ -2631,7 +2631,7 @@
 Largest file size that gives no memory use warning.
 Possible values are integers or 0 to disable the check.
 Value is expressed in bytes by default, one can use standard unit for
-convenience (e.g. 10MB, 0.1GB, etc) (default: 1000)
+convenience (e.g. 10MB, 0.1GB, etc) (default: 10MB)
 
 ``logtemplate``
 (DEPRECATED) Use ``command-templates.log`` instead.
diff --git a/mercurial/configitems.py b/mercurial/configitems.py
--- a/mercurial/configitems.py
+++ b/mercurial/configitems.py
@@ -2255,7 +2255,7 @@
 coreconfigitem(
 b'ui',
 b'large-file-limit',
-default=1000,
+default=10 * (2 ** 20),
 )
 coreconfigitem(
 b'ui',



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


D12483: help: clarify the unit of `ui.large-file-limit` config

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

REVISION SUMMARY
  Its might be a bit confusing, especially since `large-file.min-size` uses MB.

REPOSITORY
  rHG Mercurial

BRANCH
  stable

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

AFFECTED FILES
  mercurial/helptext/config.txt

CHANGE DETAILS

diff --git a/mercurial/helptext/config.txt b/mercurial/helptext/config.txt
--- a/mercurial/helptext/config.txt
+++ b/mercurial/helptext/config.txt
@@ -2630,7 +2630,8 @@
 ``large-file-limit``
 Largest file size that gives no memory use warning.
 Possible values are integers or 0 to disable the check.
-(default: 1000)
+Value is expressed in bytes by default, one can use standard unit for
+convenience (e.g. 10MB, 0.1GB, etc) (default: 1000)
 
 ``logtemplate``
 (DEPRECATED) Use ``command-templates.log`` instead.



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


D12481: debuglock: ignore ENOENT error when unlocking

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

REVISION SUMMARY
  This is consistent with the main `lock.release` code.

REPOSITORY
  rHG Mercurial

BRANCH
  stable

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

AFFECTED FILES
  mercurial/debugcommands.py

CHANGE DETAILS

diff --git a/mercurial/debugcommands.py b/mercurial/debugcommands.py
--- a/mercurial/debugcommands.py
+++ b/mercurial/debugcommands.py
@@ -2148,9 +2148,17 @@
 """
 
 if opts.get('force_free_lock'):
-repo.svfs.unlink(b'lock')
+try:
+repo.svfs.unlink(b'lock')
+except (OSError, IOError) as e:
+if e.errno != errno.ENOENT:
+raise
 if opts.get('force_free_wlock'):
-repo.vfs.unlink(b'wlock')
+try:
+repo.vfs.unlink(b'wlock')
+except (OSError, IOError) as e:
+if e.errno != errno.ENOENT:
+raise
 if opts.get('force_free_lock') or opts.get('force_free_wlock'):
 return 0
 



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


D12480: run-tests: introduce "forward-slash" version of everything on windows

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

REVISION SUMMARY
  This should be useful for some shell invocation.

REPOSITORY
  rHG Mercurial

BRANCH
  stable

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

AFFECTED FILES
  tests/run-tests.py
  tests/test-racy-mutations.t

CHANGE DETAILS

diff --git a/tests/test-racy-mutations.t b/tests/test-racy-mutations.t
--- a/tests/test-racy-mutations.t
+++ b/tests/test-racy-mutations.t
@@ -9,12 +9,12 @@
   $ hg init a
   $ cd a
 
-  $ cat > "$TESTTMP/waitlock_editor.sh" < "$TESTTMP_FORWARD_SLASH/waitlock_editor.sh" < [ -n "\${WAITLOCK_ANNOUNCE:-}" ] && touch "\${WAITLOCK_ANNOUNCE}"
   > f="\${WAITLOCK_FILE}"
   > start=\`date +%s\`
   > timeout=5
-  > $RUNTESTDIR/testlib/wait-on-file "\$timeout" "\$f"
+  > "$RUNTESTDIR_FORWARD_SLASH/testlib/wait-on-file" "\$timeout" "\$f"
   > if [ \$# -gt 1 ]; then
   > cat "\$@"
   > fi
@@ -27,9 +27,9 @@
   $ hg commit -qAm 'r0'
 
 Start an hg commit that will take a while
-  $ EDITOR_STARTED="$(pwd)/.editor_started"
-  $ MISCHIEF_MANAGED="$(pwd)/.mischief_managed"
-  $ JOBS_FINISHED="$(pwd)/.jobs_finished"
+  $ EDITOR_STARTED="$TESTTMP_FORWARD_SLASH/a/.editor_started"
+  $ MISCHIEF_MANAGED="$TESTTMP_FORWARD_SLASH/a/.mischief_managed"
+  $ JOBS_FINISHED="$TESTTMP_FORWARD_SLASH/a/.jobs_finished"
 
 #if fail-if-detected
   $ cat >> .hg/hgrc << EOF
@@ -40,7 +40,7 @@
 
   $ cat >> .hg/hgrc << EOF
   > [ui]
-  > editor=sh $TESTTMP/waitlock_editor.sh
+  > editor=sh $TESTTMP_FORWARD_SLASH/waitlock_editor.sh
   > EOF
 
   $ echo foo > foo
@@ -50,7 +50,7 @@
   >   hg commit -qAm 'r1 (foo)' --edit foo > .foo_commit_out 2>&1 ; 
touch "${JOBS_FINISHED}") &
 
 Wait for the "editor" to actually start
-  $ sh "$RUNTESTDIR/testlib/wait-on-file" 5 "${EDITOR_STARTED}"
+  $ sh "$RUNTESTDIR_FORWARD_SLASH/testlib/wait-on-file" 5 "${EDITOR_STARTED}"
 
   $ cat >> .hg/hgrc << EOF
   > [ui]
@@ -69,7 +69,7 @@
 Awaken the editor from that first commit
   $ touch "${MISCHIEF_MANAGED}"
 And wait for it to finish
-  $ WAITLOCK_FILE="${JOBS_FINISHED}" sh "$TESTTMP/waitlock_editor.sh"
+  $ WAITLOCK_FILE="${JOBS_FINISHED}" sh 
"$TESTTMP_FORWARD_SLASH/waitlock_editor.sh"
 
 #if skip-detection
 (Ensure there was no output)
diff --git a/tests/run-tests.py b/tests/run-tests.py
--- a/tests/run-tests.py
+++ b/tests/run-tests.py
@@ -1433,6 +1433,9 @@
 env['PYTHONUSERBASE'] = sysconfig.get_config_var('userbase') or ''
 env['HGEMITWARNINGS'] = '1'
 env['TESTTMP'] = _bytes2sys(self._testtmp)
+# the FORWARD_SLASH version is useful when running `sh` on non unix
+# system (e.g. Windows)
+env['TESTTMP_FORWARD_SLASH'] = env['TESTTMP'].replace(os.sep, '/')
 uid_file = os.path.join(_bytes2sys(self._testtmp), 'UID')
 env['HGTEST_UUIDFILE'] = uid_file
 env['TESTNAME'] = self.name
@@ -3113,6 +3116,8 @@
 if pathname:
 testdir = os.path.join(testdir, pathname)
 self._testdir = osenvironb[b'TESTDIR'] = testdir
+osenvironb[b'TESTDIR_FORWARD_SLASH'] = 
osenvironb[b'TESTDIR'].replace(os.sep.encode('ascii'), b'/')
+
 if self.options.outputdir:
 self._outputdir = canonpath(_sys2bytes(self.options.outputdir))
 else:
@@ -3257,6 +3262,7 @@
 fileb = _sys2bytes(__file__)
 runtestdir = os.path.abspath(os.path.dirname(fileb))
 osenvironb[b'RUNTESTDIR'] = runtestdir
+osenvironb[b'RUNTESTDIR_FORWARD_SLASH'] = 
osenvironb[b'RUNTESTDIR'].replace(os.sep.encode('ascii'), b'/')
 if PYTHON3:
 sepb = _sys2bytes(os.pathsep)
 else:



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


D12479: tests-racy-mutation: pass the editor through config instead of env variable

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

REVISION SUMMARY
  On Windows msys seems to do awful mangling of the environment variable content
  that confuses everything to the death. Going through the config works fine, so
  we do that instead.

REPOSITORY
  rHG Mercurial

BRANCH
  stable

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

AFFECTED FILES
  tests/test-racy-mutations.t

CHANGE DETAILS

diff --git a/tests/test-racy-mutations.t b/tests/test-racy-mutations.t
--- a/tests/test-racy-mutations.t
+++ b/tests/test-racy-mutations.t
@@ -38,14 +38,24 @@
   > EOF
 #endif
 
+  $ cat >> .hg/hgrc << EOF
+  > [ui]
+  > editor=sh $TESTTMP/waitlock_editor.sh
+  > EOF
+
   $ echo foo > foo
-  $ (WAITLOCK_ANNOUNCE="${EDITOR_STARTED}" \
+  $ (unset HGEDITOR;
+  >  WAITLOCK_ANNOUNCE="${EDITOR_STARTED}" \
   >  WAITLOCK_FILE="${MISCHIEF_MANAGED}" \
-  >   HGEDITOR="sh $TESTTMP/waitlock_editor.sh" \
   >   hg commit -qAm 'r1 (foo)' --edit foo > .foo_commit_out 2>&1 ; 
touch "${JOBS_FINISHED}") &
 
 Wait for the "editor" to actually start
-  $ WAITLOCK_FILE="${EDITOR_STARTED}" sh "$TESTTMP/waitlock_editor.sh"
+  $ sh "$RUNTESTDIR/testlib/wait-on-file" 5 "${EDITOR_STARTED}"
+
+  $ cat >> .hg/hgrc << EOF
+  > [ui]
+  > editor=
+  > EOF
 
 Break the locks, and make another commit.
   $ hg debuglocks -LW



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


D12437: path: explicitly declare the `bookmarks.mode` suboptions

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

REVISION SUMMARY
  This will help documentation and discovery.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  mercurial/configitems.py

CHANGE DETAILS

diff --git a/mercurial/configitems.py b/mercurial/configitems.py
--- a/mercurial/configitems.py
+++ b/mercurial/configitems.py
@@ -1759,6 +1759,12 @@
 generic=True,
 )
 coreconfigitem(
+b'paths',
+b'.*:pushurl',
+default=None,
+generic=True,
+)
+coreconfigitem(
 b'phases',
 b'checksubrepos',
 default=b'follow',



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


D12436: path: explicitly declare the `pushrev` suboptions

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

REVISION SUMMARY
  This will help documentation and discovery.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  mercurial/configitems.py

CHANGE DETAILS

diff --git a/mercurial/configitems.py b/mercurial/configitems.py
--- a/mercurial/configitems.py
+++ b/mercurial/configitems.py
@@ -1753,6 +1753,12 @@
 generic=True,
 )
 coreconfigitem(
+b'paths',
+b'.*:pushrev',
+default=None,
+generic=True,
+)
+coreconfigitem(
 b'phases',
 b'checksubrepos',
 default=b'follow',



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


D12435: path: explicitly declare the `multi-urls` suboptions

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

REVISION SUMMARY
  This will help documentation and discovery.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  mercurial/configitems.py

CHANGE DETAILS

diff --git a/mercurial/configitems.py b/mercurial/configitems.py
--- a/mercurial/configitems.py
+++ b/mercurial/configitems.py
@@ -1747,6 +1747,12 @@
 generic=True,
 )
 coreconfigitem(
+b'paths',
+b'.*:multi-urls',
+default=False,
+generic=True,
+)
+coreconfigitem(
 b'phases',
 b'checksubrepos',
 default=b'follow',



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


D12434: path: explicitly declare the `bookmarks.mode` suboptions

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

REVISION SUMMARY
  This will help documentation and discovery.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  mercurial/configitems.py

CHANGE DETAILS

diff --git a/mercurial/configitems.py b/mercurial/configitems.py
--- a/mercurial/configitems.py
+++ b/mercurial/configitems.py
@@ -1741,6 +1741,12 @@
 generic=True,
 )
 coreconfigitem(
+b'paths',
+b'.*:bookmarks.mode',
+default='default',
+generic=True,
+)
+coreconfigitem(
 b'phases',
 b'checksubrepos',
 default=b'follow',



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


Re: 6.1.1 and review delay

2022-04-01 Thread Pierre-Yves David


On 4/1/22 11:35, Raphaël Gomès wrote:
We do have a somewhat concerning bug in `test-install.t` in the CI 
after rebuilding some base images, but the reason why is not clear yet.


For the record I created a topic to get more information about that failure:

https://foss.heptapod.net/mercurial/mercurial-devel/-/jobs/462754

(as we discussed, it seems like some version of setuptools might be 
either buggy or incompatible with some of our changes)


--

Pierre-Yves David

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


D12398: discovery: also audit the number of queries done

2022-03-22 Thread marmoute (Pierre-Yves David)
marmoute created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  In addition to the number of roundtrip, we now also track the number of 
queries
  we perform, this is useful to assert the tradeoff between number of roundtrip 
and
  the number of queries.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  mercurial/debugcommands.py
  mercurial/setdiscovery.py
  mercurial/treediscovery.py
  tests/test-setdiscovery.t

CHANGE DETAILS

diff --git a/tests/test-setdiscovery.t b/tests/test-setdiscovery.t
--- a/tests/test-setdiscovery.t
+++ b/tests/test-setdiscovery.t
@@ -45,6 +45,7 @@
   unpruned common: 01241442b3c2 66f7d451a68b b5714e113bc0
   elapsed time:  * seconds (glob)
   round-trips:   2
+  queries:   6
   heads summary:
 total common heads:  2
   also local heads:  2
@@ -77,6 +78,7 @@
   all local changesets known remotely
   elapsed time:  * seconds (glob)
   round-trips:   1
+  queries:   2
   heads summary:
 total common heads:  2
   also local heads:  2
@@ -109,6 +111,7 @@
   all local changesets known remotely
   elapsed time:  * seconds (glob)
   round-trips:   1
+  queries:   1
   heads summary:
 total common heads:  1
   also local heads:  1
@@ -140,6 +143,7 @@
   unpruned common: 01241442b3c2 b5714e113bc0
   elapsed time:  * seconds (glob)
   round-trips:   1
+  queries:   0
   heads summary:
 total common heads:  2
   also local heads:  1
@@ -172,6 +176,7 @@
   all remote heads known locally
   elapsed time:  * seconds (glob)
   round-trips:   1
+  queries:   3
   heads summary:
 total common heads:  2
   also local heads:  1
@@ -204,6 +209,7 @@
   all remote heads known locally
   elapsed time:  * seconds (glob)
   round-trips:   1
+  queries:   1
   heads summary:
 total common heads:  2
   also local heads:  1
@@ -242,6 +248,7 @@
   unpruned common: bebd167eb94d
   elapsed time:  * seconds (glob)
   round-trips:   2
+  queries:   3
   heads summary:
 total common heads:  1
   also local heads:  1
@@ -277,6 +284,7 @@
   2 total queries in *.s (glob)
   elapsed time:  * seconds (glob)
   round-trips:   2
+  queries:  31
   heads summary:
 total common heads:  1
   also local heads:  1
@@ -312,6 +320,7 @@
   2 total queries in *.s (glob)
   elapsed time:  * seconds (glob)
   round-trips:   2
+  queries:  32
   heads summary:
 total common heads:  1
   also local heads:  0
@@ -343,6 +352,7 @@
   unpruned common: 66f7d451a68b bebd167eb94d
   elapsed time:  * seconds (glob)
   round-trips:   4
+  queries:   5
   heads summary:
 total common heads:  1
   also local heads:  0
@@ -378,6 +388,7 @@
   2 total queries in *.s (glob)
   elapsed time:  * seconds (glob)
   round-trips:   2
+  queries:   3
   heads summary:
 total common heads:  1
   also local heads:  0
@@ -413,6 +424,7 @@
   2 total queries in *.s (glob)
   elapsed time:  * seconds (glob)
   round-trips:   2
+  queries:   3
   heads summary:
 total common heads:  1
   also local heads:  0
@@ -450,6 +462,7 @@
   unpruned common: 2dc09a01254d
   elapsed time:  * seconds (glob)
   round-trips:   4
+  queries:   5
   heads summary:
 total common heads:  1
   also local heads:  1
@@ -485,6 +498,7 @@
   2 total queries in *.s (glob)
   elapsed time:  * seconds (glob)
   round-trips:   2
+  queries:  31
   heads summary:
 total common heads:  1
   also local heads:  1
@@ -520,6 +534,7 @@
   2 total queries in *.s (glob)
   elapsed time:  * seconds (glob)
   round-trips:   2
+  queries:  32
   heads summary:
 total common heads:  1
   also local heads:  0
@@ -551,6 +566,7 @@
   unpruned common: 2dc09a01254d 66f7d451a68b
   elapsed time:  * seconds (glob)
   round-trips:   4
+  queries:   5
   heads summary:
 total common heads:  1
   also local heads:  0
@@ -586,6 +602,7 @@
   2 total queries in *.s (glob)
   elapsed time:  * seconds (glob)
   round-trips:   2
+  queries:  30
   heads summary:
 

D12399: perf-util: add a `compare-discovery-case` script

2022-03-22 Thread marmoute (Pierre-Yves David)
marmoute created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  This script run the same discovery case using multiple variants of the 
algorithm
  and report differences in behavior, especially regarding the numbers of 
roundtrip.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  contrib/perf-utils/compare-discovery-case

CHANGE DETAILS

diff --git a/contrib/perf-utils/compare-discovery-case 
b/contrib/perf-utils/compare-discovery-case
new file mode 100644
--- /dev/null
+++ b/contrib/perf-utils/compare-discovery-case
@@ -0,0 +1,183 @@
+#!/usr/bin/env python3
+# compare various algorithm variants for a givent case
+#
+#  search-discovery-case REPO LOCAL_CASE REMOTE_CASE
+#
+# The description for the case input use the same format at the ouput of
+# search-discovery-case
+
+import json
+import os
+import subprocess
+import sys
+
+this_script = os.path.abspath(sys.argv[0])
+script_name = os.path.basename(this_script)
+this_dir = os.path.dirname(this_script)
+hg_dir = os.path.join(this_dir, '..', '..')
+HG_REPO = os.path.normpath(hg_dir)
+HG_BIN = os.path.join(HG_REPO, 'hg')
+
+
+SUBSET_PATH = os.path.join(HG_REPO, 'contrib', 'perf-utils', 'subsetmaker.py')
+
+CMD_BASE = (
+HG_BIN,
+'debugdiscovery',
+'--template',
+'json',
+'--config',
+'extensions.subset=%s' % SUBSET_PATH,
+)
+
+# --old
+# --nonheads
+#
+# devel.discovery.exchange-heads=True
+# devel.discovery.grow-sample=True
+# devel.discovery.grow-sample.dynamic=True
+
+VARIANTS = {
+'tree-discovery': ('--old',),
+'set-discovery-basic': (
+'--config',
+'devel.discovery.exchange-heads=no',
+'--config',
+'devel.discovery.grow-sample=no',
+'--config',
+'devel.discovery.grow-sample.dynamic=no',
+'--config',
+'devel.discovery.randomize=yes',
+),
+'set-discovery-heads': (
+'--config',
+'devel.discovery.exchange-heads=yes',
+'--config',
+'devel.discovery.grow-sample=no',
+'--config',
+'devel.discovery.grow-sample.dynamic=no',
+'--config',
+'devel.discovery.randomize=yes',
+),
+'set-discovery-grow-sample': (
+'--config',
+'devel.discovery.exchange-heads=yes',
+'--config',
+'devel.discovery.grow-sample=yes',
+'--config',
+'devel.discovery.grow-sample.dynamic=no',
+'--config',
+'devel.discovery.randomize=yes',
+),
+'set-discovery-dynamic-sample': (
+'--config',
+'devel.discovery.exchange-heads=yes',
+'--config',
+'devel.discovery.grow-sample=yes',
+'--config',
+'devel.discovery.grow-sample.dynamic=yes',
+'--config',
+'devel.discovery.randomize=yes',
+),
+'set-discovery-default': (
+'--config',
+'devel.discovery.randomize=yes',
+),
+}
+
+VARIANTS_KEYS = [
+'tree-discovery',
+'set-discovery-basic',
+'set-discovery-heads',
+'set-discovery-grow-sample',
+'set-discovery-dynamic-sample',
+'set-discovery-default',
+]
+
+assert set(VARIANTS.keys()) == set(VARIANTS_KEYS)
+
+
+def format_case(case):
+return '-'.join(str(s) for s in case)
+
+
+def to_revsets(case):
+t = case[0]
+if t == 'scratch':
+return 'not scratch(all(), %d, "%d")' % (case[1], case[2])
+elif t == 'randomantichain':
+return '::randomantichain(all(), "%d")' % case[1]
+elif t == 'rev':
+return '::%d' % case[1]
+else:
+assert False
+
+
+def compare(repo, local_case, remote_case):
+case = (repo, local_case, remote_case)
+for variant in VARIANTS_KEYS:
+res = process(case, VARIANTS[variant])
+revs = res["nb-revs"]
+local_heads = res["nb-head-local"]
+common_heads = res["nb-common-heads"]
+roundtrips = res["total-roundtrips"]
+queries = res["total-queries"]
+if 'tree-discovery' in variant:
+print(
+repo,
+format_case(local_case),
+format_case(remote_case),
+variant,
+roundtrips,
+queries,
+revs,
+local_heads,
+common_heads,
+)
+else:
+undecided_common = res["nb-ini_und-common"]
+undecided_missing = res["nb-ini_und-missing"]
+undecided = undecided_common + undecided_missing
+print(
+repo,
+format_case(local_case),
+format_case(remote_case),
+variant,
+roundtrips,
+queries,
+revs,
+local_heads,
+common_heads,
+undecided,
+undecided_common,
+undecided_missing,
+)
+return 0
+

D12397: search-discovery-case: display more information about the interresting case

2022-03-22 Thread marmoute (Pierre-Yves David)
marmoute created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  We display information about the total number of revs and the common/missing
  numbers. This is useful to spot the interresting case.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  contrib/perf-utils/search-discovery-case

CHANGE DETAILS

diff --git a/contrib/perf-utils/search-discovery-case 
b/contrib/perf-utils/search-discovery-case
--- a/contrib/perf-utils/search-discovery-case
+++ b/contrib/perf-utils/search-discovery-case
@@ -147,13 +147,23 @@
 roundtrips = res["total-roundtrips"]
 if roundtrips <= 1:
 return None
+total_rev = res["nb-revs"]
+common_rev = res["nb-revs-common"]
+missing_rev = res["nb-revs-missing"]
 undecided_common = res["nb-ini_und-common"]
 undecided_missing = res["nb-ini_und-missing"]
 if undecided_common == 0:
 return None
 if undecided_missing == 0:
 return None
-return (roundtrips, undecided_common, undecided_missing)
+return (
+roundtrips,
+undecided_common,
+undecided_missing,
+total_rev,
+common_rev,
+missing_rev,
+)
 
 
 def end(*args, **kwargs):



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


D12396: subsetmaker: rework the antichain generation to be usable

2022-03-22 Thread marmoute (Pierre-Yves David)
marmoute created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  Before this, antichain computation can run for 10s of hours without 
completion in
  sight. We use a more direct approach in the computation to keep the 
computation
  in complexity in check. With good result.
  
  We can now have a full antichain computation on mozilla-try in about one
  minute. Which is usable.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  contrib/perf-utils/subsetmaker.py

CHANGE DETAILS

diff --git a/contrib/perf-utils/subsetmaker.py 
b/contrib/perf-utils/subsetmaker.py
--- a/contrib/perf-utils/subsetmaker.py
+++ b/contrib/perf-utils/subsetmaker.py
@@ -159,16 +159,44 @@
 else:
 assert False
 
-selected = set()
+cl = repo.changelog
 
-baseset = revset.getset(repo, smartset.fullreposet(repo), x)
-undecided = baseset
+# We already have cheap access to the parent mapping.
+# However, we need to build a mapping of the children mapping
+parents = repo.changelog._uncheckedparentrevs
+children_map = collections.defaultdict(list)
+for r in cl:
+p1, p2 = parents(r)
+if p1 >= 0:
+children_map[p1].append(r)
+if p2 >= 0:
+children_map[p2].append(r)
+children = children_map.__getitem__
+
+selected = set()
+undecided = SortedSet(cl)
 
 while undecided:
-pick = rand.choice(list(undecided))
+# while there is "undecided content", we pick a random changeset X
+# and we remove anything in `::X + X::` from undecided content
+pick = rand.choice(undecided)
 selected.add(pick)
-undecided = repo.revs(
-'%ld and not (::%ld or %ld::head())', baseset, selected, selected
-)
+undecided.remove(pick)
+
+ancestors = set(p for p in parents(pick) if p in undecided)
+descendants = set(c for c in children(pick) if c in undecided)
+
+while ancestors:
+current = ancestors.pop()
+undecided.remove(current)
+for p in parents(current):
+if p in undecided:
+ancestors.add(p)
+while descendants:
+current = descendants.pop()
+undecided.remove(current)
+for p in children(current):
+if p in undecided:
+ancestors.add(p)
 
 return smartset.baseset(selected) & subset



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


D12395: subsetmaker: use SortedSet for the scratch variant

2022-03-22 Thread marmoute (Pierre-Yves David)
marmoute created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  This provides a massive speedup on wide repository with many heads. For 
example
  on mozilla-try, this move from un-usable slow to fairly instant.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  contrib/perf-utils/subsetmaker.py

CHANGE DETAILS

diff --git a/contrib/perf-utils/subsetmaker.py 
b/contrib/perf-utils/subsetmaker.py
--- a/contrib/perf-utils/subsetmaker.py
+++ b/contrib/perf-utils/subsetmaker.py
@@ -15,6 +15,10 @@
 smartset,
 )
 
+import sortedcontainers
+
+SortedSet = sortedcontainers.SortedSet
+
 revsetpredicate = registrar.revsetpredicate()
 
 
@@ -78,7 +82,7 @@
 n = revsetlang.getinteger(n, _(b"scratch expects a number"))
 
 selected = set()
-heads = set()
+heads = SortedSet()
 children_count = collections.defaultdict(lambda: 0)
 parents = repo.changelog._uncheckedparentrevs
 
@@ -102,9 +106,7 @@
 for x in range(n):
 if not heads:
 break
-pickable = list(heads)
-pickable.sort()
-pick = rand.choice(pickable)
+pick = rand.choice(heads)
 heads.remove(pick)
 assert pick not in selected
 selected.add(pick)



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


D12394: subsetmaker: stabilize the computation of `scratch` subset

2022-03-22 Thread marmoute (Pierre-Yves David)
marmoute created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  `heads` is set, order of the element are not deterministic and we need to
  stabilize that if we want to get reproducible results.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  contrib/perf-utils/subsetmaker.py

CHANGE DETAILS

diff --git a/contrib/perf-utils/subsetmaker.py 
b/contrib/perf-utils/subsetmaker.py
--- a/contrib/perf-utils/subsetmaker.py
+++ b/contrib/perf-utils/subsetmaker.py
@@ -102,7 +102,9 @@
 for x in range(n):
 if not heads:
 break
-pick = rand.choice(list(heads))
+pickable = list(heads)
+pickable.sort()
+pick = rand.choice(pickable)
 heads.remove(pick)
 assert pick not in selected
 selected.add(pick)



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


D12393: hgignore: ignore .testtimes in more location

2022-03-22 Thread marmoute (Pierre-Yves David)
marmoute created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  See the inline comment.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  .hgignore

CHANGE DETAILS

diff --git a/.hgignore b/.hgignore
--- a/.hgignore
+++ b/.hgignore
@@ -22,6 +22,8 @@
 tests/artifacts/cache/big-file-churn.hg
 tests/.coverage*
 tests/.testtimes*
+# the file is written in the CWD when run-tests is run.
+.testtimes
 tests/.hypothesis
 tests/hypothesis-generated
 tests/annotated



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


D12388: ci: use the `v1.0` flavor of the docker images in the CI

2022-03-19 Thread marmoute (Pierre-Yves David)
marmoute created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  This new versioning will help use to maintain backward compatibility in the
  docker image. This will be useful to deal with mismatch between default/stable
  in version and the re-run CI on older changesets in the future.
  
  Once this changeset land on stable, we will have to merge it in default. Then
  we can start make backward incompatible changes in a new image version.

REPOSITORY
  rHG Mercurial

BRANCH
  stable

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

AFFECTED FILES
  contrib/heptapod-ci.yml

CHANGE DETAILS

diff --git a/contrib/heptapod-ci.yml b/contrib/heptapod-ci.yml
--- a/contrib/heptapod-ci.yml
+++ b/contrib/heptapod-ci.yml
@@ -7,7 +7,7 @@
 variables:
 PYTHON: python
 TEST_HGMODULEPOLICY: "allow"
-HG_CI_IMAGE_TAG: "latest"
+HG_CI_IMAGE_TAG: "v1.0"
 TEST_HGTESTS_ALLOW_NETIO: "0"
 
 .all_template: 



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


D12382: test: use `wait-on-file` in `test-racy-mutations.t`

2022-03-17 Thread marmoute (Pierre-Yves David)
marmoute created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  The official utility scale its timeout with the run-tests.py one. So lets use
  it.

REPOSITORY
  rHG Mercurial

BRANCH
  stable

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

AFFECTED FILES
  tests/test-racy-mutations.t

CHANGE DETAILS

diff --git a/tests/test-racy-mutations.t b/tests/test-racy-mutations.t
--- a/tests/test-racy-mutations.t
+++ b/tests/test-racy-mutations.t
@@ -14,14 +14,7 @@
   > f="\${WAITLOCK_FILE}"
   > start=\`date +%s\`
   > timeout=5
-  > while [ \\( ! -f \$f \\) -a \\( ! -L \$f \\) ]; do
-  > now=\`date +%s\`
-  > if [ "\`expr \$now - \$start\`" -gt \$timeout ]; then
-  > echo "timeout: \$f was not created in \$timeout seconds (it is 
now \$(date +%s))"
-  > exit 1
-  > fi
-  > sleep 0.1
-  > done
+  > $RUNTESTDIR/testlib/wait-on-file "\$timeout" "\$f"
   > if [ \$# -gt 1 ]; then
   > cat "\$@"
   > fi



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


D12372: debugdiscovery: fix a typo in the help

2022-03-11 Thread marmoute (Pierre-Yves David)
marmoute created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  mercurial/debugcommands.py

CHANGE DETAILS

diff --git a/mercurial/debugcommands.py b/mercurial/debugcommands.py
--- a/mercurial/debugcommands.py
+++ b/mercurial/debugcommands.py
@@ -1020,7 +1020,7 @@
 b'',
 b'remote-as-revs',
 b"",
-b'use local as remote, with only these these revisions',
+b'use local as remote, with only these revisions',
 ),
 ]
 + cmdutil.remoteopts



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


Re: pycompat.py strategy

2022-03-02 Thread Pierre-Yves David


On 2/21/22 19:47, Gregory Szorc wrote:
I'm ~100 patches deep into purging Python 2 from the main repo. (I 
think I'll hold off submitting them until 6.1 is out the door.)


Much of the Python 2 deletion work is trivial. But one question that 
isn't trivial is what to do with pycompat.py.


Some options:

a) Attempt to delete as much as pycompat.py as possible (leaving only 
the pieces needed to abstract over differences in Python 3.5-3.x).
b) Leave the ~complete API provided by pycompat.py and delete pycompat 
usage within the repo as much as possible.
c) Leave the ~complete API provided by pycompat.py and still use 
pycompat heavily within the repo.


In my series, I'm going with "b" because after deletion of Python 2, 
many of the abstractions in Python 2 no longer make much sense and 
their presence doesn't accomplish much except confuse people through 
extra indirection. Things like pycompat.iteritems() (which is just a 
proxy to .items()) don't serve any purpose any more and IMO shouldn't 
be used.


Other parts of pycompat are harder to delete. e.g. strkwargs() and 
byteskwargs() are used pretty heavily and form an API contract. So I 
anticipate we'll be living with them for a while.


As much as I would like to delete APIs from pycompat.py entirely, I 
think we should keep them around so extensions have a stable API to 
manage the Python 2 -> 3 and <=6.1 to >6.1 migrations. However, I 
think we should establish a schedule for marking them as deprecated 
and deleting them. This schedule should be independent of their usage 
within the repo, as the two decisions are separate.


Thoughts?



Keeping the pycompat module around for some versions is probably the 
simplest from as extension point of view. So (b) seems like the best 
option to me.



--
Pierre-Yves David

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


D12214: windows: skip a section of a test that is legitimately broken on windows

2022-02-22 Thread marmoute (Pierre-Yves David)
marmoute created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  See the comment in the test itself.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  tests/test-clone-stream-format.t

CHANGE DETAILS

diff --git a/tests/test-clone-stream-format.t b/tests/test-clone-stream-format.t
--- a/tests/test-clone-stream-format.t
+++ b/tests/test-clone-stream-format.t
@@ -93,9 +93,14 @@
   $ cd ..
 
 
+#if no-windows
+
 Test streaming from/to repository without a store:
 ==
 
+This is skipped Windows needs dot-encode to handle some of the file in this
+tests, and dot-encode need the store enabled.
+
   $ hg clone --pull --config format.usestore=no server server-no-store
   requesting all changes
   adding changesets
@@ -150,6 +155,8 @@
 
   $ killdaemons.py
 
+#endif
+
 
 Test streaming from/to repository without a fncache
 ===



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


D12201: tracked-key: remove the dual write and rename to tracked-hint

2022-02-17 Thread marmoute (Pierre-Yves David)
marmoute created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  The dual-write approach was mostly useless. As explained in the previous 
version
  of the help, the key had to be read twice before we could cache a value.
  
  However this "read twice" limitation actually also apply to any usage of the
  key. If some operation wants to rely of the "same value == same tracked set"
  property it would need to read the value before, and after running that
  operation (or at least, after, in all cases). So it cannot be sure the 
operation
  it did is "valid" until checking the key after the operation. As a resultat 
such
  operation can only be read-only or rollbackable.
  
  This reduce the utility of the "same value == same tracked set" a lot.
  
  So it seems simpler to drop the double write and to update the documentation 
to
  highlight that this file does not garantee race-free operation. As a result 
the
  "key" is demoted to a "hint".
  
  Documentation is updated accordingly.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  mercurial/configitems.py
  mercurial/dirstate.py
  mercurial/helptext/config.txt
  mercurial/localrepo.py
  mercurial/requirements.py
  mercurial/upgrade_utils/actions.py
  mercurial/upgrade_utils/engine.py
  tests/test-help.t
  tests/test-persistent-nodemap.t
  tests/test-status-tracked-key.t
  tests/test-upgrade-repo.t

CHANGE DETAILS

diff --git a/tests/test-upgrade-repo.t b/tests/test-upgrade-repo.t
--- a/tests/test-upgrade-repo.t
+++ b/tests/test-upgrade-repo.t
@@ -214,7 +214,7 @@
   format-variant repo
   fncache:yes
   dirstate-v2: no
-  tracked-key: no
+  tracked-hint:no
   dotencode:  yes
   generaldelta:   yes
   share-safe: yes
@@ -231,7 +231,7 @@
   format-variant repo config default
   fncache:yesyes yes
   dirstate-v2: no no  no
-  tracked-key: no no  no
+  tracked-hint:no no  no
   dotencode:  yesyes yes
   generaldelta:   yesyes yes
   share-safe: yesyes yes
@@ -249,7 +249,7 @@
   format-variant repo config default
   fncache:yes no yes
   dirstate-v2: no no  no
-  tracked-key: no no  no
+  tracked-hint:no no  no
   dotencode:  yes no yes
   generaldelta:   yesyes yes
   share-safe: yesyes yes
@@ -267,7 +267,7 @@
   format-variant repo config default
   [formatvariant.name.mismatchconfig|fncache:   
][formatvariant.repo.mismatchconfig| yes][formatvariant.config.special| 
no][formatvariant.default| yes]
   [formatvariant.name.uptodate|dirstate-v2:   
][formatvariant.repo.uptodate|  no][formatvariant.config.default| 
no][formatvariant.default|  no]
-  [formatvariant.name.uptodate|tracked-key:   
][formatvariant.repo.uptodate|  no][formatvariant.config.default| 
no][formatvariant.default|  no]
+  [formatvariant.name.uptodate|tracked-hint:  
][formatvariant.repo.uptodate|  no][formatvariant.config.default| 
no][formatvariant.default|  no]
   [formatvariant.name.mismatchconfig|dotencode: 
][formatvariant.repo.mismatchconfig| yes][formatvariant.config.special| 
no][formatvariant.default| yes]
   [formatvariant.name.uptodate|generaldelta:  
][formatvariant.repo.uptodate| yes][formatvariant.config.default|
yes][formatvariant.default| yes]
   [formatvariant.name.uptodate|share-safe:
][formatvariant.repo.uptodate| yes][formatvariant.config.default|
yes][formatvariant.default| yes]
@@ -298,7 +298,7 @@
{
 "config": false,
 "default": false,
-"name": "tracked-key",
+"name": "tracked-hint",
 "repo": false
},
{
@@ -498,7 +498,7 @@
   format-variant repo
   fncache: no
   dirstate-v2: no
-  tracked-key: no
+  tracked-hint:no
   dotencode:   no
   generaldelta:no
   share-safe:  no
@@ -514,7 +514,7 @@
   format-variant repo config default
   fncache: noyes yes
   dirstate-v2: no no  no
-  tracked-key: no no  no
+  tracked-hint:no no  no
   dotencode:   noyes yes
   generaldelta:noyes yes
   share-safe:  noyes yes
@@ -532,7 +532,7 @@
   format-variant repo config default
   fncache: noyes yes
   dirstate-v2: no no  no
-  tracked-key: no no  no
+  tracked-hint:no no  no
   dotencode:   noyes yes
   generaldelta:no no yes
   share-safe:  noyes yes
@@ -550,7 +550,7 @@
   format-variant repo config default
   

D12200: tracked-file: rename the format option to use `use-`

2022-02-17 Thread marmoute (Pierre-Yves David)
marmoute created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  This is more consistent with the other options.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  mercurial/configitems.py
  mercurial/helptext/config.txt
  mercurial/localrepo.py
  tests/test-help.t
  tests/test-status-tracked-key.t

CHANGE DETAILS

diff --git a/tests/test-status-tracked-key.t b/tests/test-status-tracked-key.t
--- a/tests/test-status-tracked-key.t
+++ b/tests/test-status-tracked-key.t
@@ -9,7 +9,7 @@
 
   $ cat << EOF >> $HGRCPATH
   > [format]
-  > dirstate-tracked-key=yes
+  > use-dirstate-tracked-key=yes
   > EOF
 
   $ hg init tracked-key-test
@@ -172,7 +172,7 @@
 
 downgrade
 
-  $ hg debugupgraderepo --config format.dirstate-tracked-key=no --run --quiet
+  $ hg debugupgraderepo --config format.use-dirstate-tracked-key=no --run 
--quiet
   upgrade will perform the following actions:
   
   requirements
@@ -189,7 +189,7 @@
 
 upgrade
 
-  $ hg debugupgraderepo --config format.dirstate-tracked-key=yes --run --quiet
+  $ hg debugupgraderepo --config format.use-dirstate-tracked-key=yes --run 
--quiet
   upgrade will perform the following actions:
   
   requirements
diff --git a/tests/test-help.t b/tests/test-help.t
--- a/tests/test-help.t
+++ b/tests/test-help.t
@@ -1599,7 +1599,7 @@
   
   "use-dirstate-v2"
   
-  "dirstate-tracked-key"
+  "use-dirstate-tracked-key"
   
   "use-persistent-nodemap"
   
diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py
--- a/mercurial/localrepo.py
+++ b/mercurial/localrepo.py
@@ -3695,10 +3695,10 @@
 else:
 requirements.add(requirementsmod.SHARED_REQUIREMENT)
 
-if ui.configbool(b'format', b'dirstate-tracked-key'):
-version = ui.configint(b'format', b'dirstate-tracked-key.version')
+if ui.configbool(b'format', b'use-dirstate-tracked-key'):
+version = ui.configint(b'format', b'use-dirstate-tracked-key.version')
 msg = _("ignoring unknown tracked key version: %d\n")
-hint = _("see `hg help config.format.exp-dirstate-tracked-key-version")
+hint = _("see `hg help config.format.use-dirstate-tracked-key-version")
 if version != 1:
 ui.warn(msg % version, hint=hint)
 else:
diff --git a/mercurial/helptext/config.txt b/mercurial/helptext/config.txt
--- a/mercurial/helptext/config.txt
+++ b/mercurial/helptext/config.txt
@@ -944,7 +944,7 @@
 
 For a more comprehensive guide, see :hg:`help internals.dirstate-v2`.
 
-``dirstate-tracked-key``
+``use-dirstate-tracked-key``
 Enable or disable the writing of "tracked key" file alongside the dirstate.
 (default to disabled)
 
diff --git a/mercurial/configitems.py b/mercurial/configitems.py
--- a/mercurial/configitems.py
+++ b/mercurial/configitems.py
@@ -1279,13 +1279,13 @@
 )
 coreconfigitem(
 b'format',
-b'dirstate-tracked-key',
+b'use-dirstate-tracked-key',
 default=False,
 experimental=True,
 )
 coreconfigitem(
 b'format',
-b'dirstate-tracked-key.version',
+b'use-dirstate-tracked-key.version',
 default=1,
 experimental=True,
 )



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


D12198: tracked-key: make it possible to upgrade to and downgrade from the feature

2022-02-17 Thread marmoute (Pierre-Yves David)
marmoute created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  This seems rather important if we want people to start using it.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  mercurial/dirstate.py
  mercurial/upgrade_utils/actions.py
  mercurial/upgrade_utils/engine.py
  tests/test-persistent-nodemap.t
  tests/test-status-tracked-key.t
  tests/test-upgrade-repo.t

CHANGE DETAILS

diff --git a/tests/test-upgrade-repo.t b/tests/test-upgrade-repo.t
--- a/tests/test-upgrade-repo.t
+++ b/tests/test-upgrade-repo.t
@@ -214,6 +214,7 @@
   format-variant repo
   fncache:yes
   dirstate-v2: no
+  tracked-key: no
   dotencode:  yes
   generaldelta:   yes
   share-safe: yes
@@ -230,6 +231,7 @@
   format-variant repo config default
   fncache:yesyes yes
   dirstate-v2: no no  no
+  tracked-key: no no  no
   dotencode:  yesyes yes
   generaldelta:   yesyes yes
   share-safe: yesyes yes
@@ -247,6 +249,7 @@
   format-variant repo config default
   fncache:yes no yes
   dirstate-v2: no no  no
+  tracked-key: no no  no
   dotencode:  yes no yes
   generaldelta:   yesyes yes
   share-safe: yesyes yes
@@ -264,6 +267,7 @@
   format-variant repo config default
   [formatvariant.name.mismatchconfig|fncache:   
][formatvariant.repo.mismatchconfig| yes][formatvariant.config.special| 
no][formatvariant.default| yes]
   [formatvariant.name.uptodate|dirstate-v2:   
][formatvariant.repo.uptodate|  no][formatvariant.config.default| 
no][formatvariant.default|  no]
+  [formatvariant.name.uptodate|tracked-key:   
][formatvariant.repo.uptodate|  no][formatvariant.config.default| 
no][formatvariant.default|  no]
   [formatvariant.name.mismatchconfig|dotencode: 
][formatvariant.repo.mismatchconfig| yes][formatvariant.config.special| 
no][formatvariant.default| yes]
   [formatvariant.name.uptodate|generaldelta:  
][formatvariant.repo.uptodate| yes][formatvariant.config.default|
yes][formatvariant.default| yes]
   [formatvariant.name.uptodate|share-safe:
][formatvariant.repo.uptodate| yes][formatvariant.config.default|
yes][formatvariant.default| yes]
@@ -292,6 +296,12 @@
 "repo": false
},
{
+"config": false,
+"default": false,
+"name": "tracked-key",
+"repo": false
+   },
+   {
 "config": true,
 "default": true,
 "name": "dotencode",
@@ -488,6 +498,7 @@
   format-variant repo
   fncache: no
   dirstate-v2: no
+  tracked-key: no
   dotencode:   no
   generaldelta:no
   share-safe:  no
@@ -503,6 +514,7 @@
   format-variant repo config default
   fncache: noyes yes
   dirstate-v2: no no  no
+  tracked-key: no no  no
   dotencode:   noyes yes
   generaldelta:noyes yes
   share-safe:  noyes yes
@@ -520,6 +532,7 @@
   format-variant repo config default
   fncache: noyes yes
   dirstate-v2: no no  no
+  tracked-key: no no  no
   dotencode:   noyes yes
   generaldelta:no no yes
   share-safe:  noyes yes
@@ -537,6 +550,7 @@
   format-variant repo config default
   [formatvariant.name.mismatchconfig|fncache:   
][formatvariant.repo.mismatchconfig|  no][formatvariant.config.default|
yes][formatvariant.default| yes]
   [formatvariant.name.uptodate|dirstate-v2:   
][formatvariant.repo.uptodate|  no][formatvariant.config.default| 
no][formatvariant.default|  no]
+  [formatvariant.name.uptodate|tracked-key:   
][formatvariant.repo.uptodate|  no][formatvariant.config.default| 
no][formatvariant.default|  no]
   [formatvariant.name.mismatchconfig|dotencode: 
][formatvariant.repo.mismatchconfig|  no][formatvariant.config.default|
yes][formatvariant.default| yes]
   [formatvariant.name.mismatchdefault|generaldelta:  
][formatvariant.repo.mismatchdefault|  no][formatvariant.config.special| 
no][formatvariant.default| yes]
   [formatvariant.name.mismatchconfig|share-safe:
][formatvariant.repo.mismatchconfig|  no][formatvariant.config.default|
yes][formatvariant.default| yes]
@@ -1588,6 +1602,7 @@
   format-variant repo config default
   fncache:yesyes yes
   dirstate-v2: no no  no
+  tracked-key: no no  no
   dotencode:  yesyes yes
   generaldelta:   yesyes yes
   share-safe: yesyes yes
@@ -1631,6 

D12199: tracked-key: update the requirement value

2022-02-17 Thread marmoute (Pierre-Yves David)
marmoute created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  We renamed the config option but we forgot to change the actual value…

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  mercurial/requirements.py
  tests/test-status-tracked-key.t

CHANGE DETAILS

diff --git a/tests/test-status-tracked-key.t b/tests/test-status-tracked-key.t
--- a/tests/test-status-tracked-key.t
+++ b/tests/test-status-tracked-key.t
@@ -168,7 +168,7 @@
   $ ls .hg/dirstate-tracked-key
   .hg/dirstate-tracked-key
   $ hg debugrequires | grep 'tracked'
-  exp-dirstate-tracked-key-v1
+  dirstate-tracked-key-v1
 
 downgrade
 
@@ -177,7 +177,7 @@
   
   requirements
  preserved: * (glob)
- removed: exp-dirstate-tracked-key-v1
+ removed: dirstate-tracked-key-v1
   
   no revlogs to process
   
@@ -194,11 +194,11 @@
   
   requirements
  preserved: * (glob)
- added: exp-dirstate-tracked-key-v1
+ added: dirstate-tracked-key-v1
   
   no revlogs to process
   
   $ ls -1 .hg/dirstate-tracked-key
   .hg/dirstate-tracked-key
   $ hg debugrequires | grep 'tracked'
-  exp-dirstate-tracked-key-v1
+  dirstate-tracked-key-v1
diff --git a/mercurial/requirements.py b/mercurial/requirements.py
--- a/mercurial/requirements.py
+++ b/mercurial/requirements.py
@@ -18,7 +18,7 @@
 STORE_REQUIREMENT = b'store'
 FNCACHE_REQUIREMENT = b'fncache'
 
-DIRSTATE_TRACKED_KEY_V1 = b'exp-dirstate-tracked-key-v1'
+DIRSTATE_TRACKED_KEY_V1 = b'dirstate-tracked-key-v1'
 DIRSTATE_V2_REQUIREMENT = b'dirstate-v2'
 
 # When narrowing is finalized and no longer subject to format changes,



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


D12196: upgrade: prepare code (and output) for the idea of upgrading share

2022-02-16 Thread marmoute (Pierre-Yves David)
marmoute created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  This would work for a subset of action only. Our first target is dirstate-v2.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  mercurial/upgrade.py
  mercurial/upgrade_utils/actions.py
  tests/test-share-safe.t
  tests/test-upgrade-repo.t

CHANGE DETAILS

diff --git a/tests/test-upgrade-repo.t b/tests/test-upgrade-repo.t
--- a/tests/test-upgrade-repo.t
+++ b/tests/test-upgrade-repo.t
@@ -32,10 +32,12 @@
   $ hg init share-parent
   $ hg -q share share-parent share-child
 
-  $ hg -R share-child debugupgraderepo
-  abort: cannot upgrade repository; unsupported source requirement: shared
+  $ hg -R share-child debugupgraderepo --config format.sparse-revlog=no
+  abort: cannot use theses action on a share repository: sparserevlog
+  (upgrade the main repository directly)
   [255]
 
+
 Do not yet support upgrading treemanifest repos
 
   $ hg --config experimental.treemanifest=true init treemanifest
diff --git a/tests/test-share-safe.t b/tests/test-share-safe.t
--- a/tests/test-share-safe.t
+++ b/tests/test-share-safe.t
@@ -244,7 +244,8 @@
   $ echo "use-persistent-nodemap=True" >> .hg/hgrc
 
   $ hg debugupgraderepo --run -q -R ../shared1
-  abort: cannot upgrade repository; unsupported source requirement: shared
+  abort: cannot use theses action on a share repository: persistent-nodemap
+  (upgrade the main repository directly)
   [255]
 
   $ hg debugupgraderepo --run -q
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
@@ -36,7 +36,10 @@
 
 
 def preservedrequirements(repo):
-return set()
+preserved = {
+requirements.SHARED_REQUIREMENT,
+}
+return preserved & repo.requirements
 
 
 FORMAT_VARIANT = b'deficiency'
@@ -97,6 +100,9 @@
 # Whether this improvement touches the dirstate
 touches_dirstate = False
 
+# Can this action be run on a share instead of its mains repository
+compatible_with_share = False
+
 
 allformatvariant = []  # type: List[Type['formatvariant']]
 
@@ -899,8 +905,6 @@
 # This was a precursor to generaldelta and was never enabled by 
default.
 # It should (hopefully) not exist in the wild.
 b'parentdelta',
-# Upgrade should operate on the actual store, not the shared link.
-requirements.SHARED_REQUIREMENT,
 }
 
 
@@ -932,6 +936,16 @@
 m = _(b'cannot upgrade repository; unsupported source requirement: %s')
 blockingreqs = b', '.join(sorted(blockingreqs))
 raise error.Abort(m % blockingreqs)
+# Upgrade should operate on the actual store, not the shared link.
+
+bad_share = (
+requirements.SHARED_REQUIREMENT in repo.requirements
+and requirements.SHARESAFE_REQUIREMENT not in repo.requirements
+)
+if bad_share:
+m = _(b'cannot upgrade repository; share repository without 
share-safe')
+h = _(b'check :hg:`help config.format.use-share-safe`')
+raise error.Abort(m, hint=h)
 
 
 ### Verify the validity of the planned requirement changes 
@@ -972,18 +986,19 @@
 Extensions should monkeypatch this to add their custom requirements.
 """
 supported = {
+requirements.CHANGELOGV2_REQUIREMENT,
+requirements.COPIESSDC_REQUIREMENT,
+requirements.DIRSTATE_V2_REQUIREMENT,
 requirements.DOTENCODE_REQUIREMENT,
 requirements.FNCACHE_REQUIREMENT,
 requirements.GENERALDELTA_REQUIREMENT,
+requirements.NODEMAP_REQUIREMENT,
 requirements.REVLOGV1_REQUIREMENT,  # allowed in case of downgrade
-requirements.STORE_REQUIREMENT,
+requirements.REVLOGV2_REQUIREMENT,
+requirements.SHARED_REQUIREMENT,
+requirements.SHARESAFE_REQUIREMENT,
 requirements.SPARSEREVLOG_REQUIREMENT,
-requirements.COPIESSDC_REQUIREMENT,
-requirements.NODEMAP_REQUIREMENT,
-requirements.SHARESAFE_REQUIREMENT,
-requirements.REVLOGV2_REQUIREMENT,
-requirements.CHANGELOGV2_REQUIREMENT,
-requirements.DIRSTATE_V2_REQUIREMENT,
+requirements.STORE_REQUIREMENT,
 }
 for name in compression.compengines:
 engine = compression.compengines[name]
diff --git a/mercurial/upgrade.py b/mercurial/upgrade.py
--- a/mercurial/upgrade.py
+++ b/mercurial/upgrade.py
@@ -108,6 +108,22 @@
 if not enabled:
 touched_revlogs.discard(rl)
 
+if repo.shared():
+unsafe_actions = set()
+unsafe_actions.update(up_actions)
+unsafe_actions.update(removed_actions)
+unsafe_actions.update(optimizations)
+unsafe_actions = [
+a for a in unsafe_actions if not a.compatible_with_share
+]
+

D12197: upgrade: make dirstate-v2 format variant compatible with share

2022-02-16 Thread marmoute (Pierre-Yves David)
marmoute created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  This only affects the dirstate and is safe to upgrade in the share.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  mercurial/upgrade_utils/actions.py
  tests/test-upgrade-repo.t

CHANGE DETAILS

diff --git a/tests/test-upgrade-repo.t b/tests/test-upgrade-repo.t
--- a/tests/test-upgrade-repo.t
+++ b/tests/test-upgrade-repo.t
@@ -6,6 +6,8 @@
   > [format]
   > # stabilize test accross variant
   > revlog-compression=zlib
+  > [storage]
+  > dirstate-v2.slow-path=allow
   > EOF
 
 store and revlogv1 are required in source
@@ -30,6 +32,9 @@
 Cannot upgrade shared repositories
 
   $ hg init share-parent
+  $ hg -R share-parent debugbuilddag -n .+9
+  $ hg -R share-parent up tip
+  10 files updated, 0 files merged, 0 files removed, 0 files unresolved
   $ hg -q share share-parent share-child
 
   $ hg -R share-child debugupgraderepo --config format.sparse-revlog=no
@@ -37,6 +42,155 @@
   (upgrade the main repository directly)
   [255]
 
+Unless the action is compatible with share
+
+  $ hg -R share-child debugupgraderepo --config format.use-dirstate-v2=yes 
--quiet
+  requirements
+ preserved: * (glob)
+ added: dirstate-v2
+  
+  no revlogs to process
+  
+
+  $ hg -R share-child debugupgraderepo --config format.use-dirstate-v2=yes 
--quiet --run
+  upgrade will perform the following actions:
+  
+  requirements
+ preserved: * (glob)
+ added: dirstate-v2
+  
+  no revlogs to process
+  
+  $ hg debugformat -R share-child | grep dirstate-v2
+  dirstate-v2:yes
+  $ hg debugformat -R share-parent | grep dirstate-v2
+  dirstate-v2: no
+  $ hg status --all -R share-child
+  C nf0
+  C nf1
+  C nf2
+  C nf3
+  C nf4
+  C nf5
+  C nf6
+  C nf7
+  C nf8
+  C nf9
+  $ hg log -l 3 -R share-child
+  changeset:   9:0059eb38e4a4
+  tag: tip
+  user:debugbuilddag
+  date:Thu Jan 01 00:00:09 1970 +
+  summary: r9
+  
+  changeset:   8:4d5be70c8130
+  user:debugbuilddag
+  date:Thu Jan 01 00:00:08 1970 +
+  summary: r8
+  
+  changeset:   7:e60bfe72517e
+  user:debugbuilddag
+  date:Thu Jan 01 00:00:07 1970 +
+  summary: r7
+  
+  $ hg status --all -R share-parent
+  C nf0
+  C nf1
+  C nf2
+  C nf3
+  C nf4
+  C nf5
+  C nf6
+  C nf7
+  C nf8
+  C nf9
+  $ hg log -l 3 -R share-parent
+  changeset:   9:0059eb38e4a4
+  tag: tip
+  user:debugbuilddag
+  date:Thu Jan 01 00:00:09 1970 +
+  summary: r9
+  
+  changeset:   8:4d5be70c8130
+  user:debugbuilddag
+  date:Thu Jan 01 00:00:08 1970 +
+  summary: r8
+  
+  changeset:   7:e60bfe72517e
+  user:debugbuilddag
+  date:Thu Jan 01 00:00:07 1970 +
+  summary: r7
+  
+
+  $ hg -R share-child debugupgraderepo --config format.use-dirstate-v2=no 
--quiet --run
+  upgrade will perform the following actions:
+  
+  requirements
+ preserved: * (glob)
+ removed: dirstate-v2
+  
+  no revlogs to process
+  
+  $ hg debugformat -R share-child | grep dirstate-v2
+  dirstate-v2: no
+  $ hg debugformat -R share-parent | grep dirstate-v2
+  dirstate-v2: no
+  $ hg status --all -R share-child
+  C nf0
+  C nf1
+  C nf2
+  C nf3
+  C nf4
+  C nf5
+  C nf6
+  C nf7
+  C nf8
+  C nf9
+  $ hg log -l 3 -R share-child
+  changeset:   9:0059eb38e4a4
+  tag: tip
+  user:debugbuilddag
+  date:Thu Jan 01 00:00:09 1970 +
+  summary: r9
+  
+  changeset:   8:4d5be70c8130
+  user:debugbuilddag
+  date:Thu Jan 01 00:00:08 1970 +
+  summary: r8
+  
+  changeset:   7:e60bfe72517e
+  user:debugbuilddag
+  date:Thu Jan 01 00:00:07 1970 +
+  summary: r7
+  
+  $ hg status --all -R share-parent
+  C nf0
+  C nf1
+  C nf2
+  C nf3
+  C nf4
+  C nf5
+  C nf6
+  C nf7
+  C nf8
+  C nf9
+  $ hg log -l 3 -R share-parent
+  changeset:   9:0059eb38e4a4
+  tag: tip
+  user:debugbuilddag
+  date:Thu Jan 01 00:00:09 1970 +
+  summary: r9
+  
+  changeset:   8:4d5be70c8130
+  user:debugbuilddag
+  date:Thu Jan 01 00:00:08 1970 +
+  summary: r8
+  
+  changeset:   7:e60bfe72517e
+  user:debugbuilddag
+  date:Thu Jan 01 00:00:07 1970 +
+  summary: r7
+  
 
 Do not yet support upgrading treemanifest repos
 
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
@@ -196,6 +196,7 @@
 touches_changelog = False
 touches_requirements = True
 touches_dirstate = True
+compatible_with_share = True
 
 
 @registerformatvariant



To: marmoute, #hg-reviewers
Cc: mercurial-patches, mercurial-devel

D12184: dirstate-tracked-key: update the config value to match latest discussion

2022-02-15 Thread marmoute (Pierre-Yves David)
marmoute created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  Special cases are not special enough, we align the option name on the other.
  
  The `version` value is undocumented for now as it can only have a single 
value.
  It is supported in the code to properly detect and abort if more value are
  introduced in the future value.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  mercurial/configitems.py
  mercurial/helptext/config.txt
  mercurial/localrepo.py
  tests/test-help.t
  tests/test-status-tracked-key.t

CHANGE DETAILS

diff --git a/tests/test-status-tracked-key.t b/tests/test-status-tracked-key.t
--- a/tests/test-status-tracked-key.t
+++ b/tests/test-status-tracked-key.t
@@ -9,7 +9,7 @@
 
   $ cat << EOF >> $HGRCPATH
   > [format]
-  > exp-dirstate-tracked-key-version=1
+  > dirstate-tracked-key=yes
   > EOF
 
   $ hg init tracked-key-test
diff --git a/tests/test-help.t b/tests/test-help.t
--- a/tests/test-help.t
+++ b/tests/test-help.t
@@ -1599,7 +1599,7 @@
   
   "use-dirstate-v2"
   
-  "exp-dirstate-tracked-key-version"
+  "dirstate-tracked-key"
   
   "use-persistent-nodemap"
   
diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py
--- a/mercurial/localrepo.py
+++ b/mercurial/localrepo.py
@@ -3695,14 +3695,12 @@
 else:
 requirements.add(requirementsmod.SHARED_REQUIREMENT)
 
-tracked_key = ui.configint(b'format', b'exp-dirstate-tracked-key-version')
-if tracked_key:
-if tracked_key != 1:
-msg = _("ignoring unknown tracked key version: %d\n")
-hint = _(
-"see `hg help config.format.exp-dirstate-tracked-key-version"
-)
-ui.warn(msg % tracked_key, hint=hint)
+if ui.configbool(b'format', b'dirstate-tracked-key'):
+version = ui.configint(b'format', b'dirstate-tracked-key.version')
+msg = _("ignoring unknown tracked key version: %d\n")
+hint = _("see `hg help config.format.exp-dirstate-tracked-key-version")
+if version != 1:
+ui.warn(msg % version, hint=hint)
 else:
 requirements.add(requirementsmod.DIRSTATE_TRACKED_KEY_V1)
 
diff --git a/mercurial/helptext/config.txt b/mercurial/helptext/config.txt
--- a/mercurial/helptext/config.txt
+++ b/mercurial/helptext/config.txt
@@ -944,16 +944,13 @@
 
 For a more comprehensive guide, see :hg:`help internals.dirstate-v2`.
 
-``exp-dirstate-tracked-key-version``
+``dirstate-tracked-key``
 Enable or disable the writing of "tracked key" file alongside the dirstate.
+(default to disabled)
 
 That "tracked-key" can help external automations to detect changes to the
 set of tracked files.
 
-Two values are currently supported:
-- 0: no file is written (the default),
-- 1: a file in version "1" is written.
-
 The tracked-key is written in a new `.hg/dirstate-tracked-key`. That file
 contains two lines:
 - the first line is the file version (currently: 1),
diff --git a/mercurial/configitems.py b/mercurial/configitems.py
--- a/mercurial/configitems.py
+++ b/mercurial/configitems.py
@@ -1284,8 +1284,14 @@
 )
 coreconfigitem(
 b'format',
-b'exp-dirstate-tracked-key-version',
-default=0,
+b'dirstate-tracked-key',
+default=False,
+experimental=True,
+)
+coreconfigitem(
+b'format',
+b'dirstate-tracked-key.version',
+default=1,
 experimental=True,
 )
 coreconfigitem(



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


D12181: narrow: add support for merging add and remove outside of the tracked set

2022-02-15 Thread marmoute (Pierre-Yves David)
marmoute created this revision.
Herald added a reviewer: durin42.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  This extend f1eb77dceb36 
 to 
test and support the remaining action. Or, at least,
  the simple incarnation of them.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  mercurial/commit.py
  mercurial/merge.py
  tests/test-narrow-merge-outside.t

CHANGE DETAILS

diff --git a/tests/test-narrow-merge-outside.t 
b/tests/test-narrow-merge-outside.t
new file mode 100644
--- /dev/null
+++ b/tests/test-narrow-merge-outside.t
@@ -0,0 +1,111 @@
+===
+Test merge behavior with narrow for item outside of the narrow spec
+===
+
+This test currently check for  simple "outside of narrow" merge case. I suspect
+there might be more corner case that need testing, so extending this tests, or
+replacing it by a more "generative" version, comparing behavior with and 
without narow.
+
+This the feature is currently working with flat manifest only. This is the only
+case tested. Consider using test-case if tree start supporting this case of
+merge.
+
+Create some initial setup
+
+  $ . "$TESTDIR/narrow-library.sh"
+
+  $ hg init server
+  $ echo root > server/root
+  $ mkdir server/inside
+  $ mkdir server/outside
+  $ echo babar > server/inside/inside-change
+  $ echo pom > server/outside/outside-changing
+  $ echo arthur > server/outside/outside-removed
+  $ hg -R server add server/
+  adding server/inside/inside-change
+  adding server/outside/outside-changing
+  adding server/outside/outside-removed
+  adding server/root
+  $ hg -R server commit -m root
+
+
+
+  $ hg clone ssh://user@dummy/server client --narrow --include inside
+  requesting all changes
+  adding changesets
+  adding manifests
+  adding file changes
+  added 1 changesets with 1 changes to 1 files
+  new changesets a0c415d360e5
+  updating to branch default
+  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
+
+"trivial" change outside of narrow spec on the server
+
+  $ echo zephir > server/outside/outside-added
+  $ hg -R server add server/outside/outside-added
+  $ echo flore > server/outside/outside-changing
+  $ hg -R server remove server/outside/outside-removed
+  $ hg -R server commit -m "outside change"
+
+Merge them with some unrelated local change
+
+  $ echo celeste > client/inside/inside-change
+  $ hg -R client commit -m "inside change"
+  $ hg -R client pull
+  pulling from ssh://user@dummy/server
+  searching for changes
+  adding changesets
+  adding manifests
+  adding file changes
+  added 1 changesets with 0 changes to 0 files (+1 heads)
+  new changesets f9ec5453023e
+  (run 'hg heads' to see heads, 'hg merge' to merge)
+  $ hg -R client merge
+  0 files updated, 0 files merged, 0 files removed, 0 files unresolved
+  (branch merge, don't forget to commit)
+  $ hg -R client ci -m 'merge changes'
+  $ hg -R client push -r .
+  pushing to ssh://user@dummy/server
+  searching for changes
+  remote: adding changesets
+  remote: adding manifests
+  remote: adding file changes
+  remote: added 2 changesets with 1 changes to 1 files
+
+Checking result
+---
+
+general sentry of all output
+
+  $ hg --repository server manifest --debug --rev 0
+  360afd990eeff79e4a7f9f3ded5ecd7bc2fd3b59 644   inside/inside-change
+  7db95ce5cd8e734ad12e3f5f37779a08070a1399 644   outside/outside-changing
+  1591f6db41a30b68bd94ddccf4a4ce4f4fbe2a44 644   outside/outside-removed
+  50ecbc31c0e82dd60c2747c434d1f11b85c0e178 644   root
+  $ hg --repository server manifest --debug --rev 1
+  360afd990eeff79e4a7f9f3ded5ecd7bc2fd3b59 644   inside/inside-change
+  486c008d6dddcaeb5e5f99556a121800cdcfb149 644   outside/outside-added
+  153d7af5e4f53f44475bc0ff2b806c86f019eda4 644   outside/outside-changing
+  50ecbc31c0e82dd60c2747c434d1f11b85c0e178 644   root
+
+  $ hg --repository server manifest --debug --rev 2
+  1b3ab69c6c847abc8fd25537241fedcd4d188668 644   inside/inside-change
+  7db95ce5cd8e734ad12e3f5f37779a08070a1399 644   outside/outside-changing
+  1591f6db41a30b68bd94ddccf4a4ce4f4fbe2a44 644   outside/outside-removed
+  50ecbc31c0e82dd60c2747c434d1f11b85c0e178 644   root
+  $ hg --repository server manifest --debug --rev 3
+  1b3ab69c6c847abc8fd25537241fedcd4d188668 644   inside/inside-change
+  486c008d6dddcaeb5e5f99556a121800cdcfb149 644   outside/outside-added
+  153d7af5e4f53f44475bc0ff2b806c86f019eda4 644   outside/outside-changing
+  50ecbc31c0e82dd60c2747c434d1f11b85c0e178 644   root
+
+The file changed outside should be changed by the merge
+
+  $ hg --repository server manifest --debug --rev 'desc("inside change")' | 
grep outside-changing
+  7db95ce5cd8e734ad12e3f5f37779a08070a1399 

settling dirstate-tracked-key in 6.1

2022-02-13 Thread Pierre-Yves David

Hello everyone

The 6.1 freeze is looming and I would like to discuss finalizing the 
`dirstate-tracked-key` feature.
The main remaining question if the configuration option. That already 
sparked some discussion in the initial series but was a secondary issue 
as long as the feature experimental.


So after thinking more about this I don't think the `version` concerns 
warrant and special case. And I advocate for the usual 
`format.use-dirstate-tracked-key=yes` option. If needed, the version 
configuration might be dealt with by a secondary option: probably 
`format.use-dirstate-tracked-key:version`. It might be smart to 
introduce it already, to properly bark when the value is not "1". 
However this might seems premature.


What do you think ?

Cheers

PS: I am adding Kyle in CC as this feature is the related to a need he 
expressed with dirstate and concurrency issue Google had. This is not 
exactly what they wanted, but close enough to make sure they are aware 
of it. It might even fit there underlying needs ? I though I did the CC 
on the initial series but I apparently did not.


--
Pierre-Yves David

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


D12161: help: make the help for `safe-mismatch` real section

2022-02-09 Thread marmoute (Pierre-Yves David)
marmoute created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  The extra new lines mean the minirst engine were not seeing them as section…
  meaning they could not be addressed directly.

REPOSITORY
  rHG Mercurial

BRANCH
  stable

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

AFFECTED FILES
  mercurial/helptext/config.txt

CHANGE DETAILS

diff --git a/mercurial/helptext/config.txt b/mercurial/helptext/config.txt
--- a/mercurial/helptext/config.txt
+++ b/mercurial/helptext/config.txt
@@ -2029,7 +2029,6 @@
 -
 
 ``safe-mismatch.source-safe``
-
 Controls what happens when the shared repository does not use the
 share-safe mechanism but its source repository does.
 
@@ -2055,7 +2054,6 @@
 (default: True)
 
 ``safe-mismatch.source-not-safe``
-
 Controls what happens when the shared repository uses the share-safe
 mechanism but its source does not.
 



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


D12160: help: avoid repeated value in the safe-mistmatch help

2022-02-09 Thread marmoute (Pierre-Yves David)
marmoute created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  This was copy pasted and overlooked when it got in.

REPOSITORY
  rHG Mercurial

BRANCH
  stable

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

AFFECTED FILES
  mercurial/helptext/config.txt

CHANGE DETAILS

diff --git a/mercurial/helptext/config.txt b/mercurial/helptext/config.txt
--- a/mercurial/helptext/config.txt
+++ b/mercurial/helptext/config.txt
@@ -2034,7 +2034,7 @@
 share-safe mechanism but its source repository does.
 
 Possible values are `abort` (default), `allow`, `upgrade-abort` and
-`upgrade-abort`.
+`upgrade-allow`.
 
 ``abort``
 Disallows running any command and aborts
@@ -2060,7 +2060,7 @@
 mechanism but its source does not.
 
 Possible values are `abort` (default), `allow`, `downgrade-abort` and
-`downgrade-abort`.
+`downgrade-allow`.
 
 ``abort``
 Disallows running any command and aborts



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


D12159: help: add missing `.` in config reference

2022-02-09 Thread marmoute (Pierre-Yves David)
marmoute created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  The `hg help` command is still confused at the number of dots, but at least 
the
  reference is correct.

REPOSITORY
  rHG Mercurial

BRANCH
  stable

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

AFFECTED FILES
  mercurial/helptext/config.txt

CHANGE DETAILS

diff --git a/mercurial/helptext/config.txt b/mercurial/helptext/config.txt
--- a/mercurial/helptext/config.txt
+++ b/mercurial/helptext/config.txt
@@ -970,8 +970,8 @@
 
 Beware that existing shares will not be upgraded/downgraded, and by
 default, Mercurial will refuse to interact with them until the mismatch
-is resolved. See :hg:`help config share.safe-mismatch.source-safe` and
-:hg:`help config share.safe-mismatch.source-not-safe` for details.
+is resolved. See :hg:`help config.share.safe-mismatch.source-safe` and
+:hg:`help config.share.safe-mismatch.source-not-safe` for details.
 
 Introduced in Mercurial 5.7.
 
@@ -2046,7 +2046,7 @@
 tries to upgrade the share; if it fails, continue by
 respecting the share source setting
 
-Check :hg:`help config format.use-share-safe` for details about the
+Check :hg:`help config.format.use-share-safe` for details about the
 share-safe feature.
 
 ``safe-mismatch.source-safe.warn``
@@ -2072,7 +2072,7 @@
 tries to downgrade the share to not use share-safe;
 if it fails, continue by respecting the shared source setting
 
-Check :hg:`help config format.use-share-safe` for details about the
+Check :hg:`help config.format.use-share-safe` for details about the
 share-safe feature.
 
 ``safe-mismatch.source-not-safe.warn``
@@ -2117,7 +2117,7 @@
 Default to True.
 
 For details on the "persistent-nodemap" feature, see:
-:hg:`help config format.use-persistent-nodemap`.
+:hg:`help config.format.use-persistent-nodemap`.
 
 ``revlog.persistent-nodemap.slow-path``
 Control the behavior of Merucrial when using a repository with "persistent"
@@ -2129,7 +2129,7 @@
 ``abort``: Prevent access to such repositories. (This is the default)
 
 For details on the "persistent-nodemap" feature, see:
-:hg:`help config format.use-persistent-nodemap`.
+:hg:`help config.format.use-persistent-nodemap`.
 
 ``revlog.reuse-external-delta-parent``
 Control the order in which delta parents are considered when adding new



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


D12133: phabricator-refresh: add a magic value to skip it in the CI

2022-02-03 Thread marmoute (Pierre-Yves David)
marmoute created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  When maintaining (light) fork, it is useful to be able to disable this.

REPOSITORY
  rHG Mercurial

BRANCH
  stable

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

AFFECTED FILES
  contrib/heptapod-ci.yml
  contrib/phab-refresh-stack.sh

CHANGE DETAILS

diff --git a/contrib/phab-refresh-stack.sh b/contrib/phab-refresh-stack.sh
--- a/contrib/phab-refresh-stack.sh
+++ b/contrib/phab-refresh-stack.sh
@@ -1,6 +1,11 @@
 #!/bin/bash
 set -eu
 
+if [[ "$PHABRICATOR_TOKEN" == "NO-PHAB" ]]; then
+echo 'Skipping Phabricator Step' >&2
+exit 0
+fi
+
 revision_in_stack=`hg log \
 --rev '.#stack and ::. and topic()' \
 -T '\nONE-REV\n' \
@@ -27,6 +32,7 @@
 
 if [[ "$PHABRICATOR_TOKEN" == "" ]]; then
 echo 'missing $PHABRICATOR_TOKEN variable' >&2
+echo '(use PHABRICATOR_TOKEN="NO-PHAB" to disable this step)' >&2
 exit 2
 fi
 
diff --git a/contrib/heptapod-ci.yml b/contrib/heptapod-ci.yml
--- a/contrib/heptapod-ci.yml
+++ b/contrib/heptapod-ci.yml
@@ -56,6 +56,11 @@
 
 phabricator-refresh:
 stage: phabricator
+rules:
+  - if: '"$PHABRICATOR_TOKEN" != "NO-PHAB"'
+when: on_success
+  - if: '"$PHABRICATOR_TOKEN" == "NO-PHAB"'
+when: never
 variables:
   DEFAULT_COMMENT: ":white_check_mark: refresh by Heptapod after a 
successful CI run (:octopus: :green_heart:)"
   STABLE_COMMENT: ":white_check_mark: refresh by Heptapod after a 
successful CI run (:octopus: :green_heart:)\n⚠ This patch is intended for 
stable ⚠\n{image https://media.giphy.com/media/nYI8SmmChYXK0/source.gif};



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


D12129: dirstate-v2: rename the configuration to enable the format

2022-02-01 Thread marmoute (Pierre-Yves David)
marmoute created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.
marmoute added a comment.


  This patch is intended for stable.

REVISION SUMMARY
  The rename of the old experimental name was overlooked before the 6.0 release.
  
  We rename everything to use the new name (and keep the released name as an 
alias
  for compatibility).

REPOSITORY
  rHG Mercurial

BRANCH
  stable

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

AFFECTED FILES
  mercurial/configitems.py
  mercurial/helptext/config.txt
  mercurial/helptext/internals/dirstate-v2.txt
  mercurial/helptext/rust.txt
  mercurial/localrepo.py
  tests/test-basic.t
  tests/test-commandserver.t
  tests/test-dirstate-race.t
  tests/test-dirstate-race2.t
  tests/test-dirstate.t
  tests/test-help.t
  tests/test-hgignore.t
  tests/test-permissions.t
  tests/test-persistent-nodemap.t
  tests/test-purge.t
  tests/test-share-safe.t
  tests/test-status.t
  tests/test-stream-bundle-v2.t
  tests/test-symlinks.t
  tests/test-upgrade-repo.t

CHANGE DETAILS

diff --git a/tests/test-upgrade-repo.t b/tests/test-upgrade-repo.t
--- a/tests/test-upgrade-repo.t
+++ b/tests/test-upgrade-repo.t
@@ -1645,9 +1645,9 @@
 
 Upgrade to dirstate-v2
 
-  $ hg debugformat -v --config format.exp-rc-dirstate-v2=1 | grep dirstate-v2
+  $ hg debugformat -v --config format.use-dirstate-v2=1 | grep dirstate-v2
   dirstate-v2: noyes  no
-  $ hg debugupgraderepo --config format.exp-rc-dirstate-v2=1 --run
+  $ hg debugupgraderepo --config format.use-dirstate-v2=1 --run
   upgrade will perform the following actions:
   
   requirements
@@ -1707,14 +1707,14 @@
 dirstate-v2: upgrade and downgrade from and empty repository:
 -
 
-  $ hg init --config format.exp-rc-dirstate-v2=no dirstate-v2-empty
+  $ hg init --config format.use-dirstate-v2=no dirstate-v2-empty
   $ cd dirstate-v2-empty
   $ hg debugformat | grep dirstate-v2
   dirstate-v2: no
 
 upgrade
 
-  $ hg debugupgraderepo --run --config format.exp-rc-dirstate-v2=yes
+  $ hg debugupgraderepo --run --config format.use-dirstate-v2=yes
   upgrade will perform the following actions:
   
   requirements
@@ -1741,7 +1741,7 @@
 
 downgrade
 
-  $ hg debugupgraderepo --run --config format.exp-rc-dirstate-v2=no
+  $ hg debugupgraderepo --run --config format.use-dirstate-v2=no
   upgrade will perform the following actions:
   
   requirements
diff --git a/tests/test-symlinks.t b/tests/test-symlinks.t
--- a/tests/test-symlinks.t
+++ b/tests/test-symlinks.t
@@ -5,7 +5,7 @@
 #if dirstate-v2
   $ cat >> $HGRCPATH << EOF
   > [format]
-  > exp-rc-dirstate-v2=1
+  > use-dirstate-v2=1
   > [storage]
   > dirstate-v2.slow-path=allow
   > EOF
diff --git a/tests/test-stream-bundle-v2.t b/tests/test-stream-bundle-v2.t
--- a/tests/test-stream-bundle-v2.t
+++ b/tests/test-stream-bundle-v2.t
@@ -48,12 +48,12 @@
   stream2 -- {bytecount: 1693, filecount: 11, requirements: 
dotencode%2Cfncache%2Cgeneraldelta%2Crevlogv1%2Csparserevlog%2Cstore} 
(mandatory: True) (no-zstd !)
   stream2 -- {bytecount: 1693, filecount: 11, requirements: 
dotencode%2Cfncache%2Cgeneraldelta%2Crevlog-compression-zstd%2Crevlogv1%2Csparserevlog%2Cstore}
 (mandatory: True) (zstd no-rust !)
   stream2 -- {bytecount: 1693, filecount: 11, requirements: 
dotencode%2Cfncache%2Cgeneraldelta%2Cpersistent-nodemap%2Crevlog-compression-zstd%2Crevlogv1%2Csparserevlog%2Cstore}
 (mandatory: True) (rust no-dirstate-v2 !)
-  stream2 -- {bytecount: 1693, filecount: 11, requirements: 
dotencode%2Cexp-rc-dirstate-v2%2Cfncache%2Cgeneraldelta%2Cpersistent-nodemap%2Crevlog-compression-zstd%2Crevlogv1%2Csparserevlog%2Cstore}
 (mandatory: True) (dirstate-v2 !)
+  stream2 -- {bytecount: 1693, filecount: 11, requirements: 
dotencode%2Cuse-dirstate-v2%2Cfncache%2Cgeneraldelta%2Cpersistent-nodemap%2Crevlog-compression-zstd%2Crevlogv1%2Csparserevlog%2Cstore}
 (mandatory: True) (dirstate-v2 !)
   $ hg debugbundle --spec bundle.hg
   
none-v2;stream=v2;requirements%3Ddotencode%2Cfncache%2Cgeneraldelta%2Crevlogv1%2Csparserevlog%2Cstore
 (no-zstd !)
   
none-v2;stream=v2;requirements%3Ddotencode%2Cfncache%2Cgeneraldelta%2Crevlog-compression-zstd%2Crevlogv1%2Csparserevlog%2Cstore
 (zstd no-rust !)
   
none-v2;stream=v2;requirements%3Ddotencode%2Cfncache%2Cgeneraldelta%2Cpersistent-nodemap%2Crevlog-compression-zstd%2Crevlogv1%2Csparserevlog%2Cstore
 (rust no-dirstate-v2 !)
-  
none-v2;stream=v2;requirements%3Ddotencode%2Cexp-rc-dirstate-v2%2Cfncache%2Cgeneraldelta%2Cpersistent-nodemap%2Crevlog-compression-zstd%2Crevlogv1%2Csparserevlog%2Cstore
 (dirstate-v2 !)
+  
none-v2;stream=v2;requirements%3Ddotencode%2Cuse-dirstate-v2%2Cfncache%2Cgeneraldelta%2Cpersistent-nodemap%2Crevlog-compression-zstd%2Crevlogv1%2Csparserevlog%2Cstore
 (dirstate-v2 !)
 
 Test that we can apply the bundle as a stream clone bundle
 
diff --git a/tests/test-status.t b/tests/test-status.t
--- 

D12128: branchmap: stop writing cache for uncommitted data

2022-02-01 Thread marmoute (Pierre-Yves David)
marmoute created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  If we are about to write the branch while a transaction is active. we delay
  that write.  After the transaction is closed, we flush all the write we 
delayed
  (unless they have been written in between).

REPOSITORY
  rHG Mercurial

BRANCH
  stable

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

AFFECTED FILES
  mercurial/branchmap.py
  mercurial/localrepo.py
  tests/test-branches.t

CHANGE DETAILS

diff --git a/tests/test-branches.t b/tests/test-branches.t
--- a/tests/test-branches.t
+++ b/tests/test-branches.t
@@ -1336,7 +1336,5 @@
   abort: pretxnclose hook failed
   [40]
   $ cat branchmap-update-02/.hg/cache/branch2-served
-  99ba08759bc7f6fdbe5304e83d0387f35c082479 1 (missing-correct-output !)
-  99ba08759bc7f6fdbe5304e83d0387f35c082479 o A (missing-correct-output !)
-  71ca9a6d524ed3c2a215119b2086ac3b8c4c8286 3 (known-bad-output !)
-  71ca9a6d524ed3c2a215119b2086ac3b8c4c8286 o A (known-bad-output !)
+  99ba08759bc7f6fdbe5304e83d0387f35c082479 1
+  99ba08759bc7f6fdbe5304e83d0387f35c082479 o A
diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py
--- a/mercurial/localrepo.py
+++ b/mercurial/localrepo.py
@@ -2830,6 +2830,8 @@
 self.ui.debug(b'updating the branch cache\n')
 self.filtered(b'served').branchmap()
 self.filtered(b'served.hidden').branchmap()
+# flush all possibly delayed write.
+self._branchcaches.write_delayed(self)
 
 if repository.CACHE_CHANGELOG_CACHE in caches:
 self.changelog.update_caches(transaction=tr)
diff --git a/mercurial/branchmap.py b/mercurial/branchmap.py
--- a/mercurial/branchmap.py
+++ b/mercurial/branchmap.py
@@ -149,6 +149,13 @@
 def clear(self):
 self._per_filter.clear()
 
+def write_delayed(self, repo):
+unfi = repo.unfiltered()
+for filtername, cache in self._per_filter.items():
+if cache._delayed:
+repo = unfi.filtered(filtername)
+cache.write(repo)
+
 
 def _unknownnode(node):
 """raises ValueError when branchcache found a node which does not exists"""
@@ -199,6 +206,7 @@
 has a given node or not. If it's not provided, we assume that every 
node
 we have exists in changelog"""
 self._repo = repo
+self._delayed = False
 if tipnode is None:
 self.tipnode = repo.nullid
 else:
@@ -403,6 +411,13 @@
 )
 
 def write(self, repo):
+tr = repo.currenttransaction()
+if not getattr(tr, 'finalized', True):
+# Avoid premature writing.
+#
+# (The cache warming setup by localrepo will update the file 
later.)
+self._delayed = True
+return
 try:
 f = repo.cachevfs(self._filename(repo), b"w", atomictemp=True)
 cachekey = [hex(self.tipnode), b'%d' % self.tiprev]
@@ -427,6 +442,7 @@
 len(self._entries),
 nodecount,
 )
+self._delayed = False
 except (IOError, OSError, error.Abort) as inst:
 # Abort may be raised by read only opener, so log and continue
 repo.ui.debug(



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


D12127: transaction: add a way to know a transaction has been finalized

2022-02-01 Thread marmoute (Pierre-Yves David)
marmoute created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  This will be useful to fix the timing of the branchmap on disk caching.

REPOSITORY
  rHG Mercurial

BRANCH
  stable

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

AFFECTED FILES
  mercurial/transaction.py

CHANGE DETAILS

diff --git a/mercurial/transaction.py b/mercurial/transaction.py
--- a/mercurial/transaction.py
+++ b/mercurial/transaction.py
@@ -229,6 +229,10 @@
 if self._journal:
 self._abort()
 
+@property
+def finalized(self):
+return self._finalizecallback is None
+
 @active
 def startgroup(self):
 """delay registration of file entry



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


D12126: branchmap: Add a test about writing branchmap and aborted transaction

2022-02-01 Thread marmoute (Pierre-Yves David)
marmoute created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  It turn out that we update the branchmap on disk whenever we recompute it…
  including in a middle of a transaction. This means writing the new branchmap 
too
  early (the changeset are not visible yet) and worse… it mean writing branchmap
  for transaction we rollback.
  
  so we introduce a test to highlight the issue (and prevent it to regress in 
the
  future).

REPOSITORY
  rHG Mercurial

BRANCH
  stable

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

AFFECTED FILES
  tests/test-branches.t

CHANGE DETAILS

diff --git a/tests/test-branches.t b/tests/test-branches.t
--- a/tests/test-branches.t
+++ b/tests/test-branches.t
@@ -1242,3 +1242,101 @@
   C  3:4a546028fa8f (inactive)
   B  1:0bc7d348d965 (inactive)
   $ cd ..
+
+Check that the cache are not written too early
+--
+
+  $ hg log -R branchmap-testing1 -G
+  ochangeset:   3:71ca9a6d524e
+  |\   branch:  A
+  | |  tag: tip
+  | |  parent:  2:a3b807b3ff0b
+  | |  parent:  1:99ba08759bc7
+  | |  user:debugbuilddag
+  | |  date:Thu Jan 01 00:00:03 1970 +
+  | |  summary: r3
+  | |
+  | o  changeset:   2:a3b807b3ff0b
+  | |  branch:  A
+  | |  parent:  0:2ab8003a1750
+  | |  user:debugbuilddag
+  | |  date:Thu Jan 01 00:00:02 1970 +
+  | |  summary: r2
+  | |
+  o |  changeset:   1:99ba08759bc7
+  |/   branch:  A
+  |tag: p1
+  |user:debugbuilddag
+  |date:Thu Jan 01 00:00:01 1970 +
+  |summary: r1
+  |
+  o  changeset:   0:2ab8003a1750
+ branch:  A
+ tag: base
+ user:debugbuilddag
+ date:Thu Jan 01 00:00:00 1970 +
+ summary: r0
+  
+  $ hg bundle -R branchmap-testing1 --base 1 bundle.hg --rev 'head()'
+  2 changesets found
+
+Unbundling revision should warm the served cache
+
+  $ hg clone branchmap-testing1 --rev 1 branchmap-update-01
+  adding changesets
+  adding manifests
+  adding file changes
+  added 2 changesets with 0 changes to 0 files
+  new changesets 2ab8003a1750:99ba08759bc7
+  updating to branch A
+  0 files updated, 0 files merged, 0 files removed, 0 files unresolved
+  $ cat branchmap-update-01/.hg/cache/branch2-served
+  99ba08759bc7f6fdbe5304e83d0387f35c082479 1
+  99ba08759bc7f6fdbe5304e83d0387f35c082479 o A
+  $ hg -R branchmap-update-01 unbundle bundle.hg
+  adding changesets
+  adding manifests
+  adding file changes
+  added 2 changesets with 0 changes to 0 files
+  new changesets a3b807b3ff0b:71ca9a6d524e (2 drafts)
+  (run 'hg update' to get a working copy)
+  $ cat branchmap-update-01/.hg/cache/branch2-served
+  71ca9a6d524ed3c2a215119b2086ac3b8c4c8286 3
+  71ca9a6d524ed3c2a215119b2086ac3b8c4c8286 o A
+
+aborted Unbundle should not update the on disk cache
+
+  $ cat >> simplehook.py << EOF
+  > import sys
+  > from mercurial import node
+  > from mercurial import branchmap
+  > def hook(ui, repo, *args, **kwargs):
+  > s = repo.filtered(b"served")
+  > s.branchmap()
+  > return 1
+  > EOF
+  $ hg clone branchmap-testing1 --rev 1 branchmap-update-02
+  adding changesets
+  adding manifests
+  adding file changes
+  added 2 changesets with 0 changes to 0 files
+  new changesets 2ab8003a1750:99ba08759bc7
+  updating to branch A
+  0 files updated, 0 files merged, 0 files removed, 0 files unresolved
+
+  $ cat branchmap-update-02/.hg/cache/branch2-served
+  99ba08759bc7f6fdbe5304e83d0387f35c082479 1
+  99ba08759bc7f6fdbe5304e83d0387f35c082479 o A
+  $ hg -R branchmap-update-02 unbundle bundle.hg --config 
"hooks.pretxnclose=python:$TESTTMP/simplehook.py:hook"
+  adding changesets
+  adding manifests
+  adding file changes
+  transaction abort!
+  rollback completed
+  abort: pretxnclose hook failed
+  [40]
+  $ cat branchmap-update-02/.hg/cache/branch2-served
+  99ba08759bc7f6fdbe5304e83d0387f35c082479 1 (missing-correct-output !)
+  99ba08759bc7f6fdbe5304e83d0387f35c082479 o A (missing-correct-output !)
+  71ca9a6d524ed3c2a215119b2086ac3b8c4c8286 3 (known-bad-output !)
+  71ca9a6d524ed3c2a215119b2086ac3b8c4c8286 o A (known-bad-output !)



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


D12125: transaction: do not rely on a global variable to post_finalize file

2022-01-31 Thread marmoute (Pierre-Yves David)
marmoute created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  We can just add a new argument to the `addfilegenerator` function. This is 
more
  explicit and therefor clearer and less error prone.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  mercurial/bookmarks.py
  mercurial/dirstate.py
  mercurial/transaction.py
  tests/testlib/crash_transaction_late.py

CHANGE DETAILS

diff --git a/tests/testlib/crash_transaction_late.py 
b/tests/testlib/crash_transaction_late.py
--- a/tests/testlib/crash_transaction_late.py
+++ b/tests/testlib/crash_transaction_late.py
@@ -9,7 +9,6 @@
 
 from mercurial import (
 error,
-transaction,
 )
 
 
@@ -18,14 +17,15 @@
 
 
 def reposetup(ui, repo):
-
-transaction.postfinalizegenerators.add(b'late-abort')
-
 class LateAbortRepo(repo.__class__):
 def transaction(self, *args, **kwargs):
 tr = super(LateAbortRepo, self).transaction(*args, **kwargs)
 tr.addfilegenerator(
-b'late-abort', [b'late-abort'], abort, order=999
+b'late-abort',
+[b'late-abort'],
+abort,
+order=999,
+post_finalize=True,
 )
 return tr
 
diff --git a/mercurial/transaction.py b/mercurial/transaction.py
--- a/mercurial/transaction.py
+++ b/mercurial/transaction.py
@@ -25,16 +25,6 @@
 
 version = 2
 
-# These are the file generators that should only be executed after the
-# finalizers are done, since they rely on the output of the finalizers (like
-# the changelog having been written).
-postfinalizegenerators = {
-b'bookmarks',
-b'dirstate-0-key-pre',
-b'dirstate-1-main',
-b'dirstate-2-key-post',
-}
-
 GEN_GROUP_ALL = b'all'
 GEN_GROUP_PRE_FINALIZE = b'prefinalize'
 GEN_GROUP_POST_FINALIZE = b'postfinalize'
@@ -335,7 +325,13 @@
 
 @active
 def addfilegenerator(
-self, genid, filenames, genfunc, order=0, location=b''
+self,
+genid,
+filenames,
+genfunc,
+order=0,
+location=b'',
+post_finalize=False,
 ):
 """add a function to generates some files at transaction commit
 
@@ -358,10 +354,14 @@
 The `location` arguments may be used to indicate the files are located
 outside of the the standard directory for transaction. It should match
 one of the key of the `transaction.vfsmap` dictionary.
+
+The `post_finalize` argument can be set to `True` for file generation
+that must be run after the transaction has been finalized.
 """
 # For now, we are unable to do proper backup and restore of custom vfs
 # but for bookmarks that are handled outside this mechanism.
-self._filegenerators[genid] = (order, filenames, genfunc, location)
+entry = (order, filenames, genfunc, location, post_finalize)
+self._filegenerators[genid] = entry
 
 @active
 def removefilegenerator(self, genid):
@@ -381,13 +381,12 @@
 
 for id, entry in sorted(pycompat.iteritems(self._filegenerators)):
 any = True
-order, filenames, genfunc, location = entry
+order, filenames, genfunc, location, post_finalize = entry
 
 # for generation at closing, check if it's before or after finalize
-is_post = id in postfinalizegenerators
-if skip_post and is_post:
+if skip_post and post_finalize:
 continue
-elif skip_pre and not is_post:
+elif skip_pre and not post_finalize:
 continue
 
 vfs = self._vfsmap[location]
diff --git a/mercurial/dirstate.py b/mercurial/dirstate.py
--- a/mercurial/dirstate.py
+++ b/mercurial/dirstate.py
@@ -730,12 +730,14 @@
 (self._filename_tk,),
 lambda f: self._write_tracked_key(tr, f),
 location=b'plain',
+post_finalize=True,
 )
 tr.addfilegenerator(
 b'dirstate-1-main',
 (self._filename,),
 lambda f: self._writedirstate(tr, f),
 location=b'plain',
+post_finalize=True,
 )
 if write_key:
 tr.addfilegenerator(
@@ -743,6 +745,7 @@
 (self._filename_tk,),
 lambda f: self._write_tracked_key(tr, f),
 location=b'plain',
+post_finalize=True,
 )
 return
 
@@ -1425,6 +1428,7 @@
 (self._filename,),
 lambda f: self._writedirstate(tr, f),
 location=b'plain',
+post_finalize=True,
 )
 
 # ensure that pending file written above is unlinked at
diff --git 

Re: [PATCH 5 of 5] rank: compute property incrementally

2022-01-31 Thread Pierre-Yves David


On 1/31/22 15:03, pacien wrote:

# HG changeset patch
# User pacien 
# Date 1643367284 -3600
#  Fri Jan 28 11:54:44 2022 +0100
# Node ID 13b044b7e39299156aac33e68550b7004ad21cba
# Parent  04b7286cc3c4c7e332294183cfb87366d9748ca6
# EXP-Topic cl2-rank
rank: compute property incrementally

This replace the naive rank computation with more efficient incremental
method, avoiding computing the whole ancestor set when possible.

diff --git a/mercurial/revlog.py b/mercurial/revlog.py
--- a/mercurial/revlog.py
+++ b/mercurial/revlog.py
@@ -2491,7 +2491,17 @@
  # maybe the index.append should compute it when applicable instead
  rank = RANK_UNKNOWN
  if self._format_version == CHANGELOGV2:
-rank = len(list(self.ancestors([p1r, p2r], inclusive=True))) + 1
+if (p1r, p2r) == (nullrev, nullrev):
+rank = 1
+elif p1r != nullrev and p2r == nullrev:
+rank = 1 + self.fast_rank(p1r)
+elif p1r == nullrev and p2r != nullrev:
+rank = 1 + self.fast_rank(p2r)
+else:  # merge node
+# TODO: use exclusive part size from leap info when those will
+#   be available
+rank = (1 +
+  sum(1 for _ in self.ancestors([p1r, p2r], inclusive=True)))



You don't need to wait for leap based traversal, you can already use 
`self.findmissing` to have more efficient computation.



--
Pierre-Yves David

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


Re: [PATCH 3 of 5] rank: add minimal test

2022-01-31 Thread Pierre-Yves David


On 1/31/22 15:03, pacien wrote:

# HG changeset patch
# User pacien 
# Date 1643366718 -3600
#  Fri Jan 28 11:45:18 2022 +0100
# Node ID 2bf3d6c5b1fa4e0c2882752031e7ca934f7330c3
# Parent  a5e1331be0ffa00772e4de07c982dfd36cd4f8c7
# EXP-Topic cl2-rank
rank: add minimal test

This adds a small test checking the rank computation in the case of a merge.

diff --git a/tests/test-rank.t b/tests/test-rank.t
new file mode 100644
--- /dev/null
+++ b/tests/test-rank.t
@@ -0,0 +1,37 @@
+=
+Check that we can compute and exchange revision rank properly
+=
+
+  $ cat << EOF >> $HGRCPATH
+  > [format]
+  > exp-use-changelog-v2=enable-unstable-format-and-corrupt-my-data
+  > EOF
+
+
+Test minimal rank computation with merge
+
+  $ hg init rank-repo-minimal
+  $ cd rank-repo-minimal
+  $ touch 0
+  $ hg add 0
+  $ hg commit -m 0
+  $ touch 1
+  $ hg add 1
+  $ hg commit -m 1
+  $ hg update -r 0 >> /dev/null
+  $ touch 2
+  $ hg add 2
+  $ hg commit -m 2 >> /dev/null
+  $ hg merge -r 1 >> /dev/null
+  $ hg commit -m 3
+  $ touch 4
+  $ hg add 4
+  $ hg commit -m 4
+  $ hg log --template '{rev} {_fast_rank}\n'
+  4 5
+  3 4
+  2 2
+  1 2
+  0 1
+  $ cd ..



You should throw a `--graph` flag on this log call to make it easier to 
understand.


--
Pierre-Yves David

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


D12124: dirstate: introduce a "tracked-key" feature

2022-01-31 Thread marmoute (Pierre-Yves David)
marmoute created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  A new format variant is introduced. When used, a `tracked-key` file will be
  generated. That file will be update when the set of tracked file might have
  changed. This will be useful for external automation (e.g. build tool) to be
  notified when the set of relevant files changes.
  
  One of the motivation for this changes is to mitigate effect dirstate-v2 has 
on
  such automation. Since the dirstate file is updated much more frequently on
  dirstate-v2, monitoring update to that file is no longer a viable strategy.
  
  See the associated documentation for details about the feature
  
  To prevent older client to update the repository without updating that file, a
  new requirements is introduced.
  
  The `postfinalizegenerators` business is a bit weird, so I'll likely clean 
that
  up soon.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  mercurial/configitems.py
  mercurial/dirstate.py
  mercurial/helptext/config.txt
  mercurial/localrepo.py
  mercurial/requirements.py
  mercurial/transaction.py
  tests/test-help.t
  tests/test-status-tracked-key.t

CHANGE DETAILS

diff --git a/tests/test-status-tracked-key.t b/tests/test-status-tracked-key.t
new file mode 100644
--- /dev/null
+++ b/tests/test-status-tracked-key.t
@@ -0,0 +1,163 @@
+==
+Test the "tracked key" feature
+==
+
+The tracked key feature provide a file that get updated when the set of tracked
+files get updated.
+
+basic setup
+
+  $ cat << EOF >> $HGRCPATH
+  > [format]
+  > exp-dirstate-tracked-key-version=1
+  > EOF
+
+  $ hg init tracked-key-test
+  $ cd tracked-key-test
+  $ hg debugbuilddag '.+10' -n
+  $ hg log -G -T '{rev} {desc} {files}\n'
+  o  10 r10 nf10
+  |
+  o  9 r9 nf9
+  |
+  o  8 r8 nf8
+  |
+  o  7 r7 nf7
+  |
+  o  6 r6 nf6
+  |
+  o  5 r5 nf5
+  |
+  o  4 r4 nf4
+  |
+  o  3 r3 nf3
+  |
+  o  2 r2 nf2
+  |
+  o  1 r1 nf1
+  |
+  o  0 r0 nf0
+  
+  $ hg up tip
+  11 files updated, 0 files merged, 0 files removed, 0 files unresolved
+  $ hg files
+  nf0
+  nf1
+  nf10
+  nf2
+  nf3
+  nf4
+  nf5
+  nf6
+  nf7
+  nf8
+  nf9
+
+key-file exists
+---
+
+The tracked key file should exist
+
+  $ ls -1 .hg/dirstate*
+  .hg/dirstate
+  .hg/dirstate-tracked-key
+
+key-file stay the same if the tracked set is unchanged
+--
+
+(copy its content for later comparison)
+
+  $ cp .hg/dirstate-tracked-key ../key-bck
+  $ echo foo >> nf0
+  $ sleep 1
+  $ hg status
+  M nf0
+  $ diff --brief .hg/dirstate-tracked-key ../key-bck
+  $ hg revert -C nf0
+  $ sleep 1
+  $ hg status
+  $ diff --brief .hg/dirstate-tracked-key ../key-bck
+
+key-file change if the tracked set is changed manually
+--
+
+adding a file to tracking
+
+  $ cp .hg/dirstate-tracked-key ../key-bck
+  $ echo x > x
+  $ hg add x
+  $ diff --brief .hg/dirstate-tracked-key ../key-bck
+  Files .hg/dirstate-tracked-key and ../key-bck differ
+  [1]
+
+remove a file from tracking
+(forget)
+
+  $ cp .hg/dirstate-tracked-key ../key-bck
+  $ hg forget x
+  $ diff --brief .hg/dirstate-tracked-key ../key-bck
+  Files .hg/dirstate-tracked-key and ../key-bck differ
+  [1]
+
+(remove)
+
+  $ cp .hg/dirstate-tracked-key ../key-bck
+  $ hg remove nf1
+  $ diff --brief .hg/dirstate-tracked-key ../key-bck
+  Files .hg/dirstate-tracked-key and ../key-bck differ
+  [1]
+
+key-file changes on revert (when applicable)
+
+
+  $ cp .hg/dirstate-tracked-key ../key-bck
+  $ hg status
+  R nf1
+  ? x
+  $ hg revert --all
+  undeleting nf1
+  $ hg status
+  ? x
+  $ diff --brief .hg/dirstate-tracked-key ../key-bck
+  Files .hg/dirstate-tracked-key and ../key-bck differ
+  [1]
+
+
+`hg update` does affect the key-file (when needed)
+--
+
+update changing the tracked set
+
+(removing)
+
+  $ cp .hg/dirstate-tracked-key ../key-bck
+  $ hg status --rev . --rev '.#generations[-1]'
+  R nf10
+  $ hg up '.#generations[-1]'
+  0 files updated, 0 files merged, 1 files removed, 0 files unresolved
+  $ diff --brief .hg/dirstate-tracked-key ../key-bck
+  Files .hg/dirstate-tracked-key and ../key-bck differ
+  [1]
+
+(adding)
+
+  $ cp .hg/dirstate-tracked-key ../key-bck
+  $ hg status --rev . --rev '.#generations[1]'
+  A nf10
+  $ hg up '.#generations[1]'
+  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
+  $ diff --brief .hg/dirstate-tracked-key ../key-bck
+  Files .hg/dirstate-tracked-key and ../key-bck differ
+  [1]
+
+update not affecting the tracked set
+
+  $ echo foo >> nf0
+  $ hg commit -m foo
+
+  $ cp .hg/dirstate-tracked-key ../key-bck
+  $ hg status --rev . --rev '.#generations[-1]'
+  M nf0
+  $ hg up 

D12123: dirstate: rename the filegenerator used for writing

2022-01-31 Thread marmoute (Pierre-Yves David)
marmoute created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  We will need a different name in the next changesets. Changing the name is
  actually not that trivial so we do it in its own changeset.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  mercurial/dirstate.py
  mercurial/transaction.py

CHANGE DETAILS

diff --git a/mercurial/transaction.py b/mercurial/transaction.py
--- a/mercurial/transaction.py
+++ b/mercurial/transaction.py
@@ -28,7 +28,10 @@
 # These are the file generators that should only be executed after the
 # finalizers are done, since they rely on the output of the finalizers (like
 # the changelog having been written).
-postfinalizegenerators = {b'bookmarks', b'dirstate'}
+postfinalizegenerators = {
+b'bookmarks',
+b'dirstate-1-main',
+}
 
 GEN_GROUP_ALL = b'all'
 GEN_GROUP_PRE_FINALIZE = b'prefinalize'
diff --git a/mercurial/dirstate.py b/mercurial/dirstate.py
--- a/mercurial/dirstate.py
+++ b/mercurial/dirstate.py
@@ -706,7 +706,7 @@
 if tr:
 # delay writing in-memory changes out
 tr.addfilegenerator(
-b'dirstate',
+b'dirstate-1-main',
 (self._filename,),
 lambda f: self._writedirstate(tr, f),
 location=b'plain',
@@ -1374,7 +1374,7 @@
 # changes written out above, even if dirstate is never
 # changed after this
 tr.addfilegenerator(
-b'dirstate',
+b'dirstate-1-main',
 (self._filename,),
 lambda f: self._writedirstate(tr, f),
 location=b'plain',



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


D12122: dirstate: use a context manager when writing the dirstate

2022-01-31 Thread marmoute (Pierre-Yves David)
marmoute created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  This make sure the file is closed in a timely manner.
  
  We define a lambda for the file opening. It might seems a bit overkill here 
but
  a future changeset will need to do more of those.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  mercurial/dirstate.py

CHANGE DETAILS

diff --git a/mercurial/dirstate.py b/mercurial/dirstate.py
--- a/mercurial/dirstate.py
+++ b/mercurial/dirstate.py
@@ -713,8 +713,9 @@
 )
 return
 
-st = self._opener(filename, b"w", atomictemp=True, checkambig=True)
-self._writedirstate(tr, st)
+file = lambda f: self._opener(f, b"w", atomictemp=True, 
checkambig=True)
+with file(self._filename) as f:
+self._writedirstate(tr, f)
 
 def addparentchangecallback(self, category, callback):
 """add a callback to be called when the wd parents are changed



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


D12119: narrow: allow merging non-conflicting change outside of the narrow spec

2022-01-30 Thread marmoute (Pierre-Yves David)
marmoute created this revision.
Herald added a reviewer: durin42.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  We use the mergestate to carry information about these merge action and
  reprocess them at commit time to apply the necessary update.
  
  The dirstate itself is never affected and remains "pure", with content only in
  the narrow-spec. This file involved in such merge are therefor not listed in 
`hg
  status`.
  
  The current testing is based on a modification of the previous testing, that
  refused to do such merges. As a result it is a bit simple and more extensive
  testing will have to be introduced later. I am planning to do this extra
  testing.
  
  In addition, this only works for flat manifest. Support for tree manifest will
  need more work. I am not currently planning to do this work.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  mercurial/commit.py
  mercurial/merge.py
  tests/test-narrow-merge.t

CHANGE DETAILS

diff --git a/tests/test-narrow-merge.t b/tests/test-narrow-merge.t
--- a/tests/test-narrow-merge.t
+++ b/tests/test-narrow-merge.t
@@ -83,12 +83,67 @@
 TODO: Can merge non-conflicting changes outside narrow spec
 
   $ hg update -q 'desc("modify inside/f1")'
+
+#if flat
+
   $ hg merge 'desc("modify outside/f1")'
-  abort: merge affects file 'outside/f1' outside narrow, which is not yet 
supported (flat !)
+  0 files updated, 0 files merged, 0 files removed, 0 files unresolved
+  (branch merge, don't forget to commit)
+
+status should be clean
+
+  $ hg status
+  ? inside/f1.orig
+
+file out of the spec should still not be in the dirstate at all
+
+  $ hg debugdirstate | grep outside/f1
+  [1]
+
+Commit that merge
+
+  $ hg ci -m 'merge from outside to inside'
+
+status should be clean
+
+  $ hg status
+  ? inside/f1.orig
+
+file out of the spec should not be in the mergestate anymore
+
+  $ hg debugmergestate | grep outside/f1
+  [1]
+
+file out of the spec should still not be in the dirstate at all
+
+  $ hg debugdirstate | grep outside/f1
+  [1]
+
+The filenode used should come from p2
+
+  $ hg manifest --debug --rev . | grep outside/f1
+  83cd11431a3b2aff8a3995e5f27bcf33cdb5be98 644   outside/f1
+  $ hg manifest --debug --rev 'p1(.)' | grep outside/f1
+  c6b956c48be2cd4fa94be16002aba311143806fa 644   outside/f1
+  $ hg manifest --debug --rev 'p2(.)' | grep outside/f1
+  83cd11431a3b2aff8a3995e5f27bcf33cdb5be98 644   outside/f1
+
+
+remove the commit to get in the previous situation again
+
+  $ hg debugstrip -r .
+  0 files updated, 0 files merged, 0 files removed, 0 files unresolved
+  saved backup bundle to 
$TESTTMP/narrow/.hg/strip-backup/48eb25338b19-a1bb8350-backup.hg
+
+#else
+
+  $ hg merge 'desc("modify outside/f1")'
   abort: merge affects file 'outside/' outside narrow, which is not yet 
supported (tree !)
   (merging in the other direction may work)
   [255]
 
+#endif
+
   $ hg update -q 'desc("modify outside/f1")'
   $ hg merge 'desc("modify inside/f1")'
   1 files updated, 0 files merged, 0 files removed, 0 files unresolved
diff --git a/mercurial/merge.py b/mercurial/merge.py
--- a/mercurial/merge.py
+++ b/mercurial/merge.py
@@ -518,13 +518,20 @@
 mresult.removefile(f)  # just updating, ignore changes outside 
clone
 elif action[0].no_op:
 mresult.removefile(f)  # merge does not affect file
-elif action[0].narrow_safe:  # TODO: handle these cases
-msg = _(
-b'merge affects file \'%s\' outside narrow, '
-b'which is not yet supported'
-)
-hint = _(b'merging in the other direction may work')
-raise error.Abort(msg % f, hint=hint)
+elif action[0].narrow_safe:
+if not f.endswith(b'/'):
+mresult.removefile(f)  # merge won't affect on-disk files
+
+mresult.addcommitinfo(
+f, b'outside-narrow-merge-action', action[0].changes
+)
+else:  # TODO: handle the tree case
+msg = _(
+b'merge affects file \'%s\' outside narrow, '
+b'which is not yet supported'
+)
+hint = _(b'merging in the other direction may work')
+raise error.Abort(msg % f, hint=hint)
 else:
 msg = _(b'conflict in file \'%s\' is outside narrow clone')
 raise error.StateError(msg % f)
diff --git a/mercurial/commit.py b/mercurial/commit.py
--- a/mercurial/commit.py
+++ b/mercurial/commit.py
@@ -134,7 +134,13 @@
 for s in salvaged:
 files.mark_salvaged(s)
 
-if ctx.manifestnode():
+narrow_files = {}
+if not ctx.repo().narrowmatch().always():
+for f, e in ms.allextras().items():
+action = e.get(b'outside-narrow-merge-action')
+if action is not None:
+

D12117: merge-actions: have an attribute for narrow safetiness

2022-01-30 Thread marmoute (Pierre-Yves David)
marmoute created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  This allow the core doing narrow filtering to process action without
  explicitely listing all possible actions. This is important to make the 
actions
  system more flexible in the future.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  mercurial/merge.py
  mercurial/mergestate.py

CHANGE DETAILS

diff --git a/mercurial/mergestate.py b/mercurial/mergestate.py
--- a/mercurial/mergestate.py
+++ b/mercurial/mergestate.py
@@ -107,17 +107,22 @@
 _short: internal representation used to identify each action
 
 no_op:  True if the action does affect the file content or tracking status
+
+narrow_safe:
+True if the action can be safely used for a file outside of the narrow
+set
 """
 
 ALL_ACTIONS = weakref.WeakSet()
 NO_OP_ACTIONS = weakref.WeakSet()
 
-def __init__(self, short, no_op=False):
+def __init__(self, short, no_op=False, narrow_safe=False):
 self._short = short
 self.ALL_ACTIONS.add(self)
 self.no_op = no_op
 if self.no_op:
 self.NO_OP_ACTIONS.add(self)
+self.narrow_safe = narrow_safe
 
 def __hash__(self):
 return hash(self._short)
@@ -138,14 +143,14 @@
 return self._short < other._short
 
 
-ACTION_FORGET = MergeAction(b'f')
-ACTION_REMOVE = MergeAction(b'r')
-ACTION_ADD = MergeAction(b'a')
-ACTION_GET = MergeAction(b'g')
+ACTION_FORGET = MergeAction(b'f', narrow_safe=True)
+ACTION_REMOVE = MergeAction(b'r', narrow_safe=True)
+ACTION_ADD = MergeAction(b'a', narrow_safe=True)
+ACTION_GET = MergeAction(b'g', narrow_safe=True)
 ACTION_PATH_CONFLICT = MergeAction(b'p')
 ACTION_PATH_CONFLICT_RESOLVE = MergeAction('pr')
-ACTION_ADD_MODIFIED = MergeAction(b'am')
-ACTION_CREATED = MergeAction(b'c')
+ACTION_ADD_MODIFIED = MergeAction(b'am', narrow_safe=True)
+ACTION_CREATED = MergeAction(b'c', narrow_safe=True)
 ACTION_DELETED_CHANGED = MergeAction(b'dc')
 ACTION_CHANGED_DELETED = MergeAction(b'cd')
 ACTION_MERGE = MergeAction(b'm')
@@ -159,8 +164,8 @@
 # the file is absent on the ancestor and remote side of the merge
 # hence this file is new and we should keep it
 ACTION_KEEP_NEW = MergeAction(b'kn', no_op=True)
-ACTION_EXEC = MergeAction(b'e')
-ACTION_CREATED_MERGE = MergeAction(b'cm')
+ACTION_EXEC = MergeAction(b'e', narrow_safe=True)
+ACTION_CREATED_MERGE = MergeAction(b'cm', narrow_safe=True)
 
 
 # Used by concert to detect situation it does not like, not sure what the exact
diff --git a/mercurial/merge.py b/mercurial/merge.py
--- a/mercurial/merge.py
+++ b/mercurial/merge.py
@@ -509,17 +509,6 @@
 Raise an exception if the merge cannot be completed because the repo is
 narrowed.
 """
-# TODO: handle with nonconflicttypes
-nonconflicttypes = {
-mergestatemod.ACTION_ADD,
-mergestatemod.ACTION_ADD_MODIFIED,
-mergestatemod.ACTION_CREATED,
-mergestatemod.ACTION_CREATED_MERGE,
-mergestatemod.ACTION_FORGET,
-mergestatemod.ACTION_GET,
-mergestatemod.ACTION_REMOVE,
-mergestatemod.ACTION_EXEC,
-}
 # We mutate the items in the dict during iteration, so iterate
 # over a copy.
 for f, action in mresult.filemap():
@@ -529,7 +518,7 @@
 mresult.removefile(f)  # just updating, ignore changes outside 
clone
 elif action[0].no_op:
 mresult.removefile(f)  # merge does not affect file
-elif action[0] in nonconflicttypes:
+elif action[0].narrow_safe:  # TODO: handle these cases
 msg = _(
 b'merge affects file \'%s\' outside narrow, '
 b'which is not yet supported'



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


D12118: merge-actions: add some information about the "changes" the action do

2022-01-30 Thread marmoute (Pierre-Yves David)
marmoute created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  This will be useful when processing merges action outside of the narrow-spec.
  
  "support" outside of narrow file on commit

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  mercurial/mergestate.py

CHANGE DETAILS

diff --git a/mercurial/mergestate.py b/mercurial/mergestate.py
--- a/mercurial/mergestate.py
+++ b/mercurial/mergestate.py
@@ -98,6 +98,10 @@
 # This record was release in 3.7 and usage was removed in 5.6
 LEGACY_MERGE_DRIVER_MERGE = b'D'
 
+CHANGE_ADDED = b'added'
+CHANGE_REMOVED = b'removed'
+CHANGE_MODIFIED = b'modified'
+
 
 class MergeAction(object):
 """represent an "action" merge need to take for a given file
@@ -111,18 +115,29 @@
 narrow_safe:
 True if the action can be safely used for a file outside of the narrow
 set
+
+changes:
+The types of changes that his actions involves. This is a work in
+progress and not all actions have one yet. In addition, some requires
+user changes and cannot be fully decided. The value currently available
+are:
+
+- ADDED: the files is new in both parents
+- REMOVED: the files existed in one parent and is getting removed
+- MODIFIED: the files existed in at least one parent and is getting 
changed
 """
 
 ALL_ACTIONS = weakref.WeakSet()
 NO_OP_ACTIONS = weakref.WeakSet()
 
-def __init__(self, short, no_op=False, narrow_safe=False):
+def __init__(self, short, no_op=False, narrow_safe=False, changes=None):
 self._short = short
 self.ALL_ACTIONS.add(self)
 self.no_op = no_op
 if self.no_op:
 self.NO_OP_ACTIONS.add(self)
 self.narrow_safe = narrow_safe
+self.changes = changes
 
 def __hash__(self):
 return hash(self._short)
@@ -143,14 +158,16 @@
 return self._short < other._short
 
 
-ACTION_FORGET = MergeAction(b'f', narrow_safe=True)
-ACTION_REMOVE = MergeAction(b'r', narrow_safe=True)
-ACTION_ADD = MergeAction(b'a', narrow_safe=True)
-ACTION_GET = MergeAction(b'g', narrow_safe=True)
+ACTION_FORGET = MergeAction(b'f', narrow_safe=True, changes=CHANGE_REMOVED)
+ACTION_REMOVE = MergeAction(b'r', narrow_safe=True, changes=CHANGE_REMOVED)
+ACTION_ADD = MergeAction(b'a', narrow_safe=True, changes=CHANGE_ADDED)
+ACTION_GET = MergeAction(b'g', narrow_safe=True, changes=CHANGE_MODIFIED)
 ACTION_PATH_CONFLICT = MergeAction(b'p')
 ACTION_PATH_CONFLICT_RESOLVE = MergeAction('pr')
-ACTION_ADD_MODIFIED = MergeAction(b'am', narrow_safe=True)
-ACTION_CREATED = MergeAction(b'c', narrow_safe=True)
+ACTION_ADD_MODIFIED = MergeAction(
+b'am', narrow_safe=True, changes=CHANGE_ADDED
+)  # not 100% about the changes value here
+ACTION_CREATED = MergeAction(b'c', narrow_safe=True, changes=CHANGE_ADDED)
 ACTION_DELETED_CHANGED = MergeAction(b'dc')
 ACTION_CHANGED_DELETED = MergeAction(b'cd')
 ACTION_MERGE = MergeAction(b'm')
@@ -164,8 +181,10 @@
 # the file is absent on the ancestor and remote side of the merge
 # hence this file is new and we should keep it
 ACTION_KEEP_NEW = MergeAction(b'kn', no_op=True)
-ACTION_EXEC = MergeAction(b'e', narrow_safe=True)
-ACTION_CREATED_MERGE = MergeAction(b'cm', narrow_safe=True)
+ACTION_EXEC = MergeAction(b'e', narrow_safe=True, changes=CHANGE_MODIFIED)
+ACTION_CREATED_MERGE = MergeAction(
+b'cm', narrow_safe=True, changes=CHANGE_ADDED
+)
 
 
 # Used by concert to detect situation it does not like, not sure what the exact



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


D12114: merge-actions: make merge action a full featured object

2022-01-29 Thread marmoute (Pierre-Yves David)
marmoute created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  This open the way for having "smarter" value as action, making the usage code
  simpler and more flexible.
  
  We have to explicitly use __bytes__ call in a couple of place because Python2…

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  hgext/largefiles/overrides.py
  mercurial/merge.py
  mercurial/mergestate.py

CHANGE DETAILS

diff --git a/mercurial/mergestate.py b/mercurial/mergestate.py
--- a/mercurial/mergestate.py
+++ b/mercurial/mergestate.py
@@ -98,29 +98,59 @@
 LEGACY_MERGE_DRIVER_MERGE = b'D'
 
 
-ACTION_FORGET = b'f'
-ACTION_REMOVE = b'r'
-ACTION_ADD = b'a'
-ACTION_GET = b'g'
-ACTION_PATH_CONFLICT = b'p'
-ACTION_PATH_CONFLICT_RESOLVE = b'pr'
-ACTION_ADD_MODIFIED = b'am'
-ACTION_CREATED = b'c'
-ACTION_DELETED_CHANGED = b'dc'
-ACTION_CHANGED_DELETED = b'cd'
-ACTION_MERGE = b'm'
-ACTION_LOCAL_DIR_RENAME_GET = b'dg'
-ACTION_DIR_RENAME_MOVE_LOCAL = b'dm'
-ACTION_KEEP = b'k'
+class MergeAction(object):
+"""represent an "action" merge need to take for a given file
+
+Attributes:
+
+_short: internal representation used to identify each action
+"""
+
+def __init__(self, short):
+self._short = short
+
+def __hash__(self):
+return hash(self._short)
+
+def __repr__(self):
+return 'MergeAction<%s>' % self._short.decode('ascii')
+
+def __bytes__(self):
+return self._short
+
+def __eq__(self, other):
+if other is None:
+return False
+assert isinstance(other, MergeAction)
+return self._short == other._short
+
+def __lt__(self, other):
+return self._short < other._short
+
+
+ACTION_FORGET = MergeAction(b'f')
+ACTION_REMOVE = MergeAction(b'r')
+ACTION_ADD = MergeAction(b'a')
+ACTION_GET = MergeAction(b'g')
+ACTION_PATH_CONFLICT = MergeAction(b'p')
+ACTION_PATH_CONFLICT_RESOLVE = MergeAction('pr')
+ACTION_ADD_MODIFIED = MergeAction(b'am')
+ACTION_CREATED = MergeAction(b'c')
+ACTION_DELETED_CHANGED = MergeAction(b'dc')
+ACTION_CHANGED_DELETED = MergeAction(b'cd')
+ACTION_MERGE = MergeAction(b'm')
+ACTION_LOCAL_DIR_RENAME_GET = MergeAction(b'dg')
+ACTION_DIR_RENAME_MOVE_LOCAL = MergeAction(b'dm')
+ACTION_KEEP = MergeAction(b'k')
 # the file was absent on local side before merge and we should
 # keep it absent (absent means file not present, it can be a result
 # of file deletion, rename etc.)
-ACTION_KEEP_ABSENT = b'ka'
+ACTION_KEEP_ABSENT = MergeAction(b'ka')
 # the file is absent on the ancestor and remote side of the merge
 # hence this file is new and we should keep it
-ACTION_KEEP_NEW = b'kn'
-ACTION_EXEC = b'e'
-ACTION_CREATED_MERGE = b'cm'
+ACTION_KEEP_NEW = MergeAction(b'kn')
+ACTION_EXEC = MergeAction(b'e')
+ACTION_CREATED_MERGE = MergeAction(b'cm')
 
 # actions which are no op
 NO_OP_ACTIONS = (
diff --git a/mercurial/merge.py b/mercurial/merge.py
--- a/mercurial/merge.py
+++ b/mercurial/merge.py
@@ -1201,7 +1201,7 @@
 
 for f, a in mresult1.filemap(sort=True):
 m, args, msg = a
-repo.ui.debug(b' %s: %s -> %s\n' % (f, msg, m))
+repo.ui.debug(b' %s: %s -> %s\n' % (f, msg, m.__bytes__()))
 if f in fbids:
 d = fbids[f]
 if m in d:
@@ -1222,13 +1222,15 @@
 repo.ui.debug(b" list of bids for %s:\n" % f)
 for m, l in sorted(bids.items()):
 for _f, args, msg in l:
-repo.ui.debug(b'   %s -> %s\n' % (msg, m))
+repo.ui.debug(b'   %s -> %s\n' % (msg, m.__bytes__()))
 # bids is a mapping from action method to list af actions
 # Consensus?
 if len(bids) == 1:  # all bids are the same kind of method
 m, l = list(bids.items())[0]
 if all(a == l[0] for a in l[1:]):  # len(bids) is > 1
-repo.ui.note(_(b" %s: consensus for %s\n") % (f, m))
+repo.ui.note(
+_(b" %s: consensus for %s\n") % (f, m.__bytes__())
+)
 mresult.addfile(f, *l[0])
 continue
 # If keep is an option, just do it.
@@ -1286,11 +1288,12 @@
 repo.ui.note(_(b' %s: multiple bids for merge action:\n') % f)
 for m, l in sorted(bids.items()):
 for _f, args, msg in l:
-repo.ui.note(b'  %s -> %s\n' % (msg, m))
+repo.ui.note(b'  %s -> %s\n' % (msg, m.__bytes__()))
 # Pick random action. TODO: Instead, prompt user when resolving
 m, l = list(bids.items())[0]
 repo.ui.warn(
-_(b' %s: ambiguous merge - picked %s action\n') % (f, m)
+_(b' %s: ambiguous merge - picked %s action\n')
+

D12116: merge-actions: add an explicite "no_op" attribute

2022-01-29 Thread marmoute (Pierre-Yves David)
marmoute created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  This make the MergeAction smarter and able to describe themself. This is 
useful
  to help introducing more MergeAction object that better the complexity of the
  situation.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  mercurial/merge.py
  mercurial/mergestate.py
  mercurial/sparse.py

CHANGE DETAILS

diff --git a/mercurial/sparse.py b/mercurial/sparse.py
--- a/mercurial/sparse.py
+++ b/mercurial/sparse.py
@@ -396,7 +396,7 @@
 temporaryfiles.append(file)
 prunedactions[file] = action
 elif branchmerge:
-if type not in mergestatemod.NO_OP_ACTIONS:
+if not type.no_op:
 temporaryfiles.append(file)
 prunedactions[file] = action
 elif type == mergestatemod.ACTION_FORGET:
diff --git a/mercurial/mergestate.py b/mercurial/mergestate.py
--- a/mercurial/mergestate.py
+++ b/mercurial/mergestate.py
@@ -105,13 +105,19 @@
 Attributes:
 
 _short: internal representation used to identify each action
+
+no_op:  True if the action does affect the file content or tracking status
 """
 
 ALL_ACTIONS = weakref.WeakSet()
+NO_OP_ACTIONS = weakref.WeakSet()
 
-def __init__(self, short):
+def __init__(self, short, no_op=False):
 self._short = short
 self.ALL_ACTIONS.add(self)
+self.no_op = no_op
+if self.no_op:
+self.NO_OP_ACTIONS.add(self)
 
 def __hash__(self):
 return hash(self._short)
@@ -145,23 +151,17 @@
 ACTION_MERGE = MergeAction(b'm')
 ACTION_LOCAL_DIR_RENAME_GET = MergeAction(b'dg')
 ACTION_DIR_RENAME_MOVE_LOCAL = MergeAction(b'dm')
-ACTION_KEEP = MergeAction(b'k')
+ACTION_KEEP = MergeAction(b'k', no_op=True)
 # the file was absent on local side before merge and we should
 # keep it absent (absent means file not present, it can be a result
 # of file deletion, rename etc.)
-ACTION_KEEP_ABSENT = MergeAction(b'ka')
+ACTION_KEEP_ABSENT = MergeAction(b'ka', no_op=True)
 # the file is absent on the ancestor and remote side of the merge
 # hence this file is new and we should keep it
-ACTION_KEEP_NEW = MergeAction(b'kn')
+ACTION_KEEP_NEW = MergeAction(b'kn', no_op=True)
 ACTION_EXEC = MergeAction(b'e')
 ACTION_CREATED_MERGE = MergeAction(b'cm')
 
-# actions which are no op
-NO_OP_ACTIONS = (
-ACTION_KEEP,
-ACTION_KEEP_ABSENT,
-ACTION_KEEP_NEW,
-)
 
 # Used by concert to detect situation it does not like, not sure what the exact
 # criteria is
diff --git a/mercurial/merge.py b/mercurial/merge.py
--- a/mercurial/merge.py
+++ b/mercurial/merge.py
@@ -527,7 +527,7 @@
 pass
 elif not branchmerge:
 mresult.removefile(f)  # just updating, ignore changes outside 
clone
-elif action[0] in mergestatemod.NO_OP_ACTIONS:
+elif action[0].no_op:
 mresult.removefile(f)  # merge does not affect file
 elif action[0] in nonconflicttypes:
 msg = _(
@@ -699,7 +699,7 @@
 mergestatemod.ACTION_PATH_CONFLICT_RESOLVE,
 )
 and self._actionmapping[a]
-and a not in mergestatemod.NO_OP_ACTIONS
+and not a.no_op
 ):
 return True
 
@@ -1520,7 +1520,8 @@
 # mergestate so that it can be reused on commit
 ms.addcommitinfo(f, op)
 
-numupdates = mresult.len() - mresult.len(mergestatemod.NO_OP_ACTIONS)
+num_no_op = mresult.len(mergestatemod.MergeAction.NO_OP_ACTIONS)
+numupdates = mresult.len() - num_no_op
 progress = repo.ui.makeprogress(
 _(b'updating'), unit=_(b'files'), total=numupdates
 )
@@ -1624,7 +1625,7 @@
 progress.increment(item=f)
 
 # keep (noop, just log it)
-for a in mergestatemod.NO_OP_ACTIONS:
+for a in mergestatemod.MergeAction.NO_OP_ACTIONS:
 for f, args, msg in mresult.getactions((a,), sort=True):
 repo.ui.debug(b" %s: %s -> %s\n" % (f, msg, a.__bytes__()))
 # no progress



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


D12115: merge-actions: gather all created action into a set

2022-01-29 Thread marmoute (Pierre-Yves David)
marmoute created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  This is mostly to demonstrate we can do this before we start adding more
  specialized set.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  mercurial/mergestate.py

CHANGE DETAILS

diff --git a/mercurial/mergestate.py b/mercurial/mergestate.py
--- a/mercurial/mergestate.py
+++ b/mercurial/mergestate.py
@@ -4,6 +4,7 @@
 import errno
 import shutil
 import struct
+import weakref
 
 from .i18n import _
 from .node import (
@@ -106,8 +107,11 @@
 _short: internal representation used to identify each action
 """
 
+ALL_ACTIONS = weakref.WeakSet()
+
 def __init__(self, short):
 self._short = short
+self.ALL_ACTIONS.add(self)
 
 def __hash__(self):
 return hash(self._short)



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


D12113: convert: use the merge action constant

2022-01-29 Thread marmoute (Pierre-Yves David)
marmoute created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  The constant exists, lets use them. Otherwise we cannot make these constant 
more
  powerful.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  hgext/convert/hg.py
  mercurial/mergestate.py

CHANGE DETAILS

diff --git a/mercurial/mergestate.py b/mercurial/mergestate.py
--- a/mercurial/mergestate.py
+++ b/mercurial/mergestate.py
@@ -129,6 +129,15 @@
 ACTION_KEEP_NEW,
 )
 
+# Used by concert to detect situation it does not like, not sure what the exact
+# criteria is
+CONVERT_MERGE_ACTIONS = (
+ACTION_MERGE,
+ACTION_DIR_RENAME_MOVE_LOCAL,
+ACTION_CHANGED_DELETED,
+ACTION_DELETED_CHANGED,
+)
+
 
 class _mergestate_base(object):
 """track 3-way merge state of individual files
diff --git a/hgext/convert/hg.py b/hgext/convert/hg.py
--- a/hgext/convert/hg.py
+++ b/hgext/convert/hg.py
@@ -38,6 +38,7 @@
 lock as lockmod,
 logcmdutil,
 merge as mergemod,
+mergestate,
 phases,
 pycompat,
 util,
@@ -241,7 +242,7 @@
 
 # If the file requires actual merging, abort. We don't have enough
 # context to resolve merges correctly.
-if action in [b'm', b'dm', b'cd', b'dc']:
+if action in mergestate.CONVERT_MERGE_ACTIONS:
 raise error.Abort(
 _(
 b"unable to convert merge commit "
@@ -250,7 +251,7 @@
 )
 % (file, p1ctx, p2ctx)
 )
-elif action == b'k':
+elif action == mergestate.ACTION_KEEP:
 # 'keep' means nothing changed from p1
 continue
 else:



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


D12112: large-file: use the merge action constant

2022-01-29 Thread marmoute (Pierre-Yves David)
marmoute created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  The constant exists, lets use them. Otherwise we cannot make these constant 
more
  powerful.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  hgext/largefiles/overrides.py

CHANGE DETAILS

diff --git a/hgext/largefiles/overrides.py b/hgext/largefiles/overrides.py
--- a/hgext/largefiles/overrides.py
+++ b/hgext/largefiles/overrides.py
@@ -51,6 +51,12 @@
 storefactory,
 )
 
+ACTION_ADD = mergestatemod.ACTION_ADD
+ACTION_DELETED_CHANGED = mergestatemod.ACTION_DELETED_CHANGED
+ACTION_GET = mergestatemod.ACTION_GET
+ACTION_KEEP = mergestatemod.ACTION_KEEP
+ACTION_REMOVE = mergestatemod.ACTION_REMOVE
+
 eh = exthelper.exthelper()
 
 lfstatus = lfutil.lfstatus
@@ -563,8 +569,9 @@
 standin = lfutil.standin(lfile)
 (lm, largs, lmsg) = mresult.getfile(lfile, (None, None, None))
 (sm, sargs, smsg) = mresult.getfile(standin, (None, None, None))
-if sm in (b'g', b'dc') and lm != b'r':
-if sm == b'dc':
+
+if sm in (ACTION_GET, ACTION_DELETED_CHANGED) and lm != ACTION_REMOVE:
+if sm == ACTION_DELETED_CHANGED:
 f1, f2, fa, move, anc = sargs
 sargs = (p2[f2].flags(), False)
 # Case 1: normal file in the working copy, largefile in
@@ -578,26 +585,28 @@
 % lfile
 )
 if repo.ui.promptchoice(usermsg, 0) == 0:  # pick remote largefile
-mresult.addfile(lfile, b'r', None, b'replaced by standin')
-mresult.addfile(standin, b'g', sargs, b'replaces standin')
+mresult.addfile(
+lfile, ACTION_REMOVE, None, b'replaced by standin'
+)
+mresult.addfile(standin, ACTION_GET, sargs, b'replaces 
standin')
 else:  # keep local normal file
-mresult.addfile(lfile, b'k', None, b'replaces standin')
+mresult.addfile(lfile, ACTION_KEEP, None, b'replaces standin')
 if branchmerge:
 mresult.addfile(
 standin,
-b'k',
+ACTION_KEEP,
 None,
 b'replaced by non-standin',
 )
 else:
 mresult.addfile(
 standin,
-b'r',
+ACTION_REMOVE,
 None,
 b'replaced by non-standin',
 )
-elif lm in (b'g', b'dc') and sm != b'r':
-if lm == b'dc':
+if lm in (ACTION_GET, ACTION_DELETED_CHANGED) and sm != ACTION_REMOVE:
+if lm == ACTION_DELETED_CHANGED:
 f1, f2, fa, move, anc = largs
 largs = (p2[f2].flags(), False)
 # Case 2: largefile in the working copy, normal file in
@@ -615,11 +624,13 @@
 # largefile can be restored from standin safely
 mresult.addfile(
 lfile,
-b'k',
+ACTION_KEEP,
 None,
 b'replaced by standin',
 )
-mresult.addfile(standin, b'k', None, b'replaces standin')
+mresult.addfile(
+standin, ACTION_KEEP, None, b'replaces standin'
+)
 else:
 # "lfile" should be marked as "removed" without
 # removal of itself
@@ -631,12 +642,12 @@
 )
 
 # linear-merge should treat this largefile as 're-added'
-mresult.addfile(standin, b'a', None, b'keep standin')
+mresult.addfile(standin, ACTION_ADD, None, b'keep standin')
 else:  # pick remote normal file
-mresult.addfile(lfile, b'g', largs, b'replaces standin')
+mresult.addfile(lfile, ACTION_GET, largs, b'replaces standin')
 mresult.addfile(
 standin,
-b'r',
+ACTION_REMOVE,
 None,
 b'replaced by non-standin',
 )



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


D12111: merge: stop using merge action for pathconflict option

2022-01-29 Thread marmoute (Pierre-Yves David)
marmoute created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  This is not the b'r' you are looking for.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  mercurial/merge.py

CHANGE DETAILS

diff --git a/mercurial/merge.py b/mercurial/merge.py
--- a/mercurial/merge.py
+++ b/mercurial/merge.py
@@ -488,7 +488,7 @@
 mresult.addfile(
 p,
 mergestatemod.ACTION_PATH_CONFLICT,
-(pnew, mergestatemod.ACTION_REMOVE),
+(pnew, b'r'),
 b'path conflict',
 )
 remoteconflicts.remove(p)



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


D12110: merge: break up a not-so-one-liner for readability

2022-01-29 Thread marmoute (Pierre-Yves David)
marmoute created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  mercurial/merge.py

CHANGE DETAILS

diff --git a/mercurial/merge.py b/mercurial/merge.py
--- a/mercurial/merge.py
+++ b/mercurial/merge.py
@@ -2368,9 +2368,8 @@
 def back_out(ctx, parent=None, wc=None):
 if parent is None:
 if ctx.p2() is not None:
-raise error.ProgrammingError(
-b"must specify parent of merge commit to back out"
-)
+msg = b"must specify parent of merge commit to back out"
+raise error.ProgrammingError(msg)
 parent = ctx.p1()
 return _update(
 ctx.repo(),



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


D12109: merge: break up a not-so-one-liner for readability

2022-01-29 Thread marmoute (Pierre-Yves David)
marmoute created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  mercurial/merge.py

CHANGE DETAILS

diff --git a/mercurial/merge.py b/mercurial/merge.py
--- a/mercurial/merge.py
+++ b/mercurial/merge.py
@@ -1931,10 +1931,9 @@
 hint = _(b"use 'hg update' or check 'hg heads'")
 raise error.Abort(msg, hint=hint)
 if not force and (wc.files() or wc.deleted()):
-raise error.StateError(
-_(b"uncommitted changes"),
-hint=_(b"use 'hg status' to list changes"),
-)
+msg = _(b"uncommitted changes")
+hint = _(b"use 'hg status' to list changes")
+raise error.StateError(msg, hint=hint)
 if not wc.isinmemory():
 for s in sorted(wc.substate):
 wc.sub(s).bailifchanged()



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


D12108: merge: break up a not-so-one-liner for readability

2022-01-29 Thread marmoute (Pierre-Yves David)
marmoute created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  mercurial/merge.py

CHANGE DETAILS

diff --git a/mercurial/merge.py b/mercurial/merge.py
--- a/mercurial/merge.py
+++ b/mercurial/merge.py
@@ -1927,10 +1927,9 @@
 raise error.Abort(m_a)
 elif pas == [p1]:
 if not mergeancestor and wc.branch() == p2.branch():
-raise error.Abort(
-_(b"nothing to merge"),
-hint=_(b"use 'hg update' or check 'hg heads'"),
-)
+msg = _(b"nothing to merge")
+hint = _(b"use 'hg update' or check 'hg heads'")
+raise error.Abort(msg, hint=hint)
 if not force and (wc.files() or wc.deleted()):
 raise error.StateError(
 _(b"uncommitted changes"),



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


D12107: merge: break up a not-so-one-liner for readability

2022-01-29 Thread marmoute (Pierre-Yves David)
marmoute created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  mercurial/merge.py

CHANGE DETAILS

diff --git a/mercurial/merge.py b/mercurial/merge.py
--- a/mercurial/merge.py
+++ b/mercurial/merge.py
@@ -1922,13 +1922,9 @@
 hint = _(b"use 'hg resolve' to resolve")
 raise error.StateError(msg, hint=hint)
 if branchmerge:
+m_a = _(b"merging with a working directory ancestor has no effect")
 if pas == [p2]:
-raise error.Abort(
-_(
-b"merging with a working directory ancestor"
-b" has no effect"
-)
-)
+raise error.Abort(m_a)
 elif pas == [p1]:
 if not mergeancestor and wc.branch() == p2.branch():
 raise error.Abort(



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


D12106: merge: break up two not-so-one-liner for extra readability

2022-01-29 Thread marmoute (Pierre-Yves David)
marmoute created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  mercurial/merge.py

CHANGE DETAILS

diff --git a/mercurial/merge.py b/mercurial/merge.py
--- a/mercurial/merge.py
+++ b/mercurial/merge.py
@@ -1885,22 +1885,11 @@
 # updatecheck='abort' to better suppport some of these callers.
 if updatecheck is None:
 updatecheck = UPDATECHECK_LINEAR
-if updatecheck not in (
-UPDATECHECK_NONE,
-UPDATECHECK_LINEAR,
-UPDATECHECK_NO_CONFLICT,
-):
-raise ValueError(
-r'Invalid updatecheck %r (can accept %r)'
-% (
-updatecheck,
-(
-UPDATECHECK_NONE,
-UPDATECHECK_LINEAR,
-UPDATECHECK_NO_CONFLICT,
-),
-)
-)
+okay = (UPDATECHECK_NONE, UPDATECHECK_LINEAR, UPDATECHECK_NO_CONFLICT)
+if updatecheck not in okay:
+msg = r'Invalid updatecheck %r (can accept %r)'
+msg %= (updatecheck, okay)
+raise ValueError(msg)
 if wc is not None and wc.isinmemory():
 maybe_wlock = util.nullcontextmanager()
 else:
@@ -1929,10 +1918,9 @@
 raise error.StateError(_(b"outstanding uncommitted merge"))
 ms = wc.mergestate()
 if ms.unresolvedcount():
-raise error.StateError(
-_(b"outstanding merge conflicts"),
-hint=_(b"use 'hg resolve' to resolve"),
-)
+msg = _(b"outstanding merge conflicts")
+hint = _(b"use 'hg resolve' to resolve")
+raise error.StateError(msg, hint=hint)
 if branchmerge:
 if pas == [p2]:
 raise error.Abort(



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


D12105: merge: break up a not-so-one-liner for readability

2022-01-29 Thread marmoute (Pierre-Yves David)
marmoute created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  mercurial/merge.py

CHANGE DETAILS

diff --git a/mercurial/merge.py b/mercurial/merge.py
--- a/mercurial/merge.py
+++ b/mercurial/merge.py
@@ -537,9 +537,8 @@
 hint = _(b'merging in the other direction may work')
 raise error.Abort(msg % f, hint=hint)
 else:
-raise error.StateError(
-_(b'conflict in file \'%s\' is outside narrow clone') % f
-)
+msg = _(b'conflict in file \'%s\' is outside narrow clone')
+raise error.StateError(msg % f)
 
 
 class mergeresult(object):



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


D12104: merge: break up a not-so-one-liner for readability

2022-01-29 Thread marmoute (Pierre-Yves David)
marmoute created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  (even if not fully satisfied this time)

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  mercurial/merge.py

CHANGE DETAILS

diff --git a/mercurial/merge.py b/mercurial/merge.py
--- a/mercurial/merge.py
+++ b/mercurial/merge.py
@@ -530,14 +530,12 @@
 elif action[0] in mergestatemod.NO_OP_ACTIONS:
 mresult.removefile(f)  # merge does not affect file
 elif action[0] in nonconflicttypes:
-raise error.Abort(
-_(
-b'merge affects file \'%s\' outside narrow, '
-b'which is not yet supported'
-)
-% f,
-hint=_(b'merging in the other direction may work'),
+msg = _(
+b'merge affects file \'%s\' outside narrow, '
+b'which is not yet supported'
 )
+hint = _(b'merging in the other direction may work')
+raise error.Abort(msg % f, hint=hint)
 else:
 raise error.StateError(
 _(b'conflict in file \'%s\' is outside narrow clone') % f



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


D12103: merge: break up a not-so-one-liner for readability

2022-01-29 Thread marmoute (Pierre-Yves David)
marmoute created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  mercurial/merge.py

CHANGE DETAILS

diff --git a/mercurial/merge.py b/mercurial/merge.py
--- a/mercurial/merge.py
+++ b/mercurial/merge.py
@@ -346,10 +346,9 @@
 for fold, f in sorted(foldmap.items()):
 if fold.startswith(foldprefix) and not f.startswith(unfoldprefix):
 # the folded prefix matches but actual casing is different
-raise error.StateError(
-_(b"case-folding collision between %s and directory of %s")
-% (lastfull, f)
-)
+msg = _(b"case-folding collision between %s and directory of %s")
+msg %= (lastfull, f)
+raise error.StateError(msg)
 foldprefix = fold + b'/'
 unfoldprefix = f + b'/'
 lastfull = f



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


D12102: merge: break up a not-so-one-liner for readability

2022-01-29 Thread marmoute (Pierre-Yves David)
marmoute created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  mercurial/merge.py

CHANGE DETAILS

diff --git a/mercurial/merge.py b/mercurial/merge.py
--- a/mercurial/merge.py
+++ b/mercurial/merge.py
@@ -336,10 +336,9 @@
 for f in pmmf:
 fold = util.normcase(f)
 if fold in foldmap:
-raise error.StateError(
-_(b"case-folding collision between %s and %s")
-% (f, foldmap[fold])
-)
+msg = _(b"case-folding collision between %s and %s")
+msg %= (f, foldmap[fold])
+raise error.StateError(msg)
 foldmap[fold] = f
 
 # check case-folding of directories



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


D12101: merge: break up a not-so-one-liner for readability

2022-01-29 Thread marmoute (Pierre-Yves David)
marmoute created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  mercurial/merge.py

CHANGE DETAILS

diff --git a/mercurial/merge.py b/mercurial/merge.py
--- a/mercurial/merge.py
+++ b/mercurial/merge.py
@@ -41,10 +41,9 @@
 valid = [b'abort', b'ignore', b'warn']
 if config not in valid:
 validstr = b', '.join([b"'" + v + b"'" for v in valid])
-raise error.ConfigError(
-_(b"%s.%s not valid ('%s' is none of %s)")
-% (section, name, config, validstr)
-)
+msg = _(b"%s.%s not valid ('%s' is none of %s)")
+msg %= (section, name, config, validstr)
+raise error.ConfigError(msg)
 return config
 
 



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


D12096: stream-clone: allow to change persistent-nodemap format during stream clone

2022-01-27 Thread marmoute (Pierre-Yves David)
marmoute created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  Persistent nodemap affect the store format. However it is fairly isolated and
  fast to general locally. So not making it a fixed part of the stream clone is
  useful.
  
  This allow clients without persistent-nodemap support (default for client
  without Rust enabled, or simply older client). So it make it possible to 
enable
  persistent nodemap on client, where it can provide a massive boost. without 
too
  much consequence.
  
  To do so, we stop using it in the advertisement requirements for streaming and
  let the client add/remove the necessary file depending of its configuration.
  
  We still send the files as it seems like a small save to not regenerate them.
  In addition, the way we match them will overlap with the 
changelog-v2/revlog-v2
  so we can't simply skip the associated patterns.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  mercurial/requirements.py
  mercurial/revlogutils/nodemap.py
  mercurial/streamclone.py
  tests/test-bundle.t
  tests/test-clone-stream-format.t
  tests/test-clone-stream.t
  tests/test-clonebundles.t
  tests/test-debugcommands.t
  tests/test-stream-bundle-v2.t

CHANGE DETAILS

diff --git a/tests/test-stream-bundle-v2.t b/tests/test-stream-bundle-v2.t
--- a/tests/test-stream-bundle-v2.t
+++ b/tests/test-stream-bundle-v2.t
@@ -47,11 +47,11 @@
   Stream params: {}
   stream2 -- {bytecount: 1693, filecount: 11, requirements: 
generaldelta%2Crevlogv1%2Csparserevlog} (mandatory: True) (no-zstd !)
   stream2 -- {bytecount: 1693, filecount: 11, requirements: 
generaldelta%2Crevlog-compression-zstd%2Crevlogv1%2Csparserevlog} (mandatory: 
True) (zstd no-rust !)
-  stream2 -- {bytecount: 1693, filecount: 11, requirements: 
generaldelta%2Cpersistent-nodemap%2Crevlog-compression-zstd%2Crevlogv1%2Csparserevlog}
 (mandatory: True) (rust !)
+  stream2 -- {bytecount: 1693, filecount: 11, requirements: 
generaldelta%2Crevlog-compression-zstd%2Crevlogv1%2Csparserevlog} (mandatory: 
True) (rust !)
   $ hg debugbundle --spec bundle.hg
   none-v2;stream=v2;requirements%3Dgeneraldelta%2Crevlogv1%2Csparserevlog 
(no-zstd !)
   
none-v2;stream=v2;requirements%3Dgeneraldelta%2Crevlog-compression-zstd%2Crevlogv1%2Csparserevlog
 (zstd no-rust !)
-  
none-v2;stream=v2;requirements%3Dgeneraldelta%2Cpersistent-nodemap%2Crevlog-compression-zstd%2Crevlogv1%2Csparserevlog
 (rust !)
+  
none-v2;stream=v2;requirements%3Dgeneraldelta%2Crevlog-compression-zstd%2Crevlogv1%2Csparserevlog
 (rust !)
 
 Test that we can apply the bundle as a stream clone bundle
 
diff --git a/tests/test-debugcommands.t b/tests/test-debugcommands.t
--- a/tests/test-debugcommands.t
+++ b/tests/test-debugcommands.t
@@ -657,8 +657,8 @@
   devel-peer-request:   pairs: 81 bytes
   sending hello command
   sending between command
-  remote: 487
-  remote: capabilities: batch branchmap $USUAL_BUNDLE2_CAPS$ changegroupsubset 
getbundle known lookup protocaps pushkey 
streamreqs=generaldelta,persistent-nodemap,revlog-compression-zstd,revlogv1,sparserevlog
 unbundle=HG10GZ,HG10BZ,HG10UN unbundlehash
+  remote: 468
+  remote: capabilities: batch branchmap $USUAL_BUNDLE2_CAPS$ changegroupsubset 
getbundle known lookup protocaps pushkey 
streamreqs=generaldelta,revlog-compression-zstd,revlogv1,sparserevlog 
unbundle=HG10GZ,HG10BZ,HG10UN unbundlehash
   remote: 1
   devel-peer-request: protocaps
   devel-peer-request:   caps: * bytes (glob)
diff --git a/tests/test-clonebundles.t b/tests/test-clonebundles.t
--- a/tests/test-clonebundles.t
+++ b/tests/test-clonebundles.t
@@ -281,7 +281,7 @@
   writing 613 bytes for 4 files
   bundle requirements: generaldelta, revlogv1, sparserevlog (no-rust no-zstd !)
   bundle requirements: generaldelta, revlog-compression-zstd, revlogv1, 
sparserevlog (no-rust zstd !)
-  bundle requirements: generaldelta, persistent-nodemap, 
revlog-compression-zstd, revlogv1, sparserevlog (rust !)
+  bundle requirements: generaldelta, revlog-compression-zstd, revlogv1, 
sparserevlog (rust !)
 
 No bundle spec should work
 
diff --git a/tests/test-clone-stream.t b/tests/test-clone-stream.t
--- a/tests/test-clone-stream.t
+++ b/tests/test-clone-stream.t
@@ -338,23 +338,23 @@
 #endif
 #if zstd rust no-dirstate-v2
   $ f --size --hex --bytes 256 body
-  body: size=116331
+  body: size=116310
   : 04 6e 6f 6e 65 48 47 32 30 00 00 00 00 00 00 00 |.noneHG20...|
-  0010: 91 07 53 54 52 45 41 4d 32 00 00 00 00 03 00 09 |..STREAM2...|
-  0020: 06 09 04 0c 55 62 79 74 65 63 6f 75 6e 74 31 30 |Ubytecount10|
+  0010: 7c 07 53 54 52 45 41 4d 32 00 00 00 00 03 00 09 ||.STREAM2...|
+  0020: 06 09 04 0c 40 62 79 74 65 63 6f 75 6e 74 31 30 |@bytecount10|
   0030: 31 32 37 36 66 69 6c 65 63 6f 75 6e 74 31 30 39 |1276filecount109|
   0040: 33 72 65 71 75 69 72 65 6d 65 6e 74 73 67 65 6e |3requirementsgen|

D12094: debugbuilddag: add a flag to allow running it from a non-empty repository

2022-01-27 Thread marmoute (Pierre-Yves David)
marmoute created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  Allow that by default seems "dangerous", but having a flag to make it possible
  will be useful to help building some repository incrementally. The newly 
introduced support is basic, but already useful.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

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

CHANGE DETAILS

diff --git a/tests/test-completion.t b/tests/test-completion.t
--- a/tests/test-completion.t
+++ b/tests/test-completion.t
@@ -272,7 +272,7 @@
   debugantivirusrunning: 
   debugapplystreamclonebundle: 
   debugbackupbundle: recover, patch, git, limit, no-merges, stat, graph, 
style, template
-  debugbuilddag: mergeable-file, overwritten-file, new-file
+  debugbuilddag: mergeable-file, overwritten-file, new-file, from-existing
   debugbundle: all, part-type, spec
   debugcapabilities: 
   debugchangedfiles: compute
diff --git a/mercurial/debugcommands.py b/mercurial/debugcommands.py
--- a/mercurial/debugcommands.py
+++ b/mercurial/debugcommands.py
@@ -178,6 +178,12 @@
 _(b'add single file all revs overwrite'),
 ),
 (b'n', b'new-file', None, _(b'add new file at each rev')),
+(
+b'',
+b'from-existing',
+None,
+_(b'continue from a non-empty repository'),
+),
 ],
 _(b'[OPTION]... [TEXT]'),
 )
@@ -188,6 +194,7 @@
 mergeable_file=False,
 overwritten_file=False,
 new_file=False,
+from_existing=False,
 ):
 """builds a repo with a given DAG from scratch in the current empty repo
 
@@ -226,7 +233,7 @@
 text = ui.fin.read()
 
 cl = repo.changelog
-if len(cl) > 0:
+if len(cl) > 0 and not from_existing:
 raise error.Abort(_(b'repository is not empty'))
 
 # determine number of revs in DAG



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


D12095: stream-clone: add 5000 changesets to test-clone-stream-format

2022-01-27 Thread marmoute (Pierre-Yves David)
marmoute created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  This make sure the changelog is not inlined. We needs this to test coming
  behavior change around persistent-nodemap.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  tests/test-clone-stream-format.t

CHANGE DETAILS

diff --git a/tests/test-clone-stream-format.t b/tests/test-clone-stream-format.t
--- a/tests/test-clone-stream-format.t
+++ b/tests/test-clone-stream-format.t
@@ -79,6 +79,12 @@
   adding undo.i
   adding undo.n
   adding undo.py
+  $ hg debugbuilddag .+5000 --from-existing
+  $ ls -1 .hg/store/00changelog*
+  .hg/store/00changelog-*.nd (glob)
+  .hg/store/00changelog.d
+  .hg/store/00changelog.i
+  .hg/store/00changelog.n
   $ cd ..
 
 
@@ -90,16 +96,16 @@
   adding changesets
   adding manifests
   adding file changes
-  added 3 changesets with 1088 changes to 1088 files
-  new changesets 96ee1d7354c4:5223b5e3265f
+  added 5004 changesets with 1088 changes to 1088 files (+1 heads)
+  new changesets 96ee1d7354c4:06ddac466af5
   updating to branch default
-  1088 files updated, 0 files merged, 0 files removed, 0 files unresolved
+  0 files updated, 0 files merged, 0 files removed, 0 files unresolved
   $ hg verify -R server-no-store
   checking changesets
   checking manifests
   crosschecking files in changesets and manifests
   checking files
-  checked 3 changesets with 1088 changes to 1088 files
+  checked 5004 changesets with 1088 changes to 1088 files
   $ hg -R server serve -p $HGPORT -d --pid-file=hg-1.pid --error errors-1.txt
   $ cat hg-1.pid > $DAEMON_PIDS
   $ hg -R server-no-store serve -p $HGPORT2 -d --pid-file=hg-2.pid --error 
errors-2.txt
@@ -118,7 +124,7 @@
   checking manifests
   crosschecking files in changesets and manifests
   checking files
-  checked 3 changesets with 1088 changes to 1088 files
+  checked 5004 changesets with 1088 changes to 1088 files
   $ hg debugrequires -R clone-remove-store | grep store
   [1]
 
@@ -132,7 +138,7 @@
   checking manifests
   crosschecking files in changesets and manifests
   checking files
-  checked 3 changesets with 1088 changes to 1088 files
+  checked 5004 changesets with 1088 changes to 1088 files
   $ hg debugrequires -R clone-add-store | grep store
   store
 
@@ -149,16 +155,16 @@
   adding changesets
   adding manifests
   adding file changes
-  added 3 changesets with 1088 changes to 1088 files
-  new changesets 96ee1d7354c4:5223b5e3265f
+  added 5004 changesets with 1088 changes to 1088 files (+1 heads)
+  new changesets 96ee1d7354c4:06ddac466af5
   updating to branch default
-  1088 files updated, 0 files merged, 0 files removed, 0 files unresolved
+  0 files updated, 0 files merged, 0 files removed, 0 files unresolved
   $ hg verify -R server-no-fncache
   checking changesets
   checking manifests
   crosschecking files in changesets and manifests
   checking files
-  checked 3 changesets with 1088 changes to 1088 files
+  checked 5004 changesets with 1088 changes to 1088 files
   $ hg -R server serve -p $HGPORT -d --pid-file=hg-1.pid --error errors-1.txt
   $ cat hg-1.pid > $DAEMON_PIDS
   $ hg -R server-no-fncache serve -p $HGPORT2 -d --pid-file=hg-2.pid --error 
errors-2.txt
@@ -177,7 +183,7 @@
   checking manifests
   crosschecking files in changesets and manifests
   checking files
-  checked 3 changesets with 1088 changes to 1088 files
+  checked 5004 changesets with 1088 changes to 1088 files
   $ hg debugrequires -R clone-remove-fncache | grep fncache
   [1]
 
@@ -191,7 +197,7 @@
   checking manifests
   crosschecking files in changesets and manifests
   checking files
-  checked 3 changesets with 1088 changes to 1088 files
+  checked 5004 changesets with 1088 changes to 1088 files
   $ hg debugrequires -R clone-add-fncache | grep fncache
   fncache
 
@@ -209,16 +215,16 @@
   adding changesets
   adding manifests
   adding file changes
-  added 3 changesets with 1088 changes to 1088 files
-  new changesets 96ee1d7354c4:5223b5e3265f
+  added 5004 changesets with 1088 changes to 1088 files (+1 heads)
+  new changesets 96ee1d7354c4:06ddac466af5
   updating to branch default
-  1088 files updated, 0 files merged, 0 files removed, 0 files unresolved
+  0 files updated, 0 files merged, 0 files removed, 0 files unresolved
   $ hg verify -R server-no-dotencode
   checking changesets
   checking manifests
   crosschecking files in changesets and manifests
   checking files
-  checked 3 changesets with 1088 changes to 1088 files
+  checked 5004 changesets with 1088 changes to 1088 files
   $ hg -R server serve -p $HGPORT -d --pid-file=hg-1.pid --error errors-1.txt
   $ cat hg-1.pid > $DAEMON_PIDS
   $ hg -R server-no-dotencode serve -p $HGPORT2 -d --pid-file=hg-2.pid --error 
errors-2.txt
@@ -237,7 +243,7 @@
   checking manifests
   crosschecking files in changesets and manifests
   checking files
-  checked 3 

D12093: persistent-nodemap: properly delete all nodemap files on downgrade

2022-01-27 Thread marmoute (Pierre-Yves David)
marmoute created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  Previously, we were only deleting the docket file…

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

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

CHANGE DETAILS

diff --git a/tests/test-persistent-nodemap.t b/tests/test-persistent-nodemap.t
--- a/tests/test-persistent-nodemap.t
+++ b/tests/test-persistent-nodemap.t
@@ -809,8 +809,6 @@
 - manifest
   
   $ ls -1 .hg/store/ | egrep '00(changelog|manifest)(\.n|-.*\.nd)'
-  00changelog-*.nd (glob)
-  00manifest-*.nd (glob)
   undo.backup.00changelog.n
   undo.backup.00manifest.n
   $ hg debugnodemap --metadata
diff --git a/mercurial/revlogutils/nodemap.py b/mercurial/revlogutils/nodemap.py
--- a/mercurial/revlogutils/nodemap.py
+++ b/mercurial/revlogutils/nodemap.py
@@ -144,10 +144,12 @@
 
 def delete_nodemap(tr, repo, revlog):
 """Delete nodemap data on disk for a given revlog"""
-if revlog._nodemap_file is None:
-msg = "calling persist nodemap on a revlog without the feature enabled"
-raise error.ProgrammingError(msg)
-repo.svfs.tryunlink(revlog._nodemap_file)
+prefix = revlog.radix
+pattern = re.compile(br"(^|/)%s(-[0-9a-f]+\.nd|\.n(\.a)?)$" % prefix)
+dirpath = revlog.opener.dirname(revlog._indexfile)
+for f in revlog.opener.listdir(dirpath):
+if pattern.match(f):
+repo.svfs.tryunlink(f)
 
 
 def persist_nodemap(tr, revlog, pending=False, force=False):



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


D12091: stream-clone: filter possible missing requirements using all supported one

2022-01-27 Thread marmoute (Pierre-Yves David)
marmoute created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  The `supportedformat` requirements is missing some important requirements and 
it
  seems better to filter out with all requirements we know, not just an
  "arbitrary" subset.
  
  The `supportedformat` set is lacking some important requirements (for example
  `revlog-compression-zstd`). This is getting fixed on default (for Mercurial 
6.1)
  
  However, fixing that in 6.1 means the stream requirements sent over the wire
  will contains more items. And if we don't apply this fix on older version, 
they
  might end up complaining about lacking support for feature they actually 
support
  for years.
  
  This patch does not fix the deeper problem (advertised stream requirement
  lacking some of them), but focus on the trivial part : Lets use the full set 
of
  supported requirement for looking for unsupported ones.
  
  This patch should be simple to backport to older version of Mercurial and
  packager should be encouraged to do so.

REPOSITORY
  rHG Mercurial

BRANCH
  stable

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

AFFECTED FILES
  mercurial/streamclone.py
  tests/test-http-bundle1.t
  tests/test-http.t

CHANGE DETAILS

diff --git a/tests/test-http.t b/tests/test-http.t
--- a/tests/test-http.t
+++ b/tests/test-http.t
@@ -59,8 +59,10 @@
 
   $ cat > $TESTTMP/removesupportedformat.py << EOF
   > from mercurial import localrepo
-  > def extsetup(ui):
-  > localrepo.localrepository.supportedformats.remove(b'generaldelta')
+  > def reposetup(ui, repo):
+  > local = repo.local()
+  > if local is not None:
+  > local.supported.remove(b'generaldelta')
   > EOF
 
   $ hg clone --config extensions.rsf=$TESTTMP/removesupportedformat.py 
--stream http://localhost:$HGPORT/ copy3
diff --git a/tests/test-http-bundle1.t b/tests/test-http-bundle1.t
--- a/tests/test-http-bundle1.t
+++ b/tests/test-http-bundle1.t
@@ -70,8 +70,10 @@
 
   $ cat > $TESTTMP/removesupportedformat.py << EOF
   > from mercurial import localrepo
-  > def extsetup(ui):
-  > localrepo.localrepository.supportedformats.remove(b'generaldelta')
+  > def reposetup(ui, repo):
+  > local = repo.local()
+  > if local is not None:
+  > local.supported.remove(b'generaldelta')
   > EOF
 
   $ hg clone --config extensions.rsf=$TESTTMP/removesupportedformat.py 
--stream http://localhost:$HGPORT/ copy3
diff --git a/mercurial/streamclone.py b/mercurial/streamclone.py
--- a/mercurial/streamclone.py
+++ b/mercurial/streamclone.py
@@ -104,7 +104,7 @@
 
 streamreqs = set(streamreqs.split(b','))
 # Server requires something we don't support. Bail.
-missingreqs = streamreqs - repo.supportedformats
+missingreqs = streamreqs - repo.supported
 if missingreqs:
 pullop.repo.ui.warn(
 _(
@@ -481,7 +481,7 @@
 )
 
 filecount, bytecount, requirements = readbundle1header(fp)
-missingreqs = requirements - repo.supportedformats
+missingreqs = requirements - repo.supported
 if missingreqs:
 raise error.Abort(
 _(b'unable to apply stream clone: unsupported format: %s')



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


D12083: requirements: add an official `REVLOG_COMPRESSION_ZSTD` const

2022-01-24 Thread marmoute (Pierre-Yves David)
marmoute created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  Such constant was missing and its value was missing from the set of 
requirements
  that needs to be preserved through stream clone. This did not had any
  consequence yet as the "bundle 2 does not filter its requirements" is 
shadowing
  the issue.
  
  However we are now in a situation where we can fix this issue. So lets do it
  next.
  
  With the preparation work on test, changing the streamreqs value only impact 
two
  tests, where checking the full value seems to remains relevant.
  
  Important note: Since older version of Mercurial used the old 
`supportedformat`
  class attribute to check for stream requirement they supported, older version
  will consider this requirements to prevent them from using streaming clone. 
Even
  as they support this requirements for years. Pack for stable will be send to 
fix
  it, but they will have to be backported to older version if needed.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  mercurial/localrepo.py
  mercurial/requirements.py
  tests/test-bundle.t
  tests/test-clonebundles.t
  tests/test-debugcommands.t

CHANGE DETAILS

diff --git a/tests/test-debugcommands.t b/tests/test-debugcommands.t
--- a/tests/test-debugcommands.t
+++ b/tests/test-debugcommands.t
@@ -657,8 +657,8 @@
   devel-peer-request:   pairs: 81 bytes
   sending hello command
   sending between command
-  remote: 463
-  remote: capabilities: batch branchmap $USUAL_BUNDLE2_CAPS$ changegroupsubset 
getbundle known lookup protocaps pushkey 
streamreqs=generaldelta,persistent-nodemap,revlogv1,sparserevlog 
unbundle=HG10GZ,HG10BZ,HG10UN unbundlehash
+  remote: 487
+  remote: capabilities: batch branchmap $USUAL_BUNDLE2_CAPS$ changegroupsubset 
getbundle known lookup protocaps pushkey 
streamreqs=generaldelta,persistent-nodemap,revlog-compression-zstd,revlogv1,sparserevlog
 unbundle=HG10GZ,HG10BZ,HG10UN unbundlehash
   remote: 1
   devel-peer-request: protocaps
   devel-peer-request:   caps: * bytes (glob)
@@ -677,8 +677,8 @@
   devel-peer-request:   pairs: 81 bytes
   sending hello command
   sending between command
-  remote: 444
-  remote: capabilities: batch branchmap $USUAL_BUNDLE2_CAPS$ changegroupsubset 
getbundle known lookup protocaps pushkey 
streamreqs=generaldelta,revlogv1,sparserevlog unbundle=HG10GZ,HG10BZ,HG10UN 
unbundlehash
+  remote: 468
+  remote: capabilities: batch branchmap $USUAL_BUNDLE2_CAPS$ changegroupsubset 
getbundle known lookup protocaps pushkey 
streamreqs=generaldelta,revlog-compression-zstd,revlogv1,sparserevlog 
unbundle=HG10GZ,HG10BZ,HG10UN unbundlehash
   remote: 1
   devel-peer-request: protocaps
   devel-peer-request:   caps: * bytes (glob)
diff --git a/tests/test-clonebundles.t b/tests/test-clonebundles.t
--- a/tests/test-clonebundles.t
+++ b/tests/test-clonebundles.t
@@ -279,8 +279,9 @@
 
   $ hg -R server debugcreatestreamclonebundle packed.hg
   writing 613 bytes for 4 files
-  bundle requirements: generaldelta, revlogv1, sparserevlog (no-rust !)
-  bundle requirements: generaldelta, persistent-nodemap, revlogv1, 
sparserevlog (rust !)
+  bundle requirements: generaldelta, revlogv1, sparserevlog (no-rust no-zstd !)
+  bundle requirements: generaldelta, revlog-compression-zstd, revlogv1, 
sparserevlog (no-rust zstd !)
+  bundle requirements: generaldelta, persistent-nodemap, 
revlog-compression-zstd, revlogv1, sparserevlog (rust !)
 
 No bundle spec should work
 
diff --git a/tests/test-bundle.t b/tests/test-bundle.t
--- a/tests/test-bundle.t
+++ b/tests/test-bundle.t
@@ -297,32 +297,32 @@
 
   $ hg -R test debugcreatestreamclonebundle packed.hg
   writing 2665 bytes for 6 files
-  bundle requirements: generaldelta, persistent-nodemap, revlogv1, sparserevlog
+  bundle requirements: generaldelta, persistent-nodemap, 
revlog-compression-zstd, revlogv1, sparserevlog
 
   $ f -B 64 --size --sha1 --hexdump packed.hg
-  packed.hg: size=2860, sha1=81d7a2e535892cda51e82c200f818de2cca828d3
+  packed.hg: size=2884, sha1=b0c868701f8a9fe44daf094b2f5bf661cf90c789
   : 48 47 53 31 55 4e 00 00 00 00 00 00 00 06 00 00 |HGS1UN..|
-  0010: 00 00 00 00 0a 69 00 36 67 65 6e 65 72 61 6c 64 |.i.6generald|
+  0010: 00 00 00 00 0a 69 00 4e 67 65 6e 65 72 61 6c 64 |.i.Ngenerald|
   0020: 65 6c 74 61 2c 70 65 72 73 69 73 74 65 6e 74 2d |elta,persistent-|
-  0030: 6e 6f 64 65 6d 61 70 2c 72 65 76 6c 6f 67 76 31 |nodemap,revlogv1|
+  0030: 6e 6f 64 65 6d 61 70 2c 72 65 76 6c 6f 67 2d 63 |nodemap,revlog-c|
   $ hg debugbundle --spec packed.hg
-  
none-packed1;requirements%3Dgeneraldelta%2Cpersistent-nodemap%2Crevlogv1%2Csparserevlog
+  
none-packed1;requirements%3Dgeneraldelta%2Cpersistent-nodemap%2Crevlog-compression-zstd%2Crevlogv1%2Csparserevlog
 #endif
 
 #if reporevlogstore no-rust zstd
 
   $ hg -R test debugcreatestreamclonebundle packed.hg
   writing 

D12084: stream-clone: also filter the requirement we put in the bundle 2

2022-01-24 Thread marmoute (Pierre-Yves David)
marmoute created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  We were wrongly putting irrelevant requirements in the bundle and the 
receiving
  side was getting confused, treating them as being missing while still putting
  them in the `requires` file. Leading do corrupted repositories.
  
  This changes fix stream-clone behavior regarding format when bundle-2 is
  involved, so we now also test this cases.
  
  Behavior with older version of Mercurial will be fine as they filter the
  requirements they get from the bundle on their side anyway.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  mercurial/bundle2.py
  tests/test-clone-stream-format.t
  tests/test-clone-stream.t
  tests/test-stream-bundle-v2.t

CHANGE DETAILS

diff --git a/tests/test-stream-bundle-v2.t b/tests/test-stream-bundle-v2.t
--- a/tests/test-stream-bundle-v2.t
+++ b/tests/test-stream-bundle-v2.t
@@ -45,13 +45,13 @@
   $ hg bundle -a --type="none-v2;stream=v2" bundle.hg
   $ hg debugbundle bundle.hg
   Stream params: {}
-  stream2 -- {bytecount: 1693, filecount: 11, requirements: 
dotencode%2Cfncache%2Cgeneraldelta%2Crevlogv1%2Csparserevlog%2Cstore} 
(mandatory: True) (no-zstd !)
-  stream2 -- {bytecount: 1693, filecount: 11, requirements: 
dotencode%2Cfncache%2Cgeneraldelta%2Crevlog-compression-zstd%2Crevlogv1%2Csparserevlog%2Cstore}
 (mandatory: True) (zstd no-rust !)
-  stream2 -- {bytecount: 1693, filecount: 11, requirements: 
dotencode%2Cfncache%2Cgeneraldelta%2Cpersistent-nodemap%2Crevlog-compression-zstd%2Crevlogv1%2Csparserevlog%2Cstore}
 (mandatory: True) (rust !)
+  stream2 -- {bytecount: 1693, filecount: 11, requirements: 
generaldelta%2Crevlogv1%2Csparserevlog} (mandatory: True) (no-zstd !)
+  stream2 -- {bytecount: 1693, filecount: 11, requirements: 
generaldelta%2Crevlog-compression-zstd%2Crevlogv1%2Csparserevlog} (mandatory: 
True) (zstd no-rust !)
+  stream2 -- {bytecount: 1693, filecount: 11, requirements: 
generaldelta%2Cpersistent-nodemap%2Crevlog-compression-zstd%2Crevlogv1%2Csparserevlog}
 (mandatory: True) (rust !)
   $ hg debugbundle --spec bundle.hg
-  
none-v2;stream=v2;requirements%3Ddotencode%2Cfncache%2Cgeneraldelta%2Crevlogv1%2Csparserevlog%2Cstore
 (no-zstd !)
-  
none-v2;stream=v2;requirements%3Ddotencode%2Cfncache%2Cgeneraldelta%2Crevlog-compression-zstd%2Crevlogv1%2Csparserevlog%2Cstore
 (zstd no-rust !)
-  
none-v2;stream=v2;requirements%3Ddotencode%2Cfncache%2Cgeneraldelta%2Cpersistent-nodemap%2Crevlog-compression-zstd%2Crevlogv1%2Csparserevlog%2Cstore
 (rust !)
+  none-v2;stream=v2;requirements%3Dgeneraldelta%2Crevlogv1%2Csparserevlog 
(no-zstd !)
+  
none-v2;stream=v2;requirements%3Dgeneraldelta%2Crevlog-compression-zstd%2Crevlogv1%2Csparserevlog
 (zstd no-rust !)
+  
none-v2;stream=v2;requirements%3Dgeneraldelta%2Cpersistent-nodemap%2Crevlog-compression-zstd%2Crevlogv1%2Csparserevlog
 (rust !)
 
 Test that we can apply the bundle as a stream clone bundle
 
diff --git a/tests/test-clone-stream.t b/tests/test-clone-stream.t
--- a/tests/test-clone-stream.t
+++ b/tests/test-clone-stream.t
@@ -296,65 +296,65 @@
 
 #if no-zstd no-rust
   $ f --size --hex --bytes 256 body
-  body: size=119153
+  body: size=119123
   : 04 6e 6f 6e 65 48 47 32 30 00 00 00 00 00 00 00 |.noneHG20...|
-  0010: 80 07 53 54 52 45 41 4d 32 00 00 00 00 03 00 09 |..STREAM2...|
-  0020: 06 09 04 0c 44 62 79 74 65 63 6f 75 6e 74 31 30 |Dbytecount10|
+  0010: 62 07 53 54 52 45 41 4d 32 00 00 00 00 03 00 09 |b.STREAM2...|
+  0020: 06 09 04 0c 26 62 79 74 65 63 6f 75 6e 74 31 30 ||
   0030: 34 31 31 35 66 69 6c 65 63 6f 75 6e 74 31 30 39 |4115filecount109|
-  0040: 33 72 65 71 75 69 72 65 6d 65 6e 74 73 64 6f 74 |3requirementsdot|
-  0050: 65 6e 63 6f 64 65 25 32 43 66 6e 63 61 63 68 65 |encode%2Cfncache|
-  0060: 25 32 43 67 65 6e 65 72 61 6c 64 65 6c 74 61 25 |%2Cgeneraldelta%|
-  0070: 32 43 72 65 76 6c 6f 67 76 31 25 32 43 73 70 61 |2Crevlogv1%2Cspa|
-  0080: 72 73 65 72 65 76 6c 6f 67 25 32 43 73 74 6f 72 |rserevlog%2Cstor|
-  0090: 65 00 00 80 00 73 08 42 64 61 74 61 2f 30 2e 69 |es.Bdata/0.i|
-  00a0: 00 03 00 01 00 00 00 00 00 00 00 02 00 00 00 01 ||
-  00b0: 00 00 00 00 00 00 00 01 ff ff ff ff ff ff ff ff ||
-  00c0: 80 29 63 a0 49 d3 23 87 bf ce fe 56 67 92 67 2c |.)c.I.#Vg.g,|
-  00d0: 69 d1 ec 39 00 00 00 00 00 00 00 00 00 00 00 00 |i..9|
-  00e0: 75 30 73 26 45 64 61 74 61 2f 30 30 63 68 61 6e |u0s/00chan|
-  00f0: 67 65 6c 6f 67 2d 61 62 33 34 39 31 38 30 61 30 |gelog-ab349180a0|
+  0040: 33 72 65 71 75 69 72 65 6d 65 6e 74 73 67 65 6e |3requirementsgen|
+  0050: 65 72 61 6c 64 65 6c 74 61 25 32 43 72 65 76 6c |eraldelta%2Crevl|
+  0060: 6f 67 76 31 25 32 43 73 70 61 72 73 65 72 65 76 |ogv1%2Csparserev|
+  0070: 6c 6f 67 00 00 80 00 73 08 42 64 61 74 61 2f 30 |logs.Bdata/0|
+  0080: 2e 69 00 03 00 

D12080: stream-requirements: smoother matching in test-ssh-proto.t

2022-01-24 Thread marmoute (Pierre-Yves David)
marmoute created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  The value of `streamreqs` changes depending of the format used, but this is 
not
  relevant for this tests. So we doing a smarter matching of the line to avoid
  this test interfering with format changes in the future.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  tests/test-ssh-proto.t
  tests/test-ssh.t

CHANGE DETAILS

diff --git a/tests/test-ssh.t b/tests/test-ssh.t
--- a/tests/test-ssh.t
+++ b/tests/test-ssh.t
@@ -531,10 +531,8 @@
   devel-peer-request:   pairs: 81 bytes
   sending hello command
   sending between command
-  remote: 444 (no-rust !)
-  remote: 463 (rust !)
-  remote: capabilities: batch branchmap $USUAL_BUNDLE2_CAPS$ changegroupsubset 
getbundle known lookup protocaps pushkey 
streamreqs=generaldelta,revlogv1,sparserevlog unbundle=HG10GZ,HG10BZ,HG10UN 
unbundlehash (no-rust !)
-  remote: capabilities: batch branchmap $USUAL_BUNDLE2_CAPS$ changegroupsubset 
getbundle known lookup protocaps pushkey 
streamreqs=generaldelta,persistent-nodemap,revlogv1,sparserevlog 
unbundle=HG10GZ,HG10BZ,HG10UN unbundlehash (rust !)
+  remote: \d+ (re)
+  remote: capabilities: batch branchmap \$USUAL_BUNDLE2_CAPS\$ 
changegroupsubset getbundle known lookup protocaps pushkey streamreqs=[^ 
,]+(,[^ ,]+)* unbundle=HG10GZ,HG10BZ,HG10UN unbundlehash (re)
   remote: 1
   devel-peer-request: protocaps
   devel-peer-request:   caps: * bytes (glob)
diff --git a/tests/test-ssh-proto.t b/tests/test-ssh-proto.t
--- a/tests/test-ssh-proto.t
+++ b/tests/test-ssh-proto.t
@@ -55,8 +55,8 @@
   devel-peer-request:   pairs: 81 bytes
   sending hello command
   sending between command
-  remote: 444
-  remote: capabilities: batch branchmap $USUAL_BUNDLE2_CAPS$ changegroupsubset 
getbundle known lookup protocaps pushkey 
streamreqs=generaldelta,revlogv1,sparserevlog unbundle=HG10GZ,HG10BZ,HG10UN 
unbundlehash
+  remote: \d+ (re)
+  remote: capabilities: batch branchmap \$USUAL_BUNDLE2_CAPS\$ 
changegroupsubset getbundle known lookup protocaps pushkey streamreqs=[^ 
,]+(,[^ ,]+)* unbundle=HG10GZ,HG10BZ,HG10UN unbundlehash (re)
   remote: 1
   devel-peer-request: protocaps
   devel-peer-request:   caps: * bytes (glob)
@@ -77,9 +77,9 @@
   i> write(6) -> 6:
   i> hello\n
   o> readline() -> 4:
-  o> 444\n
-  o> readline() -> 444:
-  o> capabilities: batch branchmap $USUAL_BUNDLE2_CAPS$ changegroupsubset 
getbundle known lookup protocaps pushkey 
streamreqs=generaldelta,revlogv1,sparserevlog unbundle=HG10GZ,HG10BZ,HG10UN 
unbundlehash\n
+  o> \d+\\n (re)
+  o> readline\(\) -> \d+: (re)
+  o> capabilities: batch branchmap \$USUAL_BUNDLE2_CAPS\$ 
changegroupsubset getbundle known lookup protocaps pushkey streamreqs=[^ 
,]+(,[^ ,]+)* unbundle=HG10GZ,HG10BZ,HG10UN unbundlehash\\n (re)
 
 `hg debugserve --sshstdio` works
 
@@ -87,8 +87,8 @@
   $ hg debugserve --sshstdio << EOF
   > hello
   > EOF
-  444
-  capabilities: batch branchmap $USUAL_BUNDLE2_CAPS$ changegroupsubset 
getbundle known lookup protocaps pushkey 
streamreqs=generaldelta,revlogv1,sparserevlog unbundle=HG10GZ,HG10BZ,HG10UN 
unbundlehash
+  \d+ (re)
+  capabilities: batch branchmap \$USUAL_BUNDLE2_CAPS\$ changegroupsubset 
getbundle known lookup protocaps pushkey streamreqs=[^ ,]+(,[^ ,]+)* 
unbundle=HG10GZ,HG10BZ,HG10UN unbundlehash (re)
 
 I/O logging works
 
@@ -97,25 +97,25 @@
   > EOF
   e> flush() -> None
   o> write(4) -> 4:
-  o> 444\n
-  o> write(444) -> 444:
-  o> capabilities: batch branchmap $USUAL_BUNDLE2_CAPS$ changegroupsubset 
getbundle known lookup protocaps pushkey 
streamreqs=generaldelta,revlogv1,sparserevlog unbundle=HG10GZ,HG10BZ,HG10UN 
unbundlehash\n
-  444
-  capabilities: batch branchmap $USUAL_BUNDLE2_CAPS$ changegroupsubset 
getbundle known lookup protocaps pushkey 
streamreqs=generaldelta,revlogv1,sparserevlog unbundle=HG10GZ,HG10BZ,HG10UN 
unbundlehash
+  o> \d+\\n (re)
+  o> write\(\d+\) -> \d+: (re)
+  o> capabilities: batch branchmap \$USUAL_BUNDLE2_CAPS\$ 
changegroupsubset getbundle known lookup protocaps pushkey streamreqs=[^ 
,]+(,[^ ,]+)* unbundle=HG10GZ,HG10BZ,HG10UN unbundlehash\\n (re)
+  \d+ (re)
+  capabilities: batch branchmap \$USUAL_BUNDLE2_CAPS\$ changegroupsubset 
getbundle known lookup protocaps pushkey streamreqs=[^ ,]+(,[^ ,]+)* 
unbundle=HG10GZ,HG10BZ,HG10UN unbundlehash (re)
   o> flush() -> None
 
   $ hg debugserve --sshstdio --logiofile $TESTTMP/io << EOF
   > hello
   > EOF
-  444
-  capabilities: batch branchmap $USUAL_BUNDLE2_CAPS$ changegroupsubset 
getbundle known lookup protocaps pushkey 
streamreqs=generaldelta,revlogv1,sparserevlog unbundle=HG10GZ,HG10BZ,HG10UN 
unbundlehash
+  \d+ (re)
+  capabilities: batch branchmap \$USUAL_BUNDLE2_CAPS\$ changegroupsubset 
getbundle known lookup protocaps pushkey streamreqs=[^ ,]+(,[^ ,]+)* 
unbundle=HG10GZ,HG10BZ,HG10UN 

D12082: stream-requirements: smoother matching in test-http-protocol.t

2022-01-24 Thread marmoute (Pierre-Yves David)
marmoute created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  The value of `streamreqs` changes depending of the format used, but this is 
not
  relevant for this tests. So we doing a smarter matching of the line to avoid
  this test interfering with format changes in the future.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  tests/test-http-protocol.t

CHANGE DETAILS

diff --git a/tests/test-http-protocol.t b/tests/test-http-protocol.t
--- a/tests/test-http-protocol.t
+++ b/tests/test-http-protocol.t
@@ -198,7 +198,7 @@
   s> Content-Type: application/mercurial-0.1\r\n
   s> Content-Length: *\r\n (glob)
   s> \r\n
-  s> batch branchmap $USUAL_BUNDLE2_CAPS$ changegroupsubset 
compression=$BUNDLE2_COMPRESSIONS$ getbundle httpheader=1024 
httpmediatype=0.1rx,0.1tx,0.2tx known lookup pushkey 
streamreqs=generaldelta,revlogv1,sparserevlog unbundle=HG10GZ,HG10BZ,HG10UN 
unbundlehash
+  s> batch branchmap \$USUAL_BUNDLE2_CAPS\$ changegroupsubset 
compression=\$BUNDLE2_COMPRESSIONS\$ getbundle httpheader=1024 
httpmediatype=0.1rx,0.1tx,0.2tx known lookup pushkey streamreqs=[^ ,]+(,[^ 
,]+)* unbundle=HG10GZ,HG10BZ,HG10UN unbundlehash (re)
   sending listkeys command
   s> setsockopt(6, 1, 1) -> None (?)
   s> GET /?cmd=listkeys HTTP/1.1\r\n
@@ -327,9 +327,9 @@
   s> Server: testing stub value\r\n
   s> Date: $HTTP_DATE$\r\n
   s> Content-Type: application/mercurial-0.1\r\n
-  s> Content-Length: 484\r\n
+  s> Content-Length: \d+\\r\\n (re)
   s> \r\n
-  s> batch branchmap $USUAL_BUNDLE2_CAPS$ changegroupsubset 
compression=$BUNDLE2_COMPRESSIONS$ getbundle httpheader=1024 
httpmediatype=0.1rx,0.1tx,0.2tx known lookup pushkey 
streamreqs=generaldelta,revlogv1,sparserevlog unbundle=HG10GZ,HG10BZ,HG10UN 
unbundlehash
+  s> batch branchmap \$USUAL_BUNDLE2_CAPS\$ changegroupsubset 
compression=\$BUNDLE2_COMPRESSIONS\$ getbundle httpheader=1024 
httpmediatype=0.1rx,0.1tx,0.2tx known lookup pushkey streamreqs=[^ ,]+(,[^ 
,]+)* unbundle=HG10GZ,HG10BZ,HG10UN unbundlehash (re)
 
 Test with the HTTP peer
 
@@ -364,10 +364,10 @@
   s> Server: testing stub value\r\n
   s> Date: $HTTP_DATE$\r\n
   s> Content-Type: application/mercurial-0.1\r\n
-  s> Content-Length: 484\r\n
+  s> Content-Length: \d+\\r\\n (re)
   s> \r\n
   real URL is http://$LOCALIP:$HGPORT/redirected (glob)
-  s> batch branchmap $USUAL_BUNDLE2_CAPS$ changegroupsubset 
compression=$BUNDLE2_COMPRESSIONS$ getbundle httpheader=1024 
httpmediatype=0.1rx,0.1tx,0.2tx known lookup pushkey 
streamreqs=generaldelta,revlogv1,sparserevlog unbundle=HG10GZ,HG10BZ,HG10UN 
unbundlehash
+  s> batch branchmap \$USUAL_BUNDLE2_CAPS\$ changegroupsubset 
compression=\$BUNDLE2_COMPRESSIONS\$ getbundle httpheader=1024 
httpmediatype=0.1rx,0.1tx,0.2tx known lookup pushkey streamreqs=[^ ,]+(,[^ 
,]+)* unbundle=HG10GZ,HG10BZ,HG10UN unbundlehash (re)
   sending heads command
   s> setsockopt(6, 1, 1) -> None (?)
   s> GET /redirected?cmd=heads HTTP/1.1\r\n
@@ -635,10 +635,10 @@
   s> Server: testing stub value\r\n
   s> Date: $HTTP_DATE$\r\n
   s> Content-Type: application/mercurial-0.1\r\n
-  s> Content-Length: 484\r\n
+  s> Content-Length: \d+\\r\\n (re)
   s> \r\n
   real URL is http://$LOCALIP:$HGPORT/redirected (glob)
-  s> batch branchmap $USUAL_BUNDLE2_CAPS$ changegroupsubset 
compression=$BUNDLE2_COMPRESSIONS$ getbundle httpheader=1024 
httpmediatype=0.1rx,0.1tx,0.2tx known lookup pushkey 
streamreqs=generaldelta,revlogv1,sparserevlog unbundle=HG10GZ,HG10BZ,HG10UN 
unbundlehash
+  s> batch branchmap \$USUAL_BUNDLE2_CAPS\$ changegroupsubset 
compression=\$BUNDLE2_COMPRESSIONS\$ getbundle httpheader=1024 
httpmediatype=0.1rx,0.1tx,0.2tx known lookup pushkey streamreqs=[^ ,]+(,[^ 
,]+)* unbundle=HG10GZ,HG10BZ,HG10UN unbundlehash (re)
   sending heads command
   s> setsockopt(6, 1, 1) -> None (?)
   s> GET /redirected?cmd=heads HTTP/1.1\r\n



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


D12081: stream-requirements: smoother matching in test-ssh-bundle1.t

2022-01-24 Thread marmoute (Pierre-Yves David)
marmoute created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  The value of `streamreqs` changes depending of the format used, but this is 
not
  relevant for this tests. So we doing a smarter matching of the line to avoid
  this test interfering with format changes in the future.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  tests/test-ssh-bundle1.t

CHANGE DETAILS

diff --git a/tests/test-ssh-bundle1.t b/tests/test-ssh-bundle1.t
--- a/tests/test-ssh-bundle1.t
+++ b/tests/test-ssh-bundle1.t
@@ -475,10 +475,8 @@
   running .* ".*[/\\]dummyssh" ['"]user@dummy['"] ['"]hg -R remote serve 
--stdio['"] (re)
   sending hello command
   sending between command
-  remote: 444 (no-rust !)
-  remote: 463 (rust !)
-  remote: capabilities: batch branchmap $USUAL_BUNDLE2_CAPS$ changegroupsubset 
getbundle known lookup protocaps pushkey 
streamreqs=generaldelta,revlogv1,sparserevlog unbundle=HG10GZ,HG10BZ,HG10UN 
unbundlehash (no-rust !)
-  remote: capabilities: batch branchmap $USUAL_BUNDLE2_CAPS$ changegroupsubset 
getbundle known lookup protocaps pushkey 
streamreqs=generaldelta,persistent-nodemap,revlogv1,sparserevlog 
unbundle=HG10GZ,HG10BZ,HG10UN unbundlehash (rust !)
+  remote: \d+ (re)
+  remote: capabilities: batch branchmap \$USUAL_BUNDLE2_CAPS\$ 
changegroupsubset getbundle known lookup protocaps pushkey streamreqs=[^ 
,]+(,[^ ,]+)* unbundle=HG10GZ,HG10BZ,HG10UN unbundlehash (re)
   remote: 1
   sending protocaps command
   preparing listkeys for "bookmarks"



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


D12079: stream-requirements: smoother matching in test-hgweb-commands.t

2022-01-24 Thread marmoute (Pierre-Yves David)
marmoute created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  The value of `streamreqs` changes depending of the format used, but this is 
not
  relevant for this tests. So we doing a smarter matching of the line to avoid
  this test interfering with format changes in the future.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  tests/test-hgweb-commands.t

CHANGE DETAILS

diff --git a/tests/test-hgweb-commands.t b/tests/test-hgweb-commands.t
--- a/tests/test-hgweb-commands.t
+++ b/tests/test-hgweb-commands.t
@@ -2193,8 +2193,7 @@
   lookup
   pushkey
   stream-preferred
-  streamreqs=generaldelta,revlogv1,sparserevlog (no-rust !)
-  streamreqs=generaldelta,persistent-nodemap,revlogv1,sparserevlog (rust !)
+  streamreqs=*,* (glob)
   unbundle=HG10GZ,HG10BZ,HG10UN
   unbundlehash
 



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


D12078: stream-requirements: smoother matching in test-treemanifest.t

2022-01-24 Thread marmoute (Pierre-Yves David)
marmoute created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  The value of `streamreqs` changes depending of the format used, but this is 
not
  relevant for this tests. So we doing a smarter matching of the line to avoid
  this test interfering with format changes in the future.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  tests/test-treemanifest.t

CHANGE DETAILS

diff --git a/tests/test-treemanifest.t b/tests/test-treemanifest.t
--- a/tests/test-treemanifest.t
+++ b/tests/test-treemanifest.t
@@ -829,11 +829,9 @@
   $ hg -R deeprepo debugcreatestreamclonebundle repo-packed.hg
   writing 5330 bytes for 18 files (no-zstd !)
   writing 5400 bytes for 18 files (zstd !)
-  bundle requirements: generaldelta, revlogv1, sparserevlog, treemanifest 
(no-rust !)
-  bundle requirements: generaldelta, persistent-nodemap, revlogv1, 
sparserevlog, treemanifest (rust !)
+  bundle requirements:.* treemanifest(,.*)? (re)
   $ hg debugbundle --spec repo-packed.hg
-  
none-packed1;requirements%3Dgeneraldelta%2Crevlogv1%2Csparserevlog%2Ctreemanifest
 (no-rust !)
-  
none-packed1;requirements%3Dgeneraldelta%2Cpersistent-nodemap%2Crevlogv1%2Csparserevlog%2Ctreemanifest
 (rust !)
+  none-packed1;requirements%3D(.*%2C)?treemanifest(%2C.*)? (re)
 
 #endif
 



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


D12077: stream-requirements: smoother matching in test-ssh-proto-unbundle.t

2022-01-24 Thread marmoute (Pierre-Yves David)
marmoute created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  The value of `streamreqs` changes depending of the format used, but this is 
not
  relevant for this tests. So we doing a smarter matching of the line to avoid
  this test interfering with format changes in the future.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  tests/test-ssh-proto-unbundle.t

CHANGE DETAILS

diff --git a/tests/test-ssh-proto-unbundle.t b/tests/test-ssh-proto-unbundle.t
--- a/tests/test-ssh-proto-unbundle.t
+++ b/tests/test-ssh-proto-unbundle.t
@@ -50,9 +50,9 @@
   i> 
-
   i> flush() -> None
   o> readline() -> 4:
-  o> 444\n
-  o> readline() -> 444:
-  o> capabilities: batch branchmap $USUAL_BUNDLE2_CAPS$ changegroupsubset 
getbundle known lookup protocaps pushkey 
streamreqs=generaldelta,revlogv1,sparserevlog unbundle=HG10GZ,HG10BZ,HG10UN 
unbundlehash\n
+  o> \d+\\n (re)
+  o> readline\(\) -> \d+: (re)
+  o> capabilities: batch branchmap \$USUAL_BUNDLE2_CAPS\$ 
changegroupsubset getbundle known lookup protocaps pushkey streamreqs=[^ 
,]+(,[^ ,]+)* unbundle=HG10GZ,HG10BZ,HG10UN unbundlehash\\n (re)
   o> readline() -> 2:
   o> 1\n
   o> readline() -> 1:
@@ -179,9 +179,9 @@
   i> 
-
   i> flush() -> None
   o> readline() -> 4:
-  o> 444\n
-  o> readline() -> 444:
-  o> capabilities: batch branchmap $USUAL_BUNDLE2_CAPS$ changegroupsubset 
getbundle known lookup protocaps pushkey 
streamreqs=generaldelta,revlogv1,sparserevlog unbundle=HG10GZ,HG10BZ,HG10UN 
unbundlehash\n
+  o> \d+\\n (re)
+  o> readline\(\) -> \d+: (re)
+  o> capabilities: batch branchmap \$USUAL_BUNDLE2_CAPS\$ 
changegroupsubset getbundle known lookup protocaps pushkey streamreqs=[^ 
,]+(,[^ ,]+)* unbundle=HG10GZ,HG10BZ,HG10UN unbundlehash\\n (re)
   o> readline() -> 2:
   o> 1\n
   o> readline() -> 1:
@@ -247,10 +247,10 @@
   i> pairs 81\n
   i> 
-
   i> flush() -> None
-  o> readline() -> 4:
-  o> 444\n
-  o> readline() -> 444:
-  o> capabilities: batch branchmap $USUAL_BUNDLE2_CAPS$ changegroupsubset 
getbundle known lookup protocaps pushkey 
streamreqs=generaldelta,revlogv1,sparserevlog unbundle=HG10GZ,HG10BZ,HG10UN 
unbundlehash\n
+  o> readline\(\) -> \d+: (re)
+  o> \d+\\n (re)
+  o> readline\(\) -> \d+: (re)
+  o> capabilities: batch branchmap \$USUAL_BUNDLE2_CAPS\$ 
changegroupsubset getbundle known lookup protocaps pushkey streamreqs=[^ 
,]+(,[^ ,]+)* unbundle=HG10GZ,HG10BZ,HG10UN unbundlehash\\n (re)
   o> readline() -> 2:
   o> 1\n
   o> readline() -> 1:
@@ -318,9 +318,9 @@
   i> 
-
   i> flush() -> None
   o> readline() -> 4:
-  o> 444\n
-  o> readline() -> 444:
-  o> capabilities: batch branchmap $USUAL_BUNDLE2_CAPS$ changegroupsubset 
getbundle known lookup protocaps pushkey 
streamreqs=generaldelta,revlogv1,sparserevlog unbundle=HG10GZ,HG10BZ,HG10UN 
unbundlehash\n
+  o> \d+\\n (re)
+  o> readline\(\) -> \d+: (re)
+  o> capabilities: batch branchmap \$USUAL_BUNDLE2_CAPS\$ 
changegroupsubset getbundle known lookup protocaps pushkey streamreqs=[^ 
,]+(,[^ ,]+)* unbundle=HG10GZ,HG10BZ,HG10UN unbundlehash\\n (re)
   o> readline() -> 2:
   o> 1\n
   o> readline() -> 1:
@@ -387,9 +387,9 @@
   i> 
-
   i> flush() -> None
   o> readline() -> 4:
-  o> 444\n
-  o> readline() -> 444:
-  o> capabilities: batch branchmap $USUAL_BUNDLE2_CAPS$ changegroupsubset 
getbundle known lookup protocaps pushkey 
streamreqs=generaldelta,revlogv1,sparserevlog unbundle=HG10GZ,HG10BZ,HG10UN 
unbundlehash\n
+  o> \d+\\n (re)
+  o> readline\(\) -> \d+: (re)
+  o> capabilities: batch branchmap \$USUAL_BUNDLE2_CAPS\$ 
changegroupsubset getbundle known lookup protocaps pushkey streamreqs=[^ 
,]+(,[^ ,]+)* unbundle=HG10GZ,HG10BZ,HG10UN unbundlehash\\n (re)
   o> readline() -> 2:
   o> 1\n
   o> readline() -> 1:
@@ -457,9 +457,9 @@
   i> 
-
   i> flush() -> None
   o> readline() -> 4:
-  o> 444\n
-  o> readline() -> 444:
-  o> capabilities: batch branchmap $USUAL_BUNDLE2_CAPS$ changegroupsubset 
getbundle known lookup protocaps pushkey 
streamreqs=generaldelta,revlogv1,sparserevlog unbundle=HG10GZ,HG10BZ,HG10UN 
unbundlehash\n
+  o> \d+\\n (re)
+  o> readline\(\) -> \d+: (re)
+  o> capabilities: batch branchmap \$USUAL_BUNDLE2_CAPS\$ 
changegroupsubset getbundle known lookup protocaps pushkey streamreqs=[^ 
,]+(,[^ 

D12074: test-http-bad-server: abstract the `streamreqs` value

2022-01-24 Thread marmoute (Pierre-Yves David)
marmoute created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  Now that socket closing are decided much closer to the actual closure, we can
  use fuzzy matching for this part of the exchange that changes on a regular
  basis.
  
  This should make fixing bug in stream requirements and enabling new format 
much
  simpler.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  tests/test-http-bad-server.t

CHANGE DETAILS

diff --git a/tests/test-http-bad-server.t b/tests/test-http-bad-server.t
--- a/tests/test-http-bad-server.t
+++ b/tests/test-http-bad-server.t
@@ -130,17 +130,17 @@
   readline(*) -> (*) host: localhost:$HGPORT\r\n (glob)
   readline(*) -> (49) user-agent: mercurial/proto-1.0 (Mercurial 4.2)\r\n 
(glob)
   readline(*) -> (2) \r\n (glob)
-  sendall(160) -> HTTP/1.1 200 Script output follows\r\nServer: 
badhttpserver\r\nDate: $HTTP_DATE$\r\nContent-Type: 
application/mercurial-0.1\r\nContent-Length: 431\r\n\r\n (py36 !)
-  sendall(431) -> batch branchmap $USUAL_BUNDLE2_CAPS_NO_PHASES$ 
changegroupsubset compression=none getbundle httpheader=1024 
httpmediatype=0.1rx,0.1tx,0.2tx known lookup pushkey 
streamreqs=generaldelta,revlogv1 unbundle=HG10GZ,HG10BZ,HG10UN unbundlehash 
(py36 !)
-  write(160) -> HTTP/1.1 200 Script output follows\r\nServer: 
badhttpserver\r\nDate: $HTTP_DATE$\r\nContent-Type: 
application/mercurial-0.1\r\nContent-Length: 431\r\n\r\n (py3 no-py36 !)
-  write(431) -> batch branchmap $USUAL_BUNDLE2_CAPS_NO_PHASES$ 
changegroupsubset compression=none getbundle httpheader=1024 
httpmediatype=0.1rx,0.1tx,0.2tx known lookup pushkey 
streamreqs=generaldelta,revlogv1 unbundle=HG10GZ,HG10BZ,HG10UN unbundlehash 
(py3 no-py36 !)
+  sendall(160) -> HTTP/1.1 200 Script output follows\r\nServer: 
badhttpserver\r\nDate: $HTTP_DATE$\r\nContent-Type: 
application/mercurial-0.1\r\nContent-Length: *\r\n\r\n (glob) (py36 !)
+  sendall(*) -> batch branchmap $USUAL_BUNDLE2_CAPS_NO_PHASES$ 
changegroupsubset compression=none getbundle httpheader=1024 
httpmediatype=0.1rx,0.1tx,0.2tx known lookup pushkey streamreqs=* 
unbundle=HG10GZ,HG10BZ,HG10UN unbundlehash (glob) (py36 !)
+  write(160) -> HTTP/1.1 200 Script output follows\r\nServer: 
badhttpserver\r\nDate: $HTTP_DATE$\r\nContent-Type: 
application/mercurial-0.1\r\nContent-Length: *\r\n\r\n (glob) (py3 no-py36 !)
+  write(*) -> batch branchmap $USUAL_BUNDLE2_CAPS_NO_PHASES$ changegroupsubset 
compression=none getbundle httpheader=1024 httpmediatype=0.1rx,0.1tx,0.2tx 
known lookup pushkey streamreqs=* unbundle=HG10GZ,HG10BZ,HG10UN unbundlehash 
(glob) (py3 no-py36 !)
   write(36) -> HTTP/1.1 200 Script output follows\r\n (no-py3 !)
   write(23) -> Server: badhttpserver\r\n (no-py3 !)
   write(37) -> Date: $HTTP_DATE$\r\n (no-py3 !)
   write(41) -> Content-Type: application/mercurial-0.1\r\n (no-py3 !)
-  write(21) -> Content-Length: 431\r\n (no-py3 !)
+  write(21) -> Content-Length: *\r\n (glob) (no-py3 !)
   write(2) -> \r\n (no-py3 !)
-  write(431) -> batch branchmap $USUAL_BUNDLE2_CAPS_NO_PHASES$ 
changegroupsubset compression=none getbundle httpheader=1024 
httpmediatype=0.1rx,0.1tx,0.2tx known lookup pushkey 
streamreqs=generaldelta,revlogv1 unbundle=HG10GZ,HG10BZ,HG10UN unbundlehash 
(no-py3 !)
+  write(*) -> batch branchmap $USUAL_BUNDLE2_CAPS_NO_PHASES$ changegroupsubset 
compression=none getbundle httpheader=1024 httpmediatype=0.1rx,0.1tx,0.2tx 
known lookup pushkey streamreqs=* unbundle=HG10GZ,HG10BZ,HG10UN unbundlehash 
(glob) (no-py3 !)
   readline(~) -> (26) GET /?cmd=batch HTTP/1.1\r\n (glob)
   readline(*) -> (1?) Accept-Encoding* (glob)
   read limit reached; closing socket
@@ -179,17 +179,17 @@
   readline(*) -> (*) host: localhost:$HGPORT\r\n (glob)
   readline(*) -> (49) user-agent: mercurial/proto-1.0 (Mercurial 4.2)\r\n 
(glob)
   readline(*) -> (2) \r\n (glob)
-  sendall(160) -> HTTP/1.1 200 Script output follows\r\nServer: 
badhttpserver\r\nDate: $HTTP_DATE$\r\nContent-Type: 
application/mercurial-0.1\r\nContent-Length: 431\r\n\r\n (py36 !)
-  sendall(431) -> batch branchmap $USUAL_BUNDLE2_CAPS_NO_PHASES$ 
changegroupsubset compression=none getbundle httpheader=1024 
httpmediatype=0.1rx,0.1tx,0.2tx known lookup pushkey 
streamreqs=generaldelta,revlogv1 unbundle=HG10GZ,HG10BZ,HG10UN unbundlehash 
(py36 !)
-  write(160) -> HTTP/1.1 200 Script output follows\r\nServer: 
badhttpserver\r\nDate: $HTTP_DATE$\r\nContent-Type: 
application/mercurial-0.1\r\nContent-Length: 431\r\n\r\n (py3 no-py36 !)
-  write(431) -> batch branchmap $USUAL_BUNDLE2_CAPS_NO_PHASES$ 
changegroupsubset compression=none getbundle httpheader=1024 
httpmediatype=0.1rx,0.1tx,0.2tx known lookup pushkey 
streamreqs=generaldelta,revlogv1 unbundle=HG10GZ,HG10BZ,HG10UN unbundlehash 
(py3 no-py36 !)
+  sendall(160) -> HTTP/1.1 200 Script output follows\r\nServer: 
badhttpserver\r\nDate: $HTTP_DATE$\r\nContent-Type: 

D12076: test-bundle: split some variant in there own section

2022-01-24 Thread marmoute (Pierre-Yves David)
marmoute created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  Same rational as the previous commit about test-bundle.t. These line are quite
  volatile and having dedicated block will make their update clearer and 
simpler.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  tests/test-debugcommands.t

CHANGE DETAILS

diff --git a/tests/test-debugcommands.t b/tests/test-debugcommands.t
--- a/tests/test-debugcommands.t
+++ b/tests/test-debugcommands.t
@@ -649,16 +649,16 @@
   local: no
   pushable: yes
 
+#if rust
+
   $ hg --debug debugpeer ssh://user@dummy/debugrevlog
   running .* ".*[/\\]dummyssh" ['"]user@dummy['"] ['"]hg -R debugrevlog serve 
--stdio['"] (re)
   devel-peer-request: hello+between
   devel-peer-request:   pairs: 81 bytes
   sending hello command
   sending between command
-  remote: 444 (no-rust !)
-  remote: 463 (rust !)
-  remote: capabilities: batch branchmap $USUAL_BUNDLE2_CAPS$ changegroupsubset 
getbundle known lookup protocaps pushkey 
streamreqs=generaldelta,revlogv1,sparserevlog unbundle=HG10GZ,HG10BZ,HG10UN 
unbundlehash (no-rust !)
-  remote: capabilities: batch branchmap $USUAL_BUNDLE2_CAPS$ changegroupsubset 
getbundle known lookup protocaps pushkey 
streamreqs=generaldelta,persistent-nodemap,revlogv1,sparserevlog 
unbundle=HG10GZ,HG10BZ,HG10UN unbundlehash (rust !)
+  remote: 463
+  remote: capabilities: batch branchmap $USUAL_BUNDLE2_CAPS$ changegroupsubset 
getbundle known lookup protocaps pushkey 
streamreqs=generaldelta,persistent-nodemap,revlogv1,sparserevlog 
unbundle=HG10GZ,HG10BZ,HG10UN unbundlehash
   remote: 1
   devel-peer-request: protocaps
   devel-peer-request:   caps: * bytes (glob)
@@ -666,3 +666,45 @@
   url: ssh://user@dummy/debugrevlog
   local: no
   pushable: yes
+
+#endif
+
+#if no-rust zstd
+
+  $ hg --debug debugpeer ssh://user@dummy/debugrevlog
+  running .* ".*[/\\]dummyssh" ['"]user@dummy['"] ['"]hg -R debugrevlog serve 
--stdio['"] (re)
+  devel-peer-request: hello+between
+  devel-peer-request:   pairs: 81 bytes
+  sending hello command
+  sending between command
+  remote: 444
+  remote: capabilities: batch branchmap $USUAL_BUNDLE2_CAPS$ changegroupsubset 
getbundle known lookup protocaps pushkey 
streamreqs=generaldelta,revlogv1,sparserevlog unbundle=HG10GZ,HG10BZ,HG10UN 
unbundlehash
+  remote: 1
+  devel-peer-request: protocaps
+  devel-peer-request:   caps: * bytes (glob)
+  sending protocaps command
+  url: ssh://user@dummy/debugrevlog
+  local: no
+  pushable: yes
+
+#endif
+
+#if no-rust no-zstd
+
+  $ hg --debug debugpeer ssh://user@dummy/debugrevlog
+  running .* ".*[/\\]dummyssh" ['"]user@dummy['"] ['"]hg -R debugrevlog serve 
--stdio['"] (re)
+  devel-peer-request: hello+between
+  devel-peer-request:   pairs: 81 bytes
+  sending hello command
+  sending between command
+  remote: 444
+  remote: capabilities: batch branchmap $USUAL_BUNDLE2_CAPS$ changegroupsubset 
getbundle known lookup protocaps pushkey 
streamreqs=generaldelta,revlogv1,sparserevlog unbundle=HG10GZ,HG10BZ,HG10UN 
unbundlehash
+  remote: 1
+  devel-peer-request: protocaps
+  devel-peer-request:   caps: * bytes (glob)
+  sending protocaps command
+  url: ssh://user@dummy/debugrevlog
+  local: no
+  pushable: yes
+
+#endif



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


D12075: test-bundle: split each variant in there own section

2022-01-24 Thread marmoute (Pierre-Yves David)
marmoute created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  Having conditional line matching for this kind of big block is quite
  inconvenient to update. The new way should be simpler to maintain.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  tests/test-bundle.t

CHANGE DETAILS

diff --git a/tests/test-bundle.t b/tests/test-bundle.t
--- a/tests/test-bundle.t
+++ b/tests/test-bundle.t
@@ -292,32 +292,56 @@
 
 packed1 is produced properly
 
-#if reporevlogstore
+
+#if reporevlogstore rust
 
   $ hg -R test debugcreatestreamclonebundle packed.hg
-  writing 2664 bytes for 6 files (no-zstd !)
-  writing 2665 bytes for 6 files (zstd !)
-  bundle requirements: generaldelta, revlogv1, sparserevlog (no-rust !)
-  bundle requirements: generaldelta, persistent-nodemap, revlogv1, 
sparserevlog (rust !)
+  writing 2665 bytes for 6 files
+  bundle requirements: generaldelta, persistent-nodemap, revlogv1, sparserevlog
+
+  $ f -B 64 --size --sha1 --hexdump packed.hg
+  packed.hg: size=2860, sha1=81d7a2e535892cda51e82c200f818de2cca828d3
+  : 48 47 53 31 55 4e 00 00 00 00 00 00 00 06 00 00 |HGS1UN..|
+  0010: 00 00 00 00 0a 69 00 36 67 65 6e 65 72 61 6c 64 |.i.6generald|
+  0020: 65 6c 74 61 2c 70 65 72 73 69 73 74 65 6e 74 2d |elta,persistent-|
+  0030: 6e 6f 64 65 6d 61 70 2c 72 65 76 6c 6f 67 76 31 |nodemap,revlogv1|
+  $ hg debugbundle --spec packed.hg
+  
none-packed1;requirements%3Dgeneraldelta%2Cpersistent-nodemap%2Crevlogv1%2Csparserevlog
+#endif
+
+#if reporevlogstore no-rust zstd
+
+  $ hg -R test debugcreatestreamclonebundle packed.hg
+  writing 2665 bytes for 6 files
+  bundle requirements: generaldelta, revlogv1, sparserevlog
 
   $ f -B 64 --size --sha1 --hexdump packed.hg
-  packed.hg: size=2840, sha1=12bf3eee3eb8a04c503ce2d29b48f0135c7edff5 (no-zstd 
!)
-  packed.hg: size=2841, sha1=8b645a65f49b0ae43042a9f3da56d4bfdf1c7f99 (zstd 
no-rust !)
-  packed.hg: size=2860, sha1=81d7a2e535892cda51e82c200f818de2cca828d3 (rust !)
+  packed.hg: size=2841, sha1=8b645a65f49b0ae43042a9f3da56d4bfdf1c7f99
   : 48 47 53 31 55 4e 00 00 00 00 00 00 00 06 00 00 |HGS1UN..|
-  0010: 00 00 00 00 0a 68 00 23 67 65 6e 65 72 61 6c 64 |.h.#generald| 
(no-zstd !)
-  0020: 65 6c 74 61 2c 72 65 76 6c 6f 67 76 31 2c 73 70 |elta,revlogv1,sp| 
(no-zstd !)
-  0030: 61 72 73 65 72 65 76 6c 6f 67 00 64 61 74 61 2f |arserevlog.data/| 
(no-zstd !)
-  0010: 00 00 00 00 0a 69 00 23 67 65 6e 65 72 61 6c 64 |.i.#generald| 
(zstd no-rust !)
-  0020: 65 6c 74 61 2c 72 65 76 6c 6f 67 76 31 2c 73 70 |elta,revlogv1,sp| 
(zstd no-rust !)
-  0030: 61 72 73 65 72 65 76 6c 6f 67 00 64 61 74 61 2f |arserevlog.data/| 
(zstd no-rust !)
-  0010: 00 00 00 00 0a 69 00 36 67 65 6e 65 72 61 6c 64 |.i.6generald| 
(rust !)
-  0020: 65 6c 74 61 2c 70 65 72 73 69 73 74 65 6e 74 2d |elta,persistent-| 
(rust !)
-  0030: 6e 6f 64 65 6d 61 70 2c 72 65 76 6c 6f 67 76 31 |nodemap,revlogv1| 
(rust !)
+  0010: 00 00 00 00 0a 69 00 23 67 65 6e 65 72 61 6c 64 |.i.#generald|
+  0020: 65 6c 74 61 2c 72 65 76 6c 6f 67 76 31 2c 73 70 |elta,revlogv1,sp|
+  0030: 61 72 73 65 72 65 76 6c 6f 67 00 64 61 74 61 2f |arserevlog.data/|
+  $ hg debugbundle --spec packed.hg
+  none-packed1;requirements%3Dgeneraldelta%2Crevlogv1%2Csparserevlog
+#endif
+
+#if reporevlogstore no-rust no-zstd
 
+  $ hg -R test debugcreatestreamclonebundle packed.hg
+  writing 2664 bytes for 6 files
+  bundle requirements: generaldelta, revlogv1, sparserevlog
+
+  $ f -B 64 --size --sha1 --hexdump packed.hg
+  packed.hg: size=2840, sha1=12bf3eee3eb8a04c503ce2d29b48f0135c7edff5
+  : 48 47 53 31 55 4e 00 00 00 00 00 00 00 06 00 00 |HGS1UN..|
+  0010: 00 00 00 00 0a 68 00 23 67 65 6e 65 72 61 6c 64 |.h.#generald|
+  0020: 65 6c 74 61 2c 72 65 76 6c 6f 67 76 31 2c 73 70 |elta,revlogv1,sp|
+  0030: 61 72 73 65 72 65 76 6c 6f 67 00 64 61 74 61 2f |arserevlog.data/|
   $ hg debugbundle --spec packed.hg
-  none-packed1;requirements%3Dgeneraldelta%2Crevlogv1%2Csparserevlog (no-rust 
!)
-  
none-packed1;requirements%3Dgeneraldelta%2Cpersistent-nodemap%2Crevlogv1%2Csparserevlog
 (rust !)
+  none-packed1;requirements%3Dgeneraldelta%2Crevlogv1%2Csparserevlog
+#endif
+
+#if reporevlogstore
 
 generaldelta requirement is not listed in stream clone bundles unless used
 
@@ -326,25 +350,66 @@
   $ touch foo
   $ hg -q commit -A -m initial
   $ cd ..
+
+#endif
+
+#if reporevlogstore rust
+
   $ hg -R testnongd debugcreatestreamclonebundle packednongd.hg
   writing 301 bytes for 3 files
-  bundle requirements: revlogv1 (no-rust !)
-  bundle requirements: persistent-nodemap, revlogv1 (rust !)
+  bundle requirements: persistent-nodemap, revlogv1
+
+  $ f -B 64 --size --sha1 --hexdump packednongd.hg
+  packednongd.hg: size=402, sha1=d3cc1417f0e8142cf9340520b660ad3ec3ea
+  : 48 47 53 31 55 4e 00 00 00 00 00 00 00 03 00 

D12073: test-http-bad-server: use the new pattern-reading for a test-case

2022-01-24 Thread marmoute (Pierre-Yves David)
marmoute created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  This test case is now less sensitive to change of unrelated bits of the
  client/server exchange.
  
  Since this introduce some churn in the output, we do it independently for each
  test cases. This patch is the last of such changes, for both sent and recv
  cases.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  tests/test-http-bad-server.t

CHANGE DETAILS

diff --git a/tests/test-http-bad-server.t b/tests/test-http-bad-server.t
--- a/tests/test-http-bad-server.t
+++ b/tests/test-http-bad-server.t
@@ -229,7 +229,11 @@
 Now do a variation using POST to send arguments
 ===
 
-  $ hg serve --config experimental.httppostargs=true --config 
badserver.close-after-recv-bytes=329,344 -p $HGPORT -d --pid-file=hg.pid -E 
error.log
+  $ hg serve \
+  > --config badserver.close-after-recv-patterns="x-hgargs-post:,user-agent: 
mercurial/proto-1.0" \
+  > --config badserver.close-after-recv-bytes="14,26" \
+  > --config experimental.httppostargs=true \
+  > -p $HGPORT -d --pid-file=hg.pid -E error.log
   $ cat hg.pid > $DAEMON_PIDS
 
   $ hg clone http://localhost:$HGPORT/ clone
@@ -239,12 +243,12 @@
   $ killdaemons.py $DAEMON_PIDS
 
   $ cat error.log | "$PYTHON" $TESTDIR/filtertraceback.py
-  readline(329 from ~) -> (33) GET /?cmd=capabilities HTTP/1.1\r\n
-  readline(296 from *) -> (27) Accept-Encoding: identity\r\n (glob)
-  readline(269 from *) -> (35) accept: application/mercurial-0.1\r\n (glob)
-  readline(234 from *) -> (2?) host: localhost:$HGPORT\r\n (glob)
-  readline(* from *) -> (49) user-agent: mercurial/proto-1.0 (Mercurial 
4.2)\r\n (glob)
-  readline(* from *) -> (2) \r\n (glob)
+  readline(~) -> (33) GET /?cmd=capabilities HTTP/1.1\r\n
+  readline(*) -> (27) Accept-Encoding: identity\r\n (glob)
+  readline(*) -> (35) accept: application/mercurial-0.1\r\n (glob)
+  readline(*) -> (2?) host: localhost:$HGPORT\r\n (glob)
+  readline(*) -> (49) user-agent: mercurial/proto-1.0 (Mercurial 4.2)\r\n 
(glob)
+  readline(*) -> (2) \r\n (glob)
   sendall(160) -> HTTP/1.1 200 Script output follows\r\nServer: 
badhttpserver\r\nDate: $HTTP_DATE$\r\nContent-Type: 
application/mercurial-0.1\r\nContent-Length: 444\r\n\r\n (py36 !)
   sendall(444) -> batch branchmap $USUAL_BUNDLE2_CAPS_NO_PHASES$ 
changegroupsubset compression=none getbundle httpheader=1024 
httpmediatype=0.1rx,0.1tx,0.2tx httppostargs known lookup pushkey 
streamreqs=generaldelta,revlogv1 unbundle=HG10GZ,HG10BZ,HG10UN unbundlehash 
(py36 !)
   write(160) -> HTTP/1.1 200 Script output follows\r\nServer: 
badhttpserver\r\nDate: $HTTP_DATE$\r\nContent-Type: 
application/mercurial-0.1\r\nContent-Length: 444\r\n\r\n (py3 no-py36 !)
@@ -256,25 +260,25 @@
   write(21) -> Content-Length: 444\r\n (no-py3 !)
   write(2) -> \r\n (no-py3 !)
   write(444) -> batch branchmap $USUAL_BUNDLE2_CAPS_NO_PHASES$ 
changegroupsubset compression=none getbundle httpheader=1024 
httpmediatype=0.1rx,0.1tx,0.2tx httppostargs known lookup pushkey 
streamreqs=generaldelta,revlogv1 unbundle=HG10GZ,HG10BZ,HG10UN unbundlehash 
(no-py3 !)
-  readline(1?? from ~) -> (27) POST /?cmd=batch HTTP/1.1\r\n (glob)
-  readline(1?? from *) -> (27) Accept-Encoding: identity\r\n (glob)
-  readline(1?? from *) -> (41) content-type: application/mercurial-0.1\r\n 
(glob)
-  readline(6? from *) -> (33) vary: X-HgArgs-Post,X-HgProto-1\r\n (glob)
-  readline(3? from *) -> (19) x-hgargs-post: 28\r\n (glob)
-  readline(1? from *) -> (1?) x-hgproto-1: * (glob)
+  readline(~) -> (27) POST /?cmd=batch HTTP/1.1\r\n (glob)
+  readline(*) -> (27) Accept-Encoding: identity\r\n (glob)
+  readline(*) -> (41) content-type: application/mercurial-0.1\r\n (glob)
+  readline(*) -> (33) vary: X-HgArgs-Post,X-HgProto-1\r\n (glob)
+  readline(*) -> (19) x-hgargs-post: 28\r\n (glob)
+  readline(*) -> (1?) x-hgproto-1: * (glob)
   read limit reached; closing socket
-  readline(344 from ~) -> (27) POST /?cmd=batch HTTP/1.1\r\n
-  readline(317 from *) -> (27) Accept-Encoding: identity\r\n (glob)
-  readline(290 from *) -> (41) content-type: application/mercurial-0.1\r\n 
(glob)
-  readline(249 from *) -> (33) vary: X-HgArgs-Post,X-HgProto-1\r\n (glob)
-  readline(216 from *) -> (19) x-hgargs-post: 28\r\n (glob)
-  readline(197 from *) -> (61) x-hgproto-1: 0.1 0.2 comp=$USUAL_COMPRESSIONS$ 
partial-pull\r\n (glob)
-  readline(136 from *) -> (35) accept: application/mercurial-0.1\r\n (glob)
-  readline(101 from *) -> (20) content-length: 28\r\n (glob)
-  readline(81 from *) -> (*) host: localhost:$HGPORT\r\n (glob)
-  readline(* from *) -> (49) user-agent: mercurial/proto-1.0 (Mercurial 
4.2)\r\n (glob)
-  readline(* from *) -> (2) \r\n (glob)
-  read(* from 28) -> (*) cmds=* (glob)
+  readline(~) -> (27) POST /?cmd=batch HTTP/1.1\r\n
+  readline(*) -> (27) Accept-Encoding: 

D12072: test-http-bad-server: use the new pattern-reading for a test-case

2022-01-24 Thread marmoute (Pierre-Yves David)
marmoute created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  This test case is now less sensitive to change of unrelated bits of the
  client/server exchange.
  
  Since this introduce some churn in the output, we do it independently for each
  test cases.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  tests/test-http-bad-server.t

CHANGE DETAILS

diff --git a/tests/test-http-bad-server.t b/tests/test-http-bad-server.t
--- a/tests/test-http-bad-server.t
+++ b/tests/test-http-bad-server.t
@@ -158,7 +158,10 @@
 Failure to read getbundle HTTP request
 --
 
-  $ hg serve --config badserver.close-after-recv-bytes=308,317,304 -p $HGPORT 
-d --pid-file=hg.pid -E error.log
+  $ hg serve \
+  > --config badserver.close-after-recv-patterns="GET /\?cmd=batch,user-agent: 
mercurial/proto-1.0,GET /\?cmd=getbundle" \
+  > --config badserver.close-after-recv-bytes=110,26,274 \
+  > -p $HGPORT -d --pid-file=hg.pid -E error.log
   $ cat hg.pid > $DAEMON_PIDS
   $ hg clone http://localhost:$HGPORT/ clone
   requesting all changes
@@ -170,12 +173,12 @@
   $ cat error.log
   readline(1 from -1) -> (1) x (?)
   readline(1 from -1) -> (1) x (?)
-  readline(308 from ~) -> (33) GET /?cmd=capabilities HTTP/1.1\r\n
-  readline(275 from *) -> (27) Accept-Encoding: identity\r\n (glob)
-  readline(248 from *) -> (35) accept: application/mercurial-0.1\r\n (glob)
-  readline(213 from *) -> (*) host: localhost:$HGPORT\r\n (glob)
-  readline(* from *) -> (49) user-agent: mercurial/proto-1.0 (Mercurial 
4.2)\r\n (glob)
-  readline(* from *) -> (2) \r\n (glob)
+  readline(~) -> (33) GET /?cmd=capabilities HTTP/1.1\r\n
+  readline(*) -> (27) Accept-Encoding: identity\r\n (glob)
+  readline(*) -> (35) accept: application/mercurial-0.1\r\n (glob)
+  readline(*) -> (*) host: localhost:$HGPORT\r\n (glob)
+  readline(*) -> (49) user-agent: mercurial/proto-1.0 (Mercurial 4.2)\r\n 
(glob)
+  readline(*) -> (2) \r\n (glob)
   sendall(160) -> HTTP/1.1 200 Script output follows\r\nServer: 
badhttpserver\r\nDate: $HTTP_DATE$\r\nContent-Type: 
application/mercurial-0.1\r\nContent-Length: 431\r\n\r\n (py36 !)
   sendall(431) -> batch branchmap $USUAL_BUNDLE2_CAPS_NO_PHASES$ 
changegroupsubset compression=none getbundle httpheader=1024 
httpmediatype=0.1rx,0.1tx,0.2tx known lookup pushkey 
streamreqs=generaldelta,revlogv1 unbundle=HG10GZ,HG10BZ,HG10UN unbundlehash 
(py36 !)
   write(160) -> HTTP/1.1 200 Script output follows\r\nServer: 
badhttpserver\r\nDate: $HTTP_DATE$\r\nContent-Type: 
application/mercurial-0.1\r\nContent-Length: 431\r\n\r\n (py3 no-py36 !)
@@ -187,21 +190,21 @@
   write(21) -> Content-Length: 431\r\n (no-py3 !)
   write(2) -> \r\n (no-py3 !)
   write(431) -> batch branchmap $USUAL_BUNDLE2_CAPS_NO_PHASES$ 
changegroupsubset compression=none getbundle httpheader=1024 
httpmediatype=0.1rx,0.1tx,0.2tx known lookup pushkey 
streamreqs=generaldelta,revlogv1 unbundle=HG10GZ,HG10BZ,HG10UN unbundlehash 
(no-py3 !)
-  readline(13? from ~) -> (26) GET /?cmd=batch HTTP/1.1\r\n (glob)
-  readline(1?? from *) -> (27) Accept-Encoding: identity\r\n (glob)
-  readline(8? from *) -> (29) vary: X-HgArg-1,X-HgProto-1\r\n (glob)
-  readline(5? from *) -> (41) x-hgarg-1: cmds=heads+%3Bknown+nodes%3D\r\n 
(glob)
-  readline(1? from *) -> (1?) x-hgproto-1:* (glob)
+  readline(~) -> (26) GET /?cmd=batch HTTP/1.1\r\n (glob)
+  readline(*) -> (27) Accept-Encoding: identity\r\n (glob)
+  readline(*) -> (29) vary: X-HgArg-1,X-HgProto-1\r\n (glob)
+  readline(*) -> (41) x-hgarg-1: cmds=heads+%3Bknown+nodes%3D\r\n (glob)
+  readline(*) -> (1?) x-hgproto-1:* (glob)
   read limit reached; closing socket
-  readline(317 from ~) -> (26) GET /?cmd=batch HTTP/1.1\r\n
-  readline(291 from *) -> (27) Accept-Encoding: identity\r\n (glob)
-  readline(264 from *) -> (29) vary: X-HgArg-1,X-HgProto-1\r\n (glob)
-  readline(235 from *) -> (41) x-hgarg-1: cmds=heads+%3Bknown+nodes%3D\r\n 
(glob)
-  readline(194 from *) -> (61) x-hgproto-1: 0.1 0.2 comp=$USUAL_COMPRESSIONS$ 
partial-pull\r\n (glob)
-  readline(133 from *) -> (35) accept: application/mercurial-0.1\r\n (glob)
-  readline(98 from *) -> (*) host: localhost:$HGPORT\r\n (glob)
-  readline(* from *) -> (49) user-agent: mercurial/proto-1.0 (Mercurial 
4.2)\r\n (glob)
-  readline(* from *) -> (2) \r\n (glob)
+  readline(~) -> (26) GET /?cmd=batch HTTP/1.1\r\n
+  readline(*) -> (27) Accept-Encoding: identity\r\n (glob)
+  readline(*) -> (29) vary: X-HgArg-1,X-HgProto-1\r\n (glob)
+  readline(*) -> (41) x-hgarg-1: cmds=heads+%3Bknown+nodes%3D\r\n (glob)
+  readline(*) -> (61) x-hgproto-1: 0.1 0.2 comp=$USUAL_COMPRESSIONS$ 
partial-pull\r\n (glob)
+  readline(*) -> (35) accept: application/mercurial-0.1\r\n (glob)
+  readline(*) -> (*) host: localhost:$HGPORT\r\n (glob)
+  readline(*) -> (49) user-agent: mercurial/proto-1.0 (Mercurial 

D12071: test-http-bad-server: use the new pattern-reading for a test-case

2022-01-24 Thread marmoute (Pierre-Yves David)
marmoute created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  This test case is now less sensitive to change of unrelated bits of the
  client/server exchange.
  
  Since this introduce some churn in the output, we do it independently for each
  test cases.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  tests/test-http-bad-server.t

CHANGE DETAILS

diff --git a/tests/test-http-bad-server.t b/tests/test-http-bad-server.t
--- a/tests/test-http-bad-server.t
+++ b/tests/test-http-bad-server.t
@@ -113,8 +113,8 @@
 -
 
   $ hg serve \
-  > --config badserver.close-after-recv-patterns="GET /\?cmd=batch," \
-  > --config badserver.close-after-recv-bytes=15,223 \
+  > --config badserver.close-after-recv-patterns="GET /\?cmd=batch,GET 
/\?cmd=batch" \
+  > --config badserver.close-after-recv-bytes=15,197 \
   > -p $HGPORT -d --pid-file=hg.pid -E error.log
   $ cat hg.pid > $DAEMON_PIDS
   $ hg clone http://localhost:$HGPORT/ clone
@@ -144,12 +144,12 @@
   readline(~) -> (26) GET /?cmd=batch HTTP/1.1\r\n (glob)
   readline(*) -> (1?) Accept-Encoding* (glob)
   read limit reached; closing socket
-  readline(223 from ~) -> (26) GET /?cmd=batch HTTP/1.1\r\n
-  readline(197 from *) -> (27) Accept-Encoding: identity\r\n (glob)
-  readline(170 from *) -> (29) vary: X-HgArg-1,X-HgProto-1\r\n (glob)
-  readline(141 from *) -> (41) x-hgarg-1: cmds=heads+%3Bknown+nodes%3D\r\n 
(glob)
-  readline(100 from *) -> (61) x-hgproto-1: 0.1 0.2 comp=$USUAL_COMPRESSIONS$ 
partial-pull\r\n (glob)
-  readline(39 from *) -> (35) accept: application/mercurial-0.1\r\n (glob)
+  readline(~) -> (26) GET /?cmd=batch HTTP/1.1\r\n
+  readline(*) -> (27) Accept-Encoding: identity\r\n (glob)
+  readline(*) -> (29) vary: X-HgArg-1,X-HgProto-1\r\n (glob)
+  readline(*) -> (41) x-hgarg-1: cmds=heads+%3Bknown+nodes%3D\r\n (glob)
+  readline(*) -> (61) x-hgproto-1: 0.1 0.2 comp=$USUAL_COMPRESSIONS$ 
partial-pull\r\n (glob)
+  readline(*) -> (35) accept: application/mercurial-0.1\r\n (glob)
   readline(4 from *) -> (4) host (glob)
   read limit reached; closing socket
 



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


  1   2   3   4   5   6   7   8   9   10   >