3 using System
.Collections
;
4 using System
.Collections
.Generic
;
6 using Microsoft
.TeamFoundation
.Client
;
7 using Microsoft
.TeamFoundation
.VersionControl
.Common
;
8 using Microsoft
.TeamFoundation
.VersionControl
.Client
;
10 public sealed class DiffItemNull
: IDiffItem
14 public DiffItemNull ()
18 public string GetFile ()
23 public bool IsTemporary
31 set { label = value; }
34 public int GetEncoding()
36 return Encoding
.UTF8
.CodePage
;
42 static public void ShowChangeset(VersionControlServer vcs
,
43 ChangesetVersionSpec versionSpec
,
44 bool brief
, DiffOptions diffOpts
)
46 int changesetId
= versionSpec
.ChangesetId
;
47 Changeset changeset
= vcs
.GetChangeset(changesetId
, true, true);
49 // fetch all items in one fell swoop
50 List
<int> ids
= new List
<int>();
51 foreach (Change change
in changeset
.Changes
)
54 if (change
.Item
.ItemType
== ItemType
.Folder
) continue;
55 ids
.Add(change
.Item
.ItemId
);
58 // find items in prior changeset
59 Item
[] items
= vcs
.GetItems(ids
.ToArray(), changesetId
-1, true);
60 SortedList
<int, Item
> itemList
= new SortedList
<int, Item
>();
61 foreach (Item item
in items
)
63 // itemId of 0 means a null item, IOW file was added in this changeset
64 // and missing in prior changeset
65 if (item
.ItemId
== 0) continue;
66 itemList
.Add(item
.ItemId
, item
);
69 foreach (Change change
in changeset
.Changes
)
72 if (change
.Item
.ItemType
== ItemType
.Folder
) continue;
73 string p
= change
.Item
.ServerItem
.Substring(2);
81 IDiffItem a
= new DiffItemNull();
82 IDiffItem b
= new DiffItemNull();
87 if (((change
.ChangeType
& ChangeType
.Add
) != ChangeType
.Add
) &&
88 (itemList
.ContainsKey(change
.Item
.ItemId
)))
90 Item itemA
= itemList
[change
.Item
.ItemId
];
92 tnameA
= Path
.GetTempFileName();
93 itemA
.DownloadFile(tnameA
);
95 a
= new DiffItemLocalFile(tnameA
, itemA
.Encoding
,
96 changeset
.CreationDate
, true);
99 if ((change
.ChangeType
& ChangeType
.Delete
) != ChangeType
.Delete
)
101 tnameB
= Path
.GetTempFileName();
102 change
.Item
.DownloadFile(tnameB
);
104 b
= new DiffItemLocalFile(tnameB
, change
.Item
.Encoding
,
105 changeset
.CreationDate
, true);
108 diffOpts
.TargetLabel
= versionSpec
.DisplayString
;
109 Difference
.DiffFiles(vcs
, a
, b
, diffOpts
, p
, true);
111 if (!String
.IsNullOrEmpty(tnameA
))
114 if (!String
.IsNullOrEmpty(tnameB
))