Exemple #1
0
        /// <summary>
        /// Create a descriptive string for this FileSpec of the specified Type
        /// </summary>
        /// <param name="pathType">Type of path to be returned</param>
        /// <returns>string represented FileSpec of Type</returns>
        public string ToString(Type pathType)
        {
            string value = null;

            if (pathType == typeof(DepotPath))
            {
                value = DepotPath.Path;
            }
            if (pathType == typeof(ClientPath))
            {
                value = ClientPath.Path;
            }
            if (pathType == typeof(LocalPath))
            {
                value = LocalPath.Path;
                if ((value.Length > 1) && (value[1] == ':') && char.IsUpper(value, 0))
                {
                    value = value.Substring(0, 1).ToLower() + value.Substring(1);
                }
            }
            value = PathSpec.EscapePath(value);
            if (Version != null)
            {
                value += Version.ToString();
            }
            return(value);
        }
Exemple #2
0
 public MapEntry(MapType type, PathSpec left, PathSpec right, String comment)
 {
     Type    = type;
     Left    = left;
     Right   = right;
     Comment = comment;
 }
Exemple #3
0
        /// <summary>
        /// Copy the non-null entries into a new string array containing the paths
        ///   escaped for special characters
        /// </summary>
        public static string[] ToEscapedPaths(params FileSpec[] list)
        {
            if (list == null)
            {
                return(null);
            }

            if ((list.Length == 1) && (list[0] == null))
            {
                return(null);
            }

            int count = 0;

            for (int idx = 0; idx < list.Length; idx++)
            {
                if (list[idx] != null)
                {
                    count++;
                }
            }

            int idx2 = 0;

            string[] value = new string[count];

            for (int idx = 0; idx < list.Length; idx++)
            {
                if (list[idx] != null)
                {
                    if (list[idx].DepotPath != null)
                    {
                        value[idx2++] = PathSpec.EscapePath(list[idx].DepotPath.Path);
                    }
                    else if (list[idx].LocalPath != null)
                    {
                        value[idx2++] = PathSpec.EscapePath(list[idx].LocalPath.Path);
                    }
                    else if (list[idx].ClientPath != null)
                    {
                        value[idx2] = PathSpec.EscapePath(list[idx].ClientPath.Path);
                        if ((value[idx2].Length > 1) && (value[idx2][1] == ':') && char.IsUpper(value[idx2], 0))
                        {
                            value[idx2] = value[idx2].Substring(0, 1).ToLower() + value[idx2].Substring(1);
                        }
                        idx2++;
                    }
                }
            }
            return(value);
        }
Exemple #4
0
 /// <summary>
 /// Compare one PathSpec with another
 /// </summary>
 /// <param name="obj">PathSpec to compare to</param>
 /// <returns>true if equal</returns>
 public override bool Equals(object obj)
 {
     if (obj == null)
     {
         return(false);
     }
     if (obj is PathSpec)
     {
         PathSpec o = obj as PathSpec;
         return((this.GetType() == o.GetType()) &&
                (this.Path == o.Path));
     }
     return(false);
 }
Exemple #5
0
        public Stream(
            string id,
            DateTime updated,
            DateTime accessed,
            string ownername,
            string name,
            PathSpec parent,
            PathSpec baseparent,
            StreamType type,
            string description,
            StreamOption options,
            string firmerthanparent,
            string changeflowstoparent,
            string changeflowsfromparent,
            ViewMap paths,
            ViewMap remapped,
            ViewMap ignored,
            ViewMap view,
            ViewMap changeview,
            FormSpec spec,
            Dictionary <string, object> customfields,
            ParentView parentview)

        {
            Id                    = id;
            Updated               = updated;
            Accessed              = accessed;
            OwnerName             = ownername;
            Name                  = name;
            Parent                = parent;
            BaseParent            = baseparent;
            Type                  = type;
            Description           = description;
            Options               = options;
            FirmerThanParent      = firmerthanparent;
            ChangeFlowsToParent   = changeflowstoparent;
            ChangeFlowsFromParent = changeflowsfromparent;
            Paths                 = paths;
            Remapped              = remapped;
            Ignored               = ignored;
            View                  = view;
            ChangeView            = changeview;
            Spec                  = spec;
            CustomFields          = customfields;
            ParentView            = parentview;
        }
