return r
return 0
-def __tree_status(files = None, tree_id = 'HEAD', unknown = False,
+def tree_status(files = None, tree_id = 'HEAD', unknown = False,
noexclude = True, verbose = False, diff_flags = []):
"""Returns a list of pairs - [status, filename]
"""
def local_changes(verbose = True):
"""Return true if there are local changes in the tree
"""
- return len(__tree_status(verbose = verbose)) != 0
+ return len(tree_status(verbose = verbose)) != 0
# HEAD value cached
__head = None
if not files:
files = []
- cache_files = __tree_status(files, verbose = False)
+ cache_files = tree_status(files, verbose = False)
# everything is up-to-date
if len(cache_files) == 0:
return True
def commit(message, files = None, parents = None, allowempty = False,
- cache_update = True, tree_id = None,
+ cache_update = True, tree_id = None, set_head = False,
author_name = None, author_email = None, author_date = None,
committer_name = None, committer_email = None):
"""Commit the current tree to repository
elif message[-1:] != '\n':
message += '\n'
- must_switch = True
# write the index to repository
if tree_id == None:
tree_id = _output_one_line(['git-write-tree'])
- else:
- must_switch = False
+ set_head = True
# the commit
cmd = ['env']
cmd += ['-p', p]
commit_id = _output_one_line(cmd, message)
- if must_switch:
+ if set_head:
__set_head(commit_id)
return commit_id
if not files:
files = []
- cache_files = __tree_status(files, unknown = True, noexclude = noexclude,
+ cache_files = tree_status(files, unknown = True, noexclude = noexclude,
diff_flags = diff_flags)
all = not (modified or new or deleted or conflict or unknown)
tree_id = get_head()
if check_out:
- cache_files = __tree_status(files, tree_id)
+ cache_files = tree_status(files, tree_id)
# files which were added but need to be removed
rm_files = [x[1] for x in cache_files if x[0] in ['A']]