fsinfo: autocorrect "" to "."

Summary:
Without this:

  In [3]: util.getfstype('')
  IOError: [Errno 2] No such file or directory (os error 2)

And there is a code path hitting this:

  File "edenscm/mercurial/util.py", line 1483, in checknlink
    fstype = getfstype(os.path.dirname(testfile))
		# testfile = '.'
	  # os.path.dirname(".") = ""

The old implementation works fine for an empty path:

	In [2]: m.util.getfstype('')
  Out[2]: 'eden'

So let's make the new Rust implementation consistent.

Reviewed By: xavierd

Differential Revision: D20313387

fbshipit-source-id: 258c424a3e8a796d983e20b0d4656e8e3f413706
This commit is contained in:
Jun Wu 2020-03-11 17:30:14 -07:00 committed by Facebook GitHub Bot
parent ea59a506f1
commit c5c75c9f59

View File

@ -222,6 +222,13 @@ mod macos {
pub fn fstype(path: impl AsRef<Path>) -> io::Result<String> {
let path = path.as_ref();
// Auto correct an empty path to ".".
let path = if path == Path::new("") {
Path::new(".")
} else {
path
};
#[cfg(target_os = "linux")]
{
return self::linux::fstype(path);