Exemple #6
0
 public FileHistory(int revision, int changelistid, FileAction action,
                    DateTime date, string username, FileType filetype, string description,
                    string digest, long filesize, PathSpec depotpath, string clientname,
                    List <RevisionIntegrationSummary>
                    integrationsummaries)
 {
     Revision             = revision;
     ChangelistId         = changelistid;
     Action               = action;
     Date                 = date;
     UserName             = username;
     FileType             = filetype;
     Description          = description;
     Digest               = digest;
     FileSize             = filesize;
     DepotPath            = depotpath;
     ClientName           = clientname;
     IntegrationSummaries = integrationsummaries;
 }
Exemple #7
0
 /// <summary>
 /// Constructor given path and version
 /// </summary>
 /// <param name="path">location of the file</param>
 /// <param name="version">version of the file</param>
 public FileSpec(PathSpec path, VersionSpec version)
 {
     if (path.GetType() == typeof(DepotPath))
     {
         DepotPath  = (DepotPath)path;
         ClientPath = null;
         LocalPath  = null;
     }
     else if (path.GetType() == typeof(ClientPath))
     {
         DepotPath  = null;
         ClientPath = (ClientPath)path;
         LocalPath  = null;
     }
     else if (path.GetType() == typeof(LocalPath))
     {
         DepotPath  = null;
         ClientPath = null;
         LocalPath  = (LocalPath)path;
     }
     Version = version;
 }
Exemple #8
0
 public void FromIstatCmdTaggedData(TaggedObject obj)
 {
     if (obj.ContainsKey("stream"))
     {
         string p = PathSpec.UnescapePath(obj["stream"]);
         Stream = new DepotPath(p);
     }
     if (obj.ContainsKey("parent"))
     {
         string p = PathSpec.UnescapePath(obj["parent"]);
         Parent = new DepotPath(p);
     }
     if (obj.ContainsKey("type"))
     {
         _type = (obj["type"]);
     }
     if (obj.ContainsKey("parentType"))
     {
         _parenttype = (obj["parentType"]);
     }
     if (obj.ContainsKey("firmerThanParent"))
     {
         bool value;
         bool.TryParse(obj["firmerThanParent"], out value);
         FirmerThanParent = value;
     }
     if (obj.ContainsKey("changeFlowsToParent"))
     {
         bool value;
         bool.TryParse(obj["changeFlowsToParent"], out value);
         ChangeFlowsToParent = value;
     }
     if (obj.ContainsKey("changeFlowsFromParent"))
     {
         bool value;
         bool.TryParse(obj["changeFlowsFromParent"], out value);
         ChangeFlowsFromParent = value;
     }
     if (obj.ContainsKey("integToParent"))
     {
         bool value;
         bool.TryParse(obj["integToParent"], out value);
         IntegToParent = value;
     }
     if (obj.ContainsKey("integToParentHow"))
     {
         _integtoparenthow = (obj["integToParentHow"]);
     }
     if (obj.ContainsKey("toResult"))
     {
         ToResult = obj["toResult"];
     }
     if (obj.ContainsKey("integFromParent"))
     {
         bool value;
         bool.TryParse(obj["integFromParent"], out value);
         IntegFromParent = value;
     }
     if (obj.ContainsKey("integFromParentHow"))
     {
         _integfromparenthow = (obj["integFromParentHow"]);
     }
     if (obj.ContainsKey("fromResult"))
     {
         FromResult = obj["fromResult"];
     }
 }
