コード例 #1
0
ファイル: MainForm.cs プロジェクト: rustyx/vss2git
        private void goButton_Click(object sender, EventArgs e)
        {
            try
            {
                OpenLog(logTextBox.Text);

                logger.WriteLine("VSS2Git 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("Comment transcoding: {0}",
                    transcodeCheckBox.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;
                }
                // read the emails dictionary
                var emailDictionary = ReadDictionaryFile("e-mail dictionary", db.BasePath, "emails.properties");

                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.BuildChangesets();

                if (!string.IsNullOrEmpty(outDirTextBox.Text))
                {
                    IVcsWrapper vcsWrapper = CreateVcsWrapper(encoding);

                    var vcsExporter = new VcsExporter(workQueue, logger,
                        revisionAnalyzer, changesetBuilder, vcsWrapper, emailDictionary);
                    if (!string.IsNullOrEmpty(domainTextBox.Text))
                    {
                        vcsExporter.EmailDomain = domainTextBox.Text;
                    }
                    if (!transcodeCheckBox.Checked)
                    {
                        vcsExporter.CommitEncoding = encoding;
                    }
                    vcsExporter.ResetRepo = resetRepoCheckBox.Checked;
                    vcsExporter.ExportToVcs(outDirTextBox.Text, continueAfter);
                }

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

                statusTimer.Enabled = true;
                goButton.Enabled = false;
                cancelButton.Text = "Cancel";
            }
            catch (Exception ex)
            {
                ShowException(ex);
            }
        }
コード例 #2
0
        private void goButton_Click(object sender, EventArgs e)
        {
            try
            {
                OpenLog(logTextBox.Text);

                logger.WriteLine("VSS2Git 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("Comment transcoding: {0}",
                                 transcodeCheckBox.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;
                }
                // read the emails dictionary
                var emailDictionary = ReadDictionaryFile("e-mail dictionary", db.BasePath, "emails.properties");

                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.BuildChangesets();

                if (!string.IsNullOrEmpty(outDirTextBox.Text))
                {
                    IVcsWrapper vcsWrapper = CreateVcsWrapper(encoding);

                    var vcsExporter = new VcsExporter(workQueue, logger,
                                                      revisionAnalyzer, changesetBuilder, vcsWrapper, emailDictionary);
                    if (!string.IsNullOrEmpty(domainTextBox.Text))
                    {
                        vcsExporter.EmailDomain = domainTextBox.Text;
                    }
                    if (!transcodeCheckBox.Checked)
                    {
                        vcsExporter.CommitEncoding = encoding;
                    }
                    vcsExporter.ResetRepo = resetRepoCheckBox.Checked;
                    vcsExporter.ExportToVcs(outDirTextBox.Text, continueAfter);
                }

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

                statusTimer.Enabled = true;
                goButton.Enabled    = false;
                cancelButton.Text   = "Cancel";
            }
            catch (Exception ex)
            {
                ShowException(ex);
            }
        }
コード例 #3
0
        private void goButton_Click(object sender, EventArgs e)
        {
            try
            {
                AdvancedTaskbar.EnableItermediate();
                OpenLog(logTextBox.Text);

                logger.WriteLine("VSS2Git 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("Comment transcoding: {0}",
                                 transcodeCheckBox.Checked ? "enabled" : "disabled");
                logger.WriteLine("Ignore VCS errors: {0}",
                                 ignoreVcsErrorsCheckBox.Checked ? "enabled" : "disabled");
                logger.WriteLine("Collapsing path of output directory",
                                 RemovePathTextBox.Text);

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


                //start here
                string[] lines;

                // read the emails dictionary
                var emailDictionary = ReadDictionaryFile("e-mail dictionary", db.BasePath, emailPropertiesFileName);

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

                if (UseProjectsFile.Checked)
                {
                    lines = File.ReadAllLines(ProjectsFileLocation.Text, Encoding.UTF8);
                    foreach (String line in lines)
                    {
                        if (line.Length <= 0)
                        {
                            continue;
                        }
                        string[] variation = line.Split('=');
                        string   vssPath   = variation[0];
                        //Here add the paths.
                        VssProject item;
                        try
                        {
                            item = (VssProject)db.GetItem(vssPath.Trim());
                        }
                        catch (VssPathException ex)
                        {
                            MessageBox.Show(ex.Message, "Invalid project path",
                                            MessageBoxButtons.OK, MessageBoxIcon.Error);
                            return;
                        }
                        if (variation.Length > 1)
                        {
                            item.RootPath = variation[1].Trim();
                        }
                        else
                        {
                            item.RootPath = "";
                        }

                        revisionAnalyzer.AddItem(item);
                    }
                }
                else
                {
                    var paths = vssProjectTextBox.Text.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries);
                    foreach (var path in paths)
                    {
                        VssItem item;
                        try
                        {
                            item = db.GetItem(path.Trim());
                        }
                        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.AddItem(project);
                    }
                }


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

                if (!string.IsNullOrEmpty(outDirTextBox.Text))
                {
                    IVcsWrapper vcsWrapper = CreateVcsWrapper(encoding);

                    var vcsExporter = new VcsExporter(workQueue, logger,
                                                      revisionAnalyzer, changesetBuilder, vcsWrapper, emailDictionary);
                    if (!string.IsNullOrEmpty(domainTextBox.Text))
                    {
                        vcsExporter.EmailDomain = domainTextBox.Text;
                    }
                    if (!string.IsNullOrEmpty(commentTextBox.Text))
                    {
                        vcsExporter.DefaultComment = commentTextBox.Text;
                    }
                    if (!transcodeCheckBox.Checked)
                    {
                        vcsExporter.CommitEncoding = encoding;
                    }
                    vcsExporter.RemovePath = RemovePathTextBox.Text;
                    vcsExporter.TryGenerateCommitMessage = tryGenerateCommitMessageCheckBox.Checked;
                    vcsExporter.IgnoreVcsErrors          = ignoreVcsErrorsCheckBox.Checked;
                    vcsExporter.ResetRepo         = resetRepoCheckBox.Checked;
                    vcsExporter.FolderBeforeLabel = FolderBeforeLabel.Checked;

                    vcsExporter.UseProjectsFile = UseProjectsFile.Checked;

                    if (vcsExporter.ResetRepo)
                    {
                        vcsExporter.ExportToVcs(outDirTextBox.Text, null);
                    }
                    else
                    {
                        vcsExporter.ExportToVcs(outDirTextBox.Text, continueAfter);
                    }
                }

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

                statusTimer.Enabled = true;
                emailMap.Enabled    = false;
                goButton.Enabled    = false;
                cancelButton.Text   = "Cancel";
            }
            catch (Exception ex)
            {
                logger.Dispose();
                logger = Logger.Null;
                ShowException(ex);
            }
        }