Free cookie consent management tool by TermsFeed Policy Generator

source: branches/HeuristicLab.Tools/HeuristicLab.Subwcrev/HeuristicLab.Subwcrev/Program.cs @ 11250

Last change on this file since 11250 was 9234, checked in by ascheibe, 11 years ago

#2017 added tools that eyob worked on:

  • HL build center (HeuristicLab.Subversion)
  • a subwcrev replacement
  • 2 own HL apps for up- and downloading Hive jobs from HL files
File size: 2.1 KB
Line 
1using System.Collections.Generic;
2using System.IO;
3using System.Text.RegularExpressions;
4using SharpSvn;
5
6namespace HeuristicLab.Subwcrev {
7  class Program {
8
9    static void Main(string[] args) {
10      if (args.Length != 0) {
11        string path = args[0];
12        CreateFiles(path);
13      } else {
14        System.Console.WriteLine("Enter the Path..");
15      }
16    }
17
18    public static long GetRevision(string file) {
19      SvnClient client = new SvnClient();
20      SvnInfoEventArgs info;
21      client.GetInfo(file, out info);
22      return info.LastChangeRevision;     // Gets the last change revision in which node (or one of its decendent) changed.
23    }
24
25    static public void ReplaceInFile(string filePath) {
26      string file = Regex.Replace(filePath, ".cs", ".cs.frame");
27      string revNo = GetRevision(file).ToString();
28      StreamReader reader = new StreamReader(filePath);
29      string content = reader.ReadToEnd();
30      reader.Close();
31      content = Regex.Replace(content, @"\$WCREV\$", revNo);
32      StreamWriter writer = new StreamWriter(filePath);
33      writer.Write(content);
34      writer.Close();
35    }
36
37    static public void CreateFiles(string path) {
38      string[] pluginFiles = Directory.GetFiles(path, @"*Plugin.cs.frame", SearchOption.AllDirectories);
39      string[] assemblyInfoFiles = Directory.GetFiles(path, @"*AssemblyInfo.cs.frame", SearchOption.AllDirectories);
40      List<string> Files = new List<string>();
41      Files.AddRange(pluginFiles);
42      Files.AddRange(assemblyInfoFiles);
43      List<string> allFiles = new List<string>();
44
45      foreach (string files in Files) {
46        string file = Regex.Replace(files, ".cs.frame", ".cs");          //convert all ".frame" files into ".cs"
47        if (!File.Exists(file)) {
48          using (SvnClient client = new SvnClient())
49          using (Stream to = File.Create(file)) {
50            client.Write(new SvnPathTarget(files, SvnRevision.Base), to);
51          }
52          ReplaceInFile(file);                            //to replace $WCREV$ with revision number.
53        }
54      }
55    }
56
57
58  }
59}
Note: See TracBrowser for help on using the repository browser.