public virtual void visit(int parentID, Changeset cs, List <string> branches) { PatchInfo p; if (_cache.TryGetValue(cs.ChangesetId, out p)) { _seen(parentID, p); } else { /* only print stuff we haven't already seen. */ List <string> treeBranches = branches; if (treeBranches == null) { treeBranches = MegaHistory.FindChangesetBranches(cs); } p = new PatchInfo(parentID, cs, treeBranches); _cache.Add(p.cs.ChangesetId, p); for (int i = 0; i < treeBranches.Count; ++i) { /* insertion could be sped up using BinarySearch, but this keeps things simple. */ if (_branches.BinarySearch(treeBranches[i]) < 0) { _branches.Add(treeBranches[i]); _branches.Sort(); } } _visit(p); } }
static int Main(string[] args) { Values values = new Values(0x4); if (args.Length == 0 || (args.Length == 1 && (args[0] == "-h" || args[0] == "--help"))) { print_help(); return(1); } /* parse the command line arguments. */ for (int i = 0; i < args.Length; ++i) { if (args[i] == "-s" && (i + 1 < args.Length)) { values.server = args[++i]; } else if (args[i] == "--src" && (i + 1) < args.Length) { string[] globs = args[++i].Split(','); if (globs.Length == 2) { values.srcVer = new ChangesetVersionSpec(globs[1]); } values.srcPath = globs[0]; } else if (args[i] == "--from" && (i + 1) < args.Length) { string[] globs = args[++i].Split(','); if (globs.Length == 2) { values.toVer = new ChangesetVersionSpec(globs[1]); } values.fromVer = new ChangesetVersionSpec(globs[0]); } else if (args[i] == "--no-recurse") { values.noRecurse = true; } else if (args[i] == "--name-only") { values.printWhat = HistoryViewer.Printwhat.NameOnly; } else if (args[i] == "--name-status") { values.printWhat = HistoryViewer.Printwhat.NameStatus; } else if (args[i] == "--allow-branch-revisiting") { values.allowBranchRevisiting = true; } else if (args[i] == "--force-decomposition") { values.forceDecomposition = true; } else if (args[i] == "--branches-too") { values.branchesToo = true; } else { /* anything not caught by the above items is considered a target path and changeset. */ string[] globs = args[i].Split(','); values.target = globs[0]; if (globs.Length == 2) { values.targetVer = new ChangesetVersionSpec(globs[1]); } } } values.vcs = _get_tfs_server(values.server); MegaHistory.Options mhopts = new MegaHistory.Options(); mhopts.NoRecurse = values.noRecurse; mhopts.AllowBranchRevisiting = values.allowBranchRevisiting; mhopts.ForceDecomposition = values.forceDecomposition; Visitor visitor = new HistoryViewer(values.printWhat); MegaHistory megahistory = new MegaHistory(mhopts, values.vcs, visitor); if (values.branchesToo) { MegaHistory.IsChangeToConsider = delegate(Change cng) { return( (cng.ChangeType != ChangeType.Merge) /* ignore only merges. */ && ( /* look for branched items, or merged items */ ((cng.ChangeType & ChangeType.Branch) == ChangeType.Branch) || ((cng.ChangeType & ChangeType.Merge) == ChangeType.Merge) ) ); }; } bool result = megahistory.visit(values.srcPath, values.srcVer, values.target, values.targetVer, values.fromVer, values.toVer, RecursionType.Full); if (!result) { Console.WriteLine("no changesets found."); } return(0); }