D10740: revlog: avoid raising no-arg RevlogError for internal flow control

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

REVISION SUMMARY
  I'm about to make RevlogError require a `message` argument and this
  code was failing. This patch refactors it to not raise an exception
  for intra-function flow control.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  mercurial/revlog.py

CHANGE DETAILS

diff --git a/mercurial/revlog.py b/mercurial/revlog.py
--- a/mercurial/revlog.py
+++ b/mercurial/revlog.py
@@ -1538,28 +1538,33 @@
 def _partialmatch(self, id):
 # we don't care wdirfilenodeids as they should be always full hash
 maybewdir = self.nodeconstants.wdirhex.startswith(id)
+ambiguous = False
 try:
 partial = self.index.partialmatch(id)
 if partial and self.hasnode(partial):
 if maybewdir:
 # single 'ff...' match in radix tree, ambiguous with wdir
-raise error.RevlogError
-return partial
-if maybewdir:
+ambiguous = True
+else:
+return partial
+elif maybewdir:
 # no 'ff...' match in radix tree, wdir identified
 raise error.WdirUnsupported
-return None
+else:
+return None
 except error.RevlogError:
 # parsers.c radix tree lookup gave multiple matches
 # fast path: for unfiltered changelog, radix tree is accurate
 if not getattr(self, 'filteredrevs', None):
-raise error.AmbiguousPrefixLookupError(
-id, self.display_id, _(b'ambiguous identifier')
-)
+ambiguous = True
 # fall through to slow path that filters hidden revisions
 except (AttributeError, ValueError):
 # we are pure python, or key was too short to search radix tree
 pass
+if ambiguous:
+raise error.AmbiguousPrefixLookupError(
+id, self.display_id, _(b'ambiguous identifier')
+)
 
 if id in self._pcache:
 return self._pcache[id]



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


D10741: errors: make StorageError subclass Error, attaching an exit code to it

2021-05-18 Thread martinvonz (Martin von Zweigbergk)
martinvonz 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/D10741

AFFECTED FILES
  mercurial/error.py
  mercurial/scmutil.py

CHANGE DETAILS

diff --git a/mercurial/scmutil.py b/mercurial/scmutil.py
--- a/mercurial/scmutil.py
+++ b/mercurial/scmutil.py
@@ -198,11 +198,6 @@
 ui.error(b"\n%r\n" % pycompat.bytestr(stringutil.ellipsis(msg)))
 except error.CensoredNodeError as inst:
 ui.error(_(b"abort: file censored %s\n") % inst)
-except error.StorageError as inst:
-ui.error(_(b"abort: %s\n") % inst)
-if inst.hint:
-ui.error(_(b"(%s)\n") % inst.hint)
-detailed_exit_code = 50
 except error.WdirUnsupported:
 ui.error(_(b"abort: working directory revision cannot be specified\n"))
 except error.Error as inst:
diff --git a/mercurial/error.py b/mercurial/error.py
--- a/mercurial/error.py
+++ b/mercurial/error.py
@@ -91,13 +91,16 @@
 """Raised if a command needs to print an error and exit."""
 
 
-class StorageError(Hint, Exception):
+class StorageError(Error):
 """Raised when an error occurs in a storage layer.
 
 Usually subclassed by a storage-specific exception.
 """
 
-__bytes__ = _tobytes
+def __init__(self, message, hint=None):
+super(StorageError, self).__init__(
+message, hint=hint, detailed_exit_code=50
+)
 
 
 class RevlogError(StorageError):



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


D10739: errors: catch the new Error class in scmutil and chgserver

2021-05-18 Thread martinvonz (Martin von Zweigbergk)
martinvonz 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/D10739

AFFECTED FILES
  mercurial/chgserver.py
  mercurial/scmutil.py

CHANGE DETAILS

diff --git a/mercurial/scmutil.py b/mercurial/scmutil.py
--- a/mercurial/scmutil.py
+++ b/mercurial/scmutil.py
@@ -205,7 +205,7 @@
 detailed_exit_code = 50
 except error.WdirUnsupported:
 ui.error(_(b"abort: working directory revision cannot be specified\n"))
