Esempio n. 1
0
        public static Dictionary <string, SvnFileInfo> RebuildFileUrls(LogCmdResult logCmdResult)
        {
            var files = new Dictionary <string, SvnFileInfo>();

            foreach (var kvp in logCmdResult)
            {
                foreach (var resultItem in kvp.Value)
                {
                    if (!files.ContainsKey(resultItem.Path))
                    {
                        var info = new SvnFileInfo
                        {
                            Revision = kvp.Key.Revision,
                            NodeKind = resultItem.NodeKind,
                            Action   = resultItem.Action
                        };
                        files.Add(resultItem.Path, info);
                    }
                    else
                    {
                        var info = files[resultItem.Path];
                        if (kvp.Key.Revision > info.Revision)
                        {
                            var newInfo = new SvnFileInfo
                            {
                                Revision = kvp.Key.Revision,
                                NodeKind = resultItem.NodeKind,
                                Action   = resultItem.Action
                            };
                            files[resultItem.Path] = newInfo;
                        }
                    }
                }
            }

            return(files);
        }
Esempio n. 2
0
        private static LogCmdResult ParseCliResult(BridgeCli.LogCmdResult cliResult)
        {
            LogCmdResult logCmdResult = new LogCmdResult();

            foreach (var cliKvp in cliResult.Results)
            {
                LogCmdResultRevision revision = new LogCmdResultRevision(
                    cliKvp.Key.revision,
                    Encoding.UTF8.GetString(cliKvp.Key.author),
                    Encoding.UTF8.GetString(cliKvp.Key.message)
                    );
                LogCmdResultItems items = new LogCmdResultItems();
                foreach (var item in cliKvp.Value)
                {
                    string path = Encoding.UTF8.GetString(item.Path);
                    LogCmdResultItem.ItemAction itemAction = LogCmdResultItem.ItemAction.Add;
                    switch (item.Action)
                    {
                    case LogItemAction.Add:
                        itemAction = LogCmdResultItem.ItemAction.Add;
                        break;

                    case LogItemAction.Delete:
                        itemAction = LogCmdResultItem.ItemAction.Delete;
                        break;

                    case LogItemAction.Repalce:
                        itemAction = LogCmdResultItem.ItemAction.Replace;
                        break;

                    case LogItemAction.Modifiy:
                        itemAction = LogCmdResultItem.ItemAction.Modifiy;
                        break;

                    default:
                        throw new Exception(String.Format("Unknown svn path action for {0}:{1}", path,
                                                          item.Action));
                    }

                    string copyFromPath     = Encoding.UTF8.GetString(item.CopyFromPath);
                    uint   copyFromRevision = item.CopyFromRev;
                    LogCmdResultItem.ItemNodeKind nodeKind = LogCmdResultItem.ItemNodeKind.Unknown;
                    switch (item.NodeKind)
                    {
                    case SvnNodeKind.None:
                        nodeKind = LogCmdResultItem.ItemNodeKind.None;
                        break;

                    case SvnNodeKind.File:
                        nodeKind = LogCmdResultItem.ItemNodeKind.File;
                        break;

                    case SvnNodeKind.Dir:
                        nodeKind = LogCmdResultItem.ItemNodeKind.Dir;
                        break;

                    case SvnNodeKind.Symlink:
                        nodeKind = LogCmdResultItem.ItemNodeKind.Symlink;
                        break;

                    case SvnNodeKind.Unknown:
                    default:
                        nodeKind = LogCmdResultItem.ItemNodeKind.Unknown;
                        break;
                    }

                    items.Add(new LogCmdResultItem(
                                  path, itemAction, copyFromPath, copyFromRevision, nodeKind
                                  ));
                }

                logCmdResult.Add(revision, items);
            }

            return(logCmdResult);
        }