Reconstructs changesets from independent revisions.
상속: Worker
예제 #1
0
 public VcsExporter(WorkQueue workQueue, Logger logger,
     RevisionAnalyzer revisionAnalyzer, ChangesetBuilder changesetBuilder,
     IVcsWrapper vcsWrapper, IDictionary<string, string> usersmap)
     : base(workQueue, logger)
 {
     this.database = revisionAnalyzer.Database;
     this.revisionAnalyzer = revisionAnalyzer;
     this.changesetBuilder = changesetBuilder;
     this.vcsWrapper = vcsWrapper;
     this.emailDictionary = new Dictionary<string, string>();
     this.usernameDictionary = new Dictionary<string, string>();
     Regex emailRegex = new Regex("(\\S.*?)\\s*<(.+)>");
     foreach (var e in usersmap)
     {
         string key = e.Key.ToLower();
         string email = e.Value.Trim();
         if (email == "")
             continue;
         Match m = emailRegex.Match(email);
         if (m.Success)
         {
             this.usernameDictionary.Add(key, m.Groups[1].Value);
             email = m.Groups[2].Value;
         }
         this.emailDictionary.Add(key, email);
     }
 }
예제 #2
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);
            }
예제 #3
0
        public VcsExporter(WorkQueue workQueue, Logger logger,
                           RevisionAnalyzer revisionAnalyzer, ChangesetBuilder changesetBuilder,
                           IVcsWrapper vcsWrapper, IDictionary <string, string> usersmap)
            : base(workQueue, logger)
        {
            this.database           = revisionAnalyzer.Database;
            this.revisionAnalyzer   = revisionAnalyzer;
            this.changesetBuilder   = changesetBuilder;
            this.vcsWrapper         = vcsWrapper;
            this.emailDictionary    = new Dictionary <string, string>();
            this.usernameDictionary = new Dictionary <string, string>();
            Regex emailRegex = new Regex("(\\S.*?)\\s*<(.+)>");

            foreach (var e in usersmap)
            {
                string key   = e.Key.ToLower();
                string email = e.Value.Trim();
                if (email == "")
                {
                    continue;
                }
                Match m = emailRegex.Match(email);
                if (m.Success)
                {
                    this.usernameDictionary.Add(key, m.Groups[1].Value);
                    email = m.Groups[2].Value;
                }
                this.emailDictionary.Add(key, email);
            }
        }
예제 #4
0
 public GitExporter(WorkQueue workQueue, Logger logger,
     RevisionAnalyzer revisionAnalyzer, ChangesetBuilder changesetBuilder)
     : base(workQueue, logger)
 {
     this.database = revisionAnalyzer.Database;
     this.revisionAnalyzer = revisionAnalyzer;
     this.changesetBuilder = changesetBuilder;
 }
예제 #5
0
 public GitExporter(WorkQueue workQueue, Logger logger,
                    RevisionAnalyzer revisionAnalyzer, ChangesetBuilder changesetBuilder)
     : base(workQueue, logger)
 {
     this.database         = revisionAnalyzer.Database;
     this.revisionAnalyzer = revisionAnalyzer;
     this.changesetBuilder = changesetBuilder;
 }
예제 #6
0
 public VcsExporter(WorkQueue workQueue, Logger logger,
     RevisionAnalyzer revisionAnalyzer, ChangesetBuilder changesetBuilder,
     IVcsWrapper vcsWrapper, IDictionary<string, string> emailDictionary)
     : base(workQueue, logger)
 {
     this.database = revisionAnalyzer.Database;
     this.revisionAnalyzer = revisionAnalyzer;
     this.changesetBuilder = changesetBuilder;
     this.vcsWrapper = vcsWrapper;
     this.emailDictionary = emailDictionary;
 }
예제 #7
0
 public GitExporter(WorkQueue workQueue, Logger logger,
                    RevisionAnalyzer revisionAnalyzer, ChangesetBuilder changesetBuilder,
                    string repoPath, FileAnalyzer fileAnalyzer, bool inheritProjectDir = false)
     : base(workQueue, logger)
 {
     this.database          = revisionAnalyzer.Database;
     this.revisionAnalyzer  = revisionAnalyzer;
     this.changesetBuilder  = changesetBuilder;
     this.repoPath          = repoPath;
     this.fileAnalyzer      = fileAnalyzer;
     this.inheritProjectDir = inheritProjectDir;
 }
예제 #8
0
 public GitExporter(WorkQueue workQueue, Logger logger, 
     RevisionAnalyzer revisionAnalyzer, ChangesetBuilder changesetBuilder,
     string repoPath, FileAnalyzer fileAnalyzer, bool inheritProjectDir = false)
     : base(workQueue, logger)
 {
     this.database = revisionAnalyzer.Database;
     this.revisionAnalyzer = revisionAnalyzer;
     this.changesetBuilder = changesetBuilder;
     this.repoPath = repoPath;
     this.fileAnalyzer = fileAnalyzer;
     this.inheritProjectDir = inheritProjectDir;
 }
예제 #9
0
 public GitExporter(
     WorkQueue workQueue, Logger logger,
     RevisionAnalyzer revisionAnalyzer,
     ChangesetBuilder changesetBuilder,
     IMessageDispatcher messageDispatcher)
     : base(workQueue, logger, messageDispatcher)
 {
     database = revisionAnalyzer.Database;
     this.revisionAnalyzer  = revisionAnalyzer;
     this.changesetBuilder  = changesetBuilder;
     this.messageDispatcher = messageDispatcher;
 }
