Generalize the patch application procedure

Current depth for the patch command (-p3) is tied to historical
format of patches to Puppet manifests which used to be based from
/etc/puppet/modules directory.

Change the depth to -p1 generalize patching approach for other
paths in the host file system.

Change-Id: I8538af2192aa29987404fbe130934122997a2625
This commit is contained in:
Oleg Gelbukh 2016-04-11 10:34:03 +00:00
parent 4aabc73400
commit a4ed2778ab
2 changed files with 4 additions and 4 deletions

View File

@ -36,9 +36,9 @@ class MockFile(mock.MagicMock):
def assert_calls(self):
kwargs = {'stdin': self, 'cwd': magic_consts.PUPPET_DIR}
args = [((["patch", "-R", "-p3"], ), kwargs), ]
args = [((["patch", "-R", "-p1"], ), kwargs), ]
if not self.revert:
args.append(((["patch", "-N", "-p3"], ), kwargs))
args.append(((["patch", "-N", "-p1"], ), kwargs))
assert args == self.call_args

View File

@ -17,7 +17,7 @@ def patch_apply(cwd, patches, revert=False):
for path in patches:
with open(path, 'rb') as patch:
try:
subprocess.call(["patch", "-R", "-p3"], stdin=patch, cwd=cwd)
subprocess.call(["patch", "-R", "-p1"], stdin=patch, cwd=cwd)
except subprocess.CalledProcessError:
if not revert:
pass
@ -25,4 +25,4 @@ def patch_apply(cwd, patches, revert=False):
raise
if not revert:
patch.seek(0)
subprocess.call(["patch", "-N", "-p3"], stdin=patch, cwd=cwd)
subprocess.call(["patch", "-N", "-p1"], stdin=patch, cwd=cwd)