self._initRepo()
def _isInitialized(self, d):
- cmd = "git rev-parse --show-toplevel"
try:
- output = runcmd(cmd.split(), self.dir).strip()
- except CmdError as err:
+ output = runcmd(["git", "rev-parse", "--show-toplevel"], self.dir).strip()
+ except CmdError:
## runcmd returned non-zero which most likely means 128
## Not a git directory
return False
return os.path.samefile(output, self.dir) or oe.path.is_path_parent(d.getVar('WORKDIR'), output)
def _initRepo(self):
- runcmd("git init".split(), self.dir)
- runcmd("git add .".split(), self.dir)
- runcmd("git commit -a --allow-empty -m bitbake_patching_started".split(), self.dir)
+ runcmd(["git", "init"], self.dir)
+ runcmd(["git", "add", "."], self.dir)
+ runcmd(["git", "commit", "-a", "--allow-empty", "-m", "bitbake_patching_started"], self.dir)
@staticmethod
def extractPatchHeader(patchfile):
outlines, author, date, subject = GitApplyTree.interpretPatchHeader(lines)
if not author or not subject or not date:
try:
- shellcmd = ["git", "log", "--format=email", "--follow", "--diff-filter=A", "--", patchfile]
- out = runcmd(["sh", "-c", " ".join(shellcmd)], os.path.dirname(patchfile))
+ cmd = ["git", "log", "--format=email", "--follow", "--diff-filter=A", "--", patchfile]
+ out = runcmd(cmd, dir=os.path.dirname(patchfile))
except CmdError:
out = None
if out:
if paths:
shellcmd.append('--')
shellcmd.extend(paths)
- out = runcmd(["sh", "-c", " ".join(shellcmd)], os.path.join(tree, name))
+ out = runcmd(shellcmd, dir=os.path.join(tree, name))
if out:
for srcfile in out.split():
# This loop, which is used to remove any line that
def _commitpatch(self, patch, patchfilevar):
output = ""
# Add all files
- shellcmd = ["git", "add", "-f", "-A", "."]
- output += runcmd(["sh", "-c", " ".join(shellcmd)], self.dir)
+ output += runcmd(["git", "add", "-f", "-A", "."], self.dir)
# Exclude the patches directory
- shellcmd = ["git", "reset", "HEAD", self.patchdir]
- output += runcmd(["sh", "-c", " ".join(shellcmd)], self.dir)
+ output += runcmd(["git", "reset", "HEAD", self.patchdir], self.dir)
# Commit the result
(tmpfile, shellcmd) = self.prepareCommit(patch['file'], self.commituser, self.commitemail)
try:
return output
def _applypatch(self, patch, force = False, reverse = False, run = True):
- import shutil
-
def _applypatchhelper(shellcmd, patch, force = False, reverse = False, run = True):
if reverse:
shellcmd.append('-R')
except CmdError:
# Need to abort the git am, or we'll still be within it at the end
try:
- shellcmd = ["git", "--work-tree=%s" % reporoot, "am", "--abort"]
- runcmd(["sh", "-c", " ".join(shellcmd)], self.dir)
+ runcmd(["git", "--work-tree=%s" % reporoot, "am", "--abort"], self.dir)
except CmdError:
pass
# git am won't always clean up after itself, sadly, so...
- shellcmd = ["git", "--work-tree=%s" % reporoot, "reset", "--hard", "HEAD"]
- runcmd(["sh", "-c", " ".join(shellcmd)], self.dir)
+ runcmd(["git", "--work-tree=%s" % reporoot, "reset", "--hard", "HEAD"], self.dir)
# Also need to take care of any stray untracked files
- shellcmd = ["git", "--work-tree=%s" % reporoot, "clean", "-f"]
- runcmd(["sh", "-c", " ".join(shellcmd)], self.dir)
+ runcmd(["git", "--work-tree=%s" % reporoot, "clean", "-f"], self.dir)
# Fall back to git apply
shellcmd = ["git", "--git-dir=%s" % reporoot, "apply", "-p%s" % patch['strippath']]
os.chdir(self.patchset.dir)
try:
self.patchset.Push(False)
- except CmdError as v:
+ except CmdError:
# Patch application failed
patchcmd = self.patchset.Push(True, False, False)