/// <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; }
/// <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); }
/// <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"]); } }