tf rename <olddir> <newdir> should work now
[tfs.git] / class / Microsoft.TeamFoundation.VersionControl.Client / ChangeRequest.cs
blob7fbdd9cda879384a2af134002f7410effcbf1caf
1 //
2 // Microsoft.TeamFoundation.VersionControl.Client.ChangeRequest
3 //
4 // Authors:
5 // Joel Reed (joelwreed@gmail.com)
6 //
7 // Copyright (C) 2007 Joel Reed
8 //
9 // Permission is hereby granted, free of charge, to any person obtaining
10 // a copy of this software and associated documentation files (the
11 // "Software"), to deal in the Software without restriction, including
12 // without limitation the rights to use, copy, modify, merge, publish,
13 // distribute, sublicense, and/or sell copies of the Software, and to
14 // permit persons to whom the Software is furnished to do so, subject to
15 // the following conditions:
16 //
17 // The above copyright notice and this permission notice shall be
18 // included in all copies or substantial portions of the Software.
19 //
20 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
21 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
22 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
23 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
24 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
25 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
26 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
29 using System;
30 using System.IO;
31 using System.Xml;
32 using Microsoft.TeamFoundation.VersionControl.Common;
34 namespace Microsoft.TeamFoundation.VersionControl.Client
36 internal class ChangeRequest
38 private RequestType requestType = RequestType.None;
39 private int deletionId = 0;
40 private int encoding = 65001; // used to be -2
41 private ItemType itemType = ItemType.Any;
42 private LockLevel @lockLevel = LockLevel.None;
43 private string target;
44 private ItemType targetType = ItemType.Any;
45 private ItemSpec item;
46 private VersionSpec versionSpec = VersionSpec.Latest;
48 public ChangeRequest(string path, RequestType requestType, ItemType itemType)
50 this.item = new ItemSpec(path, RecursionType.None);
51 this.requestType = requestType;
52 this.itemType = itemType;
55 public ChangeRequest(string path, string target, RequestType requestType, ItemType itemType)
57 this.item = new ItemSpec(path, RecursionType.None);
58 this.target = target;
59 this.requestType = requestType;
60 this.itemType = itemType;
63 public LockLevel LockLevel
65 get { return lockLevel; }
68 public ItemSpec Item
70 get { return item; }
73 public VersionSpec VersionSpec
75 get { return versionSpec; }
78 public ItemType ItemType
80 get { return itemType; }
81 set { itemType = value; }
84 public ItemType TargetType
86 get { return targetType; }
87 set { targetType = value; }
90 public RequestType RequestType
92 get { return requestType; }
93 set { requestType = value; }
96 public int DeletionId
98 get { return deletionId; }
99 set { deletionId = value; }
102 public int Encoding
104 get { return encoding; }
105 set { encoding = value; }
108 public string Target
110 get { return target; }
111 set { target = value; }
114 internal void ToXml(XmlWriter writer, string element)
116 writer.WriteStartElement("ChangeRequest");
117 writer.WriteAttributeString("req", RequestType.ToString());
119 if (LockLevel != LockLevel.None)
120 writer.WriteAttributeString("lock", LockLevel.ToString());
122 if (RequestType == RequestType.Add)
123 writer.WriteAttributeString("enc", Encoding.ToString());
125 writer.WriteAttributeString("type", ItemType.ToString());
126 //writer.WriteAttributeString("did", DeletionId.ToString());
127 //writer.WriteAttributeString("targettype", TargetType.ToString());
129 if (!String.IsNullOrEmpty(Target))
131 // convert local path specs from platform paths to tfs paths as needed
132 string fxdTarget;
133 if (VersionControlPath.IsServerItem(Target)) fxdTarget = Target;
134 else fxdTarget = TfsPath.FromPlatformPath(Target);
135 writer.WriteAttributeString("target", fxdTarget);
138 this.Item.ToXml(writer, "item");
139 //this.VersionSpec.ToXml(writer, "vspec");
141 writer.WriteEndElement();