summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
f0b5d4d)
With this patch, when running 'stg patches' without any arguments, it
uses the locally modified files by default. This way one can see which
patches are affected by the locally modified files.
Signed-off-by: Catalin Marinas <catalin.marinas@gmail.com>
help = 'show the applied patches modifying a file'
help = 'show the applied patches modifying a file'
-usage = """%prog [options] <file> [<file>...]
+usage = """%prog [options] [<files...>]
-Show the applied patches modifying the given files. The '--diff'
-option also lists the patch log and the diff for the given files."""
+Show the applied patches modifying the given files. Without arguments,
+it shows the patches affected by the local tree modifications. The
+'--diff' option also lists the patch log and the diff for the given
+files."""
options = [make_option('-d', '--diff',
help = 'show the diff for the given files',
options = [make_option('-d', '--diff',
help = 'show the diff for the given files',
def func(parser, options, args):
"""Show the patches modifying a file
"""
def func(parser, options, args):
"""Show the patches modifying a file
"""
- if len(args) < 1:
- parser.error('incorrect number of arguments')
+ if not args:
+ files = [stat[1] for stat in git.tree_status(verbose = True)]
+ else:
+ files = args
+
+ if not files:
+ raise CmdException, 'No files specified or no local changes'
applied = crt_series.get_applied()
if not applied:
raise CmdException, 'No patches applied'
applied = crt_series.get_applied()
if not applied:
raise CmdException, 'No patches applied'
- revs = git.modifying_revs(args, crt_series.get_base(),
+ revs = git.modifying_revs(files, crt_series.get_base(),
crt_series.get_head())
revs.reverse()
crt_series.get_head())
revs.reverse()
if options.diff:
diff_output += diff_tmpl \
% (patch.get_name(), patch.get_description(),
if options.diff:
diff_output += diff_tmpl \
% (patch.get_name(), patch.get_description(),
- git.diff(args, patch.get_bottom(),
+ git.diff(files, patch.get_bottom(),
patch.get_top()))
else:
out.stdout(patch.get_name())
patch.get_top()))
else:
out.stdout(patch.get_name())
-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]
"""
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
"""
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
# HEAD value cached
__head = None
- cache_files = __tree_status(files, verbose = False)
+ cache_files = tree_status(files, verbose = False)
# everything is up-to-date
if len(cache_files) == 0:
# everything is up-to-date
if len(cache_files) == 0:
- 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)
diff_flags = diff_flags)
all = not (modified or new or deleted or conflict or unknown)
tree_id = get_head()
if check_out:
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']]
# files which were added but need to be removed
rm_files = [x[1] for x in cache_files if x[0] in ['A']]