156     from optparse 
import OptionParser
 
  158     parser = OptionParser(
 
  159         description=
"Produce a patch file from a CMT project. " 
  160         "The patch contains the changes with respect " 
  161         "to the CVS repository, including new files " 
  162         "that are present only locally. Run the script " 
  163         "from the cmt directory of a package." 
  172         help=
"Pattern to exclude new files from the patch",
 
  179         help=
"Name of the file to send the output to. Standard " 
  180         "output is used if not specified",
 
  186         help=
"Print some progress information on standard error",
 
  189         "--debug", action=
"store_true", help=
"Print debug information on standard error" 
  191     parser.set_defaults(exclusions=[])
 
  193     opts, args = parser.parse_args()
 
  196         logging.basicConfig(level=logging.DEBUG)
 
  198         logging.basicConfig(level=logging.INFO)
 
  211         "cmt/install*.history",
 
  220         "i686-slc[34567]-[ig]cc*",
 
  221         "i686-slc[34567]-clang*",
 
  222         "x86_64-slc[34567]-[ig]cc*",
 
  223         "x86_64-slc[34567]-clang*",
 
  226     if "CMTCONFIG" in os.environ:
 
  227         opts.exclusions.append(os.environ[
"CMTCONFIG"])
 
  230     if not (os.path.basename(os.getcwd()) == 
"cmt" and os.path.exists(
"requirements")):
 
  232             "This script must be executed from the cmt directory of a package." 
  241     for name, path 
in pkgs:
 
  244             "Processing %s from %s (%d/%d)",
 
  246             os.path.dirname(path),
 
  250         patch += 
diff_pkg(name, path, opts.exclusions)
 
  252     if sys.platform.startswith(
"win"):
 
  254         patch = patch.replace(
"\r", 
"")
 
  257         logging.info(
"Writing patch file %r", opts.output)
 
  258         open(opts.output, 
"w").write(patch)
 
  260         sys.stdout.write(patch)