[Bug 6612] New: Python 3.10: PY_SSIZE_T_CLEAN macro must be defined for '#' formats
https://bz.mercurial-scm.org/show_bug.cgi?id=6612 Bug ID: 6612 Summary: Python 3.10: PY_SSIZE_T_CLEAN macro must be defined for '#' formats Product: Mercurial Version: unspecified Hardware: PC OS: Linux Status: UNCONFIRMED Severity: feature Priority: wish Component: fsmonitor Assignee: bugzi...@mercurial-scm.org Reporter: mhent...@mozilla.com CC: mercurial-devel@mercurial-scm.org Python Version: --- To reproduce: 1. Install Python 3.10 2. Build/install HG such that it uses Python 3.10 3. Use the following minimal `.hgrc`: ``` [extensions] blackbox = fsmonitor = ``` 4. In the `hg` repo: `hg up` ``` ~/d/hg % ./hg up obsolete feature not enabled but 274483 markers found! ** unknown exception encountered, please report by visiting ** https://mercurial-scm.org/wiki/BugTracker ** Python 3.10.0 (default, Oct 4 2021, 00:00:00) [GCC 11.2.1 20210728 (Red Hat 11.2.1-1)] ** Mercurial Distributed SCM (version 5.9.3) ** Extensions loaded: blackbox, fsmonitor Traceback (most recent call last): File "/home/mitch/dev/hg/hgext/fsmonitor/__init__.py", line 830, in _state self.repo._watchmanclient.command( File "/home/mitch/dev/hg/hgext/fsmonitor/watchmanclient.py", line 119, in command return self._command(*args) File "/home/mitch/dev/hg/hgext/fsmonitor/watchmanclient.py", line 106, in _command return self._watchmanclient.query(*watchmanargs) File "/home/mitch/dev/hg/hgext/fsmonitor/pywatchman/__init__.py", line 1156, in query self._connect() File "/home/mitch/dev/hg/hgext/fsmonitor/pywatchman/__init__.py", line 1024, in _connect self.sockpath = self._resolvesockname() File "/home/mitch/dev/hg/hgext/fsmonitor/pywatchman/__init__.py", line 1007, in _resolvesockname result = bser.loads(stdout) SystemError: PY_SSIZE_T_CLEAN macro must be defined for '#' formats During handling of the above exception, another exception occurred: Traceback (most recent call last): File "/home/mitch/dev/hg/./hg", line 61, in dispatch.run() File "/home/mitch/dev/hg/mercurial/dispatch.py", line 144, in run status = dispatch(req) File "/home/mitch/dev/hg/mercurial/dispatch.py", line 250, in dispatch status = _rundispatch(req) File "/home/mitch/dev/hg/mercurial/dispatch.py", line 294, in _rundispatch ret = _runcatch(req) or 0 File "/home/mitch/dev/hg/mercurial/dispatch.py", line 470, in _runcatch return _callcatch(ui, _runcatchfunc) File "/home/mitch/dev/hg/mercurial/dispatch.py", line 480, in _callcatch return scmutil.callcatch(ui, func) File "/home/mitch/dev/hg/mercurial/scmutil.py", line 153, in callcatch return func() File "/home/mitch/dev/hg/mercurial/dispatch.py", line 460, in _runcatchfunc return _dispatch(req) File "/home/mitch/dev/hg/mercurial/dispatch.py", line 1273, in _dispatch return runcommand( File "/home/mitch/dev/hg/mercurial/dispatch.py", line 918, in runcommand ret = _runcommand(ui, options, cmd, d) File "/home/mitch/dev/hg/mercurial/dispatch.py", line 1285, in _runcommand return cmdfunc() File "/home/mitch/dev/hg/mercurial/dispatch.py", line 1271, in d = lambda: util.checksignature(func)(ui, *args, **strcmdopt) File "/home/mitch/dev/hg/mercurial/util.py", line 1886, in check return func(*args, **kwargs) File "/home/mitch/dev/hg/mercurial/commands.py", line 7848, in update ret = hg.updatetotally( File "/home/mitch/dev/hg/mercurial/hg.py", line 1180, in updatetotally ret = _update(repo, checkout, updatecheck=updatecheck) File "/home/mitch/dev/hg/mercurial/hg.py", line 1099, in update stats = mergemod.update(repo[node], updatecheck=updatecheck) File "/home/mitch/dev/hg/mercurial/merge.py", line 2196, in update return _update( File "/home/mitch/dev/hg/hgext/fsmonitor/__init__.py", line 890, in wrapupdate with state_update( File "/home/mitch/dev/hg/hgext/fsmonitor/__init__.py", line 788, in __enter__ self.enter() File "/home/mitch/dev/hg/hgext/fsmonitor/__init__.py", line 803, in enter self.need_leave = self._state(b'state-enter', hex(self.oldnode)) File "/home/mitch/dev/hg/hgext/fsmonitor/__init__.py", line 849, in _state self.repo.ui.log( File "/home/mitch/dev/hg/mercurial/ui.py", line 2126, in log msg = msgfmt % msgargs TypeError: %b requires a bytes-like object, or an object that implements __bytes__, not 'SystemError' ``` -- You are receiving this mail because: You are on the CC list for the bug. ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
D11752: rhg: allow rhg in sparse repos when the operations only need the store
aalekseyev 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/D11752 AFFECTED FILES rust/hg-core/src/operations/list_tracked_files.rs rust/hg-core/src/repo.rs rust/hg-core/src/requirements.rs rust/rhg/src/blackbox.rs rust/rhg/src/commands/status.rs rust/rhg/src/main.rs tests/test-rhg-sparse.t CHANGE DETAILS diff --git a/tests/test-rhg-sparse.t b/tests/test-rhg-sparse.t new file mode 100644 --- /dev/null +++ b/tests/test-rhg-sparse.t @@ -0,0 +1,33 @@ +#require rhg + + $ NO_FALLBACK="env RHG_ON_UNSUPPORTED=abort" + +Even though sparse working copy is not supported, the commands +that operate on the store still work even if the working copy is sparse. + + $ cd "$TESTTMP" + $ hg init repo-sparse + $ cd repo-sparse + $ cat > .hg/hgrc < [extensions] + > sparse= + > EOF + + $ echo a > show + $ echo x > hide + $ hg ci -Aqm 'initial' + $ hg debugsparse --include 'show' + $ ls -A + .hg + show + + $ tip=$(hg log -r . --template '{node}') + $ $NO_FALLBACK rhg files -r "$tip" + hide + show + $ $NO_FALLBACK rhg files + unsupported feature: repository uses a sparse working copy, this is not supported by rhg + [252] + + $ $NO_FALLBACK rhg cat -r "$tip" hide + x 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 @@ -104,7 +104,7 @@ if let Ok(repo) = repo { // We don't support subrepos, fallback if the subrepos file is present -if repo.working_directory_vfs().join(".hgsub").exists() { +if repo.is_a_subrepo() { let msg = "subrepos (.hgsub is present)"; return Err(CommandError::unsupported(msg)); } @@ -588,7 +588,8 @@ } } -const SUPPORTED_EXTENSIONS: &[&[u8]] = &[b"blackbox", b"share"]; +const SUPPORTED_EXTENSIONS: &[&[u8]] = +&[b"blackbox", b"share", b"sparse", b"narrow"]; fn check_extensions(config: ) -> Result<(), CommandError> { let enabled = config.get_section_keys(b"extensions"); diff --git a/rust/rhg/src/commands/status.rs b/rust/rhg/src/commands/status.rs --- a/rust/rhg/src/commands/status.rs +++ b/rust/rhg/src/commands/status.rs @@ -190,7 +190,7 @@ list_ignored: display_states.ignored, collect_traversed_dirs: false, }; -let ignore_file = repo.working_directory_vfs().join(".hgignore"); // TODO hardcoded +let ignore_file = repo.working_directory_vfs()?.join(".hgignore"); // TODO hardcoded let (mut ds_status, pattern_warnings) = dmap.status( , repo.working_directory_path().to_owned(), @@ -311,6 +311,6 @@ let contents_in_p1 = filelog_entry.data()?; let fs_path = hg_path_to_os_string(hg_path).expect("HgPath conversion"); -let fs_contents = repo.working_directory_vfs().read(fs_path)?; +let fs_contents = repo.working_directory_vfs()?.read(fs_path)?; return Ok(contents_in_p1 != &*fs_contents); } diff --git a/rust/rhg/src/blackbox.rs b/rust/rhg/src/blackbox.rs --- a/rust/rhg/src/blackbox.rs +++ b/rust/rhg/src/blackbox.rs @@ -133,11 +133,13 @@ pid, message ); -let result = -hg::logging::LogFile::new(self.repo.hg_vfs(), "blackbox.log") -.max_size(Some(self.max_size)) -.max_files(self.max_files) -.write(); +let result = hg::logging::LogFile::new( +self.repo.hg_vfs_not_using_dirstate(), +"blackbox.log", +) +.max_size(Some(self.max_size)) +.max_files(self.max_files) +.write(); match result { Ok(()) => {} Err(_io_error) => { 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 @@ -88,6 +88,9 @@ // When it starts writing to the repository, it’ll need to either keep the // persistent nodemap up to date or remove this entry: NODEMAP_REQUIREMENT, +// We don't understand sparse working copies, but we understand +// how to use the store because it's not affected by sparse. +SPARSE_REQUIREMENT, ]; // Copied from mercurial/requirements.py: 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 @@ -227,7 +227,31 @@ /// For accessing repository files (in `.hg`), except for the store /// (`.hg/store`). -pub fn hg_vfs() -> Vfs<'_> { +fn hg_vfs() -> Vfs<'_> { +Vfs { base: _hg } +} + +fn has_sparse() -> bool { +self.requirements.contains(requirements::SPARSE_REQUIREMENT) +} + +fn check_not_sparse() -> Result<(), HgError> { +if self.has_sparse() { +Err(HgError::unsupported(format!( +"repository uses a sparse working copy, this is not supported
D11751: rhg: only complain about poorly configured fallback when falling back
aalekseyev 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/D11751 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 @@ -42,6 +42,10 @@ abort: No space left on device (os error 28) [255] + $ rhg --config rhg.on-unsupported=fallback --config rhg.fallback-executable=! root > /dev/full + abort: No space left on device (os error 28) + [255] + Deleted repository $ rm -rf `pwd` $ $NO_FALLBACK rhg root 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 @@ -179,7 +179,7 @@ exit( _current_dir, , -OnUnsupported::from_config(, _repo_config), +OnUnsupported::from_config(_repo_config), Err(error.into()), non_repo_config .get_bool(b"ui", b"detailed-exit-code") @@ -197,7 +197,7 @@ exit( _current_dir, , -OnUnsupported::from_config(, _repo_config), +OnUnsupported::from_config(_repo_config), Err(CommandError::UnsupportedFeature { message: format_bytes!( b"URL-like --repository {}", @@ -287,7 +287,7 @@ Err(error) => exit( _current_dir, , -OnUnsupported::from_config(, _repo_config), +OnUnsupported::from_config(_repo_config), Err(error.into()), // TODO: show a warning or combine with original error if // `get_bool` returns an error @@ -302,7 +302,7 @@ } else { _repo_config }; -let on_unsupported = OnUnsupported::from_config(, config); +let on_unsupported = OnUnsupported::from_config(config); let result = main_with_result( _start_time, @@ -362,6 +362,20 @@ ) = (_unsupported, ) { let mut args = std::env::args_os(); +let executable = match executable { +None => { +exit_no_fallback( +ui, +OnUnsupported::Abort, +Err(CommandError::abort( +"abort: 'rhg.on-unsupported=fallback' without \ +'rhg.fallback-executable' set.", +)), +false, +); +} +Some(executable) => executable, +}; let executable_path = get_path_from_bytes(); let this_executable = args.next().expect("exepcted argv[0] to exist"); if executable_path == ::from(this_executable) { @@ -374,7 +388,8 @@ )); on_unsupported = OnUnsupported::Abort } else { -// `args` is now `argv[1..]` since we’ve already consumed `argv[0]` +// `args` is now `argv[1..]` since we’ve already consumed +// `argv[0]` let mut command = Command::new(executable_path); command.args(args); if let Some(initial) = initial_current_dir { @@ -549,13 +564,13 @@ /// Silently exit with code 252. AbortSilent, /// Try running a Python implementation -Fallback { executable: Vec }, +Fallback { executable: Option> }, } impl OnUnsupported { const DEFAULT: Self = OnUnsupported::Abort; -fn from_config(ui: , config: ) -> Self { +fn from_config(config: ) -> Self { match config .get(b"rhg", b"on-unsupported") .map(|value| value.to_ascii_lowercase()) @@ -566,18 +581,7 @@ Some(b"fallback") => OnUnsupported::Fallback { executable: config .get(b"rhg", b"fallback-executable") -.unwrap_or_else(|| { -exit_no_fallback( -ui, -Self::Abort, -Err(CommandError::abort( -"abort: 'rhg.on-unsupported=fallback' without \ -'rhg.fallback-executable' set." -)), -false, -) -}) -.to_owned(), +.map(|x| x.to_owned()), }, None => Self::DEFAULT, Some(_) => { To: aalekseyev, #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