debcheckout: some new bits

Some new bits about debcheckout (talk is cheap, code here):

  • authenticated mode. Consider svn (similar arguments stand for other VCS). When checking out alioth repositories using the svn:// prefix, the resulting local copy can't be committed to, since it would require (assuming you have an alioth account and the needed permissions) a svn+ssh:// access. "authenticated mode" is precisely for that: when checking out well-known repositories (only alioth's ATM) you can specify an extra "-a" argument, with an optional "-u" to specify your user name, and debcheckout will rewrite the repository URL so that the resulting local copy can be committed to. ATM authenticated mode works for svn, hg, bzr, git.

  • destination dir. It is now possible to specify where do you want to check out a package repository (so that we avoid ending up with tons of anonymous "trunk" directories). The syntax is the common "debcheckout PKG DESTDIR" idiom and DESTDIR, if not provided, defaults to the package name. (Thanks to JoeyH for the idea and the initial patch.)

  • sorry about arch, but ATM it's almost non-functioning, and I'm not willing to lose time on it, since among all the VCSs supported by debcheckout it's the only one I've never used. If you want support for it, please provide code!

(Perl) Tip of the day: Switch.pm

With "use Switch;" you will win a switch statement for your Perl programs, which can be used as follows:

switch ($repo_type) {
  case "cvs"  { my $module = pop @cmd; push @cmd, ("-d", $destdir, $module); }
  case /^(bzr|darcs|git|hg|svn)$/
              { push @cmd, $destdir; }
  else { die "sorry, don't know how to set the destination directory for $repo_type repositories (patches welcome!)\n"; }
}

This is far better than a chain of if/elsif statements and has even a sane semantics (e.g. no need of explicit breaks, possibility to have higher-case branches, ...). Unfortunately, it is not possible (using a simple syntax) to match a scalar value against an array case branch. Therefore the only way to factorize branches is (when possible) to rely on regexp alternative branches, as it is done in the code snippet above.