예제 #10
0
        private void statusTimer_Tick(object sender, EventArgs e)
        {
            statusLabel.Text = workQueue.LastStatus ?? "Idle";
            timeLabel.Text   = string.Format("Elapsed: {0:HH:mm:ss}",
                                             new DateTime(workQueue.ActiveTime.Ticks));

            if (revisionAnalyzer != null)
            {
                fileLabel.Text     = "Files: " + revisionAnalyzer.FileCount;
                revisionLabel.Text = "Revisions: " + revisionAnalyzer.RevisionCount;
            }

            if (changesetBuilder != null)
            {
                changeLabel.Text = "Changesets: " + changesetBuilder.Changesets.Count;
                if (changesetBuilder.Changesets.Count > 1)
                {
                    AdvancedTaskbar.EnableProgress((uint)changesetBuilder.Changesets.Count);
                }
            }

            if (workQueue.IsIdle)
            {
                revisionAnalyzer = null;
                changesetBuilder = null;

                statusTimer.Enabled = false;
                if (!goButton.Enabled)
                {
                    LoadRepoSettings();
                }
                emailMap.Enabled = true;
                goButton.Enabled = true;
                AdvancedTaskbar.Disable();
                cancelButton.Text = "Close";
                if (goAndExit && exitOnComplete)
                {
                    exitOnComplete = false;
                    Close();
                }
            }

            var exceptions = workQueue.FetchExceptions();

            if (exceptions != null)
            {
                foreach (var exception in exceptions)
                {
                    ShowException(exception);
                }
            }
        }
예제 #11
0
        private void statusTimer_Tick(object sender, EventArgs e)
        {
            progressBar1.Value = workQueue.LastProgress;
            statusLabel.Text   = workQueue.LastStatus ?? "Idle";
            timeLabel.Text     = string.Format("Elapsed: {0:HH:mm:ss}",
                                               new DateTime(workQueue.ActiveTime.Ticks));

            if (revisionAnalyzer != null)
            {
                fileLabel.Text     = "Files: " + revisionAnalyzer.FileCount;
                revisionLabel.Text = "Revisions: " + revisionAnalyzer.RevisionCount;
            }

            if (changesetBuilder != null)
            {
                changeLabel.Text     = "Changesets: " + changesetBuilder.Changesets.Count;
                progressBar1.Maximum = changesetBuilder.Changesets.Count;
                progressBar1.Visible = true;
            }

            if (workQueue.IsIdle)
            {
                revisionAnalyzer = null;
                changesetBuilder = null;

                statusTimer.Enabled  = false;
                goButton.Enabled     = true;
                progressBar1.Visible = false;
                string[] args = Environment.GetCommandLineArgs();

                if (autostart)
                {
                    {
                        Application.Exit();
                    }
                }
            }

            var exceptions = workQueue.FetchExceptions();

            if (exceptions != null)
            {
                foreach (var exception in exceptions)
                {
                    ShowException(exception);
                }
            }
        }
예제 #12
0
        private void statusTimer_Tick(object sender, EventArgs e)
        {
            statusLabel.Text = workQueue.LastStatus ?? "Idle";
            timeLabel.Text   = string.Format("Elapsed: {0:HH:mm:ss}",
                                             new DateTime(workQueue.ActiveTime.Ticks));

            if (revisionAnalyzer != null)
            {
                fileLabel.Text     = "Files: " + revisionAnalyzer.FileCount;
                revisionLabel.Text = "Revisions: " + revisionAnalyzer.RevisionCount;
            }

            if (changesetBuilder != null)
            {
                changeLabel.Text = "Changesets: " + changesetBuilder.Changesets.Count;
            }

            if (workQueue.IsIdle)
            {
                projectAnalyzer  = null;
                fileAnalyzer     = null;
                revisionAnalyzer = null;
                changesetBuilder = null;

                statusTimer.Enabled = false;
                goButton.Enabled    = true;
            }

            var exceptions = workQueue.FetchExceptions();

            if (exceptions != null)
            {
                foreach (var exception in exceptions)
                {
                    ShowException(exception);
                }
            }
        }
예제 #13
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);
            }
        }
예제 #14
0
파일: Program.cs 프로젝트: esskar/vss2git
        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();
        }
예제 #15
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();
            }
        }
예제 #16
0
        private void statusTimer_Tick(object sender, EventArgs e)
        {
            statusLabel.Text = workQueue.LastStatus ?? "Idle";
            timeLabel.Text = string.Format("Elapsed: {0:HH:mm:ss}",
                new DateTime(workQueue.ActiveTime.Ticks));

            if (revisionAnalyzer != null)
            {
                fileLabel.Text = "Files: " + revisionAnalyzer.FileCount;
                revisionLabel.Text = "Revisions: " + revisionAnalyzer.RevisionCount;
            }

            if (changesetBuilder != null)
            {
                changeLabel.Text = "Changesets: " + changesetBuilder.Changesets.Count;
            }

            if (workQueue.IsIdle)
            {
                revisionAnalyzer = null;
                changesetBuilder = null;

                statusTimer.Enabled = false;
                goButton.Enabled = true;
            }

            var exceptions = workQueue.FetchExceptions();
            if (exceptions != null)
            {
                foreach (var exception in exceptions)
                {
                    ShowException(exception);
                }
            }
        }
예제 #17
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);
            }
        }
예제 #18
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");

                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, emailPropertiesFileName);

                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 (!string.IsNullOrEmpty(commentTextBox.Text))
                    {
                        vcsExporter.DefaultComment = commentTextBox.Text;
                    }
                    if (!transcodeCheckBox.Checked)
                    {
                        vcsExporter.CommitEncoding = encoding;
                    }
                    vcsExporter.TryGenerateCommitMessage = tryGenerateCommitMessageCheckBox.Checked;
                    vcsExporter.IgnoreVcsErrors          = ignoreVcsErrorsCheckBox.Checked;
                    vcsExporter.ResetRepo = resetRepoCheckBox.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);
            }
        }