mpremote: Behaviour is confusing with multiple mountpoints
Description
Follow on from https://github.com/micropython/micropython/pull/11777#issuecomment-2390338451.
To the naive user of a system with multiple mounted filesystems the behaviour of
$ mpremote cp foo.py :
seems nondeterministic, because the destination of the copy can only be established with knowledge of the state of the target (its current directory). The same applies to
$ mpremote ls :
The following change would provide a deterministic and more discoverable interface.
- Where there is only one mounted filesystem, behaviour remains exactly as currently.
- Where there are multiple filesystems behaviour is as follows:
mpremote ls : produces a list of mountpoints (as per ls : /).
mpremote cp foo.py : throws an exception because you cannot write to '/'.
mpremote cp foo.py :/sd/ works as at present.
While this is a breaking change, an inability to write to '/' will not surprise anyone familiar with the MP directory structure.
Code Size
No response
Implementation
I hope the MicroPython maintainers or community will implement this feature
Code of Conduct
Yes, I agree
tools/mpremote: Support trailing slash on dest for non-recursive copy.
Summary
This fixes a regression in db59e55fe7a0b67d3af868990468e7b8056afe42: prior to that commit mpremote supported trailing slashes on the destination of a normal (non-recursive) copy.
Add back support for that, with the semantics that a trailing slash requires the destination to be an existing directory.
Testing
A test has been added to the mpremote tests (also a test for force copy, in a separate commit). As part of getting the test working, needed to flush stdout before printing error messages to stderr.
The mpremote tests were then run on a PYBD_SF2. They passed.