-except error.Abort as inst:
+except error.Error as inst:
 if inst.detailed_exit_code is not None:
 detailed_exit_code = inst.detailed_exit_code
 if inst.coarse_exit_code is not None:
diff --git a/mercurial/chgserver.py b/mercurial/chgserver.py
--- a/mercurial/chgserver.py
+++ b/mercurial/chgserver.py
@@ -515,7 +515,7 @@
 if inst.hint:
 self.ui.error(_(b"(%s)\n") % inst.hint)
 errorraised = True
-except error.Abort as inst:
+except error.Error as inst:
 if inst.detailed_exit_code is not None:
 detailed_exit_code = inst.detailed_exit_code
 self.ui.error(inst.format())



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


D10737: errors: make InterventionRequired subclass Abort

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

REVISION SUMMARY
  The docstring for `Abort` says that it's for errors raised by commands
  and `InterventionRequired` is definitely something raised by commands,
  so it seems that it should be an `Abort`. This patch makes it so. It
  adds a `coarse_exit_code` (in addition to the already existing
  `detailed_exit_code`) to `Abort` to achieve that, since
  `InterventionRequired` should result in a special exit code even when
  the `ui.detailed-exit-code` config is not set.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  mercurial/error.py
  mercurial/scmutil.py

CHANGE DETAILS

diff --git a/mercurial/scmutil.py b/mercurial/scmutil.py
--- a/mercurial/scmutil.py
+++ b/mercurial/scmutil.py
@@ -203,17 +203,13 @@
 if inst.hint:
 ui.error(_(b"(%s)\n") % inst.hint)
 detailed_exit_code = 50
-except error.InterventionRequired as inst:
-ui.error(b"%s\n" % inst)
-if inst.hint:
-ui.error(_(b"(%s)\n") % inst.hint)
-detailed_exit_code = 240
-coarse_exit_code = 1
 except error.WdirUnsupported:
 ui.error(_(b"abort: working directory revision cannot be specified\n"))
 except error.Abort as inst:
 if inst.detailed_exit_code is not None:
 detailed_exit_code = inst.detailed_exit_code
+if inst.coarse_exit_code is not None:
+coarse_exit_code = inst.coarse_exit_code
 ui.error(inst.format())
 except error.WorkerError as inst:
 # Don't print a message -- the worker already should have
diff --git a/mercurial/error.py b/mercurial/error.py
--- a/mercurial/error.py
+++ b/mercurial/error.py
@@ -54,10 +54,13 @@
 class Abort(Hint, Exception):
 """Raised if a command needs to print an error and exit."""
 
-def __init__(self, message, hint=None, detailed_exit_code=None):
+def __init__(
+self, message, hint=None, coarse_exit_code=None, 
detailed_exit_code=None
+):
 # type: (bytes, Optional[bytes]) -> None
 self.message = message
 self.hint = hint
+self.coarse_exit_code = coarse_exit_code
 self.detailed_exit_code = detailed_exit_code
 # Pass the message into the Exception constructor to help extensions
 # that look for exc.args[0].
@@ -192,10 +195,22 @@
 __bytes__ = _tobytes
 
 
-class InterventionRequired(Hint, Exception):
+class InterventionRequired(Abort):
 """Exception raised when a command requires human intervention."""
 
-__bytes__ = _tobytes
+def __init__(self, message, hint=None):
+super(InterventionRequired, self).__init__(
+message, hint=hint, coarse_exit_code=1, detailed_exit_code=240
+)
+
+def format(self):
+# type: () -> bytes
+from .i18n import _
+
+message = _(b"%s\n") % self.message
+if self.hint:
+message += _(b"(%s)\n") % self.hint
+return message
 
 
 class ConflictResolutionRequired(InterventionRequired):



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


D10738: errors: create superclass for Abort exception

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