Exemple #9
0
        /// <summary>
        /// Fill in the fields for the changelist using the tagged output of a "change' command
        /// </summary>
        /// <param name="objectInfo">The tagged output of a "change' command</param>
        /// <param name="GetShelved">Access shelved files or not</param>
        /// <param name="offset">Offset within array</param>
        /// <param name="dst_mismatch">Daylight savings time for conversions</param>
        public void FromChangeCmdTaggedOutput(TaggedObject objectInfo, bool GetShelved, string offset, bool dst_mismatch)
        {
            // need to check for tags starting with upper and lower case, it the 'change' command's
            //  output the tags start with an uppercase character whereas with the 'changes' command
            //  they start with a lower case character, i.e. "Change" vs "change"

            _baseForm = new FormBase();

            _baseForm.SetValues(objectInfo);

            if (objectInfo.ContainsKey("Change"))
            {
                int v = -1;
                if (int.TryParse(objectInfo["Change"], out v))
                {
                    Id = v;
                }
            }
            else if (objectInfo.ContainsKey("change"))
            {
                int v = -1;
                if (int.TryParse(objectInfo["change"], out v))
                {
                    Id = v;
                }
            }

            if (objectInfo.ContainsKey("Date"))
            {
                DateTime v;
                DateTime.TryParse(objectInfo["Date"], out v);
                ModifiedDate = v;
            }
            else if (objectInfo.ContainsKey("time"))
            {
                long v;
                if (long.TryParse(objectInfo["time"], out v))
                {
                    DateTime UTC = FormBase.ConvertUnixTime(v);
                    DateTime GMT = new DateTime(UTC.Year, UTC.Month, UTC.Day, UTC.Hour, UTC.Minute, UTC.Second,
                                                DateTimeKind.Unspecified);
                    ModifiedDate = FormBase.ConvertFromUTC(GMT, offset, dst_mismatch);
                }
            }
            if (objectInfo.ContainsKey("Client"))
            {
                ClientId = objectInfo["Client"];
            }
            else if (objectInfo.ContainsKey("client"))
            {
                ClientId = objectInfo["client"];
            }

            if (objectInfo.ContainsKey("User"))
            {
                OwnerName = objectInfo["User"];
            }
            else if (objectInfo.ContainsKey("user"))
            {
                OwnerName = objectInfo["user"];
            }


            if (objectInfo.ContainsKey("Status"))
            {
                Pending = true;
                String v = objectInfo["Status"];
                if (v == "submitted")
                {
                    Pending = false;
                }
            }
            else if (objectInfo.ContainsKey("status"))
            {
                Pending = true;
                String v = objectInfo["status"];
                if (v == "submitted")
                {
                    Pending = false;
                }
            }

            if (objectInfo.ContainsKey("Description"))
            {
                Description = objectInfo["Description"];
            }
            else if (objectInfo.ContainsKey("desc"))
            {
                Description = objectInfo["desc"];
            }
            char[] array = { '\r', '\n' };
            Description = Description.TrimEnd(array);
            Description = Description.Replace("\r", "");
            Description = Description.Replace("\n", "\r\n");

            if (objectInfo.ContainsKey("Type"))
            {
                _type = objectInfo["Type"];
            }
            else if (objectInfo.ContainsKey("changeType"))
            {
                _type = objectInfo["changeType"];
            }

            if (objectInfo.ContainsKey("shelved"))
            {
                Shelved = true;
            }

            int    idx = 0;
            String key = "Jobs0";

            if (objectInfo.ContainsKey(key))
            {
                idx  = 1;
                Jobs = new Dictionary <string, string>();
                do
                {
                    Jobs.Add(objectInfo[key], null);
                    key = String.Format("Jobs{0}", idx++);
                } while (objectInfo.ContainsKey(key));
            }
            else
            {
                key = "jobs0";
                if (objectInfo.ContainsKey(key))
                {
                    idx  = 1;
                    Jobs = new Dictionary <string, string>();
                    do
                    {
                        Jobs.Add(objectInfo[key], null);
                        key = String.Format("jobs{0}", idx++);
                    } while (objectInfo.ContainsKey(key));
                }
            }

            key = "Files0";
            if (objectInfo.ContainsKey(key))
            {
                idx   = 1;
                Files = new List <FileMetaData>();
                do
                {
                    FileMetaData file = new FileMetaData();
                    file.DepotPath = new DepotPath(PathSpec.UnescapePath(objectInfo[key]));
                    Files.Add(file);
                    key = String.Format("Files{0}", idx++);
                } while (objectInfo.ContainsKey(key));
            }
            else
            {
                key = "files0";
                if (objectInfo.ContainsKey(key))
                {
                    idx = 1;
                    SimpleList <FileMetaData> files = new SimpleList <FileMetaData>();
                    do
                    {
                        FileMetaData file = new FileMetaData();
                        file.DepotPath = new DepotPath(PathSpec.UnescapePath(objectInfo[key]));
                        Files.Add(file);
                        key = String.Format("files{0}", idx++);
                    } while (objectInfo.ContainsKey(key));
                    Files = (List <FileMetaData>)files;
                }
            }
            if (GetShelved)
            {
                key = "depotFile0";
                String actionKey = "action0";
                String typeKey   = "type0";
                String revKey    = "rev0";
                String sizeKey   = "fileSize0";
                String digestKey = "digest0";

                if (objectInfo.ContainsKey(key))
                {
                    SimpleList <ShelvedFile> shelvedFiles = new SimpleList <ShelvedFile>();
                    idx = 1;
                    do
                    {
                        ShelvedFile file = new ShelvedFile();
                        file.Path = new DepotPath(PathSpec.UnescapePath(objectInfo[key]));
                        StringEnum <FileAction> action = objectInfo[actionKey];
                        file.Action = action;
                        file.Type   = new FileType(objectInfo[typeKey]);
                        string revstr = objectInfo[revKey];
                        if (revstr == "none")
                        {
                            revstr = "0";
                        }
                        int rev = Convert.ToInt32(revstr);
                        file.Revision = rev;

                        if (objectInfo.ContainsKey(sizeKey))
                        {
                            long size = -1;
                            long.TryParse(objectInfo[sizeKey], out size);
                            file.Size = size;
                        }

                        if (objectInfo.ContainsKey(digestKey))
                        {
                            file.Digest = objectInfo[digestKey];
                        }

                        shelvedFiles.Add(file);

                        key       = String.Format("depotFile{0}", idx);
                        actionKey = String.Format("action{0}", idx);
                        typeKey   = String.Format("type{0}", idx);
                        revKey    = String.Format("rev{0}", idx);
                        sizeKey   = String.Format("fileSize{0}", idx);
                        digestKey = String.Format("digest{0}", idx++);
                    } while (objectInfo.ContainsKey(key));
                    ShelvedFiles = (List <ShelvedFile>)shelvedFiles;
                }
            }
            else
            {
                key = "depotFile0";
                String actionKey = "action0";
                String typeKey   = "type0";
                String revKey    = "rev0";
                String sizeKey   = "fileSize0";
                String digestKey = "digest0";

                if (objectInfo.ContainsKey(key))
                {
                    idx = 1;
                    SimpleList <FileMetaData> fileList = new SimpleList <FileMetaData>();
                    do
                    {
                        FileMetaData file = new FileMetaData();
                        file.DepotPath = new DepotPath(PathSpec.UnescapePath(objectInfo[key]));
                        StringEnum <FileAction> action = objectInfo[actionKey];
                        file.Action = action;
                        file.Type   = new FileType(objectInfo[typeKey]);
                        string revstr = objectInfo[revKey];
                        int    rev    = Convert.ToInt32(revstr);
                        file.HeadRev = rev;

                        if (objectInfo.ContainsKey(sizeKey))
                        {
                            long size = -1;
                            long.TryParse(objectInfo[sizeKey], out size);
                            file.FileSize = size;
                        }

                        if (objectInfo.ContainsKey(digestKey))
                        {
                            file.Digest = objectInfo[digestKey];
                        }

                        fileList.Add(file);

                        key       = String.Format("depotFile{0}", idx);
                        actionKey = String.Format("action{0}", idx);
                        typeKey   = String.Format("type{0}", idx);
                        revKey    = String.Format("rev{0}", idx);
                        sizeKey   = String.Format("fileSize{0}", idx);
                        digestKey = String.Format("digest{0}", idx++);
                    } while (objectInfo.ContainsKey(key));
                    Files = (List <FileMetaData>)fileList;
                }
            }

            key = "job0";
            String statKey = "jobstat0";

            if (objectInfo.ContainsKey(key))
            {
                idx  = 1;
                Jobs = new Dictionary <string, string>();
                do
                {
                    string jobStatus = string.Empty;
                    string jobId     = objectInfo[key];
                    if (objectInfo.ContainsKey(statKey))
                    {
                        jobStatus = objectInfo[statKey];
                    }
                    Jobs.Add(jobId, jobStatus);
                    key     = String.Format("job{0}", idx);
                    statKey = String.Format("jobstat{0}", idx++);
                } while (objectInfo.ContainsKey(key));
            }
        }
