0

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

    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);
                    }
                }
            }
        }
    }
}

例如,当文件被更改六次时,文件之间的差异有多大

4

1 回答 1

0

你可以使用 p4 注释

 GetFileAnnotationsCmdOptions gfacmo = new GetFileAnnotationsCmdOptions(GetFileAnnotationsCmdFlags.AllResults, k);
于 2013-04-10T10:20:03.933 回答