Example #1
0
 private void AddFile(P4.FileMetaData file)
 {
     lock (cache)
     {
         if (file.LocalPath != null)
         {
             cache[GetKey(file.LocalPath.Path)] = new CachedFile(file);
             logger.Trace("Adding2: {0}", file.LocalPath.Path);
         }
     }
 }
Example #2
0
        public P4FileTreeListViewItem(TreeListViewItem parentItem, P4.FileMetaData fileData, IList <object> fields)
            : base()
        {
            ParentItem = parentItem;
            Fields     = fields;
            FileData   = fileData;

            Tag = fileData;

            //FileName = fileData.LocalPath.GetFileName();
            //FileFolder = fileData.LocalPath.GetFileName();
        }
Example #3
0
 private void TLVToolStripMenuItem_Click(object sender, EventArgs e)
 {
     if (FileListLV.SelectedItems != null)
     {
         TreeListViewItem selected = FileListLV.SelectedItems[0] as TreeListViewItem;
         if (selected != null)
         {
             P4.FileMetaData fmd = (P4.FileMetaData)selected.Tag;
             _scm.SccService.ScmProvider.LaunchTimeLapseView(fmd.DepotPath.Path);
         }
     }
 }
Example #4
0
        public P4FileTreeListViewItem(TreeListViewItem parentItem, string path, P4.FileMetaData fileData)
            : base()
        {
            _fileData  = null; //fileData;
            ParentItem = parentItem;
            Fields     = null;
            Tag        = fileData;

            ImageIndex = (int)CenterImages.Portrait;
            AddSubitem(path, 0);

            this.FullLine = true;
        }
Example #5
0
 private void historyToolStripMenuItem_Click(object sender, EventArgs e)
 {
     if (FileListLV.SelectedItems != null)
     {
         TreeListViewItem selected = FileListLV.SelectedItems[0] as TreeListViewItem;
         if (selected != null)
         {
             P4.FileMetaData fmd   = (P4.FileMetaData)selected.Tag;
             IList <string>  files = new List <string>();
             files.Add(fmd.DepotPath.Path);
             _scm.SccService._P4VsProvider.P4VsViewHistoryToolWindowExt(files);
         }
     }
 }
Example #6
0
        private void changelistContextMenuStrip_Opening(object sender, CancelEventArgs e)
        {
            if (FileListLV.SelectedItems == null)
            {
                e.Cancel = true;
            }
            TreeListViewItem selected = FileListLV.SelectedItems[0] as TreeListViewItem;

            if (selected != null)
            {
                P4.FileMetaData fmd = (P4.FileMetaData)selected.Tag;
                diffToolStripMenuItem.Visible = fmd.HeadRev != 1;
            }
        }
Example #7
0
 private void fixesContextMenuStrip_Opening(object sender, CancelEventArgs e)
 {
     // check to confirm that an item is selected
     if (fixesLV.SelectedItems != null && fixesLV.SelectedItems.Count > 0)
     {
         // check here to confirm that a changelist is the selected item
         P4FileTreeListViewItem selected = fixesLV.SelectedItems[0] as P4FileTreeListViewItem;
         P4.FileMetaData        file     = selected.FileData;
         if (selected.ParentItem == null)
         {
             P4.Changelist fix = selected.Tag as P4.Changelist;
             if (fix != null && fix.Jobs != null && fix.Jobs.ContainsKey(currentJob.Id))
             {
                 removeFixToolStripMenuItem.Enabled           = true;
                 removeFixToolStripMenuItem.Visible           = true;
                 diffAgainstPreviousToolStripMenuItem.Enabled = false;
                 diffAgainstPreviousToolStripMenuItem.Visible = false;
             }
             else
             {
                 e.Cancel = true;
             }
         }
         else if (file != null && file.HeadRev > 1)
         {
             diffAgainstPreviousToolStripMenuItem.Enabled = true;
             diffAgainstPreviousToolStripMenuItem.Visible = true;
             removeFixToolStripMenuItem.Enabled           = false;
             removeFixToolStripMenuItem.Visible           = false;
         }
         else
         {
             e.Cancel = true;
         }
     }
     else
     {
         e.Cancel = true;
     }
 }
Example #8
0
 private void diffAgainstPreviousToolStripMenuItem_Click(object sender, EventArgs e)
 {
     if (fixesLV.SelectedItems != null && fixesLV.SelectedItems.Count > 0)
     {
         TreeListViewItem selected = fixesLV.SelectedItems[0] as TreeListViewItem;
         if (selected != null)
         {
             P4.FileMetaData fmd  = (P4.FileMetaData)selected.Tag;
             P4.FileSpec     file = new P4.FileSpec();
             file.DepotPath = fmd.DepotPath;
             file.Version   = new P4.Revision(fmd.HeadRev);
             P4.FileSpec file2 = new P4.FileSpec();
             file2.DepotPath = fmd.DepotPath;
             file2.Version   = new P4.Revision(fmd.HeadRev - 1);
             IList <P4.FileSpec> files = new List <P4.FileSpec>();
             files.Add(file);
             files.Add(file2);
             if (files != null)
             {
                 scm.Diff2Files(files);
             }
         }
     }
 }
Example #9
0
 private void diffToolStripMenuItem_Click(object sender, EventArgs e)
 {
     if (FileListLV.SelectedItems != null)
     {
         TreeListViewItem selected = FileListLV.SelectedItems[0] as TreeListViewItem;
         if (selected != null)
         {
             P4.FileMetaData fmd             = (P4.FileMetaData)selected.Tag;
             P4.FileSpec     fileSelectedRev = new P4.FileSpec();
             fileSelectedRev.DepotPath = fmd.DepotPath;
             fileSelectedRev.Version   = new P4.Revision(fmd.HeadRev);
             P4.FileSpec filePreviousRev = new P4.FileSpec();
             filePreviousRev.DepotPath = fmd.DepotPath;
             filePreviousRev.Version   = new P4.Revision(fmd.HeadRev - 1);
             IList <P4.FileSpec> files = new List <P4.FileSpec>();
             files.Add(filePreviousRev);
             files.Add(fileSelectedRev);
             if (files != null)
             {
                 _scm.Diff2Files(files);
             }
         }
     }
 }
