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); } }
private void LoadRepoSettings() { Invoke((MethodInvoker) delegate { IVcsWrapper vcsWrapper = outDirTextBox.Text.Length > 0 ? CreateVcsWrapper(Encoding.Default) : null; backgroundQueue.AddLast(delegate { continueAfter = vcsWrapper != null ? vcsWrapper.GetLastCommit() : null; Invoke((MethodInvoker) delegate { if (continueAfter == null) { if (continueSyncCheckBox.Checked) { resetRepoCheckBox.Checked = true; } continueSyncCheckBox.Enabled = continueSyncCheckBox.Checked = false; } else { resetRepoCheckBox.Checked = false; continueSyncCheckBox.Enabled = true; continueSyncCheckBox.Checked = true; continueSyncCheckBox.Text = "Continue sync from " + continueAfter; } }); }); }); }
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); } }
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; }
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); } }
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); } }