Patchwork [4,of,5] debugfs: display the tested path and mount point of the filesystem, if known

login
register
mail settings
Submitter Matt Harbison
Date Dec. 30, 2017, 6:37 a.m.
Message ID <b02665ecb0c1653ace0a.1514615853@Envy>
Download mbox | patch
Permalink /patch/26504/
State Accepted, archived
Headers show

Comments

Matt Harbison - Dec. 30, 2017, 6:37 a.m.
# HG changeset patch
# User Matt Harbison <matt_harbison@yahoo.com>
# Date 1514609442 18000
#      Fri Dec 29 23:50:42 2017 -0500
# Node ID b02665ecb0c1653ace0ac1ed7812ffd42317fb43
# Parent  6cfb98df0f014d6ca3b1d80f26ae0744a2c1c1c8
debugfs: display the tested path and mount point of the filesystem, if known

While implementing the pure version of osutil.getfstype(), I noticed that MSYS
path mangling is getting in the way.  Given a path \\host\share\dir:

  - If strong quoted, hg receives it unchanged, and it works as expected
  - If double quoted, it converts to \host\share\dir
  - If unquoted, it converts to \hostsharedir

The second and third cases are problematic because those are valid paths
relative to the current drive letter, so GetFullPathName()/os.path.realpath()
will expand it as such.  The net effect is to silently turn a network path test
into (typically) a "C:\" test.  Additionally, the command hangs after printing
out 'symlink: no' for the third case (but is interruptable with Ctrl + C).  This
path mangling only comes into play because of the command line arguments- it
won't affect internally obtained paths.  Therefore, the simplest thing to do is
to provide feedback on what the command is acting on.

I also added the mount point, because Windows supports nesting [1] volumes (see
the examples in "Junction Points and Mounted Folders"), and it was a useful
diagnostic for figuring out why the wrong filesystem was printed out in the
cases above.

[1] https://msdn.microsoft.com/en-us/library/windows/desktop/aa364996(v=vs.85).aspx

Patch

diff --git a/mercurial/debugcommands.py b/mercurial/debugcommands.py
--- a/mercurial/debugcommands.py
+++ b/mercurial/debugcommands.py
@@ -911,6 +911,8 @@ 
 @command('debugfsinfo', [], _('[PATH]'), norepo=True)
 def debugfsinfo(ui, path="."):
     """show information detected about current filesystem"""
+    ui.write(('path: %s\n') % path)
+    ui.write(('mounted on: %s\n') % (util.getfsmountpoint(path) or '(unknown)'))
     ui.write(('exec: %s\n') % (util.checkexec(path) and 'yes' or 'no'))
     ui.write(('fstype: %s\n') % (util.getfstype(path) or '(unknown)'))
     ui.write(('symlink: %s\n') % (util.checklink(path) and 'yes' or 'no'))