Patchwork [1,of,2] check-code: use "-" to specify a list of files from stdin

login
register
mail settings
Submitter Jun Wu
Date April 7, 2017, 5:13 a.m.
Message ID <9a84025f33b33ba68a7c.1491541981@x1c>
Download mbox | patch
Permalink /patch/19991/
State Accepted
Headers show

Comments

Jun Wu - April 7, 2017, 5:13 a.m.
# HG changeset patch
# User Jun Wu <quark@fb.com>
# Date 1491541703 25200
#      Thu Apr 06 22:08:23 2017 -0700
# Node ID 9a84025f33b33ba68a7c0bac763f9c756e1f81d0
# Parent  45761ef1bc935b1fab74adccf2541ef854b1c2eb
# Available At https://bitbucket.org/quark-zju/hg-draft
#              hg pull https://bitbucket.org/quark-zju/hg-draft -r 9a84025f33b3
check-code: use "-" to specify a list of files from stdin

This will be used by the next patch.

Patch

diff --git a/contrib/check-code.py b/contrib/check-code.py
--- a/contrib/check-code.py
+++ b/contrib/check-code.py
@@ -674,5 +674,5 @@  def checkfile(f, logfunc=_defaultlogger.
 
 def main():
-    parser = optparse.OptionParser("%prog [options] [files]")
+    parser = optparse.OptionParser("%prog [options] [files | -]")
     parser.add_option("-w", "--warnings", action="store_true",
                       help="include warning-level checks")
@@ -692,4 +692,7 @@  def main():
     if len(args) == 0:
         check = glob.glob("*")
+    elif args == ['-']:
+        # read file list from stdin
+        check = sys.stdin.read().splitlines()
     else:
         check = args