string = p.fromchild.readline().strip()
if p.wait():
raise GitException, '%s failed' % str(cmd)
string = p.fromchild.readline().strip()
if p.wait():
raise GitException, '%s failed' % str(cmd)
fs = tuple(line.rstrip().split(' ',4)[-1].split('\t',1))
if fs[1] not in conflicts:
cache_files.append(fs)
fs = tuple(line.rstrip().split(' ',4)[-1].split('\t',1))
if fs[1] not in conflicts:
cache_files.append(fs)
raise GitException, 'Unable to add file'
def rm(files, force = False):
raise GitException, 'Unable to add file'
def rm(files, force = False):
def update_cache(files = [], force = False):
"""Update the cache information for the given files
def update_cache(files = [], force = False):
"""Update the cache information for the given files
rm_files = [x[1] for x in cache_files if x[0] in ['D']]
m_files = [x[1] for x in cache_files if x[0] in ['M']]
rm_files = [x[1] for x in cache_files if x[0] in ['D']]
m_files = [x[1] for x in cache_files if x[0] in ['M']]
- if add_files and __run('git-update-cache --add --', add_files) != 0:
- raise GitException, 'Failed git-update-cache --add'
- if rm_files and __run('git-update-cache --force-remove --', rm_files) != 0:
- raise GitException, 'Failed git-update-cache --rm'
- if m_files and __run('git-update-cache --', m_files) != 0:
- raise GitException, 'Failed git-update-cache'
+ if add_files and __run('git-update-index --add --', add_files) != 0:
+ raise GitException, 'Failed git-update-index --add'
+ if rm_files and __run('git-update-index --force-remove --', rm_files) != 0:
+ raise GitException, 'Failed git-update-index --rm'
+ if m_files and __run('git-update-index --', m_files) != 0:
+ raise GitException, 'Failed git-update-index'
return True
def commit(message, files = [], parents = [], allowempty = False,
return True
def commit(message, files = [], parents = [], allowempty = False,
author_name = None, author_email = None, author_date = None,
committer_name = None, committer_email = None):
"""Commit the current tree to repository
author_name = None, author_email = None, author_date = None,
committer_name = None, committer_email = None):
"""Commit the current tree to repository
raise GitException, 'git-read-tree failed (local changes maybe?)'
# this can fail if there are conflicts
raise GitException, 'git-read-tree failed (local changes maybe?)'
# this can fail if there are conflicts
raise GitException, 'git-merge-cache failed (possible conflicts)'
def status(files = [], modified = False, new = False, deleted = False,
raise GitException, 'git-merge-cache failed (possible conflicts)'
def status(files = [], modified = False, new = False, deleted = False,
def diff(files = [], rev1 = 'HEAD', rev2 = None, out_fd = None):
"""Show the diff between rev1 and rev2
"""
def diff(files = [], rev1 = 'HEAD', rev2 = None, out_fd = None):
"""Show the diff between rev1 and rev2
"""
if rev2:
diff_str = _output(['git-diff-tree', '-p', rev1, rev2] + files)
else:
if rev2:
diff_str = _output(['git-diff-tree', '-p', rev1, rev2] + files)
else:
- diff_str = _output(['git-diff-cache', '-p', rev1] + files)
+ os.system('git-update-index --refresh > /dev/null')
+ diff_str = _output(['git-diff-index', '-p', rev1] + files)
p=popen2.Popen3('git-apply --stat')
diff(files, rev1, rev2, p.tochild)
p.tochild.close()
p=popen2.Popen3('git-apply --stat')
diff(files, rev1, rev2, p.tochild)
p.tochild.close()
+def barefiles(rev1, rev2):
+ """Return the files modified between rev1 and rev2, without status info
+ """
+
+ str = ''
+ for line in _output_lines('git-diff-tree -r %s %s' % (rev1, rev2)):
+ str += '%s\n' % line.rstrip().split(' ',4)[-1].split('\t',1)[-1]
+
+ return str.rstrip()
+
def checkout(files = [], tree_id = None, force = False):
"""Check out the given or all files
"""
if tree_id and __run('git-read-tree -m', [tree_id]) != 0:
raise GitException, 'Failed git-read-tree -m %s' % tree_id
def checkout(files = [], tree_id = None, force = False):
"""Check out the given or all files
"""
if tree_id and __run('git-read-tree -m', [tree_id]) != 0:
raise GitException, 'Failed git-read-tree -m %s' % tree_id
"""Apply a patch onto the current index. There must not be any
local changes in the tree, otherwise the command fails
"""
"""Apply a patch onto the current index. There must not be any
local changes in the tree, otherwise the command fails
"""