private void DumpUsers() { var df = new VssDatabaseFactory(vssDirTextBox.Text); var db = df.Open(); var path = vssProjectTextBox.Text; VssProject project; try { project = db.GetItem(path) as VssProject; } catch (VssPathException ex) { MessageBox.Show(ex.Message, "Invalid project path", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } if (project == null) { MessageBox.Show(path + " is not a project", "Invalid project path", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } var emailDictionary = ReadDictionaryFile("e-mail dictionary", db.BasePath, emailPropertiesFileName); AdvancedTaskbar.EnableItermediate(); this.statusTimer.Enabled = true; this.emailMap.Enabled = false; this.goButton.Enabled = false; this.cancelButton.Text = "Cancel"; revisionAnalyzer = new RevisionAnalyzer(workQueue, logger, db); if (!string.IsNullOrEmpty(excludeTextBox.Text)) { revisionAnalyzer.ExcludeFiles = excludeTextBox.Text; } revisionAnalyzer.AddItem(project); workQueue.AddLast(delegate(object work) { foreach (var dateEntry in revisionAnalyzer.SortedRevisions) { foreach (Revision revision in dateEntry.Value) { var user = revision.User.ToLower(); if (emailDictionary.ContainsKey(user)) { continue; } emailDictionary.Add(user, ""); } } string propsPath = Path.Combine(db.BasePath, emailPropertiesFileName); WriteDictionaryFile(emailDictionary, propsPath); this.BeginInvoke((MethodInvoker) delegate { MessageBox.Show(this, string.Format(emailUserNamesListMessage, propsPath), emailUserNamesListCaption, MessageBoxButtons.OK, MessageBoxIcon.Information); }); }); }
private void DumpUsers() { var df = new VssDatabaseFactory(vssDirTextBox.Text); var db = df.Open(); var path = vssProjectTextBox.Text; VssProject project; try { project = db.GetItem(path) as VssProject; } catch (VssPathException ex) { MessageBox.Show(ex.Message, "Invalid project path", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } if (project == null) { MessageBox.Show(path + " is not a project", "Invalid project path", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } 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); workQueue.AddLast(delegate(object work) { foreach (var dateEntry in revisionAnalyzer.SortedRevisions) { foreach (Revision revision in dateEntry.Value) { var user = revision.User.ToLower(); if (emailDictionary.ContainsKey(user)) { continue; } emailDictionary.Add(user, ""); } } string propsPath = db.BasePath + Path.DirectorySeparatorChar + "emails.properties"; WriteDictionaryFile(emailDictionary, propsPath); MessageBox.Show("The list of usernames is written to:\n\n" + propsPath + "\n\n" + "Please edit it and fill in email addresses in the form:\n\n" + "username = Full Name <e-mail>\n\nor\n\nusername = e-mail", "User-email mapping", MessageBoxButtons.OK, MessageBoxIcon.Information); }); }
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); } }
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(); } }
private void DumpUsers() { var df = new VssDatabaseFactory(vssDirTextBox.Text); var db = df.Open(); var path = vssProjectTextBox.Text; VssProject project; try { project = db.GetItem(path) as VssProject; } catch (VssPathException ex) { MessageBox.Show(ex.Message, "Invalid project path", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } if (project == null) { MessageBox.Show(path + " is not a project", "Invalid project path", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } 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); workQueue.AddLast(delegate (object work) { foreach (var dateEntry in revisionAnalyzer.SortedRevisions) { foreach (Revision revision in dateEntry.Value) { var user = revision.User.ToLower(); if (emailDictionary.ContainsKey(user)) continue; emailDictionary.Add(user, ""); } } string propsPath = db.BasePath + Path.DirectorySeparatorChar + "emails.properties"; WriteDictionaryFile(emailDictionary, propsPath); MessageBox.Show("The list of usernames is written to:\n\n" + propsPath + "\n\n" + "Please edit it and fill in email addresses in the form:\n\n" + "username = Full Name <e-mail>\n\nor\n\nusername = e-mail", "User-email mapping", MessageBoxButtons.OK, MessageBoxIcon.Information); }); }
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); } }
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(); }
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); } }