18 using System.Globalization;
59 public static DateTime?
acxTime(
this XElement element, XName name)
62 XAttribute attr = element.Attribute(name);
81 XAttribute attr = element.Attribute(name);
84 string temp = (string)element.Attribute(attr.Name);
85 if (!String.Equals(temp,
"* unknown *"))
99 Debug.Assert(transaction.Name ==
"transaction",
@"transaction.Name == ""transaction""");
100 return String.Equals((
string)transaction.Attribute(
"type"),
"promote");
111 Debug.Assert(transaction.Name ==
"transaction",
@"transaction.Name == ""transaction""");
113 if (transaction.acxIsPromote())
114 name = $
"{(string)transaction.Attribute("fromStreamName
")} ({(int)transaction.Attribute("fromStreamNumber
")})";
127 Debug.Assert(transaction.Name ==
"transaction",
@"transaction.Name == ""transaction""");
129 if (transaction.acxIsPromote())
130 name = $
"{(string)transaction.Attribute("streamName
")} ({(int)transaction.Attribute("streamNumber
")})";
142 Debug.Assert(transaction.Name ==
"transaction",
@"transaction.Name == ""transaction""");
143 return String.Equals((
string)transaction.Attribute(
"type"),
"co");
158 Debug.Assert(transaction.Name ==
"transaction",
@"transaction.Name == ""transaction""");
160 if (transaction.acxIsPromote() || transaction.acxIsCheckOut())
162 XElement first = transaction.Elements(
"version").FirstOrDefault();
164 name = $
"{(string)first.Attribute("virtualNamedVersion
")} ({(string)first.Attribute("virtual")})";
181 Debug.Assert(version.Name ==
"version",
@"version.Name == ""version""");
182 XElement transaction = version.Parent;
183 XElement first = transaction.Elements(
"version").FirstOrDefault();
185 if (first != null && version == first && transaction.acxIsPromote())
188 string name = $
"{(string)version.Attribute("realNamedVersion
")} ({(string)version.Attribute("real
")})";
200 Debug.Assert(version.Name ==
"version",
@"version.Name == ""version""");
202 string ancestorNamedVersion = (string)version.Attribute(
"ancestorNamedVersion");
203 if (!String.IsNullOrEmpty(ancestorNamedVersion))
204 name = $
"{ancestorNamedVersion} ({(string)version.Attribute("ancestor
")})";
216 Debug.Assert(version.Name ==
"version",
@"version.Name == ""version""");
218 string mergedAgainstNamedVersion = (string)version.Attribute(
"mergedAgainstNamedVersion");
219 if (!String.IsNullOrEmpty(mergedAgainstNamedVersion))
220 name = $
"{mergedAgainstNamedVersion} ({(string)version.Attribute("merged_against
")})";
237 Debug.Assert(element.Name ==
"transaction" || element.Name ==
"version",
238 @"element.Name == ""transaction"" || element.Name == ""version""");
240 if (element.Name ==
"transaction")
241 xe = element.Elements().FirstOrDefault();
242 else if (element.Name ==
"version")
244 XElement trans = element.Parent;
245 XElement first = trans.Elements(
"version").FirstOrDefault();
247 if (first != null && element == first && trans.acxIsPromote())
250 xe = element.ElementsBeforeSelf().LastOrDefault();
253 string comment = null;
254 if (xe != null && xe.Name ==
"comment")
255 comment = (string)xe;
266 Debug.Assert(version.Name ==
"version",
@"version.Name == ""version""");
267 string temp = (string)version.Attribute(
"realNamedVersion");
268 string name = temp.Substring(0, temp.IndexOf(
'/'));
279 Debug.Assert(version.Name ==
"version",
@"version.Name == ""version""");
280 string prncpl = null;
281 string wspace = version.acxWSpaceName();
282 int ii = wspace.LastIndexOf(
'_');
283 if (ii != -1) prncpl = wspace.Substring(++ii);
297 Debug.Assert(version.Name ==
"version",
@"version.Name == ""version""");
298 string temp = (request ==
RealVirtual.Real) ? (
string)version.Attribute(
"real") :
299 (string)version.Attribute(
"virtual");
300 if (temp == null)
return null;
301 string[] val = temp.Split(
'/');
302 int[] arr =
new int[2];
303 if (!Int32.TryParse(val[0], NumberStyles.Integer, null, out arr[0]))
return null;
304 if (!Int32.TryParse(val[1], NumberStyles.Integer, null, out arr[1]))
return null;
317 Debug.Assert(version.Name ==
"version",
@"version.Name == ""version""");
318 string temp = (request ==
RealVirtual.Real) ? (
string)version.Attribute(
"realNamedVersion") :
319 (string)version.Attribute(
"virtualNamedVersion");
320 if (temp == null)
return null;
321 string stream = temp.Substring(0, temp.IndexOf(
'/'));
ElementType
Indicates the element's type. By default, AccuRev determines the element type for a newly created ver...
static DateTime acxTime(this XElement element, XName name)
Convert element's Epoch time name XML attribute value to a .NET DateTime object.
static string acxAncestorNamed(this XElement version)
Get the ancestor-named version for version.
static bool acxIsPromote(this XElement transaction)
Determine if transaction was a promote operation.
static int[] acxStreamVersion(this XElement version, RealVirtual request)
Get the real or virtual stream and version numbers for version.
Use to validate and convert date/time values to and from .NET and AccuRev/Unix formats.
static string acxVirtualNamed(this XElement transaction)
Get the virtual-named version for the promote or co transaction.
static DateTime AcDate2DateTime(long seconds)
Convert an AccuRev date given in Unix time (seconds param) to a .NET DateTime in local time...
static string acxStreamName(this XElement version, RealVirtual request)
Get the real or virtual stream name for version.
static string acxComment(this XElement element)
Get the comment for the transaction or version element.
static bool acxIsCheckOut(this XElement transaction)
Determine if transaction was a co operation.
static string acxWSpaceOwner(this XElement version)
Get the workspace owner's principal name for version.
static string acxMergedAgainstNamed(this XElement version)
Get the merged-against-named version for version.
Custom query operators for use when using LINQ to XML.
RealVirtual
Use to specify real or virtual values.
static string acxFromStream(this XElement transaction)
Get the from-stream version for the promote transaction.
static ElementType acxType(this XElement element, XName name)
Convert element's type name attribute value to an AcUtils.ElementType enum.
static string acxWSpaceName(this XElement version)
Get the workspace name for version.
static string acxRealNamed(this XElement version)
Get the real-named version for version.
static string acxToStream(this XElement transaction)
Get the to-stream version for the promote transaction.