Skip to content

Conversation

@powercode
Copy link
Collaborator

@powercode powercode commented Jan 30, 2019

Adding a new table view, childrenWithHardlink, that has the same behavior as children view had before this PR.

The children view now uses the modified ModeWithoutHardlink property that doesn't check for hardlinks when setting the l letter of Mode column.

The Mode property keeps it's existing behavior, so this change should not be breaking.

PR Summary

#8051

Significant speedup for default filesystem output

$files = gci -Recurse c:\windows -ea:0
$files | ft | out-null
$files | ft -view childrenWithHardlink  | out-null
view time speedup
childrenWithHardlink 3m22s 1x
children 7.6s 26x

Formatting result

Output before

PS> gci

    Directory: D:\repos\PowerShell\symlinks


Mode                LastWriteTime         Length Name
----                -------------         ------ ----
d-----       2019-02-03     15:37                dir
d----l       2019-02-03     15:38                symdir
d----l       2019-02-03     15:39                symsubdir
-a----       2019-02-03     15:38              3 file
-a---l       2019-02-03     15:37              3 hardlink
-a---l       2019-02-03     15:38              0 symfile1

Output after

PS> gci

    Directory: D:\repos\PowerShell\symlinks

Mode                LastWriteTime         Length Name
----                -------------         ------ ----
d----         2019-02-03    15:37                dir
l----         2019-02-03    15:38                symdir -> D:\repos\PowerShell\symlinks\dir
l----         2019-02-03    15:39                symsubdir -> D:\repos\PowerShell\symlinks\dir\subdir\
-a---         2019-02-03    15:38              3 file
-a---         2019-02-03    15:37              3 hardlink
la---         2019-02-03    15:38              0 symfile1 -> D:\repos\PowerShell\file

PS> gci | ft -view childrenWithHardlink

    Directory: D:\repos\PowerShell\symlinks

Mode                LastWriteTime         Length Name
----                -------------         ------ ----
d----         2019-02-03    15:37                dir
l----         2019-02-03    15:38                symdir -> D:\repos\PowerShell\symlinks\dir
l----         2019-02-03    15:39                symsubdir -> D:\repos\PowerShell\symlinks\dir\subdir\
-a---         2019-02-03    15:38              3 file
la---         2019-02-03    15:37              3 hardlink
la---         2019-02-03    15:38              0 symfile1 -> D:\repos\PowerShell\file

produces the old output.

PR Context

PR Checklist

@SteveL-MSFT SteveL-MSFT added the Review - Committee The PR/Issue needs a review from the PowerShell Committee label Jan 30, 2019
@adityapatwardhan
Copy link
Member

@powercode The change looks good in general. Could you also put a before and after of how the output of Get-ChildItem looks like for future reference in the PR description.

@adityapatwardhan
Copy link
Member

@powercode Could also have a look at the CodeFactor issue, some on them are about documentation and formating. Would be nice to get those fixed.

@JamesWTruher
Copy link
Collaborator

symlinks will still appear in the default view, right?
j

@SteveL-MSFT SteveL-MSFT added Committee-Reviewed PS-Committee has reviewed this and made a decision and removed Review - Committee The PR/Issue needs a review from the PowerShell Committee labels Jan 30, 2019
@powercode
Copy link
Collaborator Author

powercode commented Jan 30, 2019

@JamesWTruher Yes, symlinks appear as an l.

@powercode
Copy link
Collaborator Author

The build errors seem unrelated to my change. Is there a way to trigger a build without a new commit?

@adityapatwardhan
Copy link
Member

@powercode Restarted the CI.

@adityapatwardhan
Copy link
Member

@powercode Please respond to the committee recommendation about re-using the d field for links instead of adding one at the end.

@powercode
Copy link
Collaborator Author

powercode commented Jan 31, 2019

@adityapatwardhan I'm on it :)

Is this what we want, or should I skip the Link resolution?

    Directory: D:\repos\PowerShell\symlinktest

Mode                LastWriteTime         Length Name
----                -------------         ------ ----
d----         2019-02-01    00:22                dir
l----         2019-02-01    00:23                symdir -> D:\repos\PowerShell\symlinktest\dir\subdir\
-a---         2019-02-01    00:20              3 file

    Directory: D:\repos\PowerShell\symlinktest\dir

