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); }); }); }
static void Main(string[] args) { var df = new VssDatabaseFactory(@"C:\VSS Test Database\CPSC 594 Database 1"); var db = df.Open(); var tree = new TreeWriter(Console.Out); tree.DumpProject(db.RootProject); }
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("VSS2Svn 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("Transcode comments to UTF-8: {0}", transcodeCheckBox.Checked ? "enabled" : "disabled"); logger.WriteLine("Use SVN standard dir structure: {0}", useSvnDirStructureCheckBox.Checked ? "enabled" : "disabled"); logger.WriteLine("Exclude all destroyed items: {0}", excludeAllDestroyedItemsCheckBox.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.ExcludeAllDestroyedItems = excludeAllDestroyedItemsCheckBox.Checked; changesetBuilder.BuildChangesets(); if (!string.IsNullOrEmpty(outDirTextBox.Text)) { var svnExporter = new SvnExporter(workQueue, logger, revisionAnalyzer, changesetBuilder); if (!transcodeCheckBox.Checked) { svnExporter.CommitEncoding = encoding; } svnExporter.ForceAnnotatedTags = forceAnnotatedCheckBox.Checked; svnExporter.ParentWindow = this; svnExporter.ExportToSvn(outDirTextBox.Text, InheritProjectDirCheckBox.Checked, useSvnDirStructureCheckBox.Checked); } workQueue.Idle += delegate { logger.Dispose(); logger = Logger.Null; }; statusTimer.Enabled = true; goButton.Enabled = false; } catch (Exception ex) { ShowException(ex); } }
static void Main(string[] args) { Console.OutputEncoding = Encoding.Default; var invalidArg = false; var argIndex = 0; while (argIndex < args.Length && args[argIndex].StartsWith("/")) { var option = args[argIndex].Substring(1).Split(':'); switch (option[0]) { case "encoding": { string encodingName; if (option.Length > 1) { encodingName = option[1]; } else if (argIndex + 1 < args.Length) { encodingName = args[++argIndex]; } else { invalidArg = true; goto InvalidArg; } Encoding encoding; try { int codePage; if (int.TryParse(encodingName, out codePage)) { encoding = Encoding.GetEncoding(codePage); } else { encoding = Encoding.GetEncoding(encodingName); } } catch { Console.WriteLine("Invalid encoding: {0}", encodingName); invalidArg = true; goto InvalidArg; } Console.OutputEncoding = encoding; break; } case "encodings": { var encodings = Encoding.GetEncodings(); Console.WriteLine("{0,-6} {1,-25} {2}", "CP", "IANA", "Description"); foreach (var encoding in encodings) { var codePage = encoding.CodePage; switch (codePage) { case 1200: case 1201: case 12000: case 12001: // UTF-16 and 32 are managed-only continue; } Console.WriteLine("{0,-6} {1,-25} {2}", codePage, encoding.Name, encoding.DisplayName); } return; } } ++argIndex; } InvalidArg: if (invalidArg || argIndex >= args.Length) { Console.WriteLine("Syntax: VssDump [options] <vss-base-path>"); Console.WriteLine("Options:"); Console.WriteLine(" /encoding:<encoding> Output encoding IANA name or code page"); Console.WriteLine(" /encodings List supported encodings and terminate"); return; } var repoPath = args[argIndex]; var df = new VssDatabaseFactory(repoPath); var db = df.Open(); Console.WriteLine("File hierarchy:"); Console.WriteLine(Separator); var tree = new TreeDumper(Console.Out) { IncludeRevisions = false }; tree.DumpProject(db.RootProject); Console.WriteLine(); Console.WriteLine("Log file contents:"); for (char c = 'a'; c <= 'z'; ++c) { string[] dataPaths = Directory.GetFiles( Path.Combine(db.DataPath, c.ToString()), "*."); foreach (string dataPath in dataPaths) { var dataFile = Path.GetFileName(dataPath).ToUpper(); var orphaned = !tree.PhysicalNames.Contains(dataFile); Console.WriteLine(Separator); Console.WriteLine("{0}{1}", dataPath, orphaned ? " (orphaned)" : ""); DumpLogFile(dataPath); } } Console.WriteLine(); Console.WriteLine("Name file contents:"); Console.WriteLine(Separator); var namePath = Path.Combine(db.DataPath, "names.dat"); DumpNameFile(namePath); Console.WriteLine(); Console.WriteLine(Separator); Console.WriteLine("Project actions: {0}", FormatCollection(projectActions)); Console.WriteLine("File actions: {0}", FormatCollection(fileActions)); }
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); } }