Add support for reverse applying a patch with <Patch reverse="[tT]rue">..
This commit is contained in:
@@ -1,3 +1,7 @@
|
||||
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>
|
||||
<!ATTLIST Patch level CDATA #IMPLIED>
|
||||
<!ATTLIST Patch target CDATA #IMPLIED>
|
||||
<!ATTLIST Patch reverse CDATA #IMPLIED>
|
||||
|
||||
|
||||
<!-- Package Section -->
|
||||
|
||||
@@ -1372,6 +1372,9 @@
|
||||
<optional>
|
||||
<attribute name="target"/>
|
||||
</optional>
|
||||
<optional>
|
||||
<attribute name="reverse"/>
|
||||
</optional>
|
||||
</group>
|
||||
</define>
|
||||
|
||||
|
||||
@@ -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,
|
||||
compressType=patch.compressionType,
|
||||
@@ -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):
|
||||
|
||||
+3
-3
@@ -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):
|
||||
os.makedirs(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')
|
||||
else:
|
||||
# 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:
|
||||
|
||||
Reference in New Issue
Block a user