REVISION SUMMARY
  I'd like to let extensions subclass `StorageError` to define a custom
  exit code. However, `StorageError` does not extend `Abort` (which is
  where the exit code currently lives), and it seems that it's not
  supposed to either (`StorageError` seems to be for lower-level errors
  and `Abort` is for command-level errors). This patch therefore
  extracts all the code from `Abort` into a new `Error` class, which
  I'll soon make `StorageError` also extend.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  mercurial/error.py

CHANGE DETAILS

diff --git a/mercurial/error.py b/mercurial/error.py
--- a/mercurial/error.py
+++ b/mercurial/error.py
@@ -51,8 +51,8 @@
 super(Hint, self).__init__(*args, **kw)
 
 
-class Abort(Hint, Exception):
-"""Raised if a command needs to print an error and exit."""
+class Error(Hint, Exception):
+"""Base class for Mercurial errors."""
 
 def __init__(
 self, message, hint=None, coarse_exit_code=None, 
detailed_exit_code=None
@@ -87,6 +87,10 @@
 return message
 
 
+class Abort(Error):
+"""Raised if a command needs to print an error and exit."""
+
+
 class StorageError(Hint, Exception):
 """Raised when an error occurs in a storage layer.
 



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


D10736: errors: move Abort earlier, so more exceptions can subclass it

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

REVISION SUMMARY
  I'd like to make at least `InterventionRequired` subclass `Abort` and
  Python requires the superclass to be defined before the subtype.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  mercurial/error.py

CHANGE DETAILS

diff --git a/mercurial/error.py b/mercurial/error.py
--- a/mercurial/error.py
+++ b/mercurial/error.py
@@ -51,6 +51,39 @@
 super(Hint, self).__init__(*args, **kw)
 
 
+class Abort(Hint, Exception):
+"""Raised if a command needs to print an error and exit."""
+
+def __init__(self, message, hint=None, detailed_exit_code=None):
+# type: (bytes, Optional[bytes]) -> None
+self.message = message
+self.hint = hint
+self.detailed_exit_code = detailed_exit_code
+# Pass the message into the Exception constructor to help extensions
+# that look for exc.args[0].
+Exception.__init__(self, message)
+
+def __bytes__(self):
+return self.message
+
+if pycompat.ispy3:
+
+def __str__(self):
+# the output would be unreadable if the message was translated,
+# but do not replace it with encoding.strfromlocal(), which
+# may raise another exception.
+return pycompat.sysstr(self.__bytes__())
+
+def format(self):
+# type: () -> bytes
+from .i18n import _
+
+message = _(b"abort: %s\n") % self.message
+if self.hint:
+message += _(b"(%s)\n") % self.hint
+return message
+
+
 class StorageError(Hint, Exception):
 """Raised when an error occurs in a storage layer.
 
@@ -182,39 +215,6 @@
 )
 
 
