Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace Platform.IsMono with actual OS checks #356

Merged
merged 5 commits into from
Nov 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/Chorus/UI/Sync/SyncStartModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ internal bool GetUsbStatusLink(IUsbDriveLocator usbDriveLocator, out string mess
try
{
var first = usbDrives[0];
if (!Platform.IsMono)
if (Platform.IsWindows)
{
message = string.Format(LocalizationManager.GetString(
"GetUsbStatus.DriveInfoAndFreeSpace",
Expand Down
19 changes: 12 additions & 7 deletions src/LibChorus/FileTypeHandlers/text/TextFileTypeHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ namespace Chorus.FileTypeHandlers.text
[Export(typeof(IChorusFileTypeHandler))]
public class TextFileTypeHandler : IChorusFileTypeHandler
{
//NB: there is a post-build step in this project which copies the diff3 folder into the output on Windows
private static string _diff3Exe = Platform.IsWindows ? "diff3/bin/diff3.exe" : "diff3";
internal TextFileTypeHandler()
{}

Expand Down Expand Up @@ -64,14 +66,18 @@ public static string GetRawMerge(string oursPath, string commonPath, string thei
{
//NB: surrounding with quotes didn't cut it to get past paths with spaces

return RunProcess("diff3/bin/diff3.exe", "-m " + LongToShortConverter.GetShortPath(oursPath) + " " +
LongToShortConverter.GetShortPath(commonPath) + " " +
LongToShortConverter.GetShortPath(theirPath));
return RunProcess(_diff3Exe, "-m" + QuoteIfNeeded(LongToShortConverter.GetShortPath(oursPath))
+ " " + QuoteIfNeeded(LongToShortConverter.GetShortPath(commonPath))
+ " " + QuoteIfNeeded(LongToShortConverter.GetShortPath(theirPath)));
}

protected static string SurroundWithQuotes(string path)
protected static string QuoteIfNeeded(string arg)
{
return "\"" + path + "\"";
if (arg.Contains(" ")) {
return "\"" + arg.Replace("\"", "\\\"") + "\"";
} else {
return arg;
}
}

public static string RunProcess(string filePath, string arguments)
Expand All @@ -81,7 +87,6 @@ public static string RunProcess(string filePath, string arguments)
p.StartInfo.RedirectStandardError = true;
p.StartInfo.RedirectStandardOutput = true;

//NB: there is a post-build step in this project which copies the diff3 folder into the output
p.StartInfo.FileName = filePath;
p.StartInfo.Arguments = arguments;
p.StartInfo.CreateNoWindow = true;
Expand Down Expand Up @@ -154,7 +159,7 @@ private static extern int GetShortPathName(

public static string GetShortPath(string path)
{
if (Platform.IsMono)
if (!Platform.IsWindows)
return path;

var shortPath = new StringBuilder(255);
Expand Down
2 changes: 1 addition & 1 deletion src/LibChorus/VcsDrivers/Mercurial/HgRepository.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1138,7 +1138,7 @@ public List<Revision> GetRevisionsFromQueryResultText(string queryResultText)
switch (label)
{
default:
if (Platform.IsMono)
if (Platform.IsLinux)
infiniteLoopChecker++;
break;
case "changeset":
Expand Down
3 changes: 2 additions & 1 deletion src/LibChorus/merge/text/PartialTextMerger.cs
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,8 @@ public static string GetRawMerge(string oursPath, string commonPath, string thei
p.StartInfo.RedirectStandardOutput = true;

//NB: there is a post-build step in this project which copies the diff3 folder into the output
p.StartInfo.FileName = "diff3/bin/diff3.exe";
var filename = File.Exists("diff3/bin/diff3.exe") ? "diff3/bin/diff3.exe" : "diff3"; // On Linux, just use diff3 from the PATH
p.StartInfo.FileName = filename;
p.StartInfo.Arguments = "-m " + oursPath + " "+commonPath+" "+theirPath;
p.StartInfo.CreateNoWindow = true;
p.Start();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public void Dispose()
private static void UpdateExtensions()
{
var extensions = new Dictionary<string, string>();
if (!Platform.IsMono)
if (Platform.IsWindows)
extensions.Add("eol", ""); //for converting line endings on windows machines
extensions.Add("hgext.graphlog", ""); //for more easily readable diagnostic logs
extensions.Add("convert", ""); //for catastrophic repair in case of repo corruption
Expand Down
Loading