Exemple #1
0
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="dp">DepotPath</param>
        /// <param name="cp">ClientPath</param>
        /// <param name="lp">LocalPath</param>
        /// <param name="version">VersionSpec</param>
        public FileSpec(DepotPath dp, ClientPath cp, LocalPath lp, VersionSpec version)
        {
            DepotPath  = dp;
            ClientPath = cp;
            LocalPath  = lp;

            Version = version;
        }
Exemple #2
0
 /// <summary>
 /// Get the Directory this file is in by checking DepotPath, ClientPath and LocalPath as needed
 /// </summary>
 /// <returns>Directory name</returns>
 public string GetDirectoryName()
 {
     if ((DepotPath != null) && (string.IsNullOrEmpty(DepotPath.Path) == false))
     {
         return(DepotPath.GetDirectoryName());
     }
     else if ((ClientPath != null) && (string.IsNullOrEmpty(ClientPath.Path) == false))
     {
         return(ClientPath.GetDirectoryName());
     }
     else if ((LocalPath != null) && (string.IsNullOrEmpty(LocalPath.Path) == false))
     {
         return(LocalPath.GetDirectoryName());
     }
     return(null);
 }
Exemple #3
0
 /// <summary>
 /// Fully parameterized constructor
 /// </summary>
 /// <param name="depotPath">Server Depot Path</param>
 /// <param name="clientPath">Client workspace Path</param>
 /// <param name="rev">Latest Revision of this file</param>
 /// <param name="haveRev">Revision of this file in the workspace</param>
 /// <param name="change">Change ID which contains this file</param>
 /// <param name="action">Last Action taken on this file</param>
 /// <param name="type">The file type</param>
 /// <param name="submittime">The time when the file was submitted</param>
 /// <param name="user">the User which created this file</param>
 /// <param name="client">the name of the client/workspace which contains this file</param>
 public File(
     DepotPath depotPath,
     ClientPath clientPath,
     Revision rev,
     Revision haveRev,
     int change,
     FileAction action,
     FileType type,
     DateTime submittime,
     string user,
     string client)
     : base(depotPath, clientPath, null, rev)
 {
     ChangeId   = change;
     Action     = action;
     Type       = type;
     SubmitTime = submittime;
     HaveRev    = haveRev;
     User       = user;
     Client     = client;
 }
Exemple #4
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 #5
0
        /// <summary>
        /// Read the fields from the tagged output of a 'stream' command
        /// </summary>
        /// <param name="objectInfo">Tagged output from the 'stream' command</param>
        public void FromStreamCmdTaggedOutput(TaggedObject objectInfo)
        {
            _baseForm = new FormBase();

            _baseForm.SetValues(objectInfo);

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

            if (objectInfo.ContainsKey("Update"))
            {
                DateTime v = DateTime.MinValue;
                DateTime.TryParse(objectInfo["Update"], out v);
                Updated = v;
            }

            if (objectInfo.ContainsKey("Access"))
            {
                DateTime v = DateTime.MinValue;
                DateTime.TryParse(objectInfo["Access"], out v);
                Accessed = v;
            }

            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("Description"))
            {
                Description = objectInfo["Description"];
            }

            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))
            {
                Paths = new ViewMap();
                while (objectInfo.ContainsKey(key))
                {
                    Paths.Add(objectInfo[key]);
                    idx++;
                    key = String.Format("Paths{0}", idx);
                }
            }
            else
            {
                Paths = null;
            }

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

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

            idx = 0;
            key = String.Format("Ignored{0}", idx);
            if (objectInfo.ContainsKey(key))
            {
                Ignored = new ViewMap();
                PathSpec LeftPath  = new ClientPath(string.Empty);
                PathSpec RightPath = new ClientPath(string.Empty);
                MapEntry Ignore    = new MapEntry(MapType.Include, LeftPath, RightPath);

                while (objectInfo.ContainsKey(key))
                {
                    string   l = (objectInfo[key]);
                    string[] p = l.Split(' ');
                    LeftPath = new ClientPath(p[0]);
                    if (p.Length > 1)
                    {
                        RightPath = new ClientPath(p[1]);
                    }
                    Ignore = new MapEntry(MapType.Include, LeftPath, RightPath);
                    Ignored.Add(Ignore);
                    idx++;
                    key = String.Format("Ignored{0}", idx);
                }
            }
            else
            {
                Ignored = null;
            }

            idx = 0;
            key = String.Format("View{0}", idx);
            if (objectInfo.ContainsKey(key))
            {
                View = new ViewMap();
                while (objectInfo.ContainsKey(key))
                {
                    View.Add(objectInfo[key]);
                    idx++;
                    key = String.Format("View{0}", idx);
                }
            }
            else
            {
                View = null;
            }
        }