D10103: relnotes: document a number of node->revision type changes

2021-03-03 Thread joerg.sonnenberger (Joerg Sonnenberger)
joerg.sonnenberger 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/D10103

AFFECTED FILES
  relnotes/next

CHANGE DETAILS

diff --git a/relnotes/next b/relnotes/next
--- a/relnotes/next
+++ b/relnotes/next
@@ -26,3 +26,8 @@
 
  * `changelog.branchinfo` is deprecated and will be removed after 5.8.
It is superseded by `changelogrevision.branchinfo`.
+
+ * Callbacks for revlog.addgroup and the changelog._nodeduplicatecallback hook
+   now get a revision number as argument instead of a node.
+
+ * revlog.addrevision returns the revision number instead of the node.



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


D10102: rhg: Fall back to Python for bundle repositories

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

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

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

CHANGE DETAILS

diff --git a/rust/hg-core/src/repo.rs b/rust/hg-core/src/repo.rs
--- a/rust/hg-core/src/repo.rs
+++ b/rust/hg-core/src/repo.rs
@@ -61,6 +61,8 @@
 let absolute_root = current_dir()?.join(root);
 if absolute_root.join(".hg").is_dir() {
 Self::new_at_path(absolute_root, config)
+} else if absolute_root.is_file() {
+Err(HgError::unsupported("bundle repository").into())
 } else {
 Err(RepoError::NotFound {
 at: root.to_owned(),



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


D10101: rhg: Fall back to Python on --repository with an URL

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

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  rust/rhg/src/main.rs

CHANGE DETAILS

diff --git a/rust/rhg/src/main.rs b/rust/rhg/src/main.rs
--- a/rust/rhg/src/main.rs
+++ b/rust/rhg/src/main.rs
@@ -95,6 +95,20 @@
 exit(&ui, on_unsupported, Err(error.into()))
 });
 
+if let Some(repo_path_bytes) = &early_args.repo {
+if repo_path_bytes.contains(&b':') {
+exit(
+&ui,
+OnUnsupported::from_config(&non_repo_config),
+Err(CommandError::UnsupportedFeature {
+message: format_bytes!(
+b"URL-like --repository {}",
+repo_path_bytes
+),
+}),
+)
+}
+}
 let repo_path = early_args.repo.as_deref().map(get_path_from_bytes);
 let repo_result = match Repo::find(&non_repo_config, repo_path) {
 Ok(repo) => Ok(repo),



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


D10100: rhg: Print non-absolutized path in "repository {} not found" errors

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

REVISION SUMMARY
  … like Python does

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

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

CHANGE DETAILS

diff --git a/rust/hg-core/src/repo.rs b/rust/hg-core/src/repo.rs
--- a/rust/hg-core/src/repo.rs
+++ b/rust/hg-core/src/repo.rs
@@ -58,9 +58,9 @@
 if let Some(root) = explicit_path {
 // Having an absolute path isn’t necessary here but can help code
 // elsewhere
-let root = current_dir()?.join(root);
-if root.join(".hg").is_dir() {
-Self::new_at_path(root, config)
+let absolute_root = current_dir()?.join(root);
+if absolute_root.join(".hg").is_dir() {
+Self::new_at_path(absolute_root, config)
 } else {
 Err(RepoError::NotFound {
 at: root.to_owned(),



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


D10099: rhg: Align "malformed --config" error message with Python

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

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  rust/hg-core/src/config/layer.rs

CHANGE DETAILS

diff --git a/rust/hg-core/src/config/layer.rs b/rust/hg-core/src/config/layer.rs
--- a/rust/hg-core/src/config/layer.rs
+++ b/rust/hg-core/src/config/layer.rs
@@ -74,7 +74,7 @@
 layer.add(section, item, value, None);
 } else {
 Err(HgError::abort(format!(
-"malformed --config option: \"{}\" \
+"malformed --config option: '{}' \
 (use --config section.name=value)",
 String::from_utf8_lossy(arg),
 )))?



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


D10098: rhg: Fall back to Python on unsupported `rhg config `

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

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  rust/rhg/src/commands/config.rs

CHANGE DETAILS

diff --git a/rust/rhg/src/commands/config.rs b/rust/rhg/src/commands/config.rs
--- a/rust/rhg/src/commands/config.rs
+++ b/rust/rhg/src/commands/config.rs
@@ -27,7 +27,7 @@
 .expect("missing required CLI argument")
 .as_bytes()
 .split_2(b'.')
-.ok_or_else(|| HgError::abort(""))?;
+.ok_or_else(|| HgError::unsupported("hg config "))?;
 
 let value = invocation.config.get(section, name).unwrap_or(b"");
 



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


D10096: tests: Add `rhg` and `no-rhg` for #require and #if in .t files

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

REVISION SUMMARY
  This will allow conditionally disabling tests that are known to fail with rhg

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  tests/hghave.py
  tests/run-tests.py
  tests/test-rhg.t

CHANGE DETAILS

diff --git a/tests/test-rhg.t b/tests/test-rhg.t
--- a/tests/test-rhg.t
+++ b/tests/test-rhg.t
@@ -1,15 +1,4 @@
-#require rust
-
-Define an rhg function that will only run if rhg exists
-  $ RHG="$RUNTESTDIR/../rust/target/release/rhg"
-  $ rhg() {
-  > if [ -f "$RHG" ]; then
-  >   "$RHG" "$@"
-  > else
-  >   echo "skipped: Cannot find rhg. Try to run cargo build in rust/rhg."
-  >   exit 80
-  > fi
-  > }
+#require rhg
 
 Unimplemented command
   $ rhg unimplemented-command --config rhg.on-unsupported=abort
@@ -167,8 +156,8 @@
   unsupported feature: `rhg cat` without `--rev` / `-r`
   [252]
 
-  $ rhg cat original --config rhg.fallback-executable="$RHG"
-  Blocking recursive fallback. The 'rhg.fallback-executable = 
*/rust/target/release/rhg' config points to `rhg` itself. (glob)
+  $ rhg cat original --config rhg.fallback-executable=rhg
+  Blocking recursive fallback. The 'rhg.fallback-executable = rhg' config 
points to `rhg` itself.
   unsupported feature: `rhg cat` without `--rev` / `-r`
   [252]
 
diff --git a/tests/run-tests.py b/tests/run-tests.py
--- a/tests/run-tests.py
+++ b/tests/run-tests.py
@@ -3144,6 +3144,7 @@
 rhgbindir = self._bindir
 if self.options.rhg or self.options.with_rhg:
 self._rhg_fallback_exe = os.path.join(self._bindir, 
self._hgcommand)
+osenvironb[b'RHG_INSTALLED_AS_HG'] = b'1' # For hghave.py
 if self.options.rhg:
 self._hgcommand = b'rhg'
 elif self.options.with_rhg:
diff --git a/tests/hghave.py b/tests/hghave.py
--- a/tests/hghave.py
+++ b/tests/hghave.py
@@ -188,6 +188,11 @@
 return 'CHGHG' in os.environ
 
 
+@check("rhg", "running with rhg as 'hg'")
+def has_rhg():
+return 'RHG_INSTALLED_AS_HG' in os.environ
+
+
 @check("cvs", "cvs client/server")
 def has_cvs():
 re = br'Concurrent Versions System.*?server'



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


D10095: tests: Add `--rhg` and `--with-rhg=` options for `run-tests.py`

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

REVISION SUMMARY
  They are mostly equivalent to the corresponding `chg` options.
  For now, many tests are still failing in this configuration.
  It is *not* run on CI.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  tests/run-tests.py

CHANGE DETAILS

diff --git a/tests/run-tests.py b/tests/run-tests.py
--- a/tests/run-tests.py
+++ b/tests/run-tests.py
@@ -540,6 +540,11 @@
 action="store_true",
 help="show chg debug logs",
 )
+hgconf.add_argument(
+"--rhg",
+action="store_true",
+help="install and use rhg Rust implementation in place of hg",
+)
 hgconf.add_argument("--compiler", help="compiler to build with")
 hgconf.add_argument(
 '--extra-config-opt',
@@ -552,6 +557,7 @@
 "--local",
 action="store_true",
 help="shortcut for --with-hg=/../hg, "
+"--with-rhg=/../rust/target/release/rhg if --rhg is set, "
 "and --with-chg=/../contrib/chg/chg if --chg is set",
 )
 hgconf.add_argument(
@@ -580,6 +586,11 @@
 help="use specified chg wrapper in place of hg",
 )
 hgconf.add_argument(
+"--with-rhg",
+metavar="RHG",
+help="use specified rhg Rust implementation in place of hg",
+)
+hgconf.add_argument(
 "--with-hg",
 metavar="HG",
 help="test using specified hg script rather than a "
@@ -667,13 +678,17 @@
 parser.error('--rust cannot be used with --no-rust')
 
 if options.local:
-if options.with_hg or options.with_chg:
-parser.error('--local cannot be used with --with-hg or --with-chg')
+if options.with_hg or options.with_rhg or options.with_chg:
+parser.error(
+'--local cannot be used with --with-hg or --with-rhg or 
--with-chg'
+)
 testdir = os.path.dirname(_sys2bytes(canonpath(sys.argv[0])))
 reporootdir = os.path.dirname(testdir)
 pathandattrs = [(b'hg', 'with_hg')]
 if options.chg:
 pathandattrs.append((b'contrib/chg/chg', 'with_chg'))
+if options.rhg:
+pathandattrs.append((b'rust/target/release/rhg', 'with_rhg'))
 for relpath, attr in pathandattrs:
 binpath = os.path.join(reporootdir, relpath)
 if os.name != 'nt' and not os.access(binpath, os.X_OK):
@@ -696,6 +711,8 @@
 
 if (options.chg or options.with_chg) and os.name == 'nt':
 parser.error('chg does not work on %s' % os.name)
+if (options.rhg or options.with_rhg) and os.name == 'nt':
+parser.error('rhg does not work on %s' % os.name)
 if options.with_chg:
 options.chg = False  # no installation to temporary location
 options.with_chg = canonpath(_sys2bytes(options.with_chg))
@@ -704,12 +721,28 @@
 and os.access(options.with_chg, os.X_OK)
 ):
 parser.error('--with-chg must specify a chg executable')
+if options.with_rhg:
+options.rhg = False  # no installation to temporary location
+options.with_rhg = canonpath(_sys2bytes(options.with_rhg))
+if not (
+os.path.isfile(options.with_rhg)
+and os.access(options.with_rhg, os.X_OK)
+):
+parser.error('--with-rhg must specify a rhg executable')
 if options.chg and options.with_hg:
 # chg shares installation location with hg
 parser.error(
 '--chg does not work when --with-hg is specified '
 '(use --with-chg instead)'
 )
+if options.rhg and options.with_hg:
+# rhg shares installation location with hg
+parser.error(
+'--rhg does not work when --with-hg is specified '
+'(use --with-rhg instead)'
+)
+if options.rhg and options.chg:
+parser.error('--rhg and --chg do not work together')
 
 if options.color == 'always' and not pygmentspresent:
 sys.stderr.write(
@@ -934,6 +967,7 @@
 slowtimeout=None,
 usechg=False,
 chgdebug=False,
+rhg_fallback_exe=None,
 useipv6=False,
 ):
 """Create a test from parameters.
@@ -991,6 +1025,7 @@
 self._hgcommand = hgcommand or b'hg'
 self._usechg = usechg
 self._chgdebug = chgdebug
+self._rhg_fallback_exe = rhg_fallback_exe
 self._useipv6 = useipv6
 
 self._aborted = False
@@ -1473,6 +1508,12 @@
 hgrc.write(b'ipv6 = %r\n' % self._useipv6)
 hgrc.write(b'server-header = testing stub value\n')
 
+if self._rhg_fallback_exe:
+hgrc.write(b'[rhg]\n')
+hgrc.write(
+b'fallback-executable = %s\n' % self._rhg_fallback_exe
+)
+
 for opt in self._extraconfigopts:

D10097: rhg: Fall back to Python for unsupported revset syntax

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

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

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

CHANGE DETAILS

diff --git a/rust/hg-core/src/revset.rs b/rust/hg-core/src/revset.rs
--- a/rust/hg-core/src/revset.rs
+++ b/rust/hg-core/src/revset.rs
@@ -2,6 +2,7 @@
 //!
 //! 
 
+use crate::errors::HgError;
 use crate::repo::Repo;
 use crate::revlog::changelog::Changelog;
 use crate::revlog::revlog::{Revlog, RevlogError};
@@ -28,7 +29,10 @@
 
 // TODO: support for the rest of the language here.
 
-Err(RevlogError::InvalidRevision)
+Err(
+HgError::unsupported(format!("cannot parse revset '{}'", input))
+.into(),
+)
 }
 
 /// Resolve the small subset of the language suitable for revlogs other than



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


D10094: rhg: Make fallback to Python the default behavior

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

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  rust/rhg/src/main.rs
  tests/test-rhg.t

CHANGE DETAILS

diff --git a/tests/test-rhg.t b/tests/test-rhg.t
--- a/tests/test-rhg.t
+++ b/tests/test-rhg.t
@@ -12,7 +12,7 @@
   > }
 
 Unimplemented command
-  $ rhg unimplemented-command
+  $ rhg unimplemented-command --config rhg.on-unsupported=abort
   unsupported feature: error: Found argument 'unimplemented-command' which 
wasn't expected, or isn't valid in this context
   
   USAGE:
@@ -153,22 +153,21 @@
   original content
 
 Fallback to Python
-  $ rhg cat original
+  $ rhg cat original --config rhg.on-unsupported=abort
   unsupported feature: `rhg cat` without `--rev` / `-r`
   [252]
-  $ FALLBACK="--config rhg.on-unsupported=fallback"
-  $ rhg cat original $FALLBACK
+  $ rhg cat original
   original content
 
-  $ rhg cat original $FALLBACK --config rhg.fallback-executable=false
+  $ rhg cat original --config rhg.fallback-executable=false
   [1]
 
-  $ rhg cat original $FALLBACK --config rhg.fallback-executable=hg-non-existent
+  $ rhg cat original --config rhg.fallback-executable=hg-non-existent
   tried to fall back to a 'hg-non-existent' sub-process but got error $ENOENT$
   unsupported feature: `rhg cat` without `--rev` / `-r`
   [252]
 
-  $ rhg cat original $FALLBACK --config rhg.fallback-executable="$RHG"
+  $ rhg cat original --config rhg.fallback-executable="$RHG"
   Blocking recursive fallback. The 'rhg.fallback-executable = 
*/rust/target/release/rhg' config points to `rhg` itself. (glob)
   unsupported feature: `rhg cat` without `--rev` / `-r`
   [252]
@@ -183,15 +182,15 @@
   store
 
   $ echo indoor-pool >> .hg/requires
-  $ rhg files
+  $ rhg files --config rhg.on-unsupported=abort
   unsupported feature: repository requires feature unknown to this Mercurial: 
indoor-pool
   [252]
 
-  $ rhg cat -r 1 copy_of_original
+  $ rhg cat -r 1 copy_of_original --config rhg.on-unsupported=abort
   unsupported feature: repository requires feature unknown to this Mercurial: 
indoor-pool
   [252]
 
-  $ rhg debugrequirements
+  $ rhg debugrequirements --config rhg.on-unsupported=abort
   unsupported feature: repository requires feature unknown to this Mercurial: 
indoor-pool
   [252]
 
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
@@ -311,27 +311,27 @@
 }
 
 impl OnUnsupported {
-const DEFAULT: Self = OnUnsupported::Abort;
 const DEFAULT_FALLBACK_EXECUTABLE: &'static [u8] = b"hg";
 
 fn from_config(config: &Config) -> Self {
-match config
+let fallback = b"fallback";
+match &*config
 .get(b"rhg", b"on-unsupported")
-.map(|value| value.to_ascii_lowercase())
-.as_deref()
+.unwrap_or(fallback)
+.to_ascii_lowercase()
 {
-Some(b"abort") => OnUnsupported::Abort,
-Some(b"abort-silent") => OnUnsupported::AbortSilent,
-Some(b"fallback") => OnUnsupported::Fallback {
-executable: config
-.get(b"rhg", b"fallback-executable")
-.unwrap_or(Self::DEFAULT_FALLBACK_EXECUTABLE)
-.to_owned(),
-},
-None => Self::DEFAULT,
-Some(_) => {
-// TODO: warn about unknown config value
-Self::DEFAULT
+b"abort" => OnUnsupported::Abort,
+b"abort-silent" => OnUnsupported::AbortSilent,
+value => {
+if value != fallback {
+// TODO: warn about unknown config value
+}
+OnUnsupported::Fallback {
+executable: config
+.get(b"rhg", b"fallback-executable")
+.unwrap_or(Self::DEFAULT_FALLBACK_EXECUTABLE)
+.to_owned(),
+}
 }
 }
 }



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