Пример #1
0
        public UnshelveFileDialog(P4ScmProvider scm)
        {
            PreferenceKey = "UnshelveFileDialog";

            _scm = scm;
            InitializeComponent();
            this.Icon  = Images.icon_p4vs_16px;
            ListImages = new System.Windows.Forms.ImageList(components);
            //
            // ListImages
            //
            ListImages.TransparentColor = System.Drawing.Color.Transparent;
            ListImages.Images.Add("noCheckBox.png", Images.noCheckBox);
            ListImages.Images.Add("CheckBox.png", Images.CheckBox);

            ShelvedFilesLV.SmallImageList     = ListImages;
            ShelvedFilesLV.ListViewItemSorter = (System.Collections.IComparer) new FileListViewSorter();

            IList <P4.Changelist> changes = _scm.GetAvailibleChangelists(-1);

            changeMap = new Dictionary <int, P4.Changelist>();

            //add new as the first item in the list
            TargetChangelistCB.Items.Add(Resources.Changelist_New);
            changeMap[-1] = null;

            //add default as the first item in the list if not already there
            TargetChangelistCB.Items.Add(Resources.Changelist_Default);
            changeMap[0] = null;

            // if there are other existing changelists, add them to the list
            if (changes != null)
            {
                foreach (P4.Changelist item in changes)
                {
                    int id = item.Id;
                    if ((id != -1) && (id != 0))
                    {
                        changeMap[id] = item;
                        int idx = TargetChangelistCB.Items.Add(SelectChangelistDlg.ChangeListToString(item));
                    }
                }
            }

            // select the default changelist
            TargetChangelistCB.SelectedIndex = 1;
        }
