Commit Graph

7 Commits

Author SHA1 Message Date
Xavier Deguillard
674e9c7900 fsinfo: return an enum instead of a String
Summary:
In a strongly typed langage, using strings should be avoided whenever possible
as they do not provide the safety guarantees that types provide.

I took the liberty of removing all the filesystems that are not relevant for
Mercurial for simplification reasons. If needs arise, we can always add a new
FsType to the enum.

Reviewed By: DurhamG

Differential Revision: D20517138

fbshipit-source-id: 0a38b53c6a87f05f4b2d664038e10c4293de96ae
2020-03-23 14:29:10 -07:00
Jun Wu
c5c75c9f59 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
2020-03-11 17:35:40 -07:00
Jun Wu
61bebcaacc fsinfo: try harder to get fuse fs type
Summary: Similar to D13982877. Try to get names like "fuse.ntfs".

Reviewed By: farnz

Differential Revision: D20313392

fbshipit-source-id: 8363d3d92843e6afb53a0003950be083034bd841
2020-03-11 17:35:39 -07:00
Jun Wu
13374f9d74 fsinfo: drop most type parameters
Summary:
Only keep type parameters at the top-level function.
This reduces the binary size and speeds up rustc.

Reviewed By: xavierd

Differential Revision: D20313388

fbshipit-source-id: 29d77731ff462fee1f1bb9f234601e3430198ae7
2020-03-11 17:35:39 -07:00
Jun Wu
c83006002c fsinfo: return unknown on unsupported platforms
Summary: This makes the code a bit more portable.

Reviewed By: xavierd

Differential Revision: D20313389

fbshipit-source-id: 080538939fa4d2d72e5905f23ad9be987d952748
2020-03-11 17:35:38 -07:00
Jun Wu
9cdc818915 fsinfo: drop "repo" from method names
Summary:
Rename the main method to "fstype". The API has no relation with repo.
So let's rename it.

Reviewed By: xavierd

Differential Revision: D20313386

fbshipit-source-id: 80dd1231ccccfe945150b117b151bce773f0dfeb
2020-03-11 17:35:38 -07:00
Jun Wu
951c8ab082 fsinfo: backport from telemetry
Summary: The fsinfo crate provides the "filesystem type" information.

Reviewed By: xavierd

Differential Revision: D20313391

fbshipit-source-id: f717f5edb32957d59d03090117cfdb8123f03933
2020-03-11 17:35:37 -07:00