internal static string GetOriginalName(PendingChange pendingChange, bool useServerPath) { string x = null; var itemName = GetItemName(pendingChange, useServerPath); if (!string.IsNullOrEmpty(pendingChange.SourceLocalItem) && !string.IsNullOrEmpty(pendingChange.LocalItem)) { x = FileSpec.GetFileName(pendingChange.SourceLocalItem); if ( !FileSpec.Equals(FileSpec.GetDirectoryName(pendingChange.SourceLocalItem), FileSpec.GetDirectoryName(pendingChange.LocalItem))) { x = pendingChange.SourceLocalItem; } if (string.Equals(x, itemName, StringComparison.Ordinal)) { x = null; } } if (x == null && !string.IsNullOrEmpty(pendingChange.SourceServerItem) && !string.IsNullOrEmpty(pendingChange.ServerItem)) { x = VersionControlPath.GetFileName(pendingChange.SourceServerItem); if ( !VersionControlPath.Equals(VersionControlPath.GetFolderName(pendingChange.SourceServerItem), VersionControlPath.GetFolderName(pendingChange.ServerItem))) { x = pendingChange.SourceServerItem; } if (string.Equals(x, itemName, StringComparison.Ordinal)) { x = null; } } return(x); }
public void EqualsTest() { FileSpec left = new FileSpec(new DepotPath("//depot/main/test.txt"), null, null, new VersionRange(1, 2)); FileSpec rightpos = new FileSpec(new DepotPath("//depot/main/test.txt"), null, null, new VersionRange(1, 2)); FileSpec rightneg1 = new FileSpec(new DepotPath("//depot/main/empty.bmp"), null, null, new VersionRange(1, 2)); FileSpec rightneg2 = new FileSpec(new DepotPath("//depot/main/test.txt"), null, null, new VersionRange(7, 8)); FileSpec rightnull = null; Assert.IsTrue(left.Equals(rightpos)); Assert.IsFalse(left.Equals(rightneg1)); Assert.IsFalse(left.Equals(rightneg2)); Assert.IsFalse(left.Equals(rightnull)); left = new FileSpec(null, new ClientPath("//user_workspace/main/test.txt"), null, new Revision(2)); rightpos = new FileSpec(null, new ClientPath("//user_workspace/main/test.txt"), null, new Revision(2)); rightneg1 = new FileSpec(null, new ClientPath("//user_workspace/main/empty.bmp"), null, new Revision(2)); rightneg2 = new FileSpec(null, new ClientPath("//user_workspace/main/test.txt"), null, new Revision(4)); rightnull = null; Assert.IsTrue(left.Equals(rightpos)); Assert.IsFalse(left.Equals(rightneg1)); Assert.IsFalse(left.Equals(rightneg2)); Assert.IsFalse(left.Equals(rightnull)); left = new FileSpec(null, null, new LocalPath(@"C:\workspace_root\test.txt"), new NoneRevision()); rightpos = new FileSpec(null, null, new LocalPath(@"C:\workspace_root\test.txt"), new NoneRevision()); rightneg1 = new FileSpec(null, null, new LocalPath(@"C:\workspace_root\empty.bmp"), new NoneRevision()); rightneg2 = new FileSpec(null, null, new LocalPath(@"C:\workspace_root\test.txt"), new HeadRevision()); rightnull = null; Assert.IsTrue(left.Equals(rightpos)); Assert.IsFalse(left.Equals(rightneg1)); Assert.IsFalse(left.Equals(rightneg2)); Assert.IsFalse(left.Equals(rightnull)); left = new FileSpec(new DepotPath("//depot/main/test.txt"), new VersionRange(1, 2)); rightpos = new FileSpec(new DepotPath("//depot/main/test.txt"), new VersionRange(1, 2)); rightneg1 = new FileSpec(new DepotPath("//depot/main/empty.bmp"), new VersionRange(1, 2)); rightneg2 = new FileSpec(new DepotPath("//depot/main/test.txt"), new VersionRange(7, 8)); rightnull = null; Assert.IsTrue(left.Equals(rightpos)); Assert.IsFalse(left.Equals(rightneg1)); Assert.IsFalse(left.Equals(rightneg2)); Assert.IsFalse(left.Equals(rightnull)); left = new FileSpec(new ClientPath("//user_workspace/main/test.txt"), new Revision(2)); rightpos = new FileSpec(new ClientPath("//user_workspace/main/test.txt"), new Revision(2)); rightneg1 = new FileSpec(new ClientPath("//user_workspace/main/empty.bmp"), new Revision(2)); rightneg2 = new FileSpec(new ClientPath("//user_workspace/main/test.txt"), new Revision(4)); rightnull = null; Assert.IsTrue(left.Equals(rightpos)); Assert.IsFalse(left.Equals(rightneg1)); Assert.IsFalse(left.Equals(rightneg2)); Assert.IsFalse(left.Equals(rightnull)); left = new FileSpec(new LocalPath(@"C:\workspace_root\test.txt"), new NoneRevision()); rightpos = new FileSpec(new LocalPath(@"C:\workspace_root\test.txt"), new NoneRevision()); rightneg1 = new FileSpec(new LocalPath(@"C:\workspace_root\empty.bmp"), new NoneRevision()); rightneg2 = new FileSpec(new LocalPath(@"C:\workspace_root\test.txt"), new HeadRevision()); rightnull = null; Assert.IsTrue(left.Equals(rightpos)); Assert.IsFalse(left.Equals(rightneg1)); Assert.IsFalse(left.Equals(rightneg2)); Assert.IsFalse(left.Equals(rightnull)); }