134 from optparse
import OptionParser
135 parser = OptionParser(description =
"Produce a patch file from a CMT project. "
136 "The patch contains the changes with respect "
137 "to the CVS repository, including new files "
138 "that are present only locally. Run the script "
139 "from the cmt directory of a package." )
140 parser.add_option(
"-x",
"--exclude", action=
"append", type=
"string",
141 metavar=
"PATTERN", dest=
"exclusions",
142 help=
"Pattern to exclude new files from the patch")
143 parser.add_option(
"-o",
"--output", action=
"store", type=
"string",
144 help=
"Name of the file to send the output to. Standard "
145 "output is used if not specified")
146 parser.add_option(
"-v",
"--verbose", action=
"store_true",
147 help=
"Print some progress information on standard error")
148 parser.add_option(
"--debug", action=
"store_true",
149 help=
"Print debug information on standard error")
150 parser.set_defaults(exclusions = [])
152 opts, args = parser.parse_args()
155 logging.basicConfig(level = logging.DEBUG)
157 logging.basicConfig(level = logging.INFO)
160 opts.exclusions += [
"*.py[co]",
169 "cmt/install*.history",
178 "i686-slc[34567]-[ig]cc*",
179 "i686-slc[34567]-clang*",
180 "x86_64-slc[34567]-[ig]cc*",
181 "x86_64-slc[34567]-clang*",
184 if "CMTCONFIG" in os.environ:
185 opts.exclusions.append(os.environ[
"CMTCONFIG"])
188 if not (os.path.basename(os.getcwd()) ==
"cmt" and os.path.exists(
"requirements")):
189 logging.error(
"This script must be executed from the cmt directory of a package.")
197 for name, path
in pkgs:
199 logging.info(
"Processing %s from %s (%d/%d)",
200 name, os.path.dirname(path), count, num_pkgs)
201 patch +=
diff_pkg(name, path, opts.exclusions)
203 if sys.platform.startswith(
"win"):
205 patch = patch.replace(
"\r",
"")
208 logging.info(
"Writing patch file %r", opts.output)
209 open(opts.output,
"w").write(patch)
211 sys.stdout.write(patch)