-class Abort(Hint, Exception):
-"""Raised if a command needs to print an error and exit."""
-
-def __init__(self, message, hint=None, detailed_exit_code=None):
-# type: (bytes, Optional[bytes]) -> None
-self.message = message
-self.hint = hint
-self.detailed_exit_code = detailed_exit_code
-# Pass the message into the Exception constructor to help extensions
-# that look for exc.args[0].
-Exception.__init__(self, message)
-
-def __bytes__(self):
-return self.message
-
-if pycompat.ispy3:
-
-def __str__(self):
-# the output would be unreadable if the message was translated,
-# but do not replace it with encoding.strfromlocal(), which
-# may raise another exception.
-return pycompat.sysstr(self.__bytes__())
-
-def format(self):
-# type: () -> bytes
-from .i18n import _
-
-message = _(b"abort: %s\n") % self.message
-if self.hint:
-message += _(b"(%s)\n") % self.hint
-return message
-
-
 class InputError(Abort):
 """Indicates that the user made an error in their input.
 



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


D10735: errors: let each Abort subclass define its error code

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

REVISION SUMMARY
  It's more flexible to have the error codes defined on the error types
  themselves. That way extensions can easily set their own exit code. It
  also means that we can reduce a bit of duplication betwen
  `scmutil.callcatch()` and `chgserver.chgcmdserver.validate()`.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  mercurial/chgserver.py
  mercurial/error.py
  mercurial/scmutil.py

CHANGE DETAILS

diff --git a/mercurial/scmutil.py b/mercurial/scmutil.py
--- a/mercurial/scmutil.py
+++ b/mercurial/scmutil.py
@@ -212,20 +212,8 @@
 except error.WdirUnsupported:
 ui.error(_(b"abort: working directory revision cannot be specified\n"))
 except error.Abort as inst:
-if isinstance(inst, (error.InputError, error.ParseError)):
-detailed_exit_code = 10
-elif isinstance(inst, error.StateError):
-detailed_exit_code = 20
-elif isinstance(inst, error.ConfigError):
-detailed_exit_code = 30
-elif isinstance(inst, error.HookAbort):
-detailed_exit_code = 40
-elif isinstance(inst, error.RemoteError):
-detailed_exit_code = 100
-elif isinstance(inst, error.SecurityError):
-detailed_exit_code = 150
-elif isinstance(inst, error.CanceledError):
-detailed_exit_code = 250
+if inst.detailed_exit_code is not None:
+detailed_exit_code = inst.detailed_exit_code
 ui.error(inst.format())
 except error.WorkerError as inst:
 # Don't print a message -- the worker already should have
diff --git a/mercurial/error.py b/mercurial/error.py
--- a/mercurial/error.py
+++ b/mercurial/error.py
@@ -185,10 +185,11 @@
 class Abort(Hint, Exception):
 """Raised if a command needs to print an error and exit."""
 
-def __init__(self, message, hint=None):
+def __init__(self, message, hint=None, detailed_exit_code=None):
 # type: (bytes, Optional[bytes]) -> None
 self.message = message
 self.hint = hint
+self.detailed_exit_code = detailed_exit_code
 # Pass the message into the Exception constructor to help extensions
 # that look for exc.args[0].
 Exception.__init__(self, message)
@@ -220,6 +221,11 @@
 Examples: Invalid command, invalid flags, invalid revision.
 """
 
+def __init__(self, message, hint=None):
+super(InputError, self).__init__(
+message, hint=hint, detailed_exit_code=10
+)
+
 
 class StateError(Abort):
 """Indicates that the operation might work if retried in a different state.
@@ -227,6 +233,11 @@
 Examples: Unresolved merge conflicts, unfinished operations.
 """
 
+def __init__(self, message, hint=None):
+super(StateError, self).__init__(
+message, hint=hint, detailed_exit_code=20
+)
+
 
 class CanceledError(Abort):
 """Indicates that the user canceled the operation.
@@ -234,6 +245,11 @@
 Examples: Close commit editor with error status, quit chistedit.
 """
 
+def __init__(self, message, hint=None):
+super(CanceledError, self).__init__(
+message, hint=hint, detailed_exit_code=250
+)
+
 
 class SecurityError(Abort):
 """Indicates that some aspect of security failed.
@@ -242,6 +258,11 @@
 filesystem, mismatched GPG signature, DoS protection.
 """
 
+def __init__(self, message, hint=None):
+super(SecurityError, self).__init__(
+message, hint=hint, detailed_exit_code=150
+)
+
 
 class HookLoadError(Abort):
 """raised when loading a hook fails, aborting an operation
@@ -254,13 +275,20 @@
 
 Exists to allow more specialized catching."""
 
+def __init__(self, message, hint=None):
+super(HookAbort, self).__init__(
+message, hint=hint, detailed_exit_code=40
+)
+
 
 class ConfigError(Abort):
 """Exception raised when parsing config files"""
 
 def __init__(self, message, location=None, hint=None):
 # type: (bytes, Optional[bytes], Optional[bytes]) -> None
