#174: Remove cd semaphore from GetComponents ---------------------------+------------------------------------------------ Reporter: eschnett | Owner: eric9 Type: defect | Status: new Priority: major | Milestone: Component: GetComponents | Version: Keywords: | ---------------------------+------------------------------------------------ GetComponents uses a semaphore that decides which task can cd into a subdirectory. This limits parallelism, since in essence only one task can cd into (and presumably thus access) a repository. Furthermore, using semaphores is a tedious and complex way to handle parallelism.
I suggest to remove the semaphore, and instead not use cd within GetComponents at all. Instead, run_command should take care of this. For example, instead of
if ($PARALLEL) {$cd_sem->down()} chdir("$orig_dir/$ROOT/repos/$git_repo"); my $err = run_command("git checkout --track -b $branch origin/$branch"); chdir("$orig_dir"); if ($PARALLEL) {$cd_sem->up()}
I would write
my $err = run_command("cd $orig_dir/$ROOT/repos/$git_repo && git checkout --track -b $branch origin/$branch");
which is four lines shorter, doesn't use semaphores, and doesn't have to handle semaphores and "cd'ing back" in error clean-up code.
I've omitted the error clean-up code in the above; indeed in the example i'm looking at, this cleanup code neither releases the semaphore nor cds back into the original directory.
Using cd this way may also avoid all problems where thorns are accidentally checked out into the wrong directory.