from stgit.out import *
from stgit.run import *
from stgit.config import config
-from sets import Set
# git exception class
class GitException(Exception):
# unknown files
if unknown:
- cmd = ['git-ls-files', '-z', '--others', '--directory']
+ cmd = ['git-ls-files', '-z', '--others', '--directory',
+ '--no-empty-directory']
if not noexclude:
cmd += ['--exclude=%s' % s for s in
['*.[ao]', '*.pyc', '.*', '*~', '#*', 'TAGS', 'tags']]
if os.path.exists(fn)]
lines = GRun(*cmd).raw_output().split('\0')
- cache_files += [('?', line) for line in lines]
+ cache_files += [('?', line) for line in lines if line]
# conflicted files
conflicts = get_conflicts()
diff_str = diff(files, rev1, rev2)
if diff_str:
try:
- GRun('git-apply', *index_opt).raw_input(diff_str).no_output()
+ GRun('git-apply', *index_opt).raw_input(
+ diff_str).discard_stderr().no_output()
except GitRunException:
return False
else:
return ''
+# TODO: take another parameter representing a diff string as we
+# usually invoke git.diff() form the calling functions
def diffstat(files = None, rev1 = 'HEAD', rev2 = None):
"""Return the diffstat between rev1 and rev2."""
- return GRun('git-apply', '--stat'
+ return GRun('git-apply', '--stat', '--summary'
).raw_input(diff(files, rev1, rev2)).raw_output()
def files(rev1, rev2, diff_flags = []):
if os.path.exists(d):
return os.listdir(d)
else:
- return None
+ return []
def remotes_list():
"""Return the list of remotes in the repository
"""
-
- return Set(__remotes_from_config()) | \
- Set(__remotes_from_dir('remotes')) | \
- Set(__remotes_from_dir('branches'))
+ return (set(__remotes_from_config())
+ | set(__remotes_from_dir('remotes'))
+ | set(__remotes_from_dir('branches')))
def remotes_local_branches(remote):
"""Returns the list of local branches fetched from given remote