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> 2010-01-22 Gökçen Eraslan <gokcen@pardus.org.tr>
* pisi/actionsapi/perlmodules.py: Do not ignore parameter in make * pisi/actionsapi/perlmodules.py: Do not ignore parameter in make
method (eg. perl Build test). Tests of some perl modules have never run method (eg. perl Build test). Tests of some perl modules have never run
......
...@@ -63,6 +63,7 @@ ...@@ -63,6 +63,7 @@
<!ATTLIST Patch compressionType CDATA #IMPLIED> <!ATTLIST Patch compressionType CDATA #IMPLIED>
<!ATTLIST Patch level CDATA #IMPLIED> <!ATTLIST Patch level CDATA #IMPLIED>
<!ATTLIST Patch target CDATA #IMPLIED> <!ATTLIST Patch target CDATA #IMPLIED>
<!ATTLIST Patch reverse CDATA #IMPLIED>
<!-- Package Section --> <!-- Package Section -->
......
...@@ -1372,6 +1372,9 @@ ...@@ -1372,6 +1372,9 @@
<optional> <optional>
<attribute name="target"/> <attribute name="target"/>
</optional> </optional>
<optional>
<attribute name="reverse"/>
</optional>
</group> </group>
</define> </define>
......
...@@ -613,6 +613,7 @@ class Builder: ...@@ -613,6 +613,7 @@ class Builder:
for patch in self.spec.source.patches: for patch in self.spec.source.patches:
patchFile = pisi.util.join_path(files_dir, patch.filename) patchFile = pisi.util.join_path(files_dir, patch.filename)
relativePath = patch.filename relativePath = patch.filename
reverseApply = patch.reverse.lower() == "true"
if patch.compressionType: if patch.compressionType:
patchFile = pisi.util.uncompress(patchFile, patchFile = pisi.util.uncompress(patchFile,
compressType=patch.compressionType, compressType=patch.compressionType,
...@@ -620,7 +621,7 @@ class Builder: ...@@ -620,7 +621,7 @@ class Builder:
relativePath = relativePath.rsplit(".%s" % patch.compressionType, 1)[0] relativePath = relativePath.rsplit(".%s" % patch.compressionType, 1)[0]
ctx.ui.action(_("* Applying patch: %s") % patch.filename) 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 return True
def generate_static_package_object(self): def generate_static_package_object(self):
......
...@@ -83,6 +83,7 @@ class Patch: ...@@ -83,6 +83,7 @@ class Patch:
s_Filename = [autoxml.String, autoxml.mandatory] s_Filename = [autoxml.String, autoxml.mandatory]
a_compressionType = [autoxml.String, autoxml.optional] a_compressionType = [autoxml.String, autoxml.optional]
a_level = [autoxml.Integer, 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? #FIXME: what's the cleanest way to give a default value for reading level?
#def decode_hook(self, node, errs, where): #def decode_hook(self, node, errs, where):
......
...@@ -463,7 +463,7 @@ def uncompress(patchFile, compressType="gz", targetDir=None): ...@@ -463,7 +463,7 @@ def uncompress(patchFile, compressType="gz", targetDir=None):
return filePath 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.""" """Apply given patch to the sourceDir."""
cwd = os.getcwd() cwd = os.getcwd()
if os.path.exists(sourceDir): if os.path.exists(sourceDir):
...@@ -485,12 +485,12 @@ def do_patch(sourceDir, patchFile, level=0, name=None): ...@@ -485,12 +485,12 @@ def do_patch(sourceDir, patchFile, level=0, name=None):
if not os.path.exists(patchesDir): if not os.path.exists(patchesDir):
os.makedirs(patchesDir) os.makedirs(patchesDir)
# Import original patch into quilt tree # 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 # run quilt push to apply original patch into tree
(ret, out, err) = run_batch('quilt push') (ret, out, err) = run_batch('quilt push')
else: else:
# run GNU patch to apply original patch into tree # 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 ret:
if out is None and err is None: 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