Example #10
0
		public static void ShelveFiles(IList<string> files, P4ScmProvider Scm, bool ShowUi)
		{
			Dictionary<int, IDictionary<string, P4.FileMetaData>> changeLists =
                new Dictionary<int, IDictionary<string, P4.FileMetaData>>();

		    bool shelvedFiles = false;

			for (int idx = 0; idx < files.Count; idx++)
			{
				int changeListId = -1;

				if (files[idx] != null && (files[idx].EndsWith("...") || files[idx].EndsWith("*")))
				{
					List<P4.FileSpec> fileSpecs = new List<P4.FileSpec>();
					fileSpecs.Add(P4.FileSpec.DepotSpec(files[idx]));
                    IList<P4.File> opened = Scm.Connection.Repository.GetOpenedFiles(fileSpecs, null);
					IList<P4.FileSpec> openedSpecs = new List<P4.FileSpec>();
					foreach (P4.File f in opened)
					{
						if ((f != null) && (f.DepotPath != null))
						{
							openedSpecs.Add(P4.FileSpec.ClientSpec(f.ClientPath.Path));
						}
					}
					IList<P4.FileMetaData> metadata = Scm.ListFileMetaData(null, openedSpecs);
					foreach (P4.FileMetaData f in metadata)
					{
                        if (f != null)
                        {
                            changeListId = f.Change;

                            if (changeLists.ContainsKey(changeListId) == false)
                            {
                                changeLists.Add(changeListId, new Dictionary<string, P4.FileMetaData>());
                            }
                            if (changeLists[changeListId].ContainsKey(f.LocalPath.Path) == false)
                            {
                                changeLists[changeListId].Add(f.LocalPath.Path, f);
                            }
                            if (f.MovedFile != null)
                            {
                                P4.FileMetaData movedFmd = Scm.GetFileMetaData(f.MovedFile.Path);
                                if ((movedFmd != null) && (movedFmd.LocalPath != null) &&
                                    (changeLists[changeListId].ContainsKey(movedFmd.LocalPath.Path) == false))
                                {
                                    changeLists[changeListId].Add(movedFmd.LocalPath.Path, movedFmd);
                                }
                            }
                        }
					}

					continue;
				}
				P4.FileMetaData fmd = null;

				fmd = Scm.Fetch(files[idx]);
				if (fmd == null)
				{
					continue;
				}
				SourceControlStatus status = Scm.GetFileStatus(files[idx]);
				if (status == SourceControlStatus.scsCheckedIn)
				{
					continue;
				}

				changeListId = fmd.Change;

                // describe cl here and see if it is shelved
                if (changeListId > 0)
                {
                    Options opts = new Options();
                    opts["-S"] = null;
                    Changelist isChangeShelved = Scm.GetChangelist(changeListId, opts);

                    if (isChangeShelved.Shelved)
                    {
                        shelvedFiles = true;
                    }
                }

				if (changeLists.ContainsKey(changeListId) == false)
				{
					changeLists.Add(changeListId, new Dictionary<string, P4.FileMetaData>());
				}
				if (changeLists[changeListId].ContainsKey(fmd.LocalPath.Path) == false)
				{
					changeLists[changeListId].Add(fmd.LocalPath.Path, fmd);
				}
				if (fmd.MovedFile != null)
				{
					P4.FileMetaData movedFmd = Scm.GetFileMetaData(fmd.MovedFile.Path);
					if ((movedFmd != null) && (movedFmd.LocalPath != null) &&
						(changeLists[changeListId].ContainsKey(movedFmd.LocalPath.Path) == false))
					{
						changeLists[changeListId].Add(movedFmd.LocalPath.Path, movedFmd);
					}
				}
			}
			bool dlgShown = false;
			foreach (int changeListId in changeLists.Keys)
			{
				ShelveFileDlg dlg = new ShelveFileDlg(Scm);

                if (!(shelvedFiles))
                {
                    dlg.ClearChangelistTB.Checked = false;
                    dlg.ClearChangelistTB.Enabled = false;
                }
				dlg.ChangelistId = changeListId;
				dlg.SelectedFileList = changeLists[changeListId].Values.ToList();
                
				if (dlg.SelectedFileList.Count <= 0)
				{
					continue;
				}
				dlgShown = true;

				DialogResult res = DialogResult.OK;

                dlg.Description = Resources.ShelveFileDlg_FilesShelvedFromDefaultChangelist;
				if (changeListId > 0)
				{
					dlg.Description = string.Format(
						Resources.ShelveFileDlg_FilesShelvedFromNumberedChangelist, changeListId);
				}
				if (ShowUi)
				{
					res = dlg.ShowDialog();
				}
				if (res == DialogResult.Cancel)
				{
					return;
				}
				// If requested delete the existing shelved flags
				if ((changeListId > 0) && (dlg.ReplaceExistingShelvedFiles))
				{
					if (Scm.ShelveFiles(changeListId, null, P4.ShelveFilesCmdFlags.Delete, true, null) == false)
					{
						return;
					}
				}
				P4.ShelveFilesCmdFlags flags = P4.ShelveFilesCmdFlags.Force;
				if (dlg.DontShelveUnchangedFiles)
				{
					flags |= ShelveFilesCmdFlags.LeaveUnchanged;
				}
				// Shelve the files
				if (Scm.ShelveFiles(changeListId, dlg.Description, flags, dlg.SelectedFileList) == false)
				{
					return;
				}

				// If requested, revert the files after shelving

				if (dlg.RevertAfterShelving)
				{
					IList<string> selection = dlg.GetSelectedFiles();
					string[] selected = selection.ToArray();
					Scm.RevertFiles(false, true, null, selected);
				}
				Scm.BroadcastChangelistUpdate(null, new P4ScmProvider.ChangelistUpdateArgs(changeListId, P4ScmProvider.ChangelistUpdateArgs.UpdateType.ContentUpdate));
			}
			if (dlgShown == false)
			{
				MessageBox.Show(Resources.ShelveFileDlg_NoShelveableFilesWarning, Resources.PerforceSCM, MessageBoxButtons.OK, MessageBoxIcon.Error);
			}
		}
Example #11
0
        //public string FileName { get; set; }
        //public string FileFolder { get; set; }

        public P4FileTreeListViewItem(TreeListViewItem parentItem, P4.FileMetaData fileData, params object[] fields)
            : this(parentItem, fileData, fields.ToList <object>())
        {
        }
