117 Return the patch data for a package.
119 rootdir = os.path.dirname(cmtdir)
122 new_files = [l.split(
None, 1)[1]
for l
in out.splitlines()
if l.startswith(
"? ")]
124 new_files = [f
for f
in new_files
if not matches(f, exclusions)]
127 logging.info(
"Added file %r", f)
131 out +=
"Index: %s\n" % f
132 out +=
"===================================================================\n"
133 out +=
command(
"diff",
"-upN",
"/dev/null", f, cwd=rootdir)[0]
135 removed_files = [l.split()[-1]
for l
in err.splitlines()
if "cannot find" in l]
136 removed_files = [f
for f
in removed_files
if not matches(f, exclusions)]
138 for f
in removed_files:
139 logging.info(
"Removed file %r", f)
141 orig =
cvs(
"up",
"-p", f, cwd=rootdir)[0]
142 out +=
"diff -u -p -N %s\n" % os.path.basename(f)
143 out +=
"--- %s\t1 Jan 1970 00:00:00 -0000\n" % f
144 out +=
"+++ /dev/null\t1 Jan 1970 00:00:00 -0000\n"
145 lines = orig.splitlines()
146 out +=
"@@ -1,%d +0,0 @@\n" % len(lines)
150 rex = re.compile(
r"^(Index: |\? |\+\+\+ |--- (?!/dev/null))", re.MULTILINE)
151 out = rex.sub(
r"\1%s/" % name, out)
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)