Пример #2
0
        private void actionBtn_Click(object sender, EventArgs e)
        {
            previewTB.Clear();
            string sourceSelection = string.Empty;

            if (sourceCB.Enabled)
            {
                sourceSelection = this.sourceCB.SelectedItem.ToString();
            }
            else if (sourceTB.Enabled)
            {
                sourceSelection = this.sourceTB.Text;
            }

            P4.Stream effectiveTarget = _scm.GetStream(_target, null, null);
            P4.Stream effectiveSource = _scm.GetStream(sourceSelection, null, null);

            if (effectiveSource == null || effectiveTarget == null)
            {
                return;
            }

            if (effectiveTarget.Type == P4.StreamType.Virtual)
            {
                if (effectiveTarget.BaseParent != null)
                {
                    effectiveTarget = _scm.GetStream(effectiveTarget.BaseParent.Path, null, null);
                }
                else if (effectiveTarget.Parent != null)
                {
                    effectiveTarget = _scm.GetStream(effectiveTarget.Parent.Path, null, null);
                }
            }

            if (effectiveSource.Type == P4.StreamType.Virtual)
            {
                if (effectiveSource.BaseParent != null)
                {
                    effectiveSource = _scm.GetStream(effectiveSource.BaseParent.Path, null, null);
                }
                else if (effectiveSource.Parent != null)
                {
                    effectiveSource = _scm.GetStream(effectiveSource.Parent.Path, null, null);
                }
            }

            P4.Options          opts  = new P4.Options();
            IList <P4.FileSpec> files = new List <P4.FileSpec>();

            if ((effectiveSource.Parent != null && effectiveSource.Parent.Path == effectiveTarget.Id) || (effectiveSource.BaseParent != null && effectiveSource.BaseParent.Path == effectiveTarget.Id))
            {
                opts["-S"] = effectiveSource.Id;
            }
            else if ((effectiveTarget.Parent != null && effectiveTarget.Parent.Path == effectiveSource.Id) || (effectiveTarget.BaseParent != null && effectiveTarget.BaseParent.Path == effectiveSource.Id))
            {
                opts["-S"] = effectiveTarget.Id;
                opts["-r"] = null;
            }

            if (_action == "merge")
            {
                files = _scm.MergeFiles(opts);
            }
            else if (_action == "copy")
            {
                files = _scm.CopyFiles(opts);
            }

            P4.P4CommandResult results = _scm.Connection.Repository.Connection.LastResults;
            string             preview = null;

            if (_scm.Connection.Repository.Connection.LastResults.ErrorList != null)
            {
                previewTB.Text = preview;
                foreach (P4.P4ClientError error in _scm.Connection.Repository.Connection.LastResults.ErrorList)
                {
                    previewTB.AppendText(error.ErrorMessage);
                }
                DialogResult = DialogResult.None;
                return;
            }
            if (files != null)
            {
                // if there are files to merge or copy, offer
                // changelist selection and submit or save
                int                   count   = files.Count();
                string                target  = targetTB.Text;
                string                action  = null;
                string                summary = string.Empty;
                P4.Changelist         getDesc = _scm.GetChangelist(-1);
                string                newChangeDescription = getDesc.Description;
                IList <P4.Changelist> changes = _scm.GetAvailibleChangelists(-1);

                if (count > 1)
                {
                    if (_action == "merge")
                    {
                        summary = string.Format(Resources.P4VsProviderService_MergeSummary, count);
                        if (newChangeDescription == null ||
                            newChangeDescription == Resources.DefaultChangeListDescription)
                        {
                            newChangeDescription = string.Format(
                                Resources.P4VsProviderService_MergeChangeDescription, target);
                        }
                    }
                    else if (_action == "copy")
                    {
                        summary = string.Format(Resources.P4VsProviderService_CopySummary, count);
                        if (newChangeDescription == null ||
                            newChangeDescription == Resources.DefaultChangeListDescription)
                        {
                            newChangeDescription = string.Format(
                                Resources.P4VsProviderService_CopyChangeDescription, target);
                        }
                        if (submitCopiedRB.Checked)
                        {
                            string[] fileStringArray = new string[count];
                            for (int idx = 0; idx < count; idx++)
                            {
                                fileStringArray[idx] = files[idx].LocalPath.Path;
                            }
                            _scm.SubmitFiles(newChangeDescription, null, false, fileStringArray);
                            return;
                        }
                    }
                }
                else
                {
                    if (_action == "merge")
                    {
                        summary = Resources.P4VsProviderService_Merge1Summary;
                        if (newChangeDescription == null ||
                            newChangeDescription == Resources.DefaultChangeListDescription)
                        {
                            newChangeDescription = string.Format(
                                Resources.P4VsProviderService_Merge1ChangeDescription, target);
                        }
                    }
                    else if (_action == "copy")
                    {
                        summary = Resources.P4VsProviderService_Copy1Summary;
                        if (newChangeDescription == null ||
                            newChangeDescription == Resources.DefaultChangeListDescription)
                        {
                            newChangeDescription = string.Format(
                                Resources.P4VsProviderService_Copy1ChangeDescription, target);
                        }
                        if (submitCopiedRB.Checked)
                        {
                            _scm.SubmitFiles(newChangeDescription, null, false, files[0].LocalPath.Path);
                            return;
                        }
                    }
                }

                int           changeListId = -1;
                P4.Changelist changelist   = SelectChangelistDlg.ShowChooseChangelistSubmit(
                    summary,
                    changes, ref newChangeDescription, out action, true, true, _scm);
                changeListId = changelist.Id;

                if (changeListId == -2)
                {
                    // user hit 'No'
                    return;
                }
                opts = new P4.Options();

                if (changeListId > 0)
                {
                    opts["-c"] = changeListId.ToString();
                }

                P4.Changelist changeToSubmit = _scm.Connection.Repository.NewChangelist();
                if (changeListId == -1)
                {
                    // Overwrite new changelist files. If default has files in it, a new
                    // changelist will automatically get those files.
                    changeToSubmit.Files       = files as IList <P4.FileMetaData>;
                    changeToSubmit.Description = changelist.Description;
                    changeToSubmit             = _scm.SaveChangelist(changeToSubmit, null);
                    opts["-c"]   = changeToSubmit.Id.ToString();
                    changeListId = changeToSubmit.Id;
                }

                if (opts.ContainsKey("-c"))
                {
                    Int32 c = Convert.ToInt32(opts["-c"]);
                    changeToSubmit = _scm.GetChangelist(c);
                    _scm.MoveFilesToChangeList(c, changelist.Description, files);
                    changeListId = changeToSubmit.Id;
                }

                // done, unless submit was hit
                if (action == "submit")
                {
                    changeToSubmit.Description = changelist.Description;

                    if (changeListId > 0)
                    {
                        SubmitDlg.SubmitPendingChanglist(changeToSubmit, changeToSubmit.Files, _scm);
                    }
                    else
                    {
                        IList <string> list = new List <string>();
                        foreach (P4.FileSpec fs in files)
                        {
                            list.Add(fs.LocalPath.Path.ToString());
                        }
                        SubmitDlg.SubmitFiles(list, _scm, false, changeToSubmit.Description);
                    }
                }
            }
            returnedFiles = files;
            DialogResult  = DialogResult.OK;
            return;
        }
