Skip to content

Commit

Permalink
Merge pull request #1385 [Release] Milestone M155
Browse files Browse the repository at this point in the history
[Release] Milestone M155
  • Loading branch information
wilbaker authored Jul 31, 2019
2 parents a3e55e2 + 8f26970 commit 4558f66
Show file tree
Hide file tree
Showing 207 changed files with 5,371 additions and 1,303 deletions.
22 changes: 12 additions & 10 deletions GVFS/FastFetch/CheckoutStage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ protected override void DoWork()
Keywords.Telemetry,
metadata: null))
{
Parallel.For(1, this.maxParallel, (i) => { this.HandleAllFileDeleteOperations(); });
Parallel.For(0, this.maxParallel, (i) => { this.HandleAllFileDeleteOperations(); });
EventMetadata metadata = new EventMetadata();
metadata.Add("FilesDeleted", this.fileDeleteCount);
activity.Stop(metadata);
Expand All @@ -104,7 +104,7 @@ protected override void DoWork()
Keywords.Telemetry,
metadata: null))
{
Parallel.For(1, this.maxParallel, (i) => { this.HandleAllDirectoryOperations(); });
Parallel.For(0, this.maxParallel, (i) => { this.HandleAllDirectoryOperations(); });
EventMetadata metadata = new EventMetadata();
metadata.Add("DirectoryOperationsCompleted", this.directoryOpCount);
activity.Stop(metadata);
Expand All @@ -117,7 +117,7 @@ protected override void DoWork()
Keywords.Telemetry,
metadata: null))
{
Parallel.For(1, this.maxParallel, (i) => { this.HandleAllFileAddOperations(); });
Parallel.For(0, this.maxParallel, (i) => { this.HandleAllFileAddOperations(); });
EventMetadata metadata = new EventMetadata();
metadata.Add("FilesWritten", this.fileWriteCount);
activity.Stop(metadata);
Expand Down Expand Up @@ -160,6 +160,8 @@ private void HandleAllDirectoryOperations()
DiffTreeResult treeOp;
while (this.diff.DirectoryOperations.TryDequeue(out treeOp))
{
string absoluteTargetPath = Path.Combine(this.enlistment.WorkingDirectoryBackingRoot, treeOp.TargetPath);

if (this.HasFailures)
{
return;
Expand All @@ -171,13 +173,13 @@ private void HandleAllDirectoryOperations()
case DiffTreeResult.Operations.Add:
try
{
Directory.CreateDirectory(treeOp.TargetPath);
Directory.CreateDirectory(absoluteTargetPath);
}
catch (Exception ex)
{
EventMetadata metadata = new EventMetadata();
metadata.Add("Operation", "CreateDirectory");
metadata.Add(nameof(treeOp.TargetPath), treeOp.TargetPath);
metadata.Add(nameof(treeOp.TargetPath), absoluteTargetPath);
this.tracer.RelatedError(metadata, ex.Message);
this.HasFailures = true;
}
Expand All @@ -186,27 +188,27 @@ private void HandleAllDirectoryOperations()
case DiffTreeResult.Operations.Delete:
try
{
if (Directory.Exists(treeOp.TargetPath))
if (Directory.Exists(absoluteTargetPath))
{
this.fileSystem.DeleteDirectory(treeOp.TargetPath);
this.fileSystem.DeleteDirectory(absoluteTargetPath);
}
}
catch (Exception ex)
{
// We are deleting directories and subdirectories in parallel
if (Directory.Exists(treeOp.TargetPath))
if (Directory.Exists(absoluteTargetPath))
{
EventMetadata metadata = new EventMetadata();
metadata.Add("Operation", "DeleteDirectory");
metadata.Add(nameof(treeOp.TargetPath), treeOp.TargetPath);
metadata.Add(nameof(treeOp.TargetPath), absoluteTargetPath);
this.tracer.RelatedError(metadata, ex.Message);
this.HasFailures = true;
}
}

break;
default:
this.tracer.RelatedError("Ignoring unexpected Tree Operation {0}: {1}", treeOp.TargetPath, treeOp.Operation);
this.tracer.RelatedError("Ignoring unexpected Tree Operation {0}: {1}", absoluteTargetPath, treeOp.Operation);
continue;
}

Expand Down
2 changes: 1 addition & 1 deletion GVFS/FastFetch/Index.cs
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ private bool UpdateFileInformationFromDiskForFiles(MemoryMappedViewAccessor inde
addedOrEditedLocalFiles,
(localPath) =>
{
string gitPath = FromDotnetFullPathToGitRelativePath(localPath, this.repoRoot);
string gitPath = localPath.Replace(Path.DirectorySeparatorChar, GVFSConstants.GitPathSeparator);
long offset;
if (this.indexEntryOffsets.TryGetValue(gitPath, out offset))
{
Expand Down
2 changes: 1 addition & 1 deletion GVFS/GVFS.Build/GVFS.props
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

<PropertyGroup Label="Parameters">
<GVFSVersion>0.2.173.2</GVFSVersion>
<GitPackageVersion>2.20190610.5</GitPackageVersion>
<GitPackageVersion>2.20190729.1</GitPackageVersion>
</PropertyGroup>

<PropertyGroup Label="DefaultSettings">
Expand Down
1 change: 0 additions & 1 deletion GVFS/GVFS.Common/FileSystem/IPlatformFileSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ public interface IPlatformFileSystem
bool SupportsFileMode { get; }
void FlushFileBuffers(string path);
void MoveAndOverwriteFile(string sourceFileName, string destinationFilename);
void CreateHardLink(string newLinkFileName, string existingFileName);
bool TryGetNormalizedPath(string path, out string normalizedPath, out string errorMessage);
void ChangeMode(string path, ushort mode);
bool HydrateFile(string fileName, byte[] buffer);
Expand Down
15 changes: 14 additions & 1 deletion GVFS/GVFS.Common/GVFSLock.cs
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,8 @@ public class ActiveGitCommandStats
private long placeholderUpdateFoldersTimeMs;
private long placeholderWriteAndFlushTimeMs;
private int deleteFolderPlacehoderAttempted;
private int folderPlaceholdersDeleted;
private int folderPlaceholdersPathNotFound;
private long parseGitIndexTimeMs;
private long projectionWriteLockHeldMs;

Expand All @@ -290,13 +292,22 @@ public void RecordReleaseExternalLockRequested()
this.lockHeldExternallyTimeMs = this.lockAcquiredTime.ElapsedMilliseconds;
}

public void RecordUpdatePlaceholders(long durationMs, long updateFilesMs, long updateFoldersMs, long writeAndFlushMs, int deleteFolderPlacehoderAttempted)
public void RecordUpdatePlaceholders(
long durationMs,
long updateFilesMs,
long updateFoldersMs,
long writeAndFlushMs,
int deleteFolderPlacehoderAttempted,
int folderPlaceholdersDeleted,
int folderPlaceholdersPathNotFound)
{
this.placeholderTotalUpdateTimeMs = durationMs;
this.placeholderUpdateFilesTimeMs = updateFilesMs;
this.placeholderUpdateFoldersTimeMs = updateFoldersMs;
this.placeholderWriteAndFlushTimeMs = writeAndFlushMs;
this.deleteFolderPlacehoderAttempted = deleteFolderPlacehoderAttempted;
this.folderPlaceholdersDeleted = folderPlaceholdersDeleted;
this.folderPlaceholdersPathNotFound = folderPlaceholdersPathNotFound;
}

public void RecordProjectionWriteLockHeld(long durationMs)
Expand Down Expand Up @@ -338,6 +349,8 @@ public void AddStatsToTelemetry(EventMetadata metadata)
metadata.Add("UpdateFilePlaceholdersMS", this.placeholderUpdateFilesTimeMs);
metadata.Add("UpdateFolderPlaceholdersMS", this.placeholderUpdateFoldersTimeMs);
metadata.Add("DeleteFolderPlacehoderAttempted", this.deleteFolderPlacehoderAttempted);
metadata.Add("FolderPlaceholdersDeleted", this.folderPlaceholdersDeleted);
metadata.Add("FolderPlaceholdersPathNotFound", this.folderPlaceholdersPathNotFound);
metadata.Add("PlaceholdersWriteAndFlushMS", this.placeholderWriteAndFlushTimeMs);
metadata.Add("ProjectionWriteLockHeldMs", this.projectionWriteLockHeldMs);

Expand Down
48 changes: 48 additions & 0 deletions GVFS/GVFS.Common/GVFSPlatform.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ public GVFSPlatform(UnderConstructionFlags underConstruction)
public UnderConstructionFlags UnderConstruction { get; }
public abstract string Name { get; }

public abstract string GVFSConfigPath { get; }

public static void Register(GVFSPlatform platform)
{
if (GVFSPlatform.Instance != null)
Expand Down Expand Up @@ -70,6 +72,27 @@ public static void Register(GVFSPlatform platform)
public abstract bool IsElevated();
public abstract string GetCurrentUser();
public abstract string GetUserIdFromLoginSessionId(int sessionId, ITracer tracer);

/// <summary>
/// Get the directory for upgrades that is permissioned to
/// require elevated privileges to modify. This can be used for
/// data that we don't want normal user accounts to modify.
/// </summary>
public abstract string GetUpgradeProtectedDataDirectory();

/// <summary>
/// Directory that upgrader log directory should be placed
/// in. There can be multiple log directories, so this is the
/// containing directory to place them in.
/// </summary>
public abstract string GetUpgradeLogDirectoryParentDirectory();

/// <summary>
/// Directory that contains the file indicating that a new
/// version is available.
/// </summary>
public abstract string GetUpgradeHighestAvailableVersionDirectory();

public abstract void ConfigureVisualStudio(string gitBinPath, ITracer tracer);

public abstract bool TryGetGVFSHooksPathAndVersion(out string hooksPaths, out string hooksVersion, out string error);
Expand All @@ -93,6 +116,10 @@ public abstract FileBasedLock CreateFileBasedLock(
ITracer tracer,
string lockPath);

public abstract ProductUpgraderPlatformStrategy CreateProductUpgraderPlatformInteractions(
PhysicalFileSystem fileSystem,
ITracer tracer);

public bool TryGetNormalizedPathRoot(string path, out string pathRoot, out string errorMessage)
{
pathRoot = null;
Expand All @@ -111,8 +138,15 @@ public bool TryGetNormalizedPathRoot(string path, out string pathRoot, out strin
public abstract class GVFSPlatformConstants
{
public static readonly char PathSeparator = Path.DirectorySeparatorChar;
public abstract int MaxPipePathLength { get; }
public abstract string ExecutableExtension { get; }
public abstract string InstallerExtension { get; }

/// <summary>
/// Indicates whether the platform supports running the upgrade application while
/// the upgrade verb is running.
/// </summary>
public abstract bool SupportsUpgradeWhileRunning { get; }
public abstract string WorkingDirectoryBackingRootPath { get; }
public abstract string DotGVFSRoot { get; }

Expand All @@ -122,6 +156,20 @@ public abstract class GVFSPlatformConstants

public abstract string GVFSExecutableName { get; }

public abstract string ProgramLocaterCommand { get; }

/// <summary>
/// Different platforms can have different requirements
/// around which processes can block upgrade. For example,
/// on Windows, we will block upgrade if any GVFS commands
/// are running, but on POSIX platforms, we relax this
/// constraint to allow upgrade to run while the upgrade
/// command is running. Another example is that
/// Non-windows platforms do not block upgrade when bash
/// is running.
/// </summary>
public abstract HashSet<string> UpgradeBlockingProcesses { get; }

public string GVFSHooksExecutableName
{
get { return "GVFS.Hooks" + this.ExecutableExtension; }
Expand Down
17 changes: 8 additions & 9 deletions GVFS/GVFS.Common/Git/DiffTreeResult.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public enum Operations
public ushort SourceMode { get; set; }
public ushort TargetMode { get; set; }

public static DiffTreeResult ParseFromDiffTreeLine(string line, string repoRoot)
public static DiffTreeResult ParseFromDiffTreeLine(string line)
{
if (string.IsNullOrEmpty(line))
{
Expand Down Expand Up @@ -100,7 +100,7 @@ public static DiffTreeResult ParseFromDiffTreeLine(string line, string repoRoot)
result.SourceSha = parts[2];
result.TargetSha = parts[3];
result.Operation = DiffTreeResult.ParseOperation(parts[4]);
result.TargetPath = ConvertPathToAbsoluteUtf8Path(repoRoot, parts[5]);
result.TargetPath = ConvertPathToUtf8Path(parts[5]);
if (result.TargetIsDirectory || result.SourceIsDirectory)
{
// Since diff-tree is not doing rename detection, file->directory or directory->file transformations are always multiple lines
Expand All @@ -118,7 +118,6 @@ public static DiffTreeResult ParseFromDiffTreeLine(string line, string repoRoot)
/// Parse the output of calling git ls-tree
/// </summary>
/// <param name="line">A line that was output from calling git ls-tree</param>
/// <param name="repoRoot">The root path of the repo that the git ls-tree was ran against</param>
/// <returns>A DiffTreeResult build from the output line</returns>
/// <remarks>
/// The call to ls-tree could be any of the following
Expand All @@ -127,7 +126,7 @@ public static DiffTreeResult ParseFromDiffTreeLine(string line, string repoRoot)
/// git ls-tree -t (treeish)
/// git ls-tree -r -t (treeish)
/// </remarks>
public static DiffTreeResult ParseFromLsTreeLine(string line, string repoRoot)
public static DiffTreeResult ParseFromLsTreeLine(string line)
{
if (string.IsNullOrEmpty(line))
{
Expand All @@ -149,7 +148,7 @@ public static DiffTreeResult ParseFromLsTreeLine(string line, string repoRoot)
{
DiffTreeResult treeAdd = new DiffTreeResult();
treeAdd.TargetIsDirectory = true;
treeAdd.TargetPath = AppendPathSeparatorIfNeeded(ConvertPathToAbsoluteUtf8Path(repoRoot, line.Substring(line.LastIndexOf("\t") + 1)));
treeAdd.TargetPath = AppendPathSeparatorIfNeeded(ConvertPathToUtf8Path(line.Substring(line.LastIndexOf("\t") + 1)));
treeAdd.Operation = DiffTreeResult.Operations.Add;

return treeAdd;
Expand All @@ -162,7 +161,7 @@ public static DiffTreeResult ParseFromLsTreeLine(string line, string repoRoot)
blobAdd.TargetMode = Convert.ToUInt16(line.Substring(0, 6), 8);
blobAdd.TargetIsSymLink = blobAdd.TargetMode == SymLinkFileIndexEntry;
blobAdd.TargetSha = line.Substring(TypeMarkerStartIndex + BlobMarker.Length, GVFSConstants.ShaStringLength);
blobAdd.TargetPath = ConvertPathToAbsoluteUtf8Path(repoRoot, line.Substring(line.LastIndexOf("\t") + 1));
blobAdd.TargetPath = ConvertPathToUtf8Path(line.Substring(line.LastIndexOf("\t") + 1));
blobAdd.Operation = DiffTreeResult.Operations.Add;

return blobAdd;
Expand Down Expand Up @@ -213,9 +212,9 @@ private static Operations ParseOperation(string gitOperationString)
}
}

private static string ConvertPathToAbsoluteUtf8Path(string repoRoot, string relativePath)
private static string ConvertPathToUtf8Path(string relativePath)
{
return Path.Combine(repoRoot, GitPathConverter.ConvertPathOctetsToUtf8(relativePath.Trim('"')).Replace(GVFSConstants.GitPathSeparator, Path.DirectorySeparatorChar));
return GitPathConverter.ConvertPathOctetsToUtf8(relativePath.Trim('"')).Replace(GVFSConstants.GitPathSeparator, Path.DirectorySeparatorChar);
}
}
}
}
Loading

0 comments on commit 4558f66

Please sign in to comment.