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

incoming.py 1.1KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. import os
  2. import subprocess
  3. from utilities import isGit, isMercurial, isBazaar
  4. def incoming(arguments):
  5. '''
  6. Shows incoming commits.
  7. '''
  8. if isGit():
  9. out, err = executeCommandWithResponse(["git", "remote"])
  10. if not err and out:
  11. executeCommandWithResponse(["git", "remote", "update", "-p"])
  12. executeCommand(["git", "log", "..@{u}"])
  13. if isMercurial():
  14. out, err = executeCommandWithResponse(["git", "paths"])
  15. if not err and out:
  16. executeCommand(["hg", "incoming"])
  17. if isBazaar():
  18. out, err = executeCommandWithResponse(["bzr", "missing"])
  19. if not err and out:
  20. executeCommand(["bzr", "missing"])
  21. def executeCommand(command):
  22. '''
  23. Execute the given command.
  24. '''
  25. subprocess.call(command, stderr=subprocess.STDOUT)
  26. def executeCommandWithResponse(command):
  27. '''
  28. Execute the given command and return the output and errors.
  29. '''
  30. proc = subprocess.Popen(command, stderr=open(os.devnull, 'w'), stdout=subprocess.PIPE)
  31. return proc.communicate()