view hgext/largefiles/wirestore.py @ 52297:644c696b6c18

rust-status: fix a future compilation error This was the warning by clippy 1.82.0, which explains the change: ``` warning: this function depends on never type fallback being `()` --> hg-core/src/dirstate_tree/status.rs:397:5 | 397 | / fn traverse_fs_directory_and_dirstate<'ancestor>( 398 | | &self, 399 | | has_ignored_ancestor: &'ancestor HasIgnoredAncestor<'ancestor>, 400 | | dirstate_nodes: ChildNodesRef<'tree, 'on_disk>, ... | 404 | | is_at_repo_root: bool, 405 | | ) -> Result<bool, DirstateV2ParseError> { | |___________________________________________^ | = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! = note: for more information, see issue #123748 <https://github.com/rust-lang/rust/issues/123748> = help: specify the types explicitly note: in edition 2024, the requirement `!: rayon::iter::FromParallelIterator<()>` will fail --> hg-core/src/dirstate_tree/status.rs:453:28 | 453 | .collect::<Result<_, _>>()?; | ^^^^^^^^^^^^ = note: `#[warn(dependency_on_unit_never_type_fallback)]` on by default ```
author Raphaël Gomès <rgomes@octobus.net>
date Tue, 29 Oct 2024 11:41:27 +0100
parents f4733654f144
children
line wrap: on
line source

# Copyright 2010-2011 Fog Creek Software
#
# This software may be used and distributed according to the terms of the
# GNU General Public License version 2 or any later version.

'''largefile store working over Mercurial's wire protocol'''

from __future__ import annotations

from . import (
    lfutil,
    remotestore,
)


class wirestore(remotestore.remotestore):
    def __init__(self, ui, repo, remote):
        cap = remote.capable(b'largefiles')
        if not cap:
            raise lfutil.storeprotonotcapable([])
        storetypes = cap.split(b',')
        if b'serve' not in storetypes:
            raise lfutil.storeprotonotcapable(storetypes)
        self.remote = remote
        super(wirestore, self).__init__(ui, repo, remote.url())

    def _put(self, hash, fd):
        return self.remote.putlfile(hash, fd)

    def _get(self, hash):
        return self.remote.getlfile(hash)

    def _stat(self, hashes):
        """For each hash, return 0 if it is available, other values if not.
        It is usually 2 if the largefile is missing, but might be 1 the server
        has a corrupted copy."""

        with self.remote.commandexecutor() as e:
            fs = []
            for hash in hashes:
                fs.append(
                    (
                        hash,
                        e.callcommand(
                            b'statlfile',
                            {
                                b'sha': hash,
                            },
                        ),
                    )
                )

            return {hash: f.result() for hash, f in fs}