Skip to content

Commit 022f88e

Browse files
authored
Merge pull request #13 from Techsola/fix_overwrites_from_other_branches
Fix overwrites from files in the original branch which causes changes in the current branch to be missed until the next commit
2 parents d497828 + 7d966b1 commit 022f88e

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

src/TfvcMigrator/Program.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -367,6 +367,7 @@ pat is not null
367367
var builder = ImmutableDictionary.CreateBuilder<BranchIdentity, ImmutableArray<(string GitRepositoryPath, TfvcItem DownloadSource)>>();
368368

369369
var itemsBuilder = ImmutableArray.CreateBuilder<(string GitRepositoryPath, TfvcItem DownloadSource)>();
370+
var itemPaths = new HashSet<string>(StringComparer.OrdinalIgnoreCase);
370371

371372
foreach (var (branch, mapping) in branchMappingsInDependentOperationOrder)
372373
{
@@ -384,11 +385,17 @@ pat is not null
384385
}
385386

386387
if (mapping.GetGitRepositoryPath(item.Path) is { } path)
388+
{
389+
if (!itemPaths.Add(path))
390+
throw new InvalidOperationException("The same Git repository path is being added with two different TFVC sources.");
391+
387392
itemsBuilder.Add((path, item));
393+
}
388394
}
389395

390396
builder.Add(branch, itemsBuilder.ToImmutable());
391397
itemsBuilder.Clear();
398+
itemPaths.Clear();
392399
}
393400

394401
return builder.ToImmutable();

src/TfvcMigrator/RepositoryBranchMapping.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ public RepositoryBranchMapping RenameRootDirectory(string oldPath, string newPat
5050
if (!PathUtils.IsAbsolute(newPath))
5151
throw new ArgumentException("New path must be absolute.", nameof(newPath));
5252

53-
if (!PathUtils.IsOrContains(oldPath, RootDirectory))
53+
if (!PathUtils.IsOrContains(RootDirectory, oldPath))
5454
throw new InvalidOperationException("The rename does not apply to this mapping.");
5555

5656
if (SubdirectoryMapping is not null)
@@ -73,7 +73,7 @@ public RepositoryBranchMapping WithSubdirectoryMapping(string branchDirectory, s
7373

7474
if (SubdirectoryMapping is var (branch, target))
7575
{
76-
if (PathUtils.IsOrContains(itemPath, target))
76+
if (PathUtils.IsOrContains(target, itemPath))
7777
return null;
7878

7979
if (PathUtils.IsOrContains(branch, itemPath))

0 commit comments

Comments
 (0)