Exemplo n.º 1
0
        private void goButton_Click(object sender, EventArgs e)
        {
            try
            {
                OpenLog(logTextBox.Text);

                logger.WriteLine("VSS2Svn version {0}", Assembly.GetExecutingAssembly().GetName().Version);

                WriteSettings();

                Encoding     encoding = Encoding.Default;
                EncodingInfo encodingInfo;
                if (codePages.TryGetValue(encodingComboBox.SelectedIndex, out encodingInfo))
                {
                    encoding = encodingInfo.GetEncoding();
                }

                logger.WriteLine("VSS encoding: {0} (CP: {1}, IANA: {2})",
                                 encoding.EncodingName, encoding.CodePage, encoding.WebName);
                logger.WriteLine("Transcode comments to UTF-8: {0}",
                                 transcodeCheckBox.Checked ? "enabled" : "disabled");
                logger.WriteLine("Use SVN standard dir structure: {0}",
                                 useSvnDirStructureCheckBox.Checked ? "enabled" : "disabled");
                logger.WriteLine("Exclude all destroyed items: {0}",
                                 excludeAllDestroyedItemsCheckBox.Checked ? "enabled" : "disabled");

                var df = new VssDatabaseFactory(vssDirTextBox.Text);
                df.Encoding = encoding;
                var db = df.Open();

                var     path = vssProjectTextBox.Text;
                VssItem item;
                try
                {
                    item = db.GetItem(path);
                }
                catch (VssPathException ex)
                {
                    MessageBox.Show(ex.Message, "Invalid project path",
                                    MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }

                var project = item as VssProject;
                if (project == null)
                {
                    MessageBox.Show(path + " is not a project", "Invalid project path",
                                    MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }

                revisionAnalyzer = new RevisionAnalyzer(workQueue, logger, db);
                if (!string.IsNullOrEmpty(excludeTextBox.Text))
                {
                    revisionAnalyzer.ExcludeFiles = excludeTextBox.Text;
                }
                revisionAnalyzer.AddItem(project);

                changesetBuilder = new ChangesetBuilder(workQueue, logger, revisionAnalyzer);
                changesetBuilder.AnyCommentThreshold = TimeSpan.FromSeconds((double)anyCommentUpDown.Value);

                changesetBuilder.SameCommentThreshold     = TimeSpan.FromSeconds((double)sameCommentUpDown.Value);
                changesetBuilder.ExcludeAllDestroyedItems = excludeAllDestroyedItemsCheckBox.Checked;
                changesetBuilder.BuildChangesets();

                if (!string.IsNullOrEmpty(outDirTextBox.Text))
                {
                    var svnExporter = new SvnExporter(workQueue, logger,
                                                      revisionAnalyzer, changesetBuilder);
                    if (!transcodeCheckBox.Checked)
                    {
                        svnExporter.CommitEncoding = encoding;
                    }
                    svnExporter.ForceAnnotatedTags = forceAnnotatedCheckBox.Checked;

                    svnExporter.ParentWindow = this;
                    svnExporter.ExportToSvn(outDirTextBox.Text, InheritProjectDirCheckBox.Checked, useSvnDirStructureCheckBox.Checked);
                }

                workQueue.Idle += delegate
                {
                    logger.Dispose();
                    logger = Logger.Null;
                };

                statusTimer.Enabled = true;
                goButton.Enabled    = false;
            }
            catch (Exception ex)
            {
                ShowException(ex);
            }
        }
Exemplo n.º 2
0
        private void goButton_Click(object sender, EventArgs e)
        {
            try
            {
                OpenLog(logTextBox.Text);

                logger.WriteLine("VSS2Svn version {0}", Assembly.GetExecutingAssembly().GetName().Version);

                WriteSettings();

                Encoding encoding = Encoding.Default;
                EncodingInfo encodingInfo;
                if (codePages.TryGetValue(encodingComboBox.SelectedIndex, out encodingInfo))
                {
                    encoding = encodingInfo.GetEncoding();
                }

                logger.WriteLine("VSS encoding: {0} (CP: {1}, IANA: {2})",
                    encoding.EncodingName, encoding.CodePage, encoding.WebName);
                logger.WriteLine("Transcode comments to UTF-8: {0}",
                    transcodeCheckBox.Checked ? "enabled" : "disabled");
                logger.WriteLine("Use SVN standard dir structure: {0}",
                    useSvnDirStructureCheckBox.Checked ? "enabled" : "disabled");
                logger.WriteLine("Exclude all destroyed items: {0}",
                    excludeAllDestroyedItemsCheckBox.Checked ? "enabled" : "disabled");

                var df = new VssDatabaseFactory(vssDirTextBox.Text);
                df.Encoding = encoding;
                var db = df.Open();

                var path = vssProjectTextBox.Text;
                VssItem item;
                try
                {
                    item = db.GetItem(path);
                }
                catch (VssPathException ex)
                {
                    MessageBox.Show(ex.Message, "Invalid project path",
                        MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }

                var project = item as VssProject;
                if (project == null)
                {
                    MessageBox.Show(path + " is not a project", "Invalid project path",
                        MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }

                revisionAnalyzer = new RevisionAnalyzer(workQueue, logger, db);
                if (!string.IsNullOrEmpty(excludeTextBox.Text))
                {
                    revisionAnalyzer.ExcludeFiles = excludeTextBox.Text;
                }
                revisionAnalyzer.AddItem(project);

                changesetBuilder = new ChangesetBuilder(workQueue, logger, revisionAnalyzer);
                changesetBuilder.AnyCommentThreshold = TimeSpan.FromSeconds((double)anyCommentUpDown.Value);

                changesetBuilder.SameCommentThreshold = TimeSpan.FromSeconds((double)sameCommentUpDown.Value);
                changesetBuilder.ExcludeAllDestroyedItems = excludeAllDestroyedItemsCheckBox.Checked;
                changesetBuilder.BuildChangesets();

                if (!string.IsNullOrEmpty(outDirTextBox.Text))
                {
                    var svnExporter = new SvnExporter(workQueue, logger,
                        revisionAnalyzer, changesetBuilder);
                    if (!transcodeCheckBox.Checked)
                    {
                        svnExporter.CommitEncoding = encoding;
                    }
                    svnExporter.ForceAnnotatedTags = forceAnnotatedCheckBox.Checked;

                    svnExporter.ParentWindow = this;
                    svnExporter.ExportToSvn(outDirTextBox.Text, InheritProjectDirCheckBox.Checked, useSvnDirStructureCheckBox.Checked);
                }

                workQueue.Idle += delegate
                {
                    logger.Dispose();
                    logger = Logger.Null;
                };

                statusTimer.Enabled = true;
                goButton.Enabled = false;
            }
            catch (Exception ex)
            {
                ShowException(ex);
            }
        }