0

i have to seek difference between files after all the changes of content so how can i read and get the content while they have the same path and directory i have to use that to implement an utility to generate statistics from the code

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

so how differ between the files for exemple when a file was changed six times

Alina B.
  • 1,256
  • 8
  • 18
  • Possible duplicate: [Basic file version diff algorithm](http://stackoverflow.com/questions/5550688/basic-file-version-diff-algorithm) and [How to compare 2 files fast using .NET?](http://stackoverflow.com/questions/1358510/how-to-compare-2-files-fast-using-net) – Alina B. Mar 18 '13 at 10:39
  • thank u interessent idea –  Mar 18 '13 at 10:46
  • but the problem it is not only about the diff –  Mar 18 '13 at 11:01
  • You can't do (the equivalent of) `p4 print -q FILE@CHANGE` (or `p4 print -q FILE#REVISION`), save the output, and then diff it however you like? – jamesdlin Mar 18 '13 at 11:27
  • Also try 'p4 diff2'. It will let you compare any two versions of a file (or an entire directory). – randy-wandisco Mar 19 '13 at 14:09
  • i gave diff as example but i'm not going to operate the diff only i will do other operations –  Mar 19 '13 at 14:37

1 Answers1

0

you can use the p4 annotate

 GetFileAnnotationsCmdOptions gfacmo = new GetFileAnnotationsCmdOptions(GetFileAnnotationsCmdFlags.AllResults, k);
gasroot
  • 515
  • 3
  • 15