Exemple #10
0
 public MapEntry(MapType type, PathSpec left, PathSpec right)
     : this(type, left, right, string.Empty)
 {
 }
Exemple #11
0
 public MapEntry(MapType type, PathSpec left, PathSpec right)
 {
     Type  = type;
     Left  = left;
     Right = right;
 }
Exemple #12
0
        public void ParseIntegratedCmdTaggedData(TaggedObject obj)
        {
            DepotPath   tp         = null;
            VersionSpec starttorev = null;
            VersionSpec endtorev   = null;

            if (obj.ContainsKey("toFile"))
            {
                string p = PathSpec.UnescapePath(obj["toFile"]);
                tp = new DepotPath(p);
            }

            if (obj.ContainsKey("startToRev"))
            {
                string str = obj["startToRev"];
                starttorev = new Revision(-1);

                if (str.StartsWith("#h")
                    |
                    str.StartsWith("#n"))
                {
                    if (str.Contains("#none"))
                    {
                        starttorev = Revision.None;
                    }

                    if (str.Contains("#have"))
                    {
                        starttorev = Revision.Have;
                    }

                    if (str.Contains("#head"))
                    {
                        starttorev = Revision.Head;
                    }
                }
                else
                {
                    str = str.Trim('#');
                    int rev = Convert.ToInt16(str);
                    starttorev = new Revision(rev);
                }
            }

            if (obj.ContainsKey("endToRev"))
            {
                string etr = obj["endToRev"];
                endtorev = new Revision(-1);

                if (etr.StartsWith("#h")
                    |
                    etr.StartsWith("#n"))
                {
                    if (etr.Contains("#none"))
                    {
                        endtorev = Revision.None;
                    }

                    if (etr.Contains("#have"))
                    {
                        endtorev = Revision.Have;
                    }

                    if (etr.Contains("#head"))
                    {
                        endtorev = Revision.Head;
                    }
                }
                else
                {
                    etr = etr.Trim('#');
                    int rev = Convert.ToInt16(etr);
                    endtorev = new Revision(rev);
                }
            }

            ToFile = new FileSpec(tp, null, null, new VersionRange(starttorev, endtorev));

            DepotPath   fp           = null;
            VersionSpec startfromrev = null;
            VersionSpec endfromrev   = null;

            if (obj.ContainsKey("fromFile"))
            {
                string p = PathSpec.UnescapePath(obj["fromFile"]);
                fp = new DepotPath(p);
            }

            if (obj.ContainsKey("startFromRev"))
            {
                string sfr = obj["startFromRev"];
                startfromrev = new Revision(-1);

                if (sfr.StartsWith("#h")
                    |
                    sfr.StartsWith("#n"))
                {
                    if (sfr.Contains("#none"))
                    {
                        startfromrev = Revision.None;
                    }

                    if (sfr.Contains("#have"))
                    {
                        startfromrev = Revision.Have;
                    }

                    if (sfr.Contains("#head"))
                    {
                        startfromrev = Revision.Head;
                    }
                }
                else
                {
                    sfr = sfr.Trim('#');
                    int rev = Convert.ToInt16(sfr);
                    startfromrev = new Revision(rev);
                }
            }

            if (obj.ContainsKey("endFromRev"))
            {
                string efr = obj["endFromRev"];
                endfromrev = new Revision(-1);

                if (efr.StartsWith("#h")
                    |
                    efr.StartsWith("#n"))
                {
                    if (efr.Contains("#none"))
                    {
                        endfromrev = Revision.None;
                    }

                    if (efr.Contains("#have"))
                    {
                        endfromrev = Revision.Have;
                    }

                    if (efr.Contains("#head"))
                    {
                        endfromrev = Revision.Head;
                    }
                }
                else
                {
                    efr = efr.Trim('#');
                    int rev = Convert.ToInt16(efr);
                    endfromrev = new Revision(rev);
                }
            }

            FromFile = new FileSpec(fp, null, null, new VersionRange(startfromrev, endfromrev));

            if (obj.ContainsKey("how"))
            {
                How = (IntegrateAction) new StringEnum <IntegrateAction>(obj["how"], true, true);
            }

            if (obj.ContainsKey("change"))
            {
                int change = -1;
                int.TryParse(obj["change"], out change);
                ChangeId = change;
            }
        }
