Version control system wrapper allowing the developer to worry about only having to learn one command set to manage all types of repositories.

utilities.py 604B

123456789101112131415161718192021222324252627
  1. import os
  2. import subprocess
  3. def isGit():
  4. '''
  5. Determine if the current directory is part of a Git repository.
  6. '''
  7. return testRepository(["git", "branch"])
  8. def isMercurial():
  9. '''
  10. Determine if the current directory is part of a Mercurial repository.
  11. '''
  12. return testRepository(["hg", "branch"])
  13. def isBazaar():
  14. '''
  15. Determine if the current directory is part of the Bazaar repository.
  16. '''
  17. return testRepository(["bzr", "root"])
  18. def testRepository(command):
  19. return subprocess.call(command, stderr=subprocess.STDOUT, stdout=open(os.devnull, 'w')) == 0