示例#1
0
        static int Main(string[] args)
        {
            ArgParser argparser = new ArgParser();

            argparser.add(
                new Arg('s', "server-name", "tfs server to connect to",
                        new string[] { "the name of the server" }, null)
                );

            List <int> unknownArgs;
            bool       argError = !argparser.parse_args(args, out unknownArgs);

            if (argError ||
                unknownArgs.Count < 0)
            {
                argparser.print_help("[item path]",
                                     new string[]
                {
                    "item path - tfs-server path of an item to check merge history for.",
                    null,
                    "test an item-based querying solution.",
                    "e.g. itembranchhistory -s foo $/foo/bar.cs",
                });

                return(1);
            }

            string server = (string)argparser.get_arg <Arg>(0);
            string path   = args[unknownArgs[0]];

            Microsoft.TeamFoundation.VersionControl.Client.VersionControlServer vcs =
                megahistory.Utils.GetTFSServer(server);

            BranchHistory bh = new BranchHistory();

            Microsoft.TeamFoundation.VersionControl.Client.VersionSpec ver =
                Microsoft.TeamFoundation.VersionControl.Client.VersionSpec.Latest;
            Microsoft.TeamFoundation.VersionControl.Client.Item item =
                vcs.GetItem(path, ver, 0, false);

            treelib.AVLTree <Microsoft.TeamFoundation.VersionControl.Client.Changeset> changes =
                bh.decompose(vcs, item);

            if (changes.empty())
            {
                Console.WriteLine("no changesets found.");
            }

            for (treelib.AVLTree <Microsoft.TeamFoundation.VersionControl.Client.Changeset> .iterator it =
                     changes.begin();
                 it != changes.end();
                 ++it)
            {
                Microsoft.TeamFoundation.VersionControl.Client.Change cng = it.item().Changes[0];

                Console.WriteLine("{0} {1}",
                                  cng.ChangeType.ToString(),
                                  cng.Item.ServerItem);
            }

            return(0);
        }
示例#2
0
        private static int Main(string[] args)
        {
            ArgParser ap = new ArgParser();

            ap.add(new Arg('s', "server", "tfs server name", "name of the tfs server.", null));
            ap.add(new Arg('c', "candidates", "candidates file name",
                           new string[] {
                "list of stuff that hasn't moved from one branch to the other.",
                " filename of '-' means stdin.",
                " this can be obtained with a command like:",
                " tf merge /recursive /candidate /noprompt <source> <destination>",
            }, null));

            System.Collections.Generic.List <int> unknownArgs;
            bool argOK = ap.parse_args(args, out unknownArgs);

            if (!argOK || unknownArgs.Count < 1)
            {
                ap.print_help("", new string[] { "foo!" });
                return(1);
            }

            IntList mergeCandidates;
            IntList toMerge = new IntList();

            {
                System.IO.TextReader rdr = null;
                if (ap.get_arg <Arg>("candidates") != "-")
                {
                    rdr = new System.IO.StreamReader(new System.IO.FileStream(ap.get_arg <Arg>("candidates"),
                                                                              System.IO.FileMode.Open, System.IO.FileAccess.Read, System.IO.FileShare.ReadWrite));
                }
                else
                {
                    rdr = Console.In;
                }

                mergeCandidates = _ReadFile(rdr);
            }

            /* process the unknown arguments.
             * these should all be target changesets.
             */
            foreach (int i in unknownArgs)
            {
                int csID = Int32.Parse(args[i]);

                IntList.iterator it = toMerge.find(csID);
                if (it == toMerge.end())
                {
                    toMerge.insert(csID);
                }
            }

            ItemMap deps             = new ItemMap();
            VersionControlServer vcs = tfsinterface.SCMUtils.GetTFSServer(ap.get_arg <Arg>("server"));

            _GenerateDeps(vcs, deps, mergeCandidates);

            /* now pull information on the target changesets.
             *
             * note:
             * we really already have pulled this information,
             * but it would be a little difficult to dual-purpose the '_GenerateDeps' function.
             * it would also make it look really confusing.
             */
            CSItemMap targetCSs = new CSItemMap();

            foreach (int csID in toMerge)
            {
                Changeset cs = vcs.GetChangeset(csID);
                ItemList  il = new ItemList();

                foreach (Change cng in cs.Changes)
                {
                    il.insert(cng.Item);
                }

                targetCSs.insert(csID, il);
            }

            Console.WriteLine("merge ordering:");
            _PrintDeps(Console.Out, deps, targetCSs);

            return(0);
        }