Exemple #13
0
        /// <summary>
        /// Given tagged output from an "fstat" command instantiate this object.
        /// </summary>
        /// <param name="obj">Tagged output from fstat</param>
        public void FromFstatCmdTaggedData(TaggedObject obj)
        {
            if (obj.ContainsKey("clientFile"))
            {
                string path = obj["clientFile"];
                if (path.StartsWith("//"))
                {
                    ClientPath = new ClientPath(obj["clientFile"]);
                }
                else
                {
                    ClientPath = new ClientPath(obj["clientFile"]);
                    LocalPath  = new LocalPath(obj["clientFile"]);
                }
            }

            if (obj.ContainsKey("path"))
            {
                LocalPath = new LocalPath(obj["path"]);
            }

            if (obj.ContainsKey("depotFile"))
            {
                string p = PathSpec.UnescapePath(obj["depotFile"]);
                DepotPath = new DepotPath(p);
            }

            if (obj.ContainsKey("movedFile"))
            {
                MovedFile = new DepotPath(obj["movedFile"]);
                if (obj.ContainsKey("movedRev"))
                {
                    int movedrev = -1;
                    if (int.TryParse(obj["movedRev"], out movedrev))
                    {
                        MovedRev = movedrev;
                    }
                }
            }

            if (obj.ContainsKey("isMapped"))
            {
                IsMapped = true;
            }

            if (obj.ContainsKey("shelved"))
            {
                Shelved = true;
            }

            if (obj.ContainsKey("headAction"))
            {
                _headAction = obj["headAction"];
            }

            if (obj.ContainsKey("headChange"))
            {
                int r = -1;
                if (int.TryParse(obj["headChange"], out r))
                {
                    HeadChange = r;
                }
            }

            if (obj.ContainsKey("headRev"))
            {
                int r = -1;
                if (int.TryParse(obj["headRev"], out r))
                {
                    HeadRev = r;
                }
            }

            if (obj.ContainsKey("headType"))
            {
                HeadType = new FileType(obj["headType"]);
            }

            if (obj.ContainsKey("headTime"))
            {
                HeadTime = FormBase.ConvertUnixTime(obj["headTime"]);
            }

            if (obj.ContainsKey("headModTime"))
            {
                HeadModTime = FormBase.ConvertUnixTime(obj["headModTime"]);
            }

            if (obj.ContainsKey("haveRev"))
            {
                int r = -1;
                if ((int.TryParse(obj["haveRev"], out r)) && (r > 0))
                {
                    HaveRev = r;
                }
            }

            if (obj.ContainsKey("desc"))
            {
                Desc = obj["desc"];
            }

            if (obj.ContainsKey("digest"))
            {
                Digest = obj["digest"];
            }

            if (obj.ContainsKey("fileSize"))
            {
                long s = -1;
                if (long.TryParse(obj["fileSize"], out s))
                {
                    FileSize = s;
                }
            }

            if (obj.ContainsKey("action"))
            {
                _action = obj["action"];
            }

            if (obj.ContainsKey("type"))
            {
                Type = new FileType(obj["type"]);
            }
            else if (obj.ContainsKey("headType"))
            {
                // If not on mapped in current client, will not have
                //the Type filed so User the HeadType
                Type = new FileType(obj["headType"]);
            }
            else
            {
                Type = new FileType(BaseFileType.Text, FileTypeModifier.None);
            }

            if (obj.ContainsKey("actionOwner"))
            {
                ActionOwner = obj["actionOwner"];
            }

            if (obj.ContainsKey("change"))
            {
                int c = -1;
                if (int.TryParse(obj["change"], out c))
                {
                    Change = c;
                }
                else
                {
                    Change = 0;
                }
            }

            if (obj.ContainsKey("resolved"))
            {
                Resolved = true;
            }

            if (obj.ContainsKey("unresolved"))
            {
                Unresolved = true;
            }

            if (obj.ContainsKey("reresolvable"))
            {
                Reresolvable = true;
            }


            if (obj.ContainsKey("otherLock"))
            {
                OtherLock = true;
            }

            if (obj.ContainsKey("otherOpen"))
            {
                int cnt = 0;
                if (int.TryParse(obj["otherOpen"], out cnt))
                {
                    OtherOpen            = cnt;
                    OtherLockUserClients = new List <string>();
                }

                if (cnt > 0)
                {
                    OtherUsers = new OtherUsers();

                    OtherOpenUserClients = new List <String>();
                    OtherActions         = new List <FileAction>();
                    OtherChanges         = new List <int>();

                    for (int idx = 0; idx < cnt; idx++)
                    {
                        string        key             = String.Format("otherOpen{0}", idx);
                        string        otherClientName = null;
                        OtherFileUser ofi             = null;

                        if (obj.ContainsKey(key))
                        {
                            otherClientName = obj[key];
                            OtherOpenUserClients.Add(otherClientName);
                        }

                        ofi        = OtherUsers[otherClientName];
                        ofi.Client = otherClientName;

                        key = String.Format("otherAction{0}", idx);

                        if (obj.ContainsKey(key))
                        {
                            StringEnum <FileAction> otheraction = obj[key];
                            OtherActions.Add(otheraction);
                            ofi.Action = otheraction;
                        }

                        key = String.Format("otherChange{0}", idx);

                        if (obj.ContainsKey(key))
                        {
                            int otherchange;
                            if (!int.TryParse(obj[key], out otherchange))
                            {
                                otherchange = 0;
                            }
                            OtherChanges.Add(otherchange);

                            ofi.ChangelistId = otherchange;
                        }

                        key = String.Format("otherLock{0}", idx);

                        if (obj.ContainsKey(key))
                        {
                            string s = obj[key];
                            OtherLockUserClients.Add(s);

                            OtherUsers[s].hasLock = true;
                        }
                    }
                }
            }

            if (obj.ContainsKey("ourLock"))
            {
                OurLock = true;
            }

            if (obj.ContainsKey("resolved") || obj.ContainsKey("unresolved"))
            {
                int idx = 0;
                StringEnum <ResolveAction> resolveaction = ResolveAction.Unresolved;
                FileSpec          resolvebasefile        = null;
                FileSpec          resolvefromfile        = null;
                int               resolvestartfromrev    = -1;
                int               resolveendfromrev      = -1;
                FileResolveAction resolverecord          = null;

                ResolveRecords = new List <FileResolveAction>();

                while (true)
                {
                    string key = String.Format("resolveAction{0}", idx);

                    if (obj.ContainsKey(key))
                    {
                        resolveaction = obj[key];
                    }
                    else
                    {
                        break;
                    }

                    key = String.Format("resolveBaseFile{0}", idx);

                    if (obj.ContainsKey(key))
                    {
                        string basefile       = obj[key];
                        int    resolvebaserev = -1;
                        int.TryParse(obj[String.Format("resolveBaseRev{0}", idx)], out resolvebaserev);
                        resolvebasefile = new FileSpec(new DepotPath(basefile), new Revision(resolvebaserev));
                    }
                    else
                    {
                        break;
                    }

                    key = String.Format("resolveFromFile{0}", idx);

                    if (obj.ContainsKey(key))
                    {
                        string fromfile = obj[key];
                        int    startfromrev, endfromrev = -1;
                        int.TryParse(obj[String.Format("resolveStartFromRev{0}", idx)], out startfromrev);
                        int.TryParse(obj[String.Format("resolveEndFromRev{0}", idx)], out endfromrev);
                        resolvefromfile = new FileSpec(new DepotPath(fromfile),
                                                       new VersionRange(new Revision(startfromrev), new Revision(endfromrev)));
                    }
                    else
                    {
                        break;
                    }

                    resolverecord = new FileResolveAction
                                        (resolveaction, resolvebasefile, resolvefromfile, resolvestartfromrev, resolveendfromrev);
                    ResolveRecords.Add(resolverecord);

                    idx++;
                }
            }

            Attributes = new Dictionary <string, object>();

            foreach (string key in obj.Keys)
            {
                if (key.StartsWith("attr-"))
                {
                    object val   = obj[key];
                    string atrib = key.Replace("attr-", "");
                    Attributes.Add(atrib, val);
                }
            }

            AttributesProp = new Dictionary <string, object>();

            foreach (string key in obj.Keys)
            {
                if (key.StartsWith("attrProp-"))
                {
                    object val   = obj[key];
                    string atrib = key.Replace("attrProp-", "");
                    AttributesProp.Add(atrib, val);
                }
            }

            AttributeDigests = new Dictionary <string, object>();

            foreach (string key in obj.Keys)
            {
                if (key.StartsWith("attrDigest-"))
                {
                    object val         = obj[key];
                    string atribDigest = key.Replace("attrDigest-", "");
                    AttributeDigests.Add(atribDigest, val);
                }
            }

            OpenAttributes = new Dictionary <string, object>();

            foreach (string key in obj.Keys)
            {
                if (key.StartsWith("openattr-"))
                {
                    object val   = obj[key];
                    string atrib = key.Replace("openattr-", "");
                    OpenAttributes.Add(atrib, val);
                }
            }

            OpenAttributesProp = new Dictionary <string, object>();

            foreach (string key in obj.Keys)
            {
                if (key.StartsWith("openattrProp-"))
                {
                    object val   = obj[key];
                    string atrib = key.Replace("openattrProp-", "");
                    OpenAttributesProp.Add(atrib, val);
                }
            }

            if (obj.ContainsKey("totalFileCount"))
            {
                long s = -1;
                if (long.TryParse(obj["totalFileCount"], out s))
                {
                    TotalFileCount = s;
                }
            }

            if (obj.ContainsKey("dir"))
            {
                Directory = PathSpec.UnescapePath(obj["dir"]);
            }
        }
