git-cvsimport-3: extract subprocess error handling

By changing subprocess.call into subprocess.check_call all invocations
of subprocesses will throw a CalledProcessError if the child fails.
This means that we can use common handling for subprocess errors and
extract this to the top-level of the script.

Signed-off-by: John Keeping <john@keeping.me.uk>
git-cvsimport-3: don't execute subcommands with the shell

Creating command strings to execute subcommands via the shell means that
care needs to be taken to quote any user-supplied values, but Python
provides a better way by passing a list of arguments when creating
subprocesses.

Make this change, changing pipelines that currently use the shell to use
pipelined subprocesses.

Signed-off-by: John Keeping <john@keeping.me.uk>
git-cvsimport-3: actually invoke git-branch

The command called if a branch is renamed is "branch -m".  This should
clearly by "git branch -m".

Signed-off-by: John Keeping <john@keeping.me.uk>
git-cvsimport-3: fix moving tags

The command "git tag -f $tag $changed" moves $tag to point at commit
$changed but $changed is the new name for the tag.  Fix this by
reordering the arguments to "git tag".

Also add a call to "git update-ref -d" to remove the old tag.

Signed-off-by: John Keeping <john@keeping.me.uk>
git-cvsimport-3: use for-each-ref not "branch -l"

git-branch is a porcelain command, switch to the plumbing command
git-for-each-ref so that we're not relying on the output format of
git-branch.

Signed-off-by: John Keeping <john@keeping.me.uk>
git-cvsimport-3: use for-each-ref not "tag -l"

git-tag is a porcelain command, switch to the plumbing command
git-for-each-ref so that we're not relying on the output format of
git-tag.

Signed-off-by: John Keeping <john@keeping.me.uk>
git-cvsimport-3: use git-update-ref to modify refs

Instead of the porcelain command "git-tag" use "git-update-ref" when
tags need to be renamed.

Signed-off-by: John Keeping <john@keeping.me.uk>

---
Is there a way to get the reflog moving from "git branch --move" using
porcelain commands?
git-cvsimport-3: checkout the new tree correctly

Once the import has finished, the branch pointed at by HEAD may have
moved.  "git checkout -q" isn't sufficient to change the working tree -
use "git checkout -f" as git-cvsimport-2.perl does.

Signed-off-by: John Keeping <john@keeping.me.uk>
---
Should we be asserting that the working tree is not dirty before
starting the import, in the same way the git-rebase does?
git-cvsimport-3: don't allow more than one module

Raise an error if more than one module is specified on the command line.

Signed-off-by: John Keeping <john@keeping.me.uk>
git-cvsimport-3: read configuration from git config

git-cvsimport-2 supports reading options from the Git repository into
which it was importing.  Make git-cvsimport-3 do the same.

Signed-off-by: John Keeping <john@keeping.me.uk>
git-cvsimport-3: overwrite CVS revision map

The current version of cvsps-3 appears to write the entire revision map
rather than just the delta since the previous run.  To handle this
correctly, open the git-cvsimport revision map file as "w" instead of
"a".