views:

68

answers:

0

Hi there. I'm using maven-scm-plugin from within a Mojo and am trying to figure out how to determine if a directory D is a valid working directory of an SCM URL U (i.e. a checkout of U to D already happened).

The context is that I want to do a checkout of U if D is a working set or do an update if it isn't.

The plan is to

  • check out U to D if D does not exist,
  • update D if D is a valid working directory of U,
  • display an error if D exists and is not a valid working directory of U.

What I tried is to call ScmManager.status(), ScmManager.list() and ScmManager.changelog() and try to guess something from their results. But that didn't work.

The results from status and changelog always return something positive (isSuccess() = true, getChangedFiles() = valid List, no exceptions to catch), whereas list throws an exception in any case.

ScmRepository and ScmFileSet don't seem to provide suitable methods as well.

An option would be to always do an update if D exists but then I cannot tell if it is a working directory of U or any SCM working directory at all.

The ideal solution would be independent of the actual SCM system and a specific ScmVersion.

Thanks for your help!

Patrick