2

ファイルのさまざまなバージョンの変更された行を確実に検出したい 私の問題は、ファイルのさまざまなバージョンを取得しようとすると、常に最新のバージョンを取得することです。どうすればさまざまなバージョンを取得できますか

String password = "*****";
String ws_client = "****";

        Repository rep;
        P4Server ps = new P4Server(conStr, user, password, ws_client);
        Server server = new Server(new ServerAddress(conStr));
        rep = new Repository(server);
        rep.Connection.UserName = user;
        Options options = new Options();

        Console.WriteLine(options.ToString());
        Client c = new Client();

        options["Password"] = password;
        rep.Connection.Client = new Client();
        rep.Connection.Connect(options);
        rep.Connection.Login(password, options);
        Console.WriteLine(rep.ToString());

      string text1="";
        string text2="";
        P4Command cmd = new P4Command(ps);
        string[]cmdargs= new string[1];
        cmdargs[0] = "";
        Console.WriteLine(cmd.ToString());
        Console.WriteLine(ps.ToString());
        Console.WriteLine(server.ToString());

        // *********************************************************************

        #region mrigla2 using filehistory class

        FileSpec filespecs = new FileSpec(FileSpec.DepotSpec("//obms/Dot-NET/Main/FixDepthSource/SLC_FDS/clsFixEventsSource.vb").DepotPath, Revision.Head);
        Options opt = new Options();
       opt.Add("-m", "");


        IList<FileHistory> filehistories = new List<FileHistory>();
        filehistories = rep.GetFileHistory(new Options(), filespecs);
        if (filehistories != null)
        {
            foreach (FileHistory fh in filehistories)
            {

                string p = fh.DepotPath.Path;

                string dpath = "//obms/Dot-NET/Main/FixDepthSource/SLC_FDS/clsFixEventsSource.vb";
                if (p==dpath)
                {
                    Console.WriteLine("Client name:" + fh.ClientName);
                    Console.WriteLine("Description:" + fh.Description);
                    Console.WriteLine("username:" + fh.UserName);
                    Console.WriteLine("Date:" + fh.Date);

                    Console.WriteLine("changelist:" + fh.ChangelistId);
                    directoriesfile.Filedirectory fsd = Program.getpaths(p, ps); 
                    Console.BackgroundColor = ConsoleColor.Red;
                    Console.WriteLine("******************revision:" + fh.Revision+"**********************");
                    if (fh.Revision == 6)
                    {  text1 = System.IO.File.ReadAllText(fsd.localPath); }

                    if (fh.Revision == 5)
                    {text2 = System.IO.File.ReadAllText(fsd.localPath); }

                    Console.BackgroundColor = ConsoleColor.Black;
                    affichcontentFile(fsd.depotPath, ps, fsd.localPath);
                    Console.WriteLine("Action:" + fh.Action);
                }





            }


        }
4

2 に答える 2

1
FileSpec fso = new FileSpec(FileSpec.DepotSpec(fsd.depotPath).DepotPath, Revision.Head);

IList<FileSpec> fsos = new List<FileSpec>();
fsos.Add(fso);

Options opts = new Options();
opts.Add("-a", "");

IList<FileAnnotation> fas = rep.GetFileAnnotations(fsos, opts);

foreach (FileAnnotation fa in fas)
{
    Console.BackgroundColor = ConsoleColor.Yellow;
    lines5+= fa.Line;
    Console.BackgroundColor = ConsoleColor.Black;
}
于 2013-03-19T09:01:56.750 に答える
1

ファイルの内容の履歴を取得するには、「p4 annotate」を使用します。

ファイルの履歴を取得するには (内容は除く)、'p4 filelog' を使用します。

ファイルの指定された 2 つのバージョン間の違いを取得するには、「p4 diff2」を使用します。

'p4 filelog' (どのバージョンがどの変更に対応するかを調べるため) と 'p4 diff2' (2 つのバージョン間の違いを計算するため) をまとめると、多くの有用な情報が得られます。

または、私がしていることを実行してください。これらのことは何もせず、P4V をインストールして、「タイム ラプス ビュー」を使用してください。これは、ファイルの履歴を簡単に調べることができる美しいビジュアル ツールです。

于 2013-03-19T01:44:02.440 に答える