Пример #3
0
        private void Init(string prompt, IList <string> files, IList <string> actions, IList <P4.Changelist> items)
        {
            PreferenceKey = "SelectChangelistDlg2";

            InitializeComponent();
            this.Icon = Images.icon_p4vs_16px;
            NewChangelistDescription = Resources.SelectChangelistDlg_DefaultNewChangeDesc;

            //PromptLbl.Text = prompt;
            msgText.Text = prompt;

            changeMap = new Dictionary <int, P4.Changelist>();

            //add new as the first item in the list
            ItemsCB.Items.Add(Resources.Changelist_New);
            changeMap[-1] = null;

            //add default as the first item in the list if not already there
            ItemsCB.Items.Add(Resources.Changelist_Default);
            changeMap[-0] = null;

            if ((items != null) && (items.Count > 0))
            {
                foreach (P4.Changelist item in items)
                {
                    int id = item.Id;
                    if ((id != -1) && (id != 0))
                    {
                        changeMap[id] = item;
                        int idx = ItemsCB.Items.Add(SelectChangelistDlg.ChangeListToString(item));
                    }
                }
            }

            Files = files;

            HideActionsColumn = (actions == null);

            if ((files != null) && (files.Count > 0))
            {
                for (int idx = 0; idx < files.Count; idx++)
                {
                    string action = string.Empty;
                    if ((actions != null) && (idx < actions.Count) && (actions[idx] != null))
                    {
                        action = actions[idx];
                    }
                    if (files[idx] != null)
                    {
                        string       fileName = Path.GetFileName(files[idx]);
                        string       path     = Path.GetDirectoryName(files[idx]);
                        ListViewItem item     = new ListViewItem(new string[] { action, fileName, path });

                        FilesList.Items.Add(item);
                    }
                }
            }
            // select the default changelist
            ItemsCB.SelectedIndex = 1;

            OkBtn.Enabled = ItemsCB.SelectedIndex >= 0;
        }
Пример #4
0
        public static int ShowQuerySave(string fileName, IList <P4.Changelist> items, out int changelistId, out string NewChangeDescription)
        {
            NewChangeDescription = null;
            changelistId         = P4VsProvider.Instance.ChangeLists.ActiveChangeList;

            //if ((items == null) || (items.Count <= 0))
            //{
            //    return Checkout;
            //}
            if (DateTime.Now - LastQuerySaveTime < TimeSpan.FromSeconds(2))
            {
                changelistId = LastQuerySaveChangelistId;
                if (changelistId == -1)
                {
                    NewChangeDescription = LastQuerySaveChangeDesc;
                }
                LastQuerySaveTime = DateTime.Now;
                return(LastQuerySaveResult);
            }
            if (Preferences.LocalSettings.GetBool("PromptForChanglist", true))
            {
                string prompt = string.Format(
                    Resources.SelectChangelistDlg_QueryEditOrSavePrompt,
                    System.IO.Path.GetFileName(fileName));
                SelectChangelistDlg dlg = new SelectChangelistDlg(prompt, items);

                dlg.saveToChangelistBtn.Visible = false;
                dlg.submitBtn.Visible           = false;

                dlg.OkBtn.Visible     = false;
                dlg.CancelBtn.Visible = false;

                dlg.CheckoutAndSaveBtn.Visible = true;
                dlg.SkipSaveBtn.Visible        = true;
                dlg.SaveAsBtn.Visible          = true;
                dlg.CancelSaveBtn.Visible      = true;

                dlg.CancelButton = dlg.CancelSaveBtn;

                dlg.ShowApplyToAllChk  = true;
                dlg.ApplyToAllChk.Text = Resources.SelectChangelistDlg_ApplyToAllFilesSaveLabel;

                dlg.CancelEditBtn.Visible = false;
                dlg.EditFileBtn.Visible   = false;
                dlg.CheckoutBtn.Visible   = false;

                dlg.BtnPanel.Controls.Clear();
                dlg.BtnPanel.Controls.Add(dlg.BtnPanelBuffer);
                dlg.BtnPanel.Controls.Add(dlg.CheckoutAndSaveBtn);
                dlg.BtnPanel.Controls.Add(dlg.SkipSaveBtn);
                dlg.BtnPanel.Controls.Add(dlg.SaveAsBtn);
                dlg.BtnPanel.Controls.Add(dlg.CancelSaveBtn);

                //dlg.BtnPanel.Controls.Add(dlg.CheckoutBtn);
                //dlg.BtnPanel.Controls.Add(dlg.EditFileBtn);
                //dlg.BtnPanel.Controls.Add(dlg.CancelEditBtn);
                //dlg.BtnPanel.Controls.Add(dlg.saveToChangelistBtn);
                //dlg.BtnPanel.Controls.Add(dlg.submitBtn);
                //dlg.BtnPanel.Controls.Add(dlg.OkBtn);
                //dlg.BtnPanel.Controls.Add(dlg.CancelBtn);

                dlg.CheckoutAndSaveBtn.Column = 1;
                dlg.SkipSaveBtn.Column        = 2;
                dlg.SaveAsBtn.Column          = 3;
                dlg.CancelSaveBtn.Column      = 4;
                dlg.BtnPanel.InitializeGrid(true);

                DialogResult result = dlg.ShowDialog();

                if (dlg.ApplyToAllChk.Checked)
                {
                    LastQuerySaveTime = DateTime.Now;
                }

                if (result == DialogResult.Cancel)
                {
                    LastQuerySaveResult = Cancel;
                    return(Cancel);
                }
                else if (result == DialogResult.Ignore)
                {
                    LastQuerySaveResult = Ignore;
                    return(Ignore);
                }
                else if (result == DialogResult.Retry)
                {
                    LastQuerySaveResult = SaveAs;
                    return(SaveAs);
                }
                changelistId = dlg.Result;
                LastQuerySaveChangelistId = changelistId;
                if (changelistId == -1)
                {
                    NewChangeDescription    = dlg.DescriptionTB.Text;
                    LastQuerySaveChangeDesc = NewChangeDescription;
                }
                LastQuerySaveResult = Checkout;
                return(Checkout);
            }
            else
            {
                return(Checkout);
            }
        }
