Kaydet (Commit) efb97cc3 authored tarafından Ozan Çağlayan's avatar Ozan Çağlayan

Add support for reverse applying a patch with <Patch reverse="[tT]rue">..

üst 2eb89439
2010-01-23 Ozan Çağlayan <ozan@pardus.org.tr>
* Add support for optional reverse="[tT]rue" in <Patch> for reverse applying
a patch.
2010-01-22 Gökçen Eraslan <gokcen@pardus.org.tr>
* pisi/actionsapi/perlmodules.py: Do not ignore parameter in make
method (eg. perl Build test). Tests of some perl modules have never run
......@@ -63,6 +63,7 @@
<!ATTLIST Patch compressionType CDATA #IMPLIED>
<!-- Package Section -->
......@@ -1372,6 +1372,9 @@
<attribute name="target"/>
<attribute name="reverse"/>
......@@ -613,6 +613,7 @@ class Builder:
for patch in self.spec.source.patches:
patchFile = pisi.util.join_path(files_dir, patch.filename)
relativePath = patch.filename
reverseApply = patch.reverse.lower() == "true"
if patch.compressionType:
patchFile = pisi.util.uncompress(patchFile,
......@@ -620,7 +621,7 @@ class Builder:
relativePath = relativePath.rsplit(".%s" % patch.compressionType, 1)[0]
ctx.ui.action(_("* Applying patch: %s") % patch.filename)
pisi.util.do_patch(self.srcDir, patchFile, level=patch.level, name=relativePath)
pisi.util.do_patch(self.srcDir, patchFile, level=patch.level, name=relativePath, reverse=reverseApply)
return True
def generate_static_package_object(self):
......@@ -83,6 +83,7 @@ class Patch:
s_Filename = [autoxml.String, autoxml.mandatory]
a_compressionType = [autoxml.String, autoxml.optional]
a_level = [autoxml.Integer, autoxml.optional]
a_reverse = [autoxml.String, autoxml.optional]
#FIXME: what's the cleanest way to give a default value for reading level?
#def decode_hook(self, node, errs, where):
......@@ -463,7 +463,7 @@ def uncompress(patchFile, compressType="gz", targetDir=None):
return filePath
def do_patch(sourceDir, patchFile, level=0, name=None):
def do_patch(sourceDir, patchFile, level=0, name=None, reverse=False):
"""Apply given patch to the sourceDir."""
cwd = os.getcwd()
if os.path.exists(sourceDir):
......@@ -485,12 +485,12 @@ def do_patch(sourceDir, patchFile, level=0, name=None):
if not os.path.exists(patchesDir):
# Import original patch into quilt tree
(ret, out, err) = run_batch('quilt import -p %d -P %s \"%s\"' % (level, name, patchFile))
(ret, out, err) = run_batch('quilt import %s -p %d -P %s \"%s\"' % (("-R" if reverse else ""), level, name, patchFile))
# run quilt push to apply original patch into tree
(ret, out, err) = run_batch('quilt push')
# run GNU patch to apply original patch into tree
(ret, out, err) = run_batch("patch --remove-empty-files --no-backup-if-mismatch -p%d < \"%s\"" % (level, patchFile))
(ret, out, err) = run_batch("patch --remove-empty-files --no-backup-if-mismatch %s -p%d < \"%s\"" % (("-R" if reverse else ""), level, patchFile))
if ret:
if out is None and err is None:
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment