Esempio n. 1
0
        public void OnExecute(CommandEventArgs e)
        {
            IAnkhSolutionSettings slnSettings = e.GetService <IAnkhSolutionSettings>();
            List <ISvnLogItem>    logItems    = new List <ISvnLogItem>(e.Selection.GetSelection <ISvnLogItem>());

            if (logItems.Count != 1)
            {
                return;
            }

            using (EditLogMessageDialog dialog = new EditLogMessageDialog())
            {
                dialog.Context    = e.Context;
                dialog.LogMessage = logItems[0].LogMessage;

                if (dialog.ShowDialog(e.Context) == DialogResult.OK)
                {
                    if (dialog.LogMessage == logItems[0].LogMessage)
                    {
                        return; // No changes
                    }
                    IAnkhConfigurationService config = e.GetService <IAnkhConfigurationService>();

                    if (config != null)
                    {
                        if (dialog.LogMessage != null && dialog.LogMessage.Trim().Length > 0)
                        {
                            config.GetRecentLogMessages().Add(dialog.LogMessage);
                        }
                    }

                    using (SvnClient client = e.GetService <ISvnClientPool>().GetClient())
                    {
                        SvnSetRevisionPropertyArgs sa = new SvnSetRevisionPropertyArgs();
                        sa.AddExpectedError(SvnErrorCode.SVN_ERR_REPOS_DISABLED_FEATURE);
                        client.SetRevisionProperty(logItems[0].RepositoryRoot, logItems[0].Revision, SvnPropertyNames.SvnLog, dialog.LogMessage, sa);

                        if (sa.LastException != null &&
                            sa.LastException.SvnErrorCode == SvnErrorCode.SVN_ERR_REPOS_DISABLED_FEATURE)
                        {
                            AnkhMessageBox mb = new AnkhMessageBox(e.Context);

                            mb.Show(sa.LastException.Message, "", MessageBoxButtons.OK, MessageBoxIcon.Information);

                            return;
                        }
                    }

                    ILogControl logWindow = e.Selection.GetActiveControl <ILogControl>();

                    if (logWindow != null)
                    {
                        // TODO: Somehow repair scroll position/number of items loaded
                        logWindow.Restart();
                    }
                }
            }
        }
Esempio n. 2
0
        public void OnExecute(CommandEventArgs e)
        {
            ISvnLogItem selectedLog = EnumTools.GetSingle(e.Selection.GetSelection <ISvnLogItem>());

            if (selectedLog == null)
            {
                return;
            }

            using (PropertyEditorDialog dialog = new PropertyEditorDialog(selectedLog.RepositoryRoot, selectedLog.Revision, true))
            {
                SvnRevisionPropertyListArgs args = new SvnRevisionPropertyListArgs();
                args.ThrowOnError = false;
                SvnPropertyCollection properties = null;

                if (!e.GetService <IProgressRunner>().RunModal(LogStrings.RetrievingRevisionProperties,
                                                               delegate(object sender, ProgressWorkerArgs wa)
                {
                    if (!wa.Client.GetRevisionPropertyList(selectedLog.RepositoryRoot, selectedLog.Revision, args, out properties))
                    {
                        properties = null;
                    }
                }).Succeeded)
                {
                    return;
                }
                else if (properties != null)
                {
                    List <PropertyEditItem> propItems = new List <PropertyEditItem>();
                    foreach (SvnPropertyValue prop in properties)
                    {
                        PropertyEditItem pi = new PropertyEditItem(dialog.ListView, prop.Key);
                        pi.OriginalValue = pi.Value = pi.BaseValue = prop;

                        propItems.Add(pi);
                    }
                    dialog.PropertyValues = propItems.ToArray();
                }

                if (dialog.ShowDialog(e.Context) != DialogResult.OK)
                {
                    return;
                }

                PropertyEditItem[] finalItems = dialog.PropertyValues;

                bool hasChanges = false;

                foreach (PropertyEditItem ei in finalItems)
                {
                    if (ei.ShouldPersist)
                    {
                        hasChanges = true;
                        break;
                    }
                }
                if (!hasChanges)
                {
                    return;
                }

                IProgressRunner progressRunner = e.GetService <IProgressRunner>();

                ProgressRunnerResult result = progressRunner.RunModal(LogStrings.UpdatingRevisionProperties,
                                                                      delegate(object sender, ProgressWorkerArgs ee)
                {
                    foreach (PropertyEditItem ei in finalItems)
                    {
                        if (!ei.ShouldPersist)
                        {
                            continue;
                        }

                        if (ei.IsDeleted)
                        {
                            ee.Client.DeleteRevisionProperty(selectedLog.RepositoryRoot, selectedLog.Revision, ei.PropertyName);
                        }
                        else if (ei.Value.StringValue != null)
                        {
                            ee.Client.SetRevisionProperty(selectedLog.RepositoryRoot, selectedLog.Revision, ei.PropertyName, ei.Value.StringValue);
                        }
                        else
                        {
                            ee.Client.SetRevisionProperty(selectedLog.RepositoryRoot, selectedLog.Revision, ei.PropertyName, ei.Value.RawValue);
                        }
                    }
                });

                if (result.Succeeded)
                {
                    ILogControl logWindow = e.Selection.GetActiveControl <ILogControl>();

                    if (logWindow != null)
                    {
                        logWindow.Restart();
                    }
                }
            } // using
        }