146 from optparse
import OptionParser
147 parser = OptionParser(description=
"Produce a patch file from a CMT project. " 148 "The patch contains the changes with respect " 149 "to the CVS repository, including new files " 150 "that are present only locally. Run the script " 151 "from the cmt directory of a package.")
152 parser.add_option(
"-x",
"--exclude", action=
"append", type=
"string",
153 metavar=
"PATTERN", dest=
"exclusions",
154 help=
"Pattern to exclude new files from the patch")
155 parser.add_option(
"-o",
"--output", action=
"store", type=
"string",
156 help=
"Name of the file to send the output to. Standard " 157 "output is used if not specified")
158 parser.add_option(
"-v",
"--verbose", action=
"store_true",
159 help=
"Print some progress information on standard error")
160 parser.add_option(
"--debug", action=
"store_true",
161 help=
"Print debug information on standard error")
162 parser.set_defaults(exclusions=[])
164 opts, args = parser.parse_args()
167 logging.basicConfig(level=logging.DEBUG)
169 logging.basicConfig(level=logging.INFO)
172 opts.exclusions += [
"*.py[co]",
181 "cmt/install*.history",
190 "i686-slc[34567]-[ig]cc*",
191 "i686-slc[34567]-clang*",
192 "x86_64-slc[34567]-[ig]cc*",
193 "x86_64-slc[34567]-clang*",
196 if "CMTCONFIG" in os.environ:
197 opts.exclusions.append(os.environ[
"CMTCONFIG"])
200 if not (os.path.basename(os.getcwd()) ==
"cmt" and os.path.exists(
"requirements")):
202 "This script must be executed from the cmt directory of a package.")
210 for name, path
in pkgs:
212 logging.info(
"Processing %s from %s (%d/%d)",
213 name, os.path.dirname(path), count, num_pkgs)
214 patch +=
diff_pkg(name, path, opts.exclusions)
216 if sys.platform.startswith(
"win"):
218 patch = patch.replace(
"\r",
"")
221 logging.info(
"Writing patch file %r", opts.output)
222 open(opts.output,
"w").
write(patch)
224 sys.stdout.write(patch)
def diff_pkg(name, cmtdir, exclusions=[])