ExportToGit() public method

public ExportToGit ( string repoPath ) : void
repoPath string
return void
Example #1
0
            private void ProcessProject(ProjectInfo projectInfo, Logger logger)
            {
                this.repoInfo = new RepoInfo(logger, projectInfo.VssKey, projectInfo.Project);

                this.repoInfo.RevisionAnalyzer = new RevisionAnalyzer(this.workQueue, logger, this.db);
                if (!string.IsNullOrEmpty(this.form.excludeTextBox.Text))
                {
                    this.repoInfo.RevisionAnalyzer.ExcludeFiles = this.form.excludeTextBox.Text;
                }
                this.repoInfo.RevisionAnalyzer.AddItem(projectInfo.Project);

                this.repoInfo.ChangesetBuilder = new ChangesetBuilder(this.workQueue, logger, this.repoInfo.RevisionAnalyzer);
                this.repoInfo.ChangesetBuilder.AnyCommentThreshold  = TimeSpan.FromSeconds((double)this.form.anyCommentUpDown.Value);
                this.repoInfo.ChangesetBuilder.SameCommentThreshold = TimeSpan.FromSeconds((double)this.form.sameCommentUpDown.Value);
                this.repoInfo.ChangesetBuilder.BuildChangesets();

                GitExporter gitExporter = new GitExporter(this.workQueue, logger, this.repoInfo.RevisionAnalyzer, this.repoInfo.ChangesetBuilder);

                if (!string.IsNullOrEmpty(this.form.domainTextBox.Text))
                {
                    gitExporter.EmailDomain = this.form.domainTextBox.Text;
                }
                if (!string.IsNullOrEmpty(this.form.commentTextBox.Text))
                {
                    gitExporter.DefaultComment = this.form.commentTextBox.Text;
                }
                if (!this.form.transcodeCheckBox.Checked)
                {
                    gitExporter.CommitEncoding = this.selectedEncoding;
                }
                gitExporter.IgnoreErrors = this.form.ignoreErrorsCheckBox.Checked;
                gitExporter.ExportToGit(processDir);
            }
Example #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");
                logger.WriteLine("Ignore errors: {0}",
                                 ignoreErrorsCheckBox.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.BuildChangesets();

                if (!string.IsNullOrEmpty(outDirTextBox.Text))
                {
                    var gitExporter = new GitExporter(workQueue, logger,
                                                      revisionAnalyzer, changesetBuilder);
                    if (!string.IsNullOrEmpty(domainTextBox.Text))
                    {
                        gitExporter.EmailDomain = domainTextBox.Text;
                    }
                    if (!transcodeCheckBox.Checked)
                    {
                        gitExporter.CommitEncoding = encoding;
                    }
                    gitExporter.IgnoreErrors = ignoreErrorsCheckBox.Checked;
                    gitExporter.ExportToGit(outDirTextBox.Text);
                }

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

                statusTimer.Enabled = true;
                goButton.Enabled    = false;
            }
            catch (Exception ex)
            {
                ShowException(ex);
            }
        }
Example #3
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;
                }

                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))
                {
                    var gitExporter = new GitExporter(workQueue, logger,
                        revisionAnalyzer, changesetBuilder);
                    if (!string.IsNullOrEmpty(domainTextBox.Text))
                    {
                        gitExporter.EmailDomain = domainTextBox.Text;
                    }
                    if (!transcodeCheckBox.Checked)
                    {
                        gitExporter.CommitEncoding = encoding;
                    }
                    gitExporter.ExportToGit(outDirTextBox.Text);
                }

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

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

                CloseLog();
            }
        }
Example #4
0
        private static void RunFromCommandLine(ProgramOptions options)
        {
            var logger            = string.IsNullOrEmpty(options.LogFile) ? Logger.Null : new Logger(options.LogFile);
            var workQueue         = new WorkQueue(1);
            var messageDispatcher = new ConsoleLoggerMessageDispatcher(logger, options.IgnoreErrors);

            messageDispatcher.Dispatch(MessageType.Info, workQueue.LastStatus ?? "Idle", MessageChoice.Ok);

            var encoding = Encoding.GetEncoding(options.CodePage);
            var df       = new VssDatabaseFactory(options.VssDirectory)
            {
                Encoding = encoding
            };
            var db   = df.Open();
            var item = db.GetItem(options.VssProject);

            if (!(item is VssProject project))
            {
                logger.WriteLine("Error: Not a vss project.");
                return;
            }

            var revisionAnalyzer = new RevisionAnalyzer(workQueue, logger, db, messageDispatcher);

            var changesetBuilder = new ChangesetBuilder(workQueue, logger, revisionAnalyzer, messageDispatcher)
            {
                AnyCommentThreshold  = TimeSpan.FromSeconds(options.AnyCommentSeconds),
                SameCommentThreshold = TimeSpan.FromSeconds(options.SameCommentSeconds)
            };

            void OnTimer(object state)
            {
                messageDispatcher.Dispatch(MessageType.Info, workQueue.LastStatus ?? "Idle", MessageChoice.Ok);
                messageDispatcher.Dispatch(MessageType.Info, $"Files: {revisionAnalyzer.FileCount}, Revisions: {revisionAnalyzer.RevisionCount}", MessageChoice.Ok);
                messageDispatcher.Dispatch(MessageType.Info, $"Changesets: {changesetBuilder.Changesets.Count}", MessageChoice.Ok);

                var exceptions = workQueue.FetchExceptions();

                if (exceptions != null)
                {
                    foreach (var exception in exceptions)
                    {
                        var message = ExceptionFormatter.Format(exception);
                        logger.WriteLine("ERROR: {0}", message);
                        logger.WriteLine(exception);
                    }
                }
            }

            var timer = new Timer(OnTimer, null, TimeSpan.Zero, TimeSpan.FromSeconds(1));

            if (!string.IsNullOrWhiteSpace(options.VssExcludePaths))
            {
                revisionAnalyzer.ExcludeFiles = options.VssExcludePaths;
            }
            revisionAnalyzer.AddItem(project);

            changesetBuilder.BuildChangesets();

            if (!string.IsNullOrEmpty(options.GitDirectory))
            {
                var gitExporter = new GitExporter(workQueue, logger,
                                                  revisionAnalyzer, changesetBuilder, messageDispatcher);
                if (!string.IsNullOrEmpty(options.DefaultEmailDomain))
                {
                    gitExporter.EmailDomain = options.DefaultEmailDomain;
                }
                if (!string.IsNullOrEmpty(options.EmailMapFile))
                {
                    if (File.Exists(options.EmailMapFile))
                    {
                        gitExporter.EmailMapFile = options.EmailMapFile;
                    }
                    else
                    {
                        logger.WriteLine($"Warn: {options.EmailMapFile} does not exist.");
                    }
                }
                if (!string.IsNullOrEmpty(options.DefaultComment))
                {
                    gitExporter.DefaultComment = options.DefaultComment;
                }
                if (!options.TranscodeComments)
                {
                    gitExporter.CommitEncoding = encoding;
                }
                gitExporter.IgnoreErrors = options.IgnoreErrors;
                gitExporter.ExportToGit(options.GitDirectory);
            }

            workQueue.WaitIdle();
            timer.Dispose();

            messageDispatcher.Dispatch(MessageType.Info, "Done", MessageChoice.Ok);

            Application.Exit();
        }