Example #12
0
        // Get Revision button click
        private void newOKBtn_Click(object sender, EventArgs e)
        {
            bool        updateSolution = false;
            IVsSolution solution       = null;
            string      path           = _scm.SolutionFile;

            IList <IVsHierarchy> projectsUpdating    = new List <IVsHierarchy>();
            IList <string>       projectsClosed      = new List <string>();
            IList <Guid>         projectsGuidsClosed = new List <Guid>();

            if (_isSolutionIncluded)
            {
                // Figure out a better test

                //updateSolution = _scm.SyncFile(
                //    new P4.SyncFilesCmdOptions(P4.SyncFilesCmdFlags.Preview, 1),
                //    path);

                updateSolution = true;
            }
            if (updateSolution)
            {
                if (DialogResult.Cancel == MessageBox.Show(
                        Resources.GetRevisionDlg_UpdatingSlnWarninig,
                        Resources.P4VS, MessageBoxButtons.OKCancel, MessageBoxIcon.Information))
                {
                    return;
                }
                solution = (IVsSolution)P4VsProvider.Instance.GetService(typeof(SVsSolution));

                P4VsProvider.Instance.SuppressConnection = true;

                if (VSConstants.S_OK != solution.CloseSolutionElement((uint)__VSSLNCLOSEOPTIONS.SLNCLOSEOPT_UnloadProject, null, 0))
                {
                    MessageBox.Show(Resources.Error_ClosingSolution, Resources.P4VS, MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
            }
            else if (P4VsProvider.Instance.SccService.SelectedNodes != null)
            {
                bool needToAsk = true;
                foreach (VSITEMSELECTION pItem in P4VsProvider.Instance.SccService.SelectedNodes)
                {
                    if ((pItem.itemid == VSConstants.VSITEMID_ROOT) && (P4VsProvider.Instance.SccService.IsProjectControlled(pItem.pHier)))
                    {
#if VS2008
                        if (DialogResult.Cancel == MessageBox.Show(Resources.GetRevisionDlg_UpdatingProjWarninig,
                                                                   Resources.P4VS, MessageBoxButtons.OKCancel, MessageBoxIcon.Information))
                        {
                            return;
                        }
                        updateSolution = true;

                        solution = (IVsSolution)GetService(typeof(SVsSolution));

                        P4VsProvider.Instance.SuppressConnection = true;

                        if (VSConstants.S_OK != solution.CloseSolutionElement((uint)__VSSLNCLOSEOPTIONS.SLNCLOSEOPT_UnloadProject, null, 0))
                        {
                            MessageBox.Show(Resources.Error_ClosingSolution, Resources.P4VS, MessageBoxButtons.OK, MessageBoxIcon.Error);
                            return;
                        }
                        break;
#else
                        IVsProject3 pProj = pItem.pHier as IVsProject3;
                        if (pProj != null)
                        {
                            if (needToAsk == true)
                            {
                                if (DialogResult.Cancel == MessageBox.Show(Resources.GetRevisionDlg_UpdatingProjWarninig,
                                                                           Resources.P4VS, MessageBoxButtons.OKCancel, MessageBoxIcon.Information))
                                {
                                    return;
                                }
                                needToAsk = false;
                            }
                            projectsUpdating.Add(pItem.pHier);

                            if (solution == null)
                            {
                                solution = (IVsSolution)P4VsProvider.Instance.GetService(typeof(SVsSolution));
                            }
                            Guid projGuid;
                            solution.GetGuidOfProject(pItem.pHier, out projGuid);
                            projectsGuidsClosed.Add(projGuid);

                            if (VSConstants.S_OK != solution.CloseSolutionElement((uint)__VSSLNCLOSEOPTIONS.SLNCLOSEOPT_UnloadProject, pItem.pHier, 0))
                            {
                                MessageBox.Show(Resources.Error_ClosingProject, Resources.P4VS, MessageBoxButtons.OK, MessageBoxIcon.Error);
                                return;
                            }
                        }
#endif
                    }
                }
            }
            List <string> refreshItems = new List <string>();

            try
            {
                //change this to a better global validator
                int  test = 0;
                bool num  = int.TryParse(ValueTB.Text, out test);
                if (specifierRB.Checked == true &&
                    num == false &&
                    specifierCB.SelectedIndex == 0 &&
                    ValueTB.Text != "head" &&
                    ValueTB.Text != "have" &&
                    ValueTB.Text != "none"
                    )
                {
                    MessageBox.Show(string.Format(Resources.GetRevisionDlg_InvalidRevisionSpecifierWarninig, ValueTB.Text));
                    ValueTB.Text = string.Empty;
                    return;
                }
                ////////
                _files = new List <P4.FileSpec>();

                foreach (ListViewItem item in filesListView.Items)
                {
                    P4.FileSpec     file = new P4.FileSpec();
                    P4.FileMetaData fmd  = new P4.FileMetaData();
                    if (item.Text.EndsWith("/..."))
                    {
                        fmd.DepotPath = new P4.DepotPath(item.Text);
                    }
                    else
                    {
                        fmd = _scm.GetFileMetaData(item.Text);
                    }

                    if (fmd.LocalPath != null)
                    {
                        file.LocalPath = fmd.LocalPath;
                    }
                    if (fmd.ClientPath != null)
                    {
                        file.ClientPath = fmd.ClientPath;
                    }
                    if (fmd.DepotPath != null)
                    {
                        file.DepotPath = fmd.DepotPath;
                    }
                    _files.Add(file);
                    refreshItems.Add(item.Text.ToString());
                }

                P4.SyncFilesCmdFlags flags = new P4.SyncFilesCmdFlags();
                flags = P4.SyncFilesCmdFlags.None;
                if (forceChk.Checked == true)
                {
                    flags = P4.SyncFilesCmdFlags.Force;
                }

                P4.Options options = new P4.Options(flags, -1);

                // set up the list of paths with specifiers that we will sync to
                IList <P4.FileSpec> files = new List <P4.FileSpec>();
                //int idx = 0;

                if (specifierRB.Checked == true)
                {
                    // #revision
                    if (specifierCB.SelectedIndex == 0)
                    {
                        bool disconnectAfterSync = false;
                        int  number = 0;
                        bool isnum  = int.TryParse(Value, out number);
                        if (isnum == true)
                        {
                            if (number == 0)
                            {
                                if (_isSolutionIncluded)
                                {
                                    if (DialogResult.Cancel == MessageBox.Show(Resources.GetRevisionDlg_RemovingSlnWarninig,
                                                                               Resources.P4VS, MessageBoxButtons.OKCancel, MessageBoxIcon.Warning))
                                    {
                                        this.DialogResult = DialogResult.Cancel;
                                        return;
                                    }
                                    disconnectAfterSync = true;
                                }
                                else
                                {
                                    if (DialogResult.Cancel == MessageBox.Show(Resources.GetRevisionDlg_RemovingProjWarninig,
                                                                               Resources.P4VS, MessageBoxButtons.OKCancel, MessageBoxIcon.Warning))
                                    {
                                        this.DialogResult = DialogResult.Cancel;
                                        return;
                                    }
                                }
                            }
                        }
                        foreach (P4.FileSpec file in _files)
                        {
                            if (isnum == true)
                            {
                                // skip meta data check for rev 0 there is none, but we dtill want to allow
                                // this as a way to remove the local copy of the file, but still keep checking
                                // to make sure other bad revisions are not fetched such as file that was moved
                                if (number != 0)
                                {
                                    IList <P4.FileSpec> fs = new List <FileSpec>();
                                    file.Version = new P4.Revision(number);
                                    fs.Add(file);
                                    IList <P4.FileMetaData> fmd = _scm.GetFileMetaData(fs, null);
                                    if (fmd == null)
                                    {
                                        if (_scm.Connection.Repository.Connection.LastResults.ErrorList != null)
                                        {
                                            if (_files.Count == 1)
                                            {
                                                P4ErrorDlg.Show(_scm.Connection.Repository.Connection.LastResults, false);
                                            }
                                            P4VsOutputWindow.AppendMessage(_scm.Connection.Repository.Connection.LastResults.ErrorList[0].ToString());
                                        }
                                        continue;
                                    }
                                }
                                file.Version = new P4.Revision(number);
                            }
                            else if (Value == "head")
                            {
                                file.Version = new P4.HeadRevision();
                            }
                            else if (Value == "have")
                            {
                                file.Version = new P4.HaveRevision();
                            }
                            else if (Value == "none")
                            {
                                file.Version = new P4.NoneRevision();
                            }
                            files.Add(file);
                        }
                        if (files.Count > 0)
                        {
                            _scm.SyncFiles(options, files);
                        }
                        if (_scm.Connection.Repository.Connection.LastResults.ErrorList != null)
                        {
                            IList <P4.P4ClientError> errors = _scm.Connection.Repository.Connection.LastResults.ErrorList.ToList();
                            foreach (P4.P4ClientError error in errors)
                            {
                                if (error.SeverityLevel == P4.ErrorSeverity.E_FAILED |
                                    error.SeverityLevel == P4.ErrorSeverity.E_FATAL)
                                {
                                    P4ErrorDlg.Show(_scm.Connection.Repository.Connection.LastResults, false);
                                    return;
                                }
                            }
                            if (_scm.SccService == null)
                            {
                                return;
                            }
                            this.DialogResult = DialogResult.OK;
                        }
                        else
                        {
                            if (_scm.SccService == null)
                            {
                                return;
                            }
                            this.DialogResult = DialogResult.OK;
                        }
                        if (disconnectAfterSync)
                        {
                            P4VsProvider.Instance.SccService.Dispose();
                        }
                    }

                    // @workspace
                    if (specifierCB.SelectedIndex == 4)
                    {
                        foreach (P4.FileSpec file in _files)
                        {
                            file.Version = new P4.ClientNameVersion(Value.ToString());
                            files.Add(file);
                        }
                        _scm.SyncFiles(options, files);
                        if (_scm.Connection.Repository.Connection.LastResults.ErrorList != null)
                        {
                            IList <P4.P4ClientError> errors = _scm.Connection.Repository.Connection.LastResults.ErrorList.ToList();
                            foreach (P4.P4ClientError error in errors)
                            {
                                if (error.SeverityLevel == P4.ErrorSeverity.E_FAILED |
                                    error.SeverityLevel == P4.ErrorSeverity.E_FATAL)
                                {
                                    P4ErrorDlg.Show(_scm.Connection.Repository.Connection.LastResults, false);
                                    return;
                                }
                            }
                            this.DialogResult = DialogResult.OK;
                        }
                        else
                        {
                            this.DialogResult = DialogResult.OK;
                        }
                    }

                    // @date/time
                    if (specifierCB.SelectedIndex == 2)
                    {
                        DateTime value = dateTimePicker.Value;

                        string timestamp = value.Date.ToShortDateString() + ":" + value.TimeOfDay.ToString();

                        foreach (P4.FileSpec file in _files)
                        {
                            file.Version = new P4.DateTimeVersion(value);
                            files.Add(file);
                        }
                        _scm.SyncFiles(options, _files);
                        if (_scm.Connection.Repository.Connection.LastResults.ErrorList != null)
                        {
                            IList <P4.P4ClientError> errors = _scm.Connection.Repository.Connection.LastResults.ErrorList.ToList();
                            foreach (P4.P4ClientError error in errors)
                            {
                                if (error.SeverityLevel == P4.ErrorSeverity.E_FAILED |
                                    error.SeverityLevel == P4.ErrorSeverity.E_FATAL)
                                {
                                    P4ErrorDlg.Show(_scm.Connection.Repository.Connection.LastResults, false);
                                    return;
                                }
                            }
                            this.DialogResult = DialogResult.OK;
                        }
                        else
                        {
                            this.DialogResult = DialogResult.OK;
                        }
                    }

                    // @changelist
                    if (specifierCB.SelectedIndex == 1)
                    {
                        if (changelistFilesChk.Checked == true)
                        {
                            foreach (P4.FileSpec file in _files)
                            {
                                file.Version = new P4.VersionRange(new P4.ChangelistIdVersion(Convert.ToInt16(Value)),
                                                                   new P4.ChangelistIdVersion(Convert.ToInt32(Value)));
                                files.Add(file);
                            }
                        }
                        else
                        {
                            foreach (P4.FileSpec file in _files)
                            {
                                file.Version = new P4.ChangelistIdVersion(Convert.ToInt32(Value));
                                files.Add(file);
                            }
                        }
                        _scm.SyncFiles(options, files);
                        if (_scm.Connection.Repository.Connection.LastResults.ErrorList != null)
                        {
                            IList <P4.P4ClientError> errors = _scm.Connection.Repository.Connection.LastResults.ErrorList.ToList();
                            foreach (P4.P4ClientError error in errors)
                            {
                                if (error.SeverityLevel == P4.ErrorSeverity.E_FAILED |
                                    error.SeverityLevel == P4.ErrorSeverity.E_FATAL)
                                {
                                    P4ErrorDlg.Show(_scm.Connection.Repository.Connection.LastResults, false);
                                    return;
                                }
                            }
                            this.DialogResult = DialogResult.OK;
                        }
                        else
                        {
                            this.DialogResult = DialogResult.OK;
                        }
                    }

                    // @label
                    if (specifierCB.SelectedIndex == 3)
                    {
                        if (removeChk.Checked == true)
                        {
                            foreach (P4.FileSpec file in _files)
                            {
                                file.Version = new P4.LabelNameVersion(Value.ToString());
                                files.Add(file);
                            }
                        }
                        else
                        {
                            foreach (P4.FileSpec file in _files)
                            {
                                file.Version = new P4.VersionRange(new P4.LabelNameVersion(Value.ToString()),
                                                                   new P4.LabelNameVersion(Value.ToString()));
                                files.Add(file);
                            }
                        }
                        _scm.SyncFiles(options, files);
                        if (_scm.Connection.Repository.Connection.LastResults.ErrorList != null)
                        {
                            IList <P4.P4ClientError> errors = _scm.Connection.Repository.Connection.LastResults.ErrorList.ToList();
                            foreach (P4.P4ClientError error in errors)
                            {
                                if (error.SeverityLevel == P4.ErrorSeverity.E_FAILED |
                                    error.SeverityLevel == P4.ErrorSeverity.E_FATAL)
                                {
                                    P4ErrorDlg.Show(_scm.Connection.Repository.Connection.LastResults, false);
                                    return;
                                }
                            }
                            this.DialogResult = DialogResult.OK;
                        }
                        else
                        {
                            this.DialogResult = DialogResult.OK;
                        }
                    }
                }

                else if (getLatestRB.Checked == true)
                {
                    files = _files;
                    _scm.SyncFiles(options, files);
                    if (_scm.Connection.Repository.Connection.LastResults.ErrorList != null)
                    {
                        IList <P4.P4ClientError> errors = _scm.Connection.Repository.Connection.LastResults.ErrorList.ToList();
                        foreach (P4.P4ClientError error in errors)
                        {
                            if (error.SeverityLevel == P4.ErrorSeverity.E_FAILED |
                                error.SeverityLevel == P4.ErrorSeverity.E_FATAL)
                            {
                                P4ErrorDlg.Show(_scm.Connection.Repository.Connection.LastResults, false);
                                return;
                            }
                        }
                        this.DialogResult = DialogResult.OK;
                    }
                    else
                    {
                        this.DialogResult = DialogResult.OK;
                    }
                }
            }
            finally
            {
                if (updateSolution)
                {
                    if (path != null)
                    {
                        solution.OpenSolutionFile(0, path);
                    }
                    if (_scm.SccService != null)
                    {
                        _scm.SccService.ResetSelection();
                    }
                }
#if !VS2008
                else if (projectsUpdating.Count > 0)
                {
                    foreach (Guid projGuid in projectsGuidsClosed)
                    {
                        Guid rProjGuid = projGuid;

                        var vsSolution4 = (IVsSolution4)solution;
                        if (vsSolution4 != null)
                        {
                            int res = vsSolution4.ReloadProject(ref rProjGuid);
                        }
                    }
                }
#endif
                // now refresh the selected nodes' glyphs
                if (_scm.SccService != null)
                {
                    _scm.SccService.UpdateProjectGlyphs(refreshItems, true);
                }
            }
        }
Example #13
0
        public DiffDlg(IList <string> paths, string specifier, string value, P4ScmProvider scm)
        {
            PreferenceKey = "DiffDlg";

            _scm   = scm;
            _paths = paths;

            InitializeComponent();
            this.Icon = Images.icon_p4vs_16px;

            if (components == null)
            {
                components = new System.ComponentModel.Container();
            }
            //
            // imageList1
            //
            imageList1 = new System.Windows.Forms.ImageList(components);
            this.imageList1.TransparentColor = System.Drawing.Color.Transparent;
            this.imageList1.Images.Add("revision_icon_base.png", Images.revision_icon_base);
            this.imageList1.Images.Add("submitted_change_icon.png", Images.submitted_change_icon);
            this.imageList1.Images.Add("datetime.png", Images.datetime);
            this.imageList1.Images.Add("labels_icon.png", Images.labels_icon);
            this.imageList1.Images.Add("clients_icon.png", Images.clients_icon);
            this.imageList1.Images.Add("portrait.png", Images.portrait);
            this.imageList1.Images.Add("client_folder.png", Images.client_folder);
            this.imageList1.Images.Add("depot_folder.png", Images.depot_folder);

            latest1stRBFmt = latest1stRB.Text;
            have1stRBFmt   = have1stRB.Text;
            latest2ndRBFmt = latest2ndRB.Text;
            have2ndRBFmt   = have2ndRB.Text;

            // dialog called from workspace tool window
            if (specifier == "workspace")
            {
            }

            // dialog called from solution explorer or VS menu
            if (specifier == "revision" ||
                specifier == "explorer")
            {
                int latest = 0;
                int have   = 0;

                // set up top path
                path1TB.Text = paths[0];
                P4.FileMetaData file1 = scm.GetFileMetaData(paths[0]);
                if (file1 != null)
                {
                    latest                       = file1.HeadRev;
                    have                         = file1.HaveRev;
                    latest1stRB.Text             = string.Format(latest1stRBFmt, latest);
                    have1stRB.Text               = string.Format(have1stRBFmt, have);
                    specifier1stCB.SelectedIndex = 0;
                    latest1stRB.Checked          = true;
                    specifier1stCB.SelectedIndex = 0;
                    if ((string.IsNullOrEmpty(path1ValueTB.Text) == true ||
                         string.IsNullOrEmpty(path1ValueTB.Text) == true) &&
                        (specifier1stRB.Checked == true))
                    {
                        diffBtn.Enabled = false;
                    }
                    else
                    {
                        diffBtn.Enabled = true;
                    }

                    // set up bottom path
                    path2TB.Text                 = paths[0];
                    latest2ndRB.Text             = string.Format(latest2ndRBFmt, latest);
                    have2ndRB.Text               = string.Format(have2ndRBFmt, have);
                    specifier2ndCB.SelectedIndex = 0;
                    have2ndRB.Checked            = true;
                    if ((string.IsNullOrEmpty(path2ValueTB.Text) == true ||
                         string.IsNullOrEmpty(path2ValueTB.Text) == true) &&
                        (specifier2ndRB.Checked == true))
                    {
                        diffBtn.Enabled = false;
                    }
                    else
                    {
                        diffBtn.Enabled = true;
                    }
                }
                else
                {
                    string msg = string.Format(Resources.DiffDlg_MissingFileError, paths[0]);
                    MessageBox.Show(msg, Resources.P4VS, MessageBoxButtons.OK, MessageBoxIcon.Error);
                    throw new ArgumentException(msg);
                }
            }
            // dialog called from history
            if (specifier == "history")
            {
                int latest = 0;
                int have   = 0;

                // set up top path
                path1TB.Text = paths[0];
                P4.FileMetaData file1 = scm.GetFileMetaData(paths[0]);
                if (file1 != null)
                {
                    latest                       = file1.HeadRev;
                    have                         = file1.HaveRev;
                    latest1stRB.Text             = string.Format(latest1stRBFmt, latest);
                    have1stRB.Text               = string.Format(have1stRBFmt, have);
                    specifier1stCB.SelectedIndex = 0;
                    if (value == "local")
                    {
                        workspace1stRB.Checked = true;
                    }
                    else
                    {
                        specifier1stRB.Checked = true;
                        path1ValueTB.Text      = value;
                    }
                    specifier1stCB.SelectedIndex = 0;
                    if ((string.IsNullOrEmpty(path1ValueTB.Text) == true ||
                         string.IsNullOrEmpty(path1ValueTB.Text) == true) &&
                        (specifier1stRB.Checked == true))
                    {
                        diffBtn.Enabled = false;
                    }
                    else
                    {
                        diffBtn.Enabled = true;
                    }

                    // set up bottom path
                    path2TB.Text                 = paths[0];
                    latest2ndRB.Text             = string.Format(latest2ndRBFmt, latest);
                    have2ndRB.Text               = string.Format(have2ndRBFmt, have);
                    specifier2ndCB.SelectedIndex = 0;
                    specifier2ndRB.Checked       = true;
                    if ((string.IsNullOrEmpty(path2ValueTB.Text) == true ||
                         string.IsNullOrEmpty(path2ValueTB.Text) == true) &&
                        (specifier2ndRB.Checked == true))
                    {
                        diffBtn.Enabled = false;
                    }
                    else
                    {
                        diffBtn.Enabled = true;
                    }
                }
                else
                {
                    string msg = string.Format(Resources.DiffDlg_MissingFileError, paths[0]);
                    MessageBox.Show(msg, Resources.P4VS, MessageBoxButtons.OK, MessageBoxIcon.Error);
                    throw new ArgumentException(msg);
                }
            }

            // dialog called from submitted changelists tool window
            if (specifier == "changelist")
            {
                // set up top path
                path1TB.Text = string.Empty;
                specifier1stCB.SelectedIndex = 1;
                specifier1stRB.Checked       = true;
                path1ValueTB.Text            = value;
                diffBtn.Enabled = false;

                // set up bottom path
                path2TB.Text = string.Empty;
                specifier2ndCB.SelectedIndex = 0;
                specifier2ndRB.Checked       = true;
                diffBtn.Enabled = false;
            }

            // dialog called from labels tool window
            if (specifier == "label")
            {
            }
        }
Example #14
0
        //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);
        }
Example #15
0
        private void AutoResolveBtn_Click(object sender, EventArgs e)
        {
            if (SelectedItems == null)
            {
                return;
            }

            AutoResolveMethod method = SelectedMethod;

            P4.ResolveFilesCmdFlags flags = P4.ResolveFilesCmdFlags.None;
            if (MergeBinaryAsText)
            {
                flags |= P4.ResolveFilesCmdFlags.ForceTextualMerge;
            }
            switch (method)
            {
            default:
            case AutoResolveMethod.Safe:
                flags |= P4.ResolveFilesCmdFlags.AutomaticSafeMode;
                break;

            case AutoResolveMethod.SafeMerge:
                flags |= P4.ResolveFilesCmdFlags.AutomaticMergeMode;
                break;

            case AutoResolveMethod.Source:
                flags |= P4.ResolveFilesCmdFlags.AutomaticTheirsMode;
                break;

            case AutoResolveMethod.Target:
                flags |= P4.ResolveFilesCmdFlags.AutomaticYoursMode;
                break;

            case AutoResolveMethod.MergeWithConflicts:
                flags |= P4.ResolveFilesCmdFlags.AutomaticForceMergeMode;
                break;
            }
            P4.Options options = new P4.ResolveCmdOptions(flags, -1);

            //Dictionary<string, ResolveFileDlg.FileListViewItem> itemMap = new Dictionary<string, ResolveFileDlg.FileListViewItem>();

            int failedResolves = 0;

            foreach (ResolveFileDlg.FileListViewItem item in SelectedItems)
            {
                try
                {
                    IList <P4.FileResolveRecord> records =
                        Scm.Connection.Repository.Connection.Client.ResolveFiles(
                            null, options, item.ResolveRecord.LocalFilePath);

                    //bool resolveFailed = true;
                    //if (records != null)
                    //{
                    //    foreach (P4.FileResolveRecord r in records)
                    //    {
                    //        if (r.Action != P4.FileAction.None)
                    //        {
                    //            resolveFailed = false;
                    //            break;
                    //        }
                    //    }
                    //}
                    //if (resolveFailed)
                    //{
                    //    failedResolves++;
                    //}
                    P4.P4CommandResult results = null;
                    P4.FileMetaData    newMd   = Scm.GetFileMetaData(null, item.ResolveRecord.LocalFilePath.Path, out results);
                    if (newMd.Unresolved)
                    {
                        failedResolves++;
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message, Resources.PerforceSCM, MessageBoxButtons.OK);
                    return;
                }
            }
            if (UpdateListView != null)
            {
                UpdateListView();
            }
            if (failedResolves > 0)
            {
                string msg = string.Format(Resources.ResolveFileAutoControl_FilesNotResolvedWarning, failedResolves);
                MessageBox.Show(msg, Resources.P4VS, MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
Example #16
0
        public SourceControlStatus(P4.FileMetaData f)
        {
            Flags = SourceControlStatusFlags.scsUncontrolled;

            try
            {
                if (f != null)
                {
                    if (f.HeadAction == P4.FileAction.Delete)
                    {
                        Flags = SourceControlStatusFlags.scsDeletedAtHead;
                        if (f.Action == P4.FileAction.Add)
                        {
                            Flags |= SourceControlStatusFlags.scsMarkedAdd | SourceControlStatusFlags.scsCheckedOut;
                        }
                    }
                    else if (f.Action == P4.FileAction.Add)
                    {
                        Flags = SourceControlStatusFlags.scsMarkedAdd | SourceControlStatusFlags.scsCheckedOut;
                    }
                    else if (f.Action == P4.FileAction.Branch)
                    {
                        Flags = SourceControlStatusFlags.scsBranched | SourceControlStatusFlags.scsCheckedOut;
                    }
                    else if (f.Action == P4.FileAction.Delete)
                    {
                        Flags = SourceControlStatusFlags.scsMarkedDelete | SourceControlStatusFlags.scsCheckedOut;
                    }
                    else if (f.Action == P4.FileAction.MoveAdd)
                    {
                        Flags = SourceControlStatusFlags.scsMoved;
                    }
                    else if (f.IsInDepot)
                    {
                        Flags = SourceControlStatusFlags.scsCheckedIn;
                    }
                    if (f.Action == P4.FileAction.Edit)
                    {
                        Flags = SourceControlStatusFlags.scsCheckedOut;
                    }
                    if (f.OurLock)
                    {
                        Flags |= SourceControlStatusFlags.scsLockedSelf;
                    }
                    if (f.OtherOpen > 0)
                    {
                        for (int idx = 0; idx < f.OtherOpen; idx++)
                        {
                            if (f.OtherActions[idx] == P4.FileAction.Edit || f.OtherActions[idx] == P4.FileAction.Integrate)
                            {
                                Flags |= SourceControlStatusFlags.scsOtherCheckedOut;
                            }
                            if (f.OtherActions[idx] == P4.FileAction.Delete)
                            {
                                Flags |= SourceControlStatusFlags.scsMarkedDelete | SourceControlStatus.scsOtherCheckedOut;
                            }
                        }
                    }

                    if (f.OtherLock)
                    {
                        Flags |= SourceControlStatusFlags.scsLockedOther;
                    }

                    if (f.IsStale)
                    {
                        Flags |= SourceControlStatusFlags.scsStale;
                    }
                    if (f.Unresolved)
                    {
                        Flags |= SourceControlStatusFlags.scsNeedsResolve;
                    }
                    if (f.Action == P4.FileAction.Integrate)
                    {
                        Flags |= SourceControlStatusFlags.scsIntegrated;
                    }
                    if ((f.HaveRev == 0) && (f.Action != P4.FileAction.Add) && (f.Action != P4.FileAction.MoveAdd) && (f.Action != P4.FileAction.Branch))
                    {
                        Flags |= SourceControlStatusFlags.scsNotOnDisk;
                    }
                }
            }
            catch (Exception)
            {
                Flags = SourceControlStatusFlags.scsUncontrolled;
            }
        }
Example #17
0
 public CachedFile(P4.FileMetaData file)
 {
     _file      = file;
     ScmStatus  = new SourceControlStatus(file);
     LastUpdate = DateTime.Now;
 }
Example #18
0
        private void addBtn_Click(object sender, EventArgs e)
        {
            try
            {
                DepotPathDlg dlg = new DepotPathDlg(_scm.SccService, Resources.GetRevisionDlg_AddFilesFoldersPrompt, false);


                if (DialogResult.OK == dlg.ShowDialog())
                {
                    string depotPath = null;
                    if (dlg.SelectedFile != null)
                    {
                        depotPath = dlg.SelectedFile;
                    }

                    P4.FileMetaData f = new P4.FileMetaData();
                    f.DepotPath = new P4.DepotPath(depotPath);
                    IList <P4.FileMetaData> fmd    = null;
                    IList <object>          fields = new List <object>();
                    fields.Add(P4FileTreeListViewItem.SubItemFlag.DepotFullPath);
                    P4FileTreeListViewItem lvi = new P4FileTreeListViewItem(null, f, fields);

                    if (depotPath != null && depotPath.EndsWith("/..."))
                    {
                        try
                        {
                            P4.Options options = new P4.Options();
                            //options["Op"] = null;
                            options["-m"] = "1";

                            fmd = _scm.GetFileMetaData(options, depotPath);
                        }
                        catch (P4Exception ex)
                        {
                            if (!(ex.ErrorCode == P4ClientError.MsgDb_NotUnderRoot))
                            {
                                MessageBox.Show(ex.Message, Resources.P4VS);
                                return;
                            }
                        }



                        //lvi.Text = depotPath;


                        foreach (ListViewItem item in filesListView.Items)
                        {
                            if (item.Text.Equals(lvi.Text))
                            {
                                return;
                            }
                        }

                        filesListView.Items.Add(lvi);
                    }

                    else
                    {
                        P4.FileMetaData file = null;
                        {
                            try
                            {
                                file = _scm.GetFileMetaData(depotPath);
                            }
                            catch (P4.P4Exception ex)
                            {
                                if ((ex.ErrorCode == P4.P4ClientError.MsgDb_NotUnderRoot) ||
                                    (ex.ErrorCode == P4.P4ClientError.MsgDb_NotUnderClient))
                                {
                                }
                                else
                                {
                                    MessageBox.Show(ex.Message, Resources.P4VS);
                                    //LogExeption(ex);

                                    return;
                                }
                            }
                            catch (Exception ex)
                            {
                                MessageBox.Show(ex.Message, Resources.P4VS);
                                return;
                            }

                            if (file != null && file.LocalPath != null)
                            {
                                lvi.Text = file.LocalPath.Path;
                            }
                            else
                            {
                                if (file != null && file.DepotPath != null)
                                {
                                    lvi.Text = file.DepotPath.Path;
                                }
                            }


                            foreach (ListViewItem item in filesListView.Items)
                            {
                                if (item.Text.Equals(lvi.Text))
                                {
                                    return;
                                }
                            }

                            filesListView.Items.Add(lvi);
                        }
                    }
                    filesListView.Refresh();

                    newOKBtn.Enabled = filesListView.Items.Count > 0;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, Resources.P4VS);
                this.DialogResult = DialogResult.Cancel;
            }
        }
Example #19
0
		private void ChangelistFilesLV_ItemChecked(object sender, ItemCheckedEventArgs e)
		{
            if (e.Item.Checked == true)
            {
                e.Item.ImageIndex = 1;
            }
            else
            {
                e.Item.ImageIndex = 0;
            }
            
			if (inChangelistFilesLV_ItemChecked == true)
			{
				// don't recurse
				return;
			}
			inChangelistFilesLV_ItemChecked = true;

			// turn off the select all checked event, so it won't effect other controls
			SelectAllCB.CheckedChanged -= new EventHandler(SelectAllCB_CheckedChanged);

			// turn off the item checked event, so it won't recurse for linked files
			ChangelistFilesLV.ItemChecked -= new ItemCheckedEventHandler(ChangelistFilesLV_ItemChecked);
			try
			{
#if DEBUG_DB
				int i = 0;
				foreach (ListViewItem it in ChangelistFilesLV.Items)
				{
				    P4.FileMetaData m = it.Tag as P4.FileMetaData;
				    string fp = m.DepotPath.Path;
				    logger.Trace("Item {0}: {1}", i++, fp));
				}
#endif
				P4.FileMetaData fmd = (P4.FileMetaData)(e.Item.Tag);

				if ((_scm != null) && (fmd.MovedFile != null))
				{
					try
					{
						ListViewItem item = listItemMap[fmd.MovedFile.Path];
						if ((item != null) && (item.Checked != e.Item.Checked))
						{
							item.Checked = e.Item.Checked;
						}
					}
					catch { } // ignore errors
				}

				SelectAllCB.Checked = true;
				ShelveBtn.Enabled = false;
				foreach (ListViewItem item in ChangelistFilesLV.Items)
				{
					ShelveBtn.Enabled |= item.Checked;
					SelectAllCB.Checked &= item.Checked;
				}

			}
			finally
			{
				// turn back on the select all checked event, so it won't effect other controls
				SelectAllCB.CheckedChanged += new EventHandler(SelectAllCB_CheckedChanged);
				// turn back on the individual item check handler
				ChangelistFilesLV.ItemChecked += new ItemCheckedEventHandler(ChangelistFilesLV_ItemChecked);

				inChangelistFilesLV_ItemChecked = false;
			}
		}
Example #20
0
        public void CheckoutResource(IList <string> sel)
        {
            IList <VSITEMSELECTION> nodes = SccService.SelectedNodes;

            IList <string> lockedFiles   = new List <string>();
            IList <string> lockUsers     = new List <string>();
            IList <string> staleFiles    = new List <string>();
            IList <string> checkoutFiles = new List <string>();

            for (int idx = 0; idx < sel.Count; idx++)
            {
                string file = sel[idx];

                bool isWildcard = file.EndsWith("...") || file.EndsWith("*");

                if (isWildcard == false)
                {
                    P4.FileMetaData fmd = null;

                    if (string.IsNullOrEmpty(file) == false)
                    {
                        fmd = SccService.ScmProvider.Fetch(file);
                    }

                    if (fmd != null &&
                        fmd.HeadType.Modifiers.HasFlag(P4.FileTypeModifier.ExclusiveOpen) &&
                        fmd.OtherOpen > 0)
                    {
                        // Show the error for exclusive open file and continue
                        // without adding file to list of files to checkout
                        P4ErrorDlg.Show(Resources.P4VsProvider_ExclusiveOpenError, false, false);
                        continue;
                    }
                    if ((fmd == null) || (fmd.HeadAction == P4.FileAction.Delete))
                    {
                        sel.RemoveAt(idx--);
                        continue;
                    }
                    if (fmd.OtherLock)
                    {
                        lockedFiles.Add(fmd.LocalPath.Path);
                        string otherlocks = string.Empty;
                        foreach (string otherLock in fmd.OtherLockUserClients)
                        {
                            if (string.IsNullOrEmpty(otherlocks) == false)
                            {
                                otherlocks += ",";
                            }
                            otherlocks += otherLock;
                        }
                        lockUsers.Add(otherlocks);
                    }
                    if (fmd.IsStale)
                    {
                        staleFiles.Add(fmd.LocalPath.Path);
                    }
                }
                else
                {
                    IList <P4.FileMetaData> fmdList = SccService.ScmProvider.GetFileMetaData(null, file);

                    foreach (P4.FileMetaData fmd in fmdList)
                    {
                        if (fmd.OtherLock)
                        {
                            lockedFiles.Add(fmd.LocalPath.Path);
                            string otherlocks = string.Empty;
                            foreach (string otherLock in fmd.OtherLockUserClients)
                            {
                                if (string.IsNullOrEmpty(otherlocks) == false)
                                {
                                    otherlocks += ",";
                                }
                                otherlocks += otherLock;
                            }
                            lockUsers.Add(otherlocks);
                        }
                        if (fmd.IsStale)
                        {
                            staleFiles.Add(fmd.LocalPath.Path);
                        }
                    }
                }
                checkoutFiles.Add(file);
            }
            if ((lockedFiles != null) && (lockedFiles.Count > 0))
            {
                string lockWarning = Resources.WarningStyle_Locked_Prompt;
                if (FileListWarningDlg.Show(lockedFiles, lockUsers, FileListWarningDlg.WarningStyle.Locked) == DialogResult.Cancel)
                {
                    return;
                }
            }

            if ((staleFiles != null) && (staleFiles.Count > 0))
            {
                DialogResult answer = FileListWarningDlg.Show(staleFiles, null, FileListWarningDlg.WarningStyle.GetLatest);
                if (answer == DialogResult.Cancel)
                {
                    return;
                }
                if (answer == DialogResult.OK)
                {
                    if (!SccService.SyncFiles(null, staleFiles))
                    {
                        return;
                    }
                }
            }

            if (checkoutFiles.Count < 1)
            {
                return;
            }

            P4.Changelist getDesc = SccService.ScmProvider.GetChangelist(-1);
            if (getDesc == null)
            {
                return;
            }

            string newChangeDescription = getDesc.Description;

            if (newChangeDescription == Resources.DefaultChangeListDescription)
            {
                newChangeDescription = Resources.P4VsProvider_CheckoutFilesDefaultChangelistDescription;
            }
            IList <P4.Changelist> changes = SccService.ScmProvider.GetAvailibleChangelists(-1);

            int    changeListId = -1;
            string prompt       = Resources.P4VsProvider_CheckoutFilePrompt;

            if (sel.Count >= 2)
            {
                prompt = Resources.P4VsProvider_CheckoutFilesPrompt;
            }
            changeListId = SelectChangelistDlg2.ShowChooseChangelistYesNo(prompt, checkoutFiles, changes, ref newChangeDescription);

            if (changeListId < -1)
            {
                // user hit cancel
                return;
            }
            if (string.IsNullOrEmpty(newChangeDescription))
            {
                newChangeDescription = Resources.P4VsProvider_CheckoutFilesDefaultChangelistDescription;
            }
            SelectChangelistDlg.CurrentChangeList = SccService.CheckoutFiles(sel, changeListId, newChangeDescription);

            // now refresh the selected nodes' glyphs
            Glyphs.RefreshNodesGlyphs(nodes, sel);
        }
Example #21
0
		public static void ShelveFiles(IList<P4.FileMetaData> files, P4.Changelist changelist, P4ScmProvider ScmProvider, bool ShowUi)
		{
			ShelveFileDlg dlg = new ShelveFileDlg(ScmProvider);
            bool shelvedFiles = changelist.Shelved;

			dlg.ChangelistId = changelist.Id;
			if ((files != null) && (files.Count > 0))
			{
			    List<P4.FileMetaData> linkedFiles = new List<P4.FileMetaData>();
				foreach (P4.FileMetaData fmd in files)
				{
					if (fmd.MovedFile != null)
					{
						P4.FileMetaData movedFmd = ScmProvider.GetFileMetaData(fmd.MovedFile.Path);
						linkedFiles.Add(movedFmd);
					}
                   
				}
                foreach (P4.FileMetaData fmd in linkedFiles)
                {

                    files.Add(fmd);
                }
			    dlg.SelectedFileList = files;

                
			}
			if (dlg.SelectedFileList.Count <= 0)
			{
				dlg.SelectAllCB.Checked = true;
			}

            if (!(shelvedFiles))
            {
                dlg.ClearChangelistTB.Checked = false;
                dlg.ClearChangelistTB.Enabled = false;
            }
			DialogResult res = DialogResult.OK;

			dlg.Description = Resources.ShelveFileDlg_FilesShelvedFromDefaultChangelist;
			if (changelist.Id > 0)
			{
				dlg.Description = string.Format(
					Resources.ShelveFileDlg_FilesShelvedFromNumberedChangelist, changelist.Id);
			}
			if (ShowUi)
			{
				res = dlg.ShowDialog();
			}
			if (res == DialogResult.Cancel)
			{
				return;
			}
			// If requested delete the existing shelved flags
			if ((changelist.Id > 0) && (dlg.ReplaceExistingShelvedFiles))
			{
				if (ScmProvider.ShelveFiles(changelist.Id, null, P4.ShelveFilesCmdFlags.Delete, true, null) == false)
				{
					return;
				}
			}
			P4.ShelveFilesCmdFlags flags = P4.ShelveFilesCmdFlags.Force;
			if (dlg.DontShelveUnchangedFiles)
			{
				flags |= ShelveFilesCmdFlags.LeaveUnchanged;
			}
			// Shelve the files
			if (ScmProvider.ShelveFiles(changelist.Id, dlg.Description, flags, dlg.SelectedFileList) == false)
			{
				return;
			}

			// If requested, revert the files after shelving

			if (dlg.RevertAfterShelving)
			{
				ScmProvider.RevertFiles(false, true, null, dlg.GetSelectedFiles().ToArray());
			}
			ScmProvider.BroadcastChangelistUpdate(null, new P4ScmProvider.ChangelistUpdateArgs(changelist.Id, P4ScmProvider.ChangelistUpdateArgs.UpdateType.ContentUpdate));
		}