根据修订号获取内容文件

时间:2013-03-18 10:32:54

标签: c# perforce

我必须在内容的所有更改之后寻找文件之间的差异,以便我如何在具有相同路径和目录的同时阅读和获取内容 我必须使用它来实现一个实用程序来从代码生成统计信息

    IList<FileSpec> filesToFind = new List<FileSpec>();
filesToFind.Add( new FileSpec(FileSpec.DepotSpec(dpath).DepotPath, Revision.None));
string[] files = new string[1];
files[0] = dpath;
P4Command command = new P4Command(ps, "where", true, files);
Options opts = new Options();
string v1="", v2="", v3="";  
P4CommandResult results = command.Run(opts);
TaggedObjectList list = (results.TaggedOutput);
foreach (TaggedObject obj in list)
{
    Console.Out.WriteLine("v1=" + v1 + "hhhhhhhhh1");
    int i = 0; string v="";
    foreach (String s in obj.Keys)
    {
        String value = "n/a";
        obj.TryGetValue(s, out value);
        if (obj.Keys.ElementAt(i).Equals("depotFile"))
            v1 = value;
        if (obj.Keys.ElementAt(i).Equals("clientFile"))
            v2 = value;
        if (obj.Keys.ElementAt(i).Equals("path"))
            v3 = value;
        Console.Out.WriteLine(s + " = " + value);

        i++;
    }

    String path = v3;

    if (path==null)
    {
        Console.WriteLine("Can't' find file, {0}", path);
    }
    else
    {
        string extension = Path.GetExtension(path);
        if (extension!=null && !("".Equals(extension)))
        {
            Console.WriteLine("Processing solution file, {0}", path);

            FileInfo fi = new FileInfo(path);
            using (StreamReader sr = new StreamReader(path, true))
            {
                Encoding encode = sr.CurrentEncoding;

                string line = null;
                while ((line = sr.ReadLine()) != null)
                {
                    while (((line = sr.ReadLine()) != null) && (line.Contains("EndGlobalSection") == false))
                    {
                        Console.WriteLine(line);
                    }
                }
            }
        }
    }
}

因此,当文件被更改六次时,例如文件之间的差异

1 个答案:

答案 0 :(得分:0)

您可以使用p4注释

 GetFileAnnotationsCmdOptions gfacmo = new GetFileAnnotationsCmdOptions(GetFileAnnotationsCmdFlags.AllResults, k);