]> git.rkrishnan.org Git - tahoe-lafs/tahoe-lafs.git/blob - darcsver-1.6.3.egg/scripts/darcsverscript.py
setup: David-Sarah's new gen-package-table.py plus my patch to put the newer versions...
[tahoe-lafs/tahoe-lafs.git] / darcsver-1.6.3.egg / scripts / darcsverscript.py
1 #! /usr/bin/env python
2
3 from optparse import OptionParser
4 import os, sys
5
6 from darcsver import darcsvermodule, __version__
7
8 try:
9     EXE_NAME=os.path.basename(sys.argv[0])
10 except:
11     EXE_NAME="darcsver"
12
13 def main():
14     parser = OptionParser(usage="Usage: %prog [options] [pkgname [verfilename]]",
15                           version="%prog " + str(__version__),
16                           prog=EXE_NAME)
17     parser.add_option("-q", "--quiet", default=False, action="store_true",
18                       help="Be quiet, do the job without any output.")
19     parser.add_option("--count-all-patches", "--revision-number", default=False,
20                       action="store_true", dest="count_all_patches",
21                       help="By default %s counts the number of patches since the "
22                            "most recent release tag. With this option, it counts "
23                            "all the patches in the repository." % EXE_NAME)
24
25     options, args = parser.parse_args()
26
27     if args:
28         pkgname = args.pop(0)
29     else:
30         pkgname = os.path.basename(os.getcwd())
31         if not options.quiet:
32             print "%s: You didn't pass a pkg-name on the command-line, so I'm going to take the name of the current working directory: \"%s\"" % (EXE_NAME, pkgname,)
33
34     if args:
35         verfilename = args.pop(0)
36     else:
37         verfilename = os.path.join(pkgname, "_version.py")
38         if not options.quiet:
39             print "%s: You didn't pass a verfilename on the command-line, so I'm going to build one from the name of the package: \"%s\"" % (EXE_NAME, verfilename,)
40
41     (rc, newverstr) = darcsvermodule.update(pkgname=pkgname, verfilename=verfilename, revision_number=options.count_all_patches, quiet=options.quiet, EXE_NAME=EXE_NAME)
42     return rc
43
44 if __name__ == "__main__":
45     rc = main()
46     sys.exit(rc)