Пример #5
0
        public static int ShowChooseChangelist(string prompt, IList <P4.Changelist> items, ref string NewChangeDescription)
        {
            //if ((items == null) || (items.Count <= 0))
            //{
            //    return 0;
            //}
            if (Preferences.LocalSettings.GetBool("PromptForChanglist", true) || (P4VsProvider.Instance.ChangeLists.ActiveChangeList == -2))
            {
                if (ActiveChangeList > -1)
                {
                    CurrentChangeListLastUse = DateTime.Now;
//					NewChangeDescription = CurrentChangeDescription;
                    return(CurrentChangeList);
                }
                SelectChangelistDlg dlg = new SelectChangelistDlg(prompt, items);

                dlg.NewChangelistDescription = NewChangeDescription;

                dlg.OkBtn.Visible     = true;
                dlg.CancelBtn.Visible = true;

                dlg.CancelButton = dlg.CancelBtn;

                dlg.saveToChangelistBtn.Visible = false;
                dlg.submitBtn.Visible           = false;

                dlg.CheckoutAndSaveBtn.Visible = false;
                dlg.SkipSaveBtn.Visible        = false;
                dlg.SaveAsBtn.Visible          = false;
                dlg.CancelSaveBtn.Visible      = false;

                dlg.CancelEditBtn.Visible = false;
                dlg.EditFileBtn.Visible   = false;
                dlg.CheckoutBtn.Visible   = false;

                dlg.BtnPanel.Controls.Clear();
                dlg.BtnPanel.Controls.Add(dlg.BtnPanelBuffer);
                //dlg.BtnPanel.Controls.Add(dlg.CancelEditBtn);
                dlg.BtnPanel.Controls.Add(dlg.CancelBtn);
                //dlg.BtnPanel.Controls.Add(dlg.CancelSaveBtn);
                //dlg.BtnPanel.Controls.Add(dlg.SkipSaveBtn);
                //dlg.BtnPanel.Controls.Add(dlg.SaveAsBtn);
                //dlg.BtnPanel.Controls.Add(dlg.CheckoutAndSaveBtn);
                //dlg.BtnPanel.Controls.Add(dlg.CheckoutBtn);
                //dlg.BtnPanel.Controls.Add(dlg.EditFileBtn);
                //dlg.BtnPanel.Controls.Add(dlg.submitBtn);
                dlg.BtnPanel.Controls.Add(dlg.OkBtn);
                //dlg.BtnPanel.Controls.Add(dlg.saveToChangelistBtn);

                dlg.OkBtn.Column     = 1;
                dlg.CancelBtn.Column = 2;
                dlg.BtnPanel.InitializeGrid(true);

                if (dlg.ShowDialog() == DialogResult.Cancel)
                {
                    CurrentChangeList = -2;
                    return(CurrentChangeList);
                }
                int changelistId = dlg.Result;
                if (changelistId == -1)
                {
                    NewChangeDescription = dlg.DescriptionTB.Text;
//					CurrentChangeDescription = NewChangeDescription;
                }
                CurrentChangeListLastUse = DateTime.Now;
                CurrentChangeList        = changelistId;
                return(changelistId);
            }
            else
            {
                return(P4VsProvider.Instance.ChangeLists.ActiveChangeList);
            }
        }