Mode                LastWriteTime         Length Name
----                -------------         ------ ----
d----         2019-02-01    00:22                subdir
-a---         2019-02-01    00:22              3 subfile
la---         2019-02-01    00:21              0 symfile1 -> D:\repos\PowerShell\symlinktest\file

@SteveL-MSFT
Copy link
Member

SteveL-MSFT commented Jan 31, 2019

@powercode yes, that's perfect!

@powercode
Copy link
Collaborator Author

@SteveL-MSFT I'm playing now with moving AddScriptBlockColumn into hidden code properties. Seems to be a bit faster to.

Any reason not to do that? The Name string needed it to get to the internal methods for Link management.

@powercode
Copy link
Collaborator Author

A bit of feature creep here :) Feel free to pick the commits you want!

@adityapatwardhan
Copy link
Member

@powercode Please have a look at the test failure

Copy link
Member

@SteveL-MSFT SteveL-MSFT left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should have some tests validating the formating changes

@powercode
Copy link
Collaborator Author

I consider the remaining CodeFactor issues to be noise, and the CI static analysis seem to complain about spelling in MD files.

@iSazonov iSazonov added the Documentation Needed in this repo Documentation is needed in this repo label Feb 2, 2019
Copy link
Collaborator

@iSazonov iSazonov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@SteveL-MSFT Has PowerShell Committee approved new public APIs?

@powercode
Copy link
Collaborator Author

This is what the default view and the childrenWithHardlink view looks like:

PS> gci
    Directory: D:\repos\PowerShell\symlinks

Mode                LastWriteTime         Length Name
----                -------------         ------ ----
d----         2019-02-03    15:37                dir
l----         2019-02-03    15:38                symdir -> D:\repos\PowerShell\symlinks\dir
l----         2019-02-03    15:39                symsubdir -> D:\repos\PowerShell\symlinks\dir\subdir\
-a---         2019-02-03    15:38              3 file
-a---         2019-02-03    15:37              3 hardlink
la---         2019-02-03    15:38              0 symfile1 -> D:\repos\PowerShell\file
PS> gci | ft -view childrenWithHardlink

    Directory: D:\repos\PowerShell\symlinks

Mode                LastWriteTime         Length Name
----                -------------         ------ ----
d----         2019-02-03    15:37                dir
l----         2019-02-03    15:38                symdir -> D:\repos\PowerShell\symlinks\dir
l----         2019-02-03    15:39                symsubdir -> D:\repos\PowerShell\symlinks\dir\subdir\
-a---         2019-02-03    15:38              3 file
la---         2019-02-03    15:37              3 hardlink
la---         2019-02-03    15:38              0 symfile1 -> D:\repos\PowerShell\file

@adityapatwardhan
Copy link
Member

@powercode I have pushed changes to convert the new xUnit tests to Pester. I also rebased to master to resolve some merge conflicts. Please have a look if I have missed something. And thank you for your patience.

}
return Platform.IsWindows
? fileInfo.Attributes.HasFlag(System.IO.FileAttributes.ReparsePoint)
: Platform.NonWindowsIsSymLink(fileInfo);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder why we use Platform.IsWindows not #if UNIX?

The only code path that used multiple return values was !CORECLR.

I removed the obsolete #ifdef-ed code.
@powercode
Copy link
Collaborator Author

I adressed @daxian-dbw's feedback.
The other changes LGTM.

@adityapatwardhan
Copy link
Member

@daxian-dbw Can you update your review?

Copy link
Member

@daxian-dbw daxian-dbw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@powercode
Copy link
Collaborator Author

@daxian-dbw You won the race!
With several seconds :)

@adityapatwardhan adityapatwardhan merged commit 9983297 into PowerShell:master Mar 12, 2019
@adityapatwardhan adityapatwardhan added CL-Engine Indicates that a PR should be marked as an engine change in the Change Log CL-General Indicates that a PR should be marked as a general cmdlet change in the Change Log and removed CL-Engine Indicates that a PR should be marked as an engine change in the Change Log labels Mar 12, 2019
@adityapatwardhan
Copy link
Member

@powercode Thanks for your contribution and patience!

@lukeb1961
Copy link

How will a normal person using Powershell, know that these FT views exist?

@iSazonov
Copy link
Collaborator

@lukeb1961 Please open a feature request (for tab completion) and/or doc isuue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CL-General Indicates that a PR should be marked as a general cmdlet change in the Change Log Committee-Reviewed PS-Committee has reviewed this and made a decision Documentation Needed in this repo Documentation is needed in this repo

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants