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