##// END OF EJS Templates
global: use python3 in shebangs...
global: use python3 in shebangs Python 3 is the future. We want Python scripts to be using Python 3 by default. This change updates all `#!/usr/bin/env python` shebangs to use `python3`. Does this mean all scripts use or require Python 3: no. In the test environment, the `PATH` environment variable in tests is updated to guarantee that the Python executable used to run run-tests.py is used. Since test scripts all now use `#!/usr/bin/env python3`, we had to update this code to install a `python3` symlink instead of `python`. It is possible there are some random scripts now executed with the incorrect Python interpreter in some contexts. However, I would argue that this was a pre-existing bug: we should almost always be executing new Python processes using the `sys.executable` from the originating Python script, as `python` or `python3` won't guarantee we'll use the same interpreter. Differential Revision: https://phab.mercurial-scm.org/D9273

File last commit:

r45500:26114bd6 default
r46434:c102b704 default
Show More
non_normal_entries.rs
76 lines | 2.3 KiB | application/rls-services+xml | RustLexer
/ rust / hg-cpython / src / dirstate / non_normal_entries.rs
Raphaël Gomès
rust-dirstatemap: add `NonNormalEntries` class...
r44779 // non_normal_other_parent_entries.rs
//
// Copyright 2020 Raphaël Gomès <rgomes@octobus.net>
//
// This software may be used and distributed according to the terms of the
// GNU General Public License version 2 or any later version.
use cpython::{
Raphaël Gomès
rust-cpython: make `NonNormalEntires` iterable to fix `fsmonitor` (issue6276)...
r44903 exc::NotImplementedError, CompareOp, ObjectProtocol, PyBytes, PyClone,
PyErr, PyList, PyObject, PyResult, PyString, Python, PythonObject,
ToPyObject, UnsafePyLeaked,
Raphaël Gomès
rust-dirstatemap: add `NonNormalEntries` class...
r44779 };
use crate::dirstate::DirstateMap;
Raphaël Gomès
rust-cpython: make `NonNormalEntires` iterable to fix `fsmonitor` (issue6276)...
r44903 use hg::utils::hg_path::HgPathBuf;
use std::cell::RefCell;
use std::collections::hash_set;
Raphaël Gomès
rust-dirstatemap: add `NonNormalEntries` class...
r44779
py_class!(pub class NonNormalEntries |py| {
data dmap: DirstateMap;
def __contains__(&self, key: PyObject) -> PyResult<bool> {
self.dmap(py).non_normal_entries_contains(py, key)
}
def remove(&self, key: PyObject) -> PyResult<PyObject> {
self.dmap(py).non_normal_entries_remove(py, key)
}
def union(&self, other: PyObject) -> PyResult<PyList> {
self.dmap(py).non_normal_entries_union(py, other)
}
def __richcmp__(&self, other: PyObject, op: CompareOp) -> PyResult<bool> {
match op {
CompareOp::Eq => self.is_equal_to(py, other),
CompareOp::Ne => Ok(!self.is_equal_to(py, other)?),
_ => Err(PyErr::new::<NotImplementedError, _>(py, ""))
}
}
def __repr__(&self) -> PyResult<PyString> {
self.dmap(py).non_normal_entries_display(py)
}
Raphaël Gomès
rust-cpython: make `NonNormalEntires` iterable to fix `fsmonitor` (issue6276)...
r44903
def __iter__(&self) -> PyResult<NonNormalEntriesIterator> {
self.dmap(py).non_normal_entries_iter(py)
}
Raphaël Gomès
rust-dirstatemap: add `NonNormalEntries` class...
r44779 });
impl NonNormalEntries {
pub fn from_inner(py: Python, dm: DirstateMap) -> PyResult<Self> {
Self::create_instance(py, dm)
}
fn is_equal_to(&self, py: Python, other: PyObject) -> PyResult<bool> {
for item in other.iter(py)? {
if !self.dmap(py).non_normal_entries_contains(py, item?)? {
return Ok(false);
}
}
Ok(true)
}
Raphaël Gomès
rust-cpython: make `NonNormalEntires` iterable to fix `fsmonitor` (issue6276)...
r44903
fn translate_key(
py: Python,
key: &HgPathBuf,
) -> PyResult<Option<PyBytes>> {
Raphaël Gomès
rust: do a clippy pass...
r45500 Ok(Some(PyBytes::new(py, key.as_bytes())))
Raphaël Gomès
rust-cpython: make `NonNormalEntires` iterable to fix `fsmonitor` (issue6276)...
r44903 }
Raphaël Gomès
rust-dirstatemap: add `NonNormalEntries` class...
r44779 }
Raphaël Gomès
rust-cpython: make `NonNormalEntires` iterable to fix `fsmonitor` (issue6276)...
r44903
type NonNormalEntriesIter<'a> = hash_set::Iter<'a, HgPathBuf>;
py_shared_iterator!(
NonNormalEntriesIterator,
UnsafePyLeaked<NonNormalEntriesIter<'static>>,
NonNormalEntries::translate_key,
Option<PyBytes>
);