Exemple #14
0
        /// <summary>
        /// Read the fields from the tagged output of a 'streams' command
        /// </summary>
        /// <param name="objectInfo">Tagged output from the 'streams' command</param>
        /// <param name="offset">Date processing</param>
        /// <param name="dst_mismatch">DST for date</param>
        public void FromStreamsCmdTaggedOutput(TaggedObject objectInfo, string offset, bool dst_mismatch)
        {
            _baseForm = new FormBase();

            _baseForm.SetValues(objectInfo);

            if (objectInfo.ContainsKey("Stream"))
            {
                Id = objectInfo["Stream"];
            }

            if (objectInfo.ContainsKey("Update"))
            {
                DateTime UTC = FormBase.ConvertUnixTime(objectInfo["Update"]);
                DateTime GMT = new DateTime(UTC.Year, UTC.Month, UTC.Day, UTC.Hour, UTC.Minute, UTC.Second,
                                            DateTimeKind.Unspecified);
                Updated = FormBase.ConvertFromUTC(GMT, offset, dst_mismatch);
            }

            if (objectInfo.ContainsKey("Access"))
            {
                DateTime UTC = FormBase.ConvertUnixTime(objectInfo["Access"]);
                DateTime GMT = new DateTime(UTC.Year, UTC.Month, UTC.Day, UTC.Hour, UTC.Minute, UTC.Second,
                                            DateTimeKind.Unspecified);
                Accessed = FormBase.ConvertFromUTC(GMT, offset, dst_mismatch);
            }

            if (objectInfo.ContainsKey("Owner"))
            {
                OwnerName = objectInfo["Owner"];
            }

            if (objectInfo.ContainsKey("Name"))
            {
                Name = objectInfo["Name"];
            }

            if (objectInfo.ContainsKey("Parent"))
            {
                Parent = new DepotPath(objectInfo["Parent"]);
            }

            if (objectInfo.ContainsKey("baseParent"))
            {
                BaseParent = new DepotPath(objectInfo["baseParent"]);
            }

            if (objectInfo.ContainsKey("Type"))
            {
                _type = (objectInfo["Type"]);
            }

            if (objectInfo.ContainsKey("desc"))
            {
                Description = objectInfo["desc"];
            }

            if (objectInfo.ContainsKey("Options"))
            {
                String optionsStr = objectInfo["Options"];
                _options = optionsStr;
            }

            if (objectInfo.ContainsKey("firmerThanParent"))
            {
                FirmerThanParent = objectInfo["firmerThanParent"];
            }

            if (objectInfo.ContainsKey("changeFlowsToParent"))
            {
                ChangeFlowsToParent = objectInfo["changeFlowsToParent"];
            }

            if (objectInfo.ContainsKey("changeFlowsFromParent"))
            {
                ChangeFlowsFromParent = objectInfo["changeFlowsFromParent"];
            }

            int    idx = 0;
            string key = String.Format("Paths{0}", idx);

            if (objectInfo.ContainsKey(key))
            {
                ViewMap Paths                  = new ViewMap();
                StringEnum <MapType> map       = null;
                PathSpec             LeftPath  = null;
                PathSpec             RightPath = null;
                MapEntry             Path      = new MapEntry(map, LeftPath, RightPath);

                while (objectInfo.ContainsKey(key))
                {
                    string   l = (objectInfo[key]);
                    string[] p = l.Split(' ');
                    map       = p[0];
                    LeftPath  = new DepotPath(p[1]);
                    RightPath = new DepotPath(p[2]);
                    Path      = new MapEntry(map, LeftPath, RightPath);
                    Paths.Add(Path);
                    idx++;
                    key = String.Format("Paths{0}", idx);
                }
            }

            idx = 0;
            key = String.Format("Remapped{0}", idx);
            if (objectInfo.ContainsKey(key))
            {
                ViewMap  Remapped  = new ViewMap();
                PathSpec LeftPath  = null;
                PathSpec RightPath = null;
                MapEntry Remap     = new MapEntry(MapType.Include, LeftPath, RightPath);

                while (objectInfo.ContainsKey(key))
                {
                    string   l = (objectInfo[key]);
                    string[] p = l.Split(' ');
                    LeftPath  = new DepotPath(p[0]);
                    RightPath = new DepotPath(p[1]);
                    Remap     = new MapEntry(MapType.Include, LeftPath, RightPath);
                    Remapped.Add(Remap);
                    idx++;
                    key = String.Format("Remapped{0}", idx);
                }
            }

            idx = 0;
            key = String.Format("Ignored{0}", idx);
            if (objectInfo.ContainsKey(key))
            {
                List <FileSpec> Ignored = new List <FileSpec>();
                FileSpec        ignore  = new FileSpec(new DepotPath(string.Empty), null);

                while (objectInfo.ContainsKey(key))
                {
                    string i = (objectInfo[key]);
                    ignore = new FileSpec(new DepotPath(i), null);
                    Ignored.Add(ignore);
                    idx++;
                    key = String.Format("Remapped{0}", idx);
                }
            }
            else
            {
                Ignored = null;
            }
        }