示例#3
0
        static int Main(string[] args)
        {
            Values    values    = new Values(0x4);
            ArgParser argParser = new ArgParser();

            argParser.add(new Arg('s', "server", "server name", "the tfs server to connect to", null));
            argParser.add(new tfsinterface.PathVersionArg("src", "path[,version]", "the source of the changesets"));
            argParser.add(new tfsinterface.VersionArg("from", "version[,version]", "the changeset range to look in."));
            argParser.add(new FlagArg("name-only", "add the path of the files to the changeset info", false));
            argParser.add(new FlagArg("name-status",
                                      "print the path and the change type in the changeset info", false));
            argParser.add(new ArgInt('d', "distance",
                                     new string[] {
                "distance or number of merge queries to run.",
                "default=1",
                "e.g. distance=2",
                " source path=$/main/ version=12",
                " query #1 = $/main/ => decompose 12.",
                "  12 => $/development/group1/ version 10",
                " query #2 = $/development/group1/ => decompose 10.",
                "  10 => $/code_review/group1/ version 8",
                " process stops."
            }, 1));
            argParser.add(new ArgInt('j', "threads",
                                     new string[] {
                "number of threads to run merge queries in",
                " defaults to 8.",
                " if set to 1, queries are done in order.",
                " e.g. ",
                "query changeset 12, query parents of changeset 12, starting at the first parent.",
                " query the first parent, <insert recursion>"
            }, 8));
            argParser.add(new ArgInt('c', "count",
                                     new string[] {
                "max number history items to query",
                " defaults to 10.",
                " if a range isn't specified, ",
                "this will control how many history items that are decomposed.",
            }, 10));

            List <int> unknownArgs;
            bool       argError = false == argParser.parse_args(args, out unknownArgs);

            /* if we don't have any args, the user needs to fix that too. */
            if (!argError && (unknownArgs.Count < 1))
            {
                argError = true;
            }

            if (argError)
            {
                /* get the version of the megahistory library. */
                Version  version = null;
                Assembly asm     = Assembly.GetAssembly(typeof(megahistorylib.MegaHistory));
                version = asm.GetName().Version;
                /* ******************** */
                string libVersion = null;

                object[] objs = asm.GetCustomAttributes(typeof(System.Reflection.AssemblyInformationalVersionAttribute), true);
                if (objs != null)
                {
                    System.Reflection.AssemblyInformationalVersionAttribute attr = objs[0] as System.Reflection.AssemblyInformationalVersionAttribute;

                    if (attr != null)
                    {
                        libVersion = string.Format("lib version git: {0}", attr.InformationalVersion);
                    }
                }

                if (libVersion == null)
                {
                    libVersion =
                        string.Format("lib version {0}.{1}.{2}.{3} (sp{4}/{5})",
                                      version.Major, version.Minor, version.Build, version.Revision,
                                      version.MajorRevision, version.MinorRevision);
                }

                argParser.print_help("<target>[,<version>]",
                                     new string[]
                {
                    libVersion,
                    "target - the required path we're looking at",
                    "version - an optional version of the target path",
                    string.Empty,
                    "queries tfs for the list of changesets which make up a merge",
                    string.Empty,
                    "eg: megahistory -s foo --src $/foo,45 --from 10,45 $/bar,43"
                }
                                     );

                return(1);
            }

            if (unknownArgs.Count > 0)
            {
                /* anything not caught by the above items is considered a target path and changeset. */
                tfsinterface.PathVersionArg.GetParts(args[unknownArgs[0]], out values.target, out values.targetVer);
            }

            values.server = (string)argParser.get_arg <Arg>('s');

            {
                tfsinterface.PathVersionArg arg = argParser.get_arg <tfsinterface.PathVersionArg>("src");
                if (arg.Data != null)
                {
                    arg.get_parts(out values.srcPath, out values.srcVer);
                }
            }
            {
                tfsinterface.VersionArg arg = argParser.get_arg <tfsinterface.VersionArg>("from");
                if (arg.Data != null)
                {
                    arg.get_parts(out values.fromVer, out values.toVer);
                }
            }

            if ((bool)argParser.get_arg <FlagArg>("name-only"))
            {
                values.printWhat = HistoryViewer.Printwhat.NameOnly;
            }

            else if ((bool)argParser.get_arg <FlagArg>("name-status"))
            {
                values.printWhat = HistoryViewer.Printwhat.NameStatus;
            }

            {
                saastdlib.ArgInt arg = argParser.get_arg <saastdlib.ArgInt>('d');
                values.maxDistance = arg;
            }

            values.threads = argParser.get_arg <saastdlib.ArgInt>('j');
            values.count   = argParser.get_arg <saastdlib.ArgInt>('c');

            megahistorylib.MegaHistory megahistory =
                new megahistorylib.MegaHistory(values.server, values.maxDistance);

            megahistorylib.MegaHistory.THREAD_COUNT = values.threads;

            /* this won't do a single changeset decomposition...? */
            megahistory.query(values.target, values.targetVer, values.count, values.fromVer, values.toVer, null);

            HistoryViewer visitor = new HistoryViewer(values.printWhat, megahistory.Results);

            visitor.print(Console.Out);

            return(0);
        }