private static bool FilterSyncOutput(PerforceOutputLine Line, PerforceTagRecordParser Parser, List <string> TamperedFiles, TextWriter Log) { if (Line.Channel == PerforceOutputChannel.TaggedInfo) { Parser.OutputLine(Line.Text); return(true); } Log.WriteLine(Line.Text); const string Prefix = "Can't clobber writable file "; if (Line.Channel == PerforceOutputChannel.Error && Line.Text.StartsWith(Prefix)) { TamperedFiles.Add(Line.Text.Substring(Prefix.Length).Trim()); return(true); } return(Line.Channel != PerforceOutputChannel.Error); }
public bool Sync(List <string> DepotPaths, int ChangeNumber, Action <PerforceFileRecord> SyncOutput, List <string> TamperedFiles, TextWriter Log) { // Write all the files we want to sync to a temp file string TempFileName = Path.GetTempFileName(); using (StreamWriter Writer = new StreamWriter(TempFileName)) { foreach (string DepotPath in DepotPaths) { Writer.WriteLine("{0}@{1}", DepotPath, ChangeNumber); } } // Create a filter to strip all the sync records bool bResult; using (PerforceTagRecordParser Parser = new PerforceTagRecordParser(x => SyncOutput(new PerforceFileRecord(x)))) { bResult = RunCommand(String.Format("-x \"{0}\" -z tag sync", TempFileName), null, Line => FilterSyncOutput(Line, Parser, TamperedFiles, Log), CommandOptions.NoFailOnErrors | CommandOptions.IgnoreFilesUpToDateError | CommandOptions.IgnoreExitCode, Log); } return(bResult); }
private bool RunCommand(string CommandLine, out List <Dictionary <string, string> > TagRecords, CommandOptions Options, TextWriter Log) { List <string> Lines; if (!RunCommand("-ztag " + CommandLine, PerforceOutputChannel.TaggedInfo, out Lines, Options, Log)) { TagRecords = null; return(false); } List <Dictionary <string, string> > LocalOutput = new List <Dictionary <string, string> >(); using (PerforceTagRecordParser Parser = new PerforceTagRecordParser(Record => LocalOutput.Add(Record))) { foreach (string Line in Lines) { Parser.OutputLine(Line); } } TagRecords = LocalOutput; return(true); }
public bool Sync(List <string> DepotPaths, int ChangeNumber, Action <PerforceFileRecord> SyncOutput, List <string> TamperedFiles, PerforceSyncOptions Options, TextWriter Log) { // Write all the files we want to sync to a temp file string TempFileName = Path.GetTempFileName(); using (StreamWriter Writer = new StreamWriter(TempFileName)) { foreach (string DepotPath in DepotPaths) { Writer.WriteLine("{0}@{1}", DepotPath, ChangeNumber); } } // Create a filter to strip all the sync records bool bResult; using (PerforceTagRecordParser Parser = new PerforceTagRecordParser(x => SyncOutput(new PerforceFileRecord(x)))) { StringBuilder CommandLine = new StringBuilder(); CommandLine.AppendFormat("-x \"{0}\" -z tag", TempFileName); if (Options != null && Options.NumRetries > 0) { CommandLine.AppendFormat(" -r {0}", Options.NumRetries); } if (Options != null && Options.TcpBufferSize > 0) { CommandLine.AppendFormat(" -v net.tcpsize={0}", Options.TcpBufferSize); } CommandLine.Append(" sync"); if (Options != null && Options.NumThreads > 1) { CommandLine.AppendFormat(" --parallel=threads={0}", Options.NumThreads); } bResult = RunCommand(CommandLine.ToString(), null, Line => FilterSyncOutput(Line, Parser, TamperedFiles, Log), CommandOptions.NoFailOnErrors | CommandOptions.IgnoreFilesUpToDateError | CommandOptions.IgnoreExitCode, Log); } return(bResult); }
private bool RunCommand(string CommandLine, out List<Dictionary<string, string>> TagRecords, CommandOptions Options, TextWriter Log) { List<string> Lines; if(!RunCommand("-ztag " + CommandLine, PerforceOutputChannel.TaggedInfo, out Lines, Options, Log)) { TagRecords = null; return false; } List<Dictionary<string, string>> LocalOutput = new List<Dictionary<string, string>>(); using(PerforceTagRecordParser Parser = new PerforceTagRecordParser(Record => LocalOutput.Add(Record))) { foreach(string Line in Lines) { Parser.OutputLine(Line); } } TagRecords = LocalOutput; return true; }
private static bool FilterSyncOutput(PerforceOutputLine Line, PerforceTagRecordParser Parser, List<string> TamperedFiles, TextWriter Log) { if(Line.Channel == PerforceOutputChannel.TaggedInfo) { Parser.OutputLine(Line.Text); return true; } Log.WriteLine(Line.Text); const string Prefix = "Can't clobber writable file "; if(Line.Channel == PerforceOutputChannel.Error && Line.Text.StartsWith(Prefix)) { TamperedFiles.Add(Line.Text.Substring(Prefix.Length).Trim()); return true; } return Line.Channel != PerforceOutputChannel.Error; }
public bool Sync(List<string> DepotPaths, int ChangeNumber, Action<PerforceFileRecord> SyncOutput, List<string> TamperedFiles, TextWriter Log) { // Write all the files we want to sync to a temp file string TempFileName = Path.GetTempFileName(); using(StreamWriter Writer = new StreamWriter(TempFileName)) { foreach(string DepotPath in DepotPaths) { Writer.WriteLine("{0}@{1}", DepotPath, ChangeNumber); } } // Create a filter to strip all the sync records bool bResult; using(PerforceTagRecordParser Parser = new PerforceTagRecordParser(x => SyncOutput(new PerforceFileRecord(x)))) { bResult = RunCommand(String.Format("-x \"{0}\" -z tag sync", TempFileName), null, Line => FilterSyncOutput(Line, Parser, TamperedFiles, Log), CommandOptions.NoFailOnErrors | CommandOptions.IgnoreFilesUpToDateError | CommandOptions.IgnoreExitCode, Log); } return bResult; }