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

add.py 782B

1234567891011121314151617181920212223242526272829303132333435
  1. import subprocess
  2. from utilities import isGit, isMercurial, isBazaar
  3. def add(arguments):
  4. '''
  5. Add file(s) to the pending changes.
  6. '''
  7. if isGit():
  8. # If no additional arguments were passed assume
  9. # we want to add all pending changes.
  10. if len(arguments) == 0:
  11. arguments.append(".")
  12. command = ["git", "add"]
  13. command.extend(arguments)
  14. executeCommand(command)
  15. if isMercurial():
  16. command = ["hg", "add"]
  17. command.extend(arguments)
  18. executeCommand(command)
  19. if isBazaar():
  20. command = ["bzr", "add"]
  21. command.extend(arguments)
  22. executeCommand(command)
  23. def executeCommand(command):
  24. '''
  25. Execute the given command.
  26. '''
  27. subprocess.call(command)