-super(ConfigError, self).__init__(message, hint=hint)
+super(ConfigError, self).__init__(
+message, hint=hint, detailed_exit_code=30
+)
 self.location = location
 
 def format(self):
@@ -307,6 +335,11 @@
 class RemoteError(Abort):
 """Exception raised when interacting with a remote repo fails"""
 
+def __init__(self, message, hint=None):
+super(RemoteError, self).__init__(
+message, hint=hint, detailed_exit_code=100
+)
+
 
 class OutOfBandError(RemoteError):
 """Exception raised when a remote repo reports failure"""
@@ -327,7 +360,9 @@
 
 def __init__(self, message, location=None, hint=None):
 # type: (bytes, 

Failed pipeline for branch/default | mercurial-devel | 32a92b4a

2021-05-18 Thread Heptapod


Pipeline #22116 has failed!

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

Commit: 32a92b4a ( 
https://foss.heptapod.net/octobus/mercurial-devel/-/commit/32a92b4a933893e3e6fabf2de5c8ae6fd4a48555
 )
Commit Message: sparse: make sure excluded subrepos don't break...
Commit Author: alexrayne ( https://foss.heptapod.net/alexrayne )

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

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

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

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

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

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

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

Stage: tests
Name: checks-py3

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



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


D10734: Enable widen when files are excluded by sparse and not included by narrow

2021-05-18 Thread charlesetc (Charles Chamberlain)
charlesetc created this revision.
Herald added a reviewer: durin42.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  In a repo where some directories are included by narrow and the complement are
  excluded by sparse, it was previously impossible to widen either because 
trying
  to widen narrow would complain that the requested files are outside the sparse
  checkout and trying to widen sparse would complain that the requested files 
are
  outside the narrow checkout.
  
  This changes the `hg tracked --addinclude` command to only actually update any
  newly accessible files in the dirstate if they are also accessible via sparse.

REPOSITORY
  rHG Mercurial

BRANCH
  stable

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

AFFECTED FILES
  mercurial/narrowspec.py
  tests/test-narrow-sparse.t

CHANGE DETAILS

diff --git a/tests/test-narrow-sparse.t b/tests/test-narrow-sparse.t
--- a/tests/test-narrow-sparse.t
+++ b/tests/test-narrow-sparse.t
@@ -67,3 +67,36 @@
   treemanifest (tree !)
 
   $ hg debugrebuilddirstate
+
+We only make the following assertions for the flat test case since the
+treemanifest test case fails with "path ends in directory separator: outside/"
+which seems like a bug unrelated to the regression this is testing for.
+
+#if flat
+widening with both sparse and narrow is possible
+
+  $ cat >> .hg/hgrc < [extensions]
+  > sparse = 
+  > narrow = 
+  > EOF
+
+  $ hg debugsparse -X outside/f -X widest/f
+  $ hg tracked -q --addinclude outside/f
+  $ tree
+  .
+  `-- inside
+  `-- f
+  
+  1 directory, 1 file
+
+  $ hg debugsparse -d outside/f
+  $ tree
+  .
+  |-- inside
+  |   `-- f
+  `-- outside
+  `-- f
+  
+  2 directories, 2 files
+#endif
diff --git a/mercurial/narrowspec.py b/mercurial/narrowspec.py
--- a/mercurial/narrowspec.py
+++ b/mercurial/narrowspec.py
@@ -347,6 +347,9 @@
 ds.drop(f)
 
 pctx = repo[b'.']
+
+# only update added files that are in the sparse checkout
+addedmatch = matchmod.intersectmatchers(addedmatch, sparse.matcher(repo))
 newfiles = [f for f in pctx.manifest().walk(addedmatch) if f not in ds]
 for f in newfiles:
 ds.normallookup(f)



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


D10733: hghave: make error output easier to diagnose

2021-05-18 Thread durin42 (Augie Fackler)
durin42 created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  I had a typo that meant the new bash check was throwing an exception
  (due to a missing argument), but it was very hard to diagnose without
  this change.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  tests/hghave.py

CHANGE DETAILS

diff --git a/tests/hghave.py b/tests/hghave.py
--- a/tests/hghave.py
+++ b/tests/hghave.py
@@ -104,8 +104,8 @@
 check, desc = checks[feature]
 try:
 available = check()
-except Exception:
-result['error'].append('hghave check failed: %s' % feature)
+except Exception as e:
+result['error'].append('hghave check %s failed: %r' % (feature, e))
 continue
 
 if not negate and not available:



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


D10732: tests: add req on bash for test-transaction-rollback-on-sigpipe (issue6429)

2021-05-18 Thread durin42 (Augie Fackler)
durin42 created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  I think we could work around this by rewriting the helper scripts in
  Python, but I don't want to deal with that now and this should prevent
  failures due to a lack of bash.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  tests/hghave.py
  tests/test-transaction-rollback-on-sigpipe.t

CHANGE DETAILS

diff --git a/tests/test-transaction-rollback-on-sigpipe.t 
b/tests/test-transaction-rollback-on-sigpipe.t
--- a/tests/test-transaction-rollback-on-sigpipe.t
+++ b/tests/test-transaction-rollback-on-sigpipe.t
@@ -1,3 +1,4 @@
+#require bash
 Test that, when an hg push is interrupted and the remote side recieves SIGPIPE,
 the remote hg is able to successfully roll back the transaction.
 
diff --git a/tests/hghave.py b/tests/hghave.py
--- a/tests/hghave.py
+++ b/tests/hghave.py
@@ -1121,3 +1121,8 @@
 return True
 except ImportError:
 return False
+
+
+@check("bash", "bash shell")
+def has_bash():
+return matchoutput("bash -c 'echo hi'", b'^hi$')



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


D10731: updatecaches: deprecate the `full` argument

2021-05-18 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 all users were migrated, we can use deprecate the old way. This would
  give potential extensions code a heads up on the API change.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  mercurial/localrepo.py

CHANGE DETAILS

diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py
--- a/mercurial/localrepo.py
+++ b/mercurial/localrepo.py
@@ -2740,13 +2740,18 @@
 
 unfi = self.unfiltered()
 
-if caches is None:
-if full:
-caches = repository.CACHES_ALL
-if full == b"post-clone":
-caches = repository.CACHES_POST_CLONE
-else:
-caches = repository.CACHES_DEFAULT
+if full:
+msg = (
+"`full` argument for `repo.updatecaches` is deprecated\n"
+"(use `caches=repository.CACHE_ALL` instead)"
+)
+self.ui.deprecwarn(msg, "5.9")
+caches = repository.CACHES_ALL
+if full == b"post-clone":
+caches = repository.CACHES_POST_CLONE
+caches = repository.CACHES_ALL
+elif caches is None:
+caches = repository.CACHES_DEFAULT
 
 if repository.CACHE_BRANCHMAP_SERVED in caches:
 if tr is None or tr.changes[b'origrepolen'] < len(self):



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


D10730: updatecaches: use the `caches` argument instead of a special `full` value

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

REVISION SUMMARY
  After a clone we want to update most cachem, but not exactly all of them. We
  can now cleanly express this.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  mercurial/hg.py
  mercurial/interfaces/repository.py
  mercurial/localrepo.py

CHANGE DETAILS

diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py
--- a/mercurial/localrepo.py
+++ b/mercurial/localrepo.py
@@ -2744,8 +2744,7 @@
 if full:
 caches = repository.CACHES_ALL
 if full == b"post-clone":
-caches = caches.copy()
-caches.discard(repository.CACHE_FILE_NODE_TAGS)
+caches = repository.CACHES_POST_CLONE
 else:
 caches = repository.CACHES_DEFAULT
 
diff --git a/mercurial/interfaces/repository.py 
b/mercurial/interfaces/repository.py
--- a/mercurial/interfaces/repository.py
+++ b/mercurial/interfaces/repository.py
@@ -87,6 +87,11 @@
 CACHE_TAGS_SERVED,
 }
 
+# the cache to warm by default on simple call
+# (this is a mutable set to let extension update it)
+CACHES_POST_CLONE = CACHES_ALL.copy()
+CACHES_POST_CLONE.discard(CACHE_FILE_NODE_TAGS)
+
 
 class ipeerconnection(interfaceutil.Interface):
 """Represents a "connection" to a repository.
diff --git a/mercurial/hg.py b/mercurial/hg.py
--- a/mercurial/hg.py
+++ b/mercurial/hg.py
@@ -52,6 +52,7 @@
 verify as verifymod,
 vfs as vfsmod,
 )
+from .interfaces import repository as repositorymod
 from .utils import (
 hashutil,
 stringutil,
@@ -1054,7 +1055,7 @@
 # as the only "bad" outcome would be some slowness. That potential
 # slowness already affect reader.
 with destrepo.lock():
-destrepo.updatecaches(full=b"post-clone")
+destrepo.updatecaches(caches=repositorymod.CACHES_POST_CLONE)
 finally:
 release(srclock, destlock)
 if cleandir is not None:



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


D10729: updatecaches: use the caches argument in `hg debugupdatecaches`

2021-05-18 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 new way.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

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
@@ -91,6 +91,7 @@
 wireprotoserver,
 wireprotov2peer,
 )
+from .interfaces import repository
 from .utils import (
 cborutil,
 compression,
@@ -4047,7 +4048,7 @@
 def debugupdatecaches(ui, repo, *pats, **opts):
 """warm all known caches in the repository"""
 with repo.wlock(), repo.lock():
-repo.updatecaches(full=True)
+repo.updatecaches(caches=repository.CACHES_ALL)
 
 
 @command(



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


D10727: updatecaches: introduce a set of constants to control which are updated

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

REVISION SUMMARY
  Passing around a set of constant to select what need warming will be cleaner
  and more flexible. We did not changed the API yet, as this changes is already
  large enough. In the rest of the rest we will change more code to actually use
  this constants (or more realistically pre-defined set of constant directly)

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  mercurial/interfaces/repository.py
  mercurial/localrepo.py

CHANGE DETAILS

diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py
--- a/mercurial/localrepo.py
+++ b/mercurial/localrepo.py
@@ -2738,40 +2738,56 @@
 # later call to `destroyed` will refresh them.
 return
 
-if tr is None or tr.changes[b'origrepolen'] < len(self):
-# accessing the 'served' branchmap should refresh all the others,
-self.ui.debug(b'updating the branch cache\n')
-self.filtered(b'served').branchmap()
-self.filtered(b'served.hidden').branchmap()
+unfi = self.unfiltered()
 
 if full:
-unfi = self.unfiltered()
-
+caches = repository.CACHES_ALL
+if full == b"post-clone":
+caches = caches.copy()
+caches.discard(repository.CACHE_FILE_NODE_TAGS)
+else:
+caches = repository.CACHES_DEFAULT
+
+if repository.CACHE_BRANCHMAP_SERVED in caches:
+if tr is None or tr.changes[b'origrepolen'] < len(self):
+# accessing the 'served' branchmap should refresh all the 
others,
+self.ui.debug(b'updating the branch cache\n')
+self.filtered(b'served').branchmap()
+self.filtered(b'served.hidden').branchmap()
+
+if repository.CACHE_CHANGELOG_CACHE in caches:
 self.changelog.update_caches(transaction=tr)
+
+if repository.CACHE_MANIFESTLOG_CACHE in caches:
 self.manifestlog.update_caches(transaction=tr)
 
+if repository.CACHE_REV_BRANCH in caches:
 rbc = unfi.revbranchcache()
 for r in unfi.changelog:
 rbc.branchinfo(r)
 rbc.write()
 
+if repository.CACHE_FULL_MANIFEST in caches:
 # ensure the working copy parents are in the manifestfulltextcache
 for ctx in self[b'.'].parents():
 ctx.manifest()  # accessing the manifest is enough
 
-if not full == b"post-clone":
-# accessing fnode cache warms the cache
-tagsmod.fnoderevs(self.ui, unfi, unfi.changelog.revs())
+if repository.CACHE_FILE_NODE_TAGS in caches:
+# accessing fnode cache warms the cache
+tagsmod.fnoderevs(self.ui, unfi, unfi.changelog.revs())
+
+if repository.CACHE_TAGS_DEFAULT in caches:
 # accessing tags warm the cache
 self.tags()
+if repository.CACHE_TAGS_SERVED in caches:
 self.filtered(b'served').tags()
 
-# The `full` arg is documented as updating even the lazily-loaded
-# caches immediately, so we're forcing a write to cause these 
caches
-# to be warmed up even if they haven't explicitly been requested
-# yet (if they've never been used by hg, they won't ever have been
-# written, even if they're a subset of another kind of cache that
-# *has* been used).
+if repository.CACHE_BRANCHMAP_ALL in caches:
+# The CACHE_BRANCHMAP_ALL updates lazily-loaded caches immediately,
+# so we're forcing a write to cause these caches to be warmed up
+# even if they haven't explicitly been requested yet (if they've
+# never been used by hg, they won't ever have been written, even if
+# they're a subset of another kind of cache that *has* been used).
 for filt in repoview.filtertable.keys():
 filtered = self.filtered(filt)
 filtered.branchmap().write(filtered)
diff --git a/mercurial/interfaces/repository.py 
b/mercurial/interfaces/repository.py
--- a/mercurial/interfaces/repository.py
+++ b/mercurial/interfaces/repository.py
@@ -1,4 +1,5 @@
 # repository.py - Interfaces and base classes for repositories and peers.
+# coding: utf-8
 #
 # Copyright 2017 Gregory Szorc 
 #
@@ -44,6 +45,49 @@
 CG_DELTAMODE_P1 = b'p1'
 
 
+## Cache related constants:
+#
+# Used to control which cache should be warmed in a repo.updatecaches(…) call.
+
+# Warm branchmaps of all known repoview's filter-level
+CACHE_BRANCHMAP_ALL = b"branchmap-all"
+# Warm branchmaps of repoview's filter-level used by server
+CACHE_BRANCHMAP_SERVED = b"branchmap-served"
+# Warm internal changelog cache (eg: persistent nodemap)
+CACHE_CHANGELOG_CACHE = b"changelog-cache"

D10728: updatecaches: adds a `caches` parameters to `repo.updatecaches`

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

REVISION SUMMARY
  It will superseed the `full` parameters (and its `post-clone` variant from
  stable). Various caller will be updated in the rest of this series.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  mercurial/localrepo.py

CHANGE DETAILS

diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py
--- a/mercurial/localrepo.py
+++ b/mercurial/localrepo.py
@@ -2718,7 +2718,7 @@
 return updater
 
 @unfilteredmethod
-def updatecaches(self, tr=None, full=False):
+def updatecaches(self, tr=None, full=False, caches=None):
 """warm appropriate caches
 
 If this function is called after a transaction closed. The transaction
@@ -2740,13 +2740,14 @@
 
 unfi = self.unfiltered()
 
-if full:
-caches = repository.CACHES_ALL
-if full == b"post-clone":
-caches = caches.copy()
-caches.discard(repository.CACHE_FILE_NODE_TAGS)
-else:
-caches = repository.CACHES_DEFAULT
+if caches is None:
+if full:
+caches = repository.CACHES_ALL
+if full == b"post-clone":
+caches = caches.copy()
+caches.discard(repository.CACHE_FILE_NODE_TAGS)
+else:
+caches = repository.CACHES_DEFAULT
 
 if repository.CACHE_BRANCHMAP_SERVED in caches:
 if tr is None or tr.changes[b'origrepolen'] < len(self):



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