X-Git-Url: https://git.distorted.org.uk/~mdw/stgit/blobdiff_plain/64354a2d7d5f11f2592f72b74b48d750cf00c6f7..6ef533bcc52fbf933e9f428d8ea2bf690f0ad76a:/stgit/git.py diff --git a/stgit/git.py b/stgit/git.py index 025d15d..5f3f030 100644 --- a/stgit/git.py +++ b/stgit/git.py @@ -22,6 +22,7 @@ import sys, os, popen2, re, gitmergeonefile from stgit import basedir from stgit.utils import * +from stgit.config import config # git exception class class GitException(Exception): @@ -78,6 +79,9 @@ class Commit: def get_log(self): return self.__log + def __str__(self): + return self.get_id_hash() + # dictionary of Commit objects, used to avoid multiple calls to git __commits = dict() @@ -691,22 +695,24 @@ def pull(repository = 'origin', refspec = None): if refspec: args.append(refspec) - if __run('git-pull', args) != 0: + if __run(config.get('stgit', 'pullcmd'), args) != 0: raise GitException, 'Failed "git-pull %s"' % repository -def apply_patch(filename = None, base = None): +def apply_patch(filename = None, diff = None, base = None): """Apply a patch onto the current or given index. There must not be any local changes in the tree, otherwise the command fails """ def __apply_patch(): - if filename: - return __run('git-apply --index', [filename]) == 0 - else: - try: + try: + if filename: + return __run('git-apply --index', [filename]) == 0 + elif diff: + _input_str('git-apply --index', diff) + else: _input('git-apply --index', sys.stdin) - except GitException: - return False - return True + except GitException: + return False + return True if base: orig_head = get_head()