I think the code needs to be split up so that CopyFrom() in the loop body calls CopyFromOneTuple(), which then also splits out the tuple routing into its own CopyFromOneTupleRoute() function (that's 200 LOC on its own...). I suspect it'd also be good to refactor the partition-change code out into its own function.
+1 I had a hard time with this when doing my copy_srf() misadventure.