/// <summary> /// instantiate this FileType from a string /// </summary> /// <param name="spec">string to parse</param> internal void Parse(string spec) { String flags = null; // check for historical filetypes if (spec == "ctempobj") { this.BaseType = BaseFileType.Binary; this.Modifiers = FileTypeModifier.HeadrevOnly | FileTypeModifier.Writable; return; } if (spec == "ctext") { this.BaseType = BaseFileType.Text; this.Modifiers = FileTypeModifier.CompressedFiles; return; } if (spec == "cxtext") { this.BaseType = BaseFileType.Text; this.Modifiers = FileTypeModifier.CompressedFiles | FileTypeModifier.Exec; return; } if (spec == "ktext") { this.BaseType = BaseFileType.Text; this.Modifiers = FileTypeModifier.KeywordsAll; return; } if (spec == "kxtext") { this.BaseType = BaseFileType.Text; this.Modifiers = FileTypeModifier.KeywordsAll | FileTypeModifier.Exec; return; } if (spec == "ltext") { this.BaseType = BaseFileType.Text; this.Modifiers = FileTypeModifier.FullRevisions; return; } if (spec == "tempobj") { this.BaseType = BaseFileType.Binary; this.Modifiers = FileTypeModifier.FullRevisions | FileTypeModifier.HeadrevOnly | FileTypeModifier.Writable; return; } if (spec == "ubinary") { this.BaseType = BaseFileType.Binary; this.Modifiers = FileTypeModifier.FullRevisions; return; } if (spec == "uresource") { this.BaseType = BaseFileType.Resource; this.Modifiers = FileTypeModifier.FullRevisions; return; } if (spec == "uxbinary") { this.BaseType = BaseFileType.Binary; this.Modifiers = FileTypeModifier.FullRevisions | FileTypeModifier.Exec; return; } if (spec == "xbinary") { this.BaseType = BaseFileType.Binary; this.Modifiers = FileTypeModifier.Exec; return; } if (spec == "xltext") { this.BaseType = BaseFileType.Text; this.Modifiers = FileTypeModifier.FullRevisions | FileTypeModifier.Exec; return; } if (spec == "xtext") { this.BaseType = BaseFileType.Text; this.Modifiers = FileTypeModifier.Exec; return; } if (spec == "xtempobj") { this.BaseType = BaseFileType.Binary; this.Modifiers = FileTypeModifier.FullRevisions | FileTypeModifier.HeadrevOnly | FileTypeModifier.Writable | FileTypeModifier.Exec; return; } if (spec == "xutf16") { this.BaseType = BaseFileType.UTF16; this.Modifiers = FileTypeModifier.Exec; return; } if (spec == "xutf8") { this.BaseType = BaseFileType.UTF8; this.Modifiers = FileTypeModifier.Exec; return; } if (spec == "xunicode") { this.BaseType = BaseFileType.Unicode; this.Modifiers = FileTypeModifier.Exec; return; } if (spec.StartsWith("+")) { // no base type specified this.BaseType = BaseFileType.Unspecified; flags = spec.TrimStart('+'); } else { string[] parts = spec.Split('+'); try { this._baseType = parts[0]; } catch { this.BaseType = BaseFileType.Unspecified; } if (parts.Length > 1) { flags = parts[1]; } else { return; // no flags, so we're done } } for (int idx = 0; idx < flags.Length; idx++) { if ((idx + 1 < flags.Length) && (flags[idx] == 'S')) { if (char.IsNumber(flags[idx + 1])) { this.Modifiers |= FileTypeModifier.NRevsOnly; int cnt = 0; while ((idx + cnt + 1 < flags.Length) && char.IsNumber(flags[idx + cnt + 1])) { cnt++; } int revs = 1; int.TryParse(flags.Substring(idx + 1, cnt), out revs); this.StoredRevs = revs; idx += cnt; } else { this.Modifiers |= FileTypeModifier.HeadrevOnly; } } else if ((idx + 1 < flags.Length) && (flags[idx] == 'k')) { if (flags[idx + 1] == 'o') { this.Modifiers |= FileTypeModifier.KeywordsLimited; idx++; } else { this.Modifiers |= FileTypeModifier.KeywordsAll; } } else { switch (flags[idx]) { case 'm': this.Modifiers |= FileTypeModifier.ModTime; break; case 'w': this.Modifiers |= FileTypeModifier.Writable; break; case 'x': this.Modifiers |= FileTypeModifier.Exec; break; case 'k': this.Modifiers |= FileTypeModifier.KeywordsAll; break; case 'l': this.Modifiers |= FileTypeModifier.ExclusiveOpen; break; case 'C': this.Modifiers |= FileTypeModifier.CompressedFiles; break; case 'D': this.Modifiers |= FileTypeModifier.RCSDeltaFiles; break; case 'F': this.Modifiers |= FileTypeModifier.FullRevisions; break; case 'S': this.Modifiers |= FileTypeModifier.HeadrevOnly; break; case 'X': this.Modifiers |= FileTypeModifier.ArchiveTrigger; break; default: //unknown flag break; } } } }
/// <summary> /// Parse the fields from a changelist specification /// </summary> /// <param name="spec">Text of the changelist specification in server format</param> /// <returns>true if parse successful</returns> public bool Parse(String spec) { _baseForm = new FormBase(); _baseForm.Parse(spec); // parse the values into the underlying dictionary if (_baseForm.ContainsKey("Change")) { int v = -1; int.TryParse((string)_baseForm["Change"], out v); Id = v; } if (_baseForm.ContainsKey("Date")) { DateTime v; DateTime.TryParse((string)_baseForm["Date"], out v); ModifiedDate = v; } if (_baseForm.ContainsKey("Client")) { ClientId = (string)_baseForm["Client"]; } if (_baseForm.ContainsKey("User")) { OwnerName = (string)_baseForm["User"]; } if (_baseForm.ContainsKey("Status")) { Pending = true; String v = (string)_baseForm["Status"]; if (v == "submitted") { Pending = false; } } if (_baseForm.ContainsKey("Type")) { _type = (string)_baseForm["Type"]; } if (_baseForm.ContainsKey("Description")) { if (_baseForm["Description"] is string) { Description = (string)_baseForm["Description"]; } else if (_baseForm["Description"] is SimpleList <string> ) { SimpleList <string> strList = _baseForm["Description"] as SimpleList <string>; Description = string.Empty; SimpleListItem <string> current = strList.Head; bool addCRLF = false; while (current != null) { if (addCRLF) { Description += "\r\n"; } else { addCRLF = true; } Description += current.Item; current = current.Next; } } else if (_baseForm["Description"] is IList <string> ) { IList <string> strList = _baseForm["Description"] as IList <string>; Description = string.Empty; for (int idx = 0; idx < strList.Count; idx++) { if (idx > 0) { Description += "\r\n"; } Description += strList[idx]; } } } if (_baseForm.ContainsKey("Jobs")) { if (_baseForm["Jobs"] is IList <string> ) { IList <string> strList = _baseForm["Jobs"] as IList <string>; Jobs = new Dictionary <string, string>(strList.Count); foreach (string job in strList) { if (job.Contains('#')) { string[] parts = job.Split('#'); Jobs[parts[0].Trim()] = null; } else { Jobs[job] = null; } } } else if (_baseForm["Jobs"] is SimpleList <string> ) { SimpleList <string> strList = _baseForm["Jobs"] as SimpleList <string>; Jobs = new Dictionary <string, string>(strList.Count); SimpleListItem <string> current = strList.Head; while (current != null) { string job = current.Item; if (job.Contains('#')) { string[] parts = job.Split('#'); Jobs[parts[0].Trim()] = null; } else { Jobs[job] = null; } current = current.Next; } } } if (_baseForm.ContainsKey("Files")) { if (_baseForm["Files"] is IList <string> ) { IList <string> files = (IList <string>)_baseForm["Files"]; Files = new List <FileMetaData>(files.Count); foreach (string path in files) { FileMetaData file = new FileMetaData(); if (path.Contains('#')) { string[] parts = path.Split('#'); file.DepotPath = new DepotPath(parts[0].Trim()); } else { file.DepotPath = new DepotPath(path); } Files.Add(file); } } else if (_baseForm["Files"] is SimpleList <string> ) { SimpleList <string> files = (SimpleList <string>)_baseForm["Files"]; Files = new List <FileMetaData>(files.Count); SimpleListItem <string> current = files.Head; while (current != null) { FileMetaData file = new FileMetaData(); if (current.Item.Contains('#')) { string[] parts = current.Item.Split('#'); file.DepotPath = new DepotPath(parts[0].Trim()); } else { file.DepotPath = new DepotPath(current.Item); } Files.Add(file); current = current.Next; } } } return(true); }
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"]; } }
private void PopulateCommonFields(TaggedObject objectInfo) { if (objectInfo.ContainsKey("Stream")) { Id = objectInfo["Stream"]; specDef.Remove("Stream"); } if (objectInfo.ContainsKey("Owner")) { OwnerName = objectInfo["Owner"]; specDef.Remove("Owner"); } if (objectInfo.ContainsKey("Name")) { Name = objectInfo["Name"]; specDef.Remove("Name"); } if (objectInfo.ContainsKey("Parent")) { Parent = new DepotPath(objectInfo["Parent"]); specDef.Remove("Parent"); } if (objectInfo.ContainsKey("baseParent")) { BaseParent = new DepotPath(objectInfo["baseParent"]); specDef.Remove("baseParent"); } if (objectInfo.ContainsKey("Type")) { _type = (objectInfo["Type"]); specDef.Remove("Type"); } if (objectInfo.ContainsKey("Description")) { Description = objectInfo["Description"]; specDef.Remove("Description"); } if (objectInfo.ContainsKey("desc")) { Description = objectInfo["desc"]; specDef.Remove("desc"); } if (objectInfo.ContainsKey("Options")) { String optionsStr = objectInfo["Options"]; _options = optionsStr; specDef.Remove("Options"); } if (objectInfo.ContainsKey("firmerThanParent")) { FirmerThanParent = objectInfo["firmerThanParent"]; specDef.Remove("firmerThanParent"); } if (objectInfo.ContainsKey("changeFlowsToParent")) { ChangeFlowsToParent = objectInfo["changeFlowsToParent"]; specDef.Remove("changeFlowsToParent"); } if (objectInfo.ContainsKey("changeFlowsFromParent")) { ChangeFlowsFromParent = objectInfo["changeFlowsFromParent"]; specDef.Remove("changeFlowsFromParent"); } if (objectInfo.ContainsKey("ParentView")) { _parentView = (objectInfo["ParentView"]); specDef.Remove("ParentView"); } }
/// <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)); } }
public FileSubmitRecord(FileAction action, FileSpec file) { _action = action; File = file; }
public FileSubmitRecord() { _action = FileAction.None; File = null; }
/// <summary> /// Read the fields from the tagged output of a user command /// </summary> /// <param name="objectInfo">Tagged output from the 'user' command</param> /// <param name="offset">Date processing</param> /// <param name="dst_mismatch">DST for date</param> public void FromUserCmdTaggedOutput(TaggedObject objectInfo, string offset, bool dst_mismatch) { _baseForm = new FormBase(); _baseForm.SetValues(objectInfo); if (objectInfo.ContainsKey("User")) { Id = objectInfo["User"]; } if (objectInfo.ContainsKey("Email")) { EmailAddress = objectInfo["Email"]; } if (objectInfo.ContainsKey("Update")) { DateTime d; if (DateTime.TryParse(objectInfo["Update"] as string, out d)) { Updated = d; } else { long unixTime = 0; if (Int64.TryParse(objectInfo["Update"], out unixTime)) { DateTime UTC = FormBase.ConvertUnixTime(unixTime); 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 d; if (DateTime.TryParse(objectInfo["Access"] as string, out d)) { Updated = d; } else { long unixTime = 0; if (Int64.TryParse(objectInfo["Access"], out unixTime)) { DateTime UTC = FormBase.ConvertUnixTime(unixTime); 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("FullName")) { FullName = objectInfo["FullName"]; } if (objectInfo.ContainsKey("JobView")) { JobView = objectInfo["JobView"]; } String key = "Reviews0"; int idx = 0; Reviews = new StringList(); while (objectInfo.ContainsKey((key = String.Format("Reviews{0}", idx)))) { idx++; Reviews.Add(objectInfo[key]); } if (objectInfo.ContainsKey("Password")) { Password = objectInfo["Password"]; } if (objectInfo.ContainsKey("Type")) { _type = objectInfo["Type"]; } }
/// <summary> /// Parse the fields from a user specification /// </summary> /// <param name="spec">Text of the user specification in server format</param> /// <returns></returns> public bool Parse(String spec) { _baseForm = new FormBase(); _baseForm.Parse(spec); // parse the values into the underlying dictionary if (_baseForm.ContainsKey("User")) { Id = _baseForm["User"] as string; } if (_baseForm.ContainsKey("Email")) { EmailAddress = _baseForm["Email"] as string; } if (_baseForm.ContainsKey("Update")) { DateTime v = DateTime.MinValue; DateTime.TryParse(_baseForm["Update"] as string, out v); Updated = v; } if (_baseForm.ContainsKey("Access")) { DateTime v = DateTime.MinValue; DateTime.TryParse(_baseForm["Access"] as string, out v); Accessed = v; } if (_baseForm.ContainsKey("FullName")) { FullName = _baseForm["FullName"] as string; } if (_baseForm.ContainsKey("JobView")) { JobView = _baseForm["JobView"] as string; } if (_baseForm.ContainsKey("Reviews")) { if (_baseForm["Reviews"] is IList <string> ) { Reviews = _baseForm["Reviews"] as IList <string>; } if (_baseForm["Reviews"] is SimpleList <string> ) { SimpleList <string> sls = (SimpleList <string>)_baseForm["Reviews"]; Reviews = (List <string>)sls; } } if (_baseForm.ContainsKey("Password")) { Password = _baseForm["Password"] as string; } if (_baseForm.ContainsKey("Type")) { _type = _baseForm["Type"] as string; } else { Type = UserType.Standard; } return(true); }
/// <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"]); } }
/// <summary> /// Parse the fields from a stream specification /// </summary> /// <param name="spec">Text of the stream specification in server format</param> /// <returns></returns> public bool Parse(String spec) { _baseForm = new FormBase(); _baseForm.Parse(spec); // parse the values into the underlying dictionary if (_baseForm.ContainsKey("Stream")) { Id = _baseForm["Stream"] as string; } if (_baseForm.ContainsKey("Update")) { DateTime d; if (DateTime.TryParse(_baseForm["Update"] as string, out d)) { Updated = d; } } if (_baseForm.ContainsKey("Access")) { DateTime d; if (DateTime.TryParse(_baseForm["Access"] as string, out d)) { Accessed = d; } } if (_baseForm.ContainsKey("Owner")) { OwnerName = _baseForm["Owner"] as string; } if (_baseForm.ContainsKey("Name")) { Name = _baseForm["Name"] as string; } if (_baseForm.ContainsKey("Parent")) { string line = _baseForm["Parent"] as string; Parent = new DepotPath(line); } if (_baseForm.ContainsKey("Type")) { _type = _baseForm["Type"] as string; } if (_baseForm.ContainsKey("Description")) { Description = _baseForm["Description"] as string; } if (_baseForm.ContainsKey("Options")) { _options = _baseForm["Options"] as string; } return(true); }
/// <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; } }
/// <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; } }
public FileResolveRecord() { _action = FileAction.None; }