//private P4.Label _labelToAdd = null; public static List <P4.FileSpec> Show(IList <string> paths, string specifier, string value, P4ScmProvider scm) { List <P4.FileSpec> files = new List <P4.FileSpec>(); DiffDlg dlg = null; try { dlg = new DiffDlg(paths, specifier, value, scm); } catch { return(null); } if (dlg.ShowDialog() != DialogResult.Cancel) { if (dlg.DialogResult == DialogResult.OK) { // get the strings to diff string path1 = dlg.path1TB.Text; string path2 = dlg.path2TB.Text; // create the 2 filespecs P4.FileSpec spec1 = new P4.FileSpec(); P4.FileSpec spec2 = new P4.FileSpec(); if (path1.StartsWith("//")) { spec1.DepotPath = new P4.DepotPath(path1); } else { spec1.LocalPath = new P4.LocalPath(path1); } if (path2.StartsWith("//")) { spec2.DepotPath = new P4.DepotPath(path2); } else { spec2.LocalPath = new P4.LocalPath(path2); } // build spec one if (dlg.specifier1stRB.Checked == true) { // #revision if (dlg.specifier1stCB.SelectedIndex == 0) { if (dlg.path1ValueTB.Text == string.Empty) { spec1.Version = null; } else { try { int rev1 = Convert.ToInt32(dlg.path1ValueTB.Text); spec1.Version = new P4.Revision(rev1); } catch (Exception) { MessageBox.Show(string.Format(Resources.DiffDlg_InvalidRevisionSpecifier, dlg.path1ValueTB.Text), Resources.PerforceSCM, MessageBoxButtons.OK); Show(paths, specifier, value, scm); return(files); } } } // @workspace if (dlg.specifier1stCB.SelectedIndex == 4) { if (dlg.path1ValueTB.Text == string.Empty) { spec1.Version = null; } else { string ws1 = dlg.path1ValueTB.Text; spec1.Version = new P4.ClientNameVersion(ws1); } } // @date/time if (dlg.specifier1stCB.SelectedIndex == 2) { DateTime dt1 = dlg.path1dateTimePicker.Value; spec1.Version = new P4.DateTimeVersion(dt1); } // @changelist if (dlg.specifier1stCB.SelectedIndex == 1) { if (dlg.path1ValueTB.Text == string.Empty) { spec1.Version = null; } else { try { int cl1 = Convert.ToInt32(dlg.path1ValueTB.Text); spec1.Version = new P4.ChangelistIdVersion(cl1); } catch (Exception) { MessageBox.Show(string.Format(Resources.DiffDlg_InvalidChangelistSpecifier, dlg.path1ValueTB.Text), Resources.PerforceSCM, MessageBoxButtons.OK); Show(paths, specifier, value, scm); return(files); } } } // @label if (dlg.specifier1stCB.SelectedIndex == 3) { if (dlg.path1ValueTB.Text == string.Empty) { spec1.Version = null; } else { string lb1 = dlg.path1ValueTB.Text; spec1.Version = new P4.LabelNameVersion(lb1); } } } if (dlg.workspace1stRB.Checked == true) { // if diffing with local path, get that from the file metadata // and null out the spec's depot path if (spec1.DepotPath != null) { P4.FileMetaData fmd = scm.GetFileMetaData(spec1.DepotPath.Path); if (fmd != null) { spec1.LocalPath = fmd.LocalPath; spec1.DepotPath = null; } } } if (dlg.latest1stRB.Checked == true) { spec1.Version = new P4.HeadRevision(); } if (dlg.have1stRB.Checked == true) { spec1.Version = new P4.HaveRevision(); } // build spec 2 if (dlg.specifier2ndRB.Checked == true) { // #revision if (dlg.specifier2ndCB.SelectedIndex == 0) { if (dlg.path2ValueTB.Text == string.Empty) { spec2.Version = null; } else { try { int rev2 = Convert.ToInt32(dlg.path2ValueTB.Text); spec2.Version = new P4.Revision(rev2); } catch (Exception) { MessageBox.Show(string.Format(Resources.DiffDlg_InvalidRevisionSpecifier, dlg.path1ValueTB.Text), Resources.PerforceSCM, MessageBoxButtons.OK); Show(paths, specifier, value, scm); return(files); } } } // @workspace if (dlg.specifier2ndCB.SelectedIndex == 4) { if (dlg.path2ValueTB.Text == string.Empty) { spec2.Version = null; } else { string ws2 = dlg.path2ValueTB.Text; spec2.Version = new P4.ClientNameVersion(ws2); } } // @date/time if (dlg.specifier2ndCB.SelectedIndex == 2) { DateTime dt2 = dlg.path2dateTimePicker.Value; spec2.Version = new P4.DateTimeVersion(dt2); } // @changelist if (dlg.specifier2ndCB.SelectedIndex == 1) { if (dlg.path2ValueTB.Text == string.Empty) { spec2.Version = null; } else { try { int cl2 = Convert.ToInt32(dlg.path2ValueTB.Text); spec2.Version = new P4.ChangelistIdVersion(cl2); } catch (Exception) { MessageBox.Show(string.Format(Resources.DiffDlg_InvalidChangelistSpecifier, dlg.path1ValueTB.Text), Resources.PerforceSCM, MessageBoxButtons.OK); Show(paths, specifier, value, scm); return(files); } } } // @label if (dlg.specifier2ndCB.SelectedIndex == 3) { if (dlg.path2ValueTB.Text == string.Empty) { spec2.Version = null; } else { string lb2 = dlg.path2ValueTB.Text; spec2.Version = new P4.LabelNameVersion(lb2); } } } if (dlg.workspace2ndRB.Checked == true) { // if diffing with local path, get that from the file metadata // and null out the spec's depot path if (spec2.DepotPath != null) { P4.FileMetaData fmd = scm.GetFileMetaData(spec2.DepotPath.Path); if (fmd != null) { spec2.LocalPath = fmd.LocalPath; spec2.DepotPath = null; } } } if (dlg.latest2ndRB.Checked == true) { spec2.Version = new P4.HeadRevision(); } if (dlg.have2ndRB.Checked == true) { spec2.Version = new P4.HaveRevision(); } files.Add(spec1); files.Add(spec2); IList <P4.FileMetaData> checkForValid = scm.GetFileMetaData(files, null); if (checkForValid == null || (checkForValid != null && checkForValid.Count < 2)) { if (scm.Connection.Repository.Connection.LastResults.ErrorList != null) { P4.P4ClientErrorList invalid = scm.Connection.Repository.Connection.LastResults.ErrorList; string message = string.Empty; foreach (P4ClientError error in invalid) { message = message + error.ErrorMessage; } MessageBox.Show(message); Show(paths, specifier, value, scm); return(files); } } if (files != null) { scm.Diff2Files(files); } return(files); } } return(null); }