Пример #6
0
        public static P4.Changelist ShowChooseChangelistSubmit(string prompt, IList <P4.Changelist> items,
                                                               ref string NewChangeDescription, out string action, bool streams, bool integ, P4ScmProvider scm)
        {
            action = null;
            P4.Changelist changelist = scm.Connection.Repository.NewChangelist();
            // Make sure files is empty. If default has files in it, a new changelist
            // will automatically get those files.
            changelist.Files = new List <P4.FileMetaData>();
            if (Preferences.LocalSettings.GetBool("PromptForChanglist", true) ||
                integ == true)
            {
                SelectChangelistDlg dlg = new SelectChangelistDlg(prompt, items);

                dlg.saveToChangelistBtn.Enabled = true;
                dlg.saveToChangelistBtn.Visible = true;
                dlg.submitBtn.Enabled           = true;
                dlg.submitBtn.Visible           = true;

                if (streams)
                {
                    dlg.CancelBtn.Visible = false;
                    dlg.CancelBtn.Enabled = false;
                    dlg.ControlBox        = false;

                    dlg.BtnPanel.Controls.Clear();
                    dlg.BtnPanel.Controls.Add(dlg.BtnPanelBuffer);
                    dlg.BtnPanel.Controls.Add(dlg.saveToChangelistBtn);
                    dlg.BtnPanel.Controls.Add(dlg.submitBtn);

                    dlg.saveToChangelistBtn.Column = 1;
                    dlg.submitBtn.Column           = 2;
                    dlg.submitBtn.Column           = 3;
                    dlg.BtnPanel.InitializeGrid(true);
                }
                else
                {
                    dlg.CancelBtn.Visible = true;

                    dlg.BtnPanel.Controls.Clear();
                    dlg.BtnPanel.Controls.Add(dlg.BtnPanelBuffer);
                    dlg.BtnPanel.Controls.Add(dlg.saveToChangelistBtn);
                    dlg.BtnPanel.Controls.Add(dlg.submitBtn);
                    dlg.BtnPanel.Controls.Add(dlg.CancelBtn);

                    dlg.saveToChangelistBtn.Column = 1;
                    dlg.submitBtn.Column           = 2;
                    dlg.submitBtn.Column           = 3;
                    dlg.CancelBtn.Column           = 4;
                    dlg.BtnPanel.InitializeGrid(true);
                }
                dlg.NewChangelistDescription = NewChangeDescription;

                dlg.CancelButton = dlg.CancelBtn;

                dlg.OkBtn.Visible = false;

                dlg.CheckoutAndSaveBtn.Visible = false;
                dlg.SkipSaveBtn.Visible        = false;
                dlg.SaveAsBtn.Visible          = false;
                dlg.CancelSaveBtn.Visible      = false;

                dlg.CancelEditBtn.Visible = false;
                dlg.EditFileBtn.Visible   = false;
                dlg.CheckoutBtn.Visible   = false;

                //dlg.BtnPanel.Controls.Add(dlg.CancelEditBtn);
                //dlg.BtnPanel.Controls.Add(dlg.CancelBtn);
                //dlg.BtnPanel.Controls.Add(dlg.CancelSaveBtn);
                //dlg.BtnPanel.Controls.Add(dlg.SkipSaveBtn);
                //dlg.BtnPanel.Controls.Add(dlg.SaveAsBtn);
                //dlg.BtnPanel.Controls.Add(dlg.CheckoutAndSaveBtn);
                //dlg.BtnPanel.Controls.Add(dlg.CheckoutBtn);
                //dlg.BtnPanel.Controls.Add(dlg.EditFileBtn);

                if (dlg.ShowDialog() == DialogResult.Cancel)
                {
                    return(null);
                }

                if (dlg.DialogResult == DialogResult.OK)
                {
                    // Save to Changelist
                    changelist.Description = dlg.DescriptionTB.Text;
                    return(changelist);
                }

                if (dlg.DialogResult == DialogResult.Yes)
                {
                    // Submit...
                    action = "submit";
                    changelist.Description = dlg.DescriptionTB.Text;
                    return(changelist);
                }

                int changelistId = dlg.Result;
                if (changelistId == -1)
                {
                    changelist.Description = dlg.DescriptionTB.Text;
                }
                return(changelist);
            }
            else
            {
                changelist = P4VsProvider.CurrentScm.GetChangelist(P4VsProvider.Instance.ChangeLists.ActiveChangeList, null);
                return(changelist);
            }
        }
