lastchange: add a flag to only print the svn revision number

This allows me to change one of the callers to not parse the
"REVISION=1234" output, which will allow me to change that output
in a future change.

BUG=41264

Review URL: http://codereview.chromium.org/6265021

git-svn-id: http://src.chromium.org/svn/trunk/src/build@72170 4ff67af0-8c30-449e-8e8b-ad334ec8d88c
This commit is contained in:
evan@chromium.org 2011-01-21 19:19:21 +00:00
Родитель c05507a57e
Коммит c9f4c5403d
1 изменённых файлов: 10 добавлений и 6 удалений

Просмотреть файл

@ -71,11 +71,13 @@ def main(argv=None):
if argv is None:
argv = sys.argv
parser = optparse.OptionParser(usage="lastchange.py [-h] [[-o] FILE]")
parser = optparse.OptionParser(usage="lastchange.py [options]")
parser.add_option("-d", "--default-lastchange", metavar="FILE",
help="default last change input FILE")
parser.add_option("-o", "--output", metavar="FILE",
help="write last change to FILE")
parser.add_option("--revision-only", action='store_true',
help="just print the SVN revision number")
opts, args = parser.parse_args(argv[1:])
out_file = opts.output
@ -90,12 +92,14 @@ def main(argv=None):
change = FetchChange(opts.default_lastchange)
contents = "LASTCHANGE=%s\n" % change
if out_file:
WriteIfChanged(out_file, contents)
if opts.revision_only:
print change
else:
sys.stdout.write(contents)
contents = "LASTCHANGE=%s\n" % change
if out_file:
WriteIfChanged(out_file, contents)
else:
sys.stdout.write(contents)
return 0