Skip to content

Commit 1592d01

Browse files
authored
Merge pull request #17 from Techsola/merge_and_delete
Support changesets that merge from a branch and delete it simultaneously
2 parents 3edec49 + 675ac4c commit 1592d01

File tree

2 files changed

+15
-13
lines changed

2 files changed

+15
-13
lines changed

src/TfvcMigrator/Program.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
using System.CommandLine;
22
using System.CommandLine.NamingConventionBinder;
33
using System.Globalization;
4+
using System.Linq;
45
using System.Text;
56
using LibGit2Sharp;
67
using Microsoft.TeamFoundation.SourceControl.WebApi;
@@ -526,7 +527,8 @@ private static async IAsyncEnumerable<MappingState> EnumerateMappingStatesAsync(
526527
keySelector: mappingByBranch => mappingByBranch.Branch,
527528
dependenciesSelector: mappingByBranch => additionalParents
528529
.Where(b => b.Branch == mappingByBranch.Branch)
529-
.Select(b => b.ParentBranch))
530+
.Select(b => b.ParentBranch)
531+
.Where(branchMappings.ContainsKey)) // If the parent branch is also being deleted in the same commit, it doesn't affect the relative order
530532
.ToImmutableArray();
531533

532534
yield return new MappingState(

src/TfvcMigrator/TopologyAnalyzer.cs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -62,18 +62,6 @@ public IEnumerable<TopologicalOperation> GetTopologicalOperations(IReadOnlyList<
6262
}
6363
}
6464

65-
foreach (var change in changesetChanges)
66-
{
67-
if (change.ChangeType.HasFlag(VersionControlChangeType.Delete) && currentBranchPaths.Remove(change.Item.Path))
68-
{
69-
if (change.ChangeType != VersionControlChangeType.Delete)
70-
throw new NotImplementedException("Poorly-understood combination");
71-
72-
var deletedBranch = branchIdentifier.Delete(changeset, change.Item.Path);
73-
yield return new DeleteOperation(changeset, deletedBranch);
74-
}
75-
}
76-
7765
branchIdentifier.NoFurtherChangesUpTo(changeset - 1);
7866

7967
var (branches, merges) = GetBranchAndMergeOperations(changesetChanges, branchIdentifier);
@@ -89,6 +77,18 @@ public IEnumerable<TopologicalOperation> GetTopologicalOperations(IReadOnlyList<
8977
{
9078
yield return operation;
9179
}
80+
81+
foreach (var change in changesetChanges)
82+
{
83+
if (change.ChangeType.HasFlag(VersionControlChangeType.Delete) && currentBranchPaths.Remove(change.Item.Path))
84+
{
85+
if (change.ChangeType != VersionControlChangeType.Delete)
86+
throw new NotImplementedException("Poorly-understood combination");
87+
88+
var deletedBranch = branchIdentifier.Delete(changeset, change.Item.Path);
89+
yield return new DeleteOperation(changeset, deletedBranch);
90+
}
91+
}
9292
}
9393

9494
private static (ImmutableArray<BranchOperation> Branches, ImmutableArray<MergeOperation> Merges)

0 commit comments

Comments
 (0)