Пример #7
0
        public static int ShowChooseChangelistMoveFilesInChangelist(string prompt, IList <P4.Changelist> items, ref string NewChangeDescription, P4ScmProvider scm)
        {
            if (ActiveChangeList > -1)
            {
                CurrentChangeListLastUse = DateTime.Now;
                //					NewChangeDescription = CurrentChangeDescription;
                return(CurrentChangeList);
            }
            SelectChangelistDlg dlg = new SelectChangelistDlg(prompt, items);

            dlg.DontShowAgainCB.Enabled = false;
            dlg.DontShowAgainCB.Visible = false;

            dlg.saveToChangelistBtn.Visible = false;
            dlg.submitBtn.Visible           = false;

            dlg.NewChangelistDescription = NewChangeDescription;

            dlg.OkBtn.Visible     = true;
            dlg.CancelBtn.Visible = true;

            dlg.CancelButton = dlg.CancelBtn;

            dlg.CheckoutAndSaveBtn.Visible = false;
            dlg.SkipSaveBtn.Visible        = false;
            dlg.SaveAsBtn.Visible          = false;
            dlg.CancelSaveBtn.Visible      = false;

            dlg.CancelEditBtn.Visible = false;
            dlg.EditFileBtn.Visible   = false;
            dlg.CheckoutBtn.Visible   = false;

            dlg.BtnPanel.Controls.Clear();
            dlg.BtnPanel.Controls.Add(dlg.BtnPanelBuffer);
            //dlg.BtnPanel.Controls.Add(dlg.CancelEditBtn);
            dlg.BtnPanel.Controls.Add(dlg.CancelBtn);
            //dlg.BtnPanel.Controls.Add(dlg.CancelSaveBtn);
            //dlg.BtnPanel.Controls.Add(dlg.SkipSaveBtn);
            //dlg.BtnPanel.Controls.Add(dlg.SaveAsBtn);
            //dlg.BtnPanel.Controls.Add(dlg.CheckoutAndSaveBtn);
            //dlg.BtnPanel.Controls.Add(dlg.CheckoutBtn);
            //dlg.BtnPanel.Controls.Add(dlg.EditFileBtn);
            //dlg.BtnPanel.Controls.Add(dlg.submitBtn);
            dlg.BtnPanel.Controls.Add(dlg.OkBtn);
            //dlg.BtnPanel.Controls.Add(dlg.saveToChangelistBtn);

            dlg.OkBtn.Column     = 1;
            dlg.CancelBtn.Column = 2;
            dlg.BtnPanel.InitializeGrid(true);

            if (dlg.ShowDialog() == DialogResult.Cancel)
            {
                CurrentChangeList = -2;
                return(CurrentChangeList);
            }
            int changelistId = dlg.Result;

            if (changelistId == -1)
            {
                P4.Changelist newChange = scm.Connection.Repository.NewChangelist();
                // Make sure files is empty. If default has files in it, a new changelist
                // will automatically get those files.
                newChange.Files = new List <P4.FileMetaData>();

                newChange.Description = dlg.DescriptionTB.Text;
                newChange             = scm.SaveChangelist(newChange, null);
                if (newChange != null)
                {
                    return(newChange.Id);
                }
                else
                {
                    return(changelistId);
                }
            }
            CurrentChangeListLastUse = DateTime.Now;
            CurrentChangeList        = changelistId;
            return(changelistId);
        }