Lines Matching +full:self +full:- +full:refresh
2 # SPDX-License-Identifier: GPL-2.0-only
10 def __init__(self, path): argument
11 self.path = path
13 def __str__(self): argument
14 return "Error: %s not found." % self.path
17 def __init__(self, command, exitstatus, output): argument
18 self.command = command
19 self.status = exitstatus
20 self.output = output
22 def __str__(self): argument
24 (self.command, self.status, self.output)
35 # print("cwd: %s -> %s" % (olddir, dir))
43 stdout = stdout.decode('utf-8')
44 stderr = stderr.decode('utf-8')
51 bb.note("--- Patch fuzz start ---\n%s\n--- Patch fuzz end ---" % format(stdout))
61 def __init__(self, msg): argument
62 self.msg = msg
64 def __str__(self): argument
65 return "Patch Error: %s" % self.msg
72 def __init__(self, dir, d): argument
73 self.dir = dir
74 self.d = d
75 self.patches = []
76 self._current = None
78 def current(self): argument
79 return self._current
81 def Clean(self): argument
88 def Import(self, patch, force): argument
93 patch["file"] = bb.fetch2.localpath(patch["remote"], self.d)
100 patch["file"] = self.d.expand(bb.fetch2.localpath(patch["remote"], self.d))
104 def Push(self, force): argument
107 def Pop(self, force): argument
110 def Refresh(self, remote = None, all = None): member in PatchSet
136 for encoding in ['utf-8', 'latin-1']:
142 if line.startswith('--- '):
185 def __init__(self, dir, d): argument
186 PatchSet.__init__(self, dir, d)
187 self.patchdir = os.path.join(self.dir, 'patches')
188 self.seriespath = os.path.join(self.dir, 'patches', 'series')
189 bb.utils.mkdirhier(self.patchdir)
191 def _appendPatchFile(self, patch, strippath): argument
192 with open(self.seriespath, 'a') as f:
194 shellcmd = ["cat", patch, ">" , self.patchdir + "/" + os.path.basename(patch)]
195 runcmd(["sh", "-c", " ".join(shellcmd)], self.dir)
197 def _removePatch(self, p): argument
201 self._applypatch(patch, False, True)
203 def _removePatchFile(self, all = False): argument
204 if not os.path.exists(self.seriespath):
206 with open(self.seriespath, 'r+') as f:
210 self._removePatch(os.path.join(self.patchdir, p.strip()))
213 self._removePatch(os.path.join(self.patchdir, patches[-1].strip()))
215 with open(self.seriespath, 'w') as f:
219 def Import(self, patch, force = None): argument
221 PatchSet.Import(self, patch, force)
223 if self._current is not None:
224 i = self._current + 1
227 self.patches.insert(i, patch)
229 def _applypatch(self, patch, force = False, reverse = False, run = True): argument
230 …shellcmd = ["cat", patch['file'], "|", "patch", "--no-backup-if-mismatch", "-p", patch['strippath'…
232 shellcmd.append('-R')
235 return "sh" + "-c" + " ".join(shellcmd)
238 shellcmd.append('--dry-run')
241 output = runcmd(["sh", "-c", " ".join(shellcmd)], self.dir)
246 shellcmd.pop(len(shellcmd) - 1)
247 output = runcmd(["sh", "-c", " ".join(shellcmd)], self.dir)
253 self._appendPatchFile(patch['file'], patch['strippath'])
257 def Push(self, force = False, all = False, run = True): argument
258 bb.note("self._current is %s" % self._current)
259 bb.note("patches is %s" % self.patches)
261 for i in self.patches:
263 self._applypatch(i, force)
264 self._current = i
266 if self._current is not None:
267 next = self._current + 1
271 bb.note("applying patch %s" % self.patches[next])
272 ret = self._applypatch(self.patches[next], force)
274 self._current = next
277 def Pop(self, force = None, all = None): argument
279 self._removePatchFile(True)
280 self._current = None
282 self._removePatchFile(False)
284 if self._current == 0:
285 self._current = None
287 if self._current is not None:
288 self._current = self._current - 1
290 def Clean(self): argument
292 self.Pop(all=True)
298 def __init__(self, dir, d): argument
299 PatchTree.__init__(self, dir, d)
300 self.commituser = d.getVar('PATCH_GIT_USER_NAME')
301 self.commitemail = d.getVar('PATCH_GIT_USER_EMAIL')
302 if not self._isInitialized(d):
303 self._initRepo()
305 def _isInitialized(self, d): argument
306 cmd = "git rev-parse --show-toplevel"
308 output = runcmd(cmd.split(), self.dir).strip()
310 ## runcmd returned non-zero which most likely means 128
313 ## Make sure repo is in builddir to not break top-level git repos, or under workdir
314 … return os.path.samefile(output, self.dir) or oe.path.is_path_parent(d.getVar('WORKDIR'), output)
316 def _initRepo(self): argument
317 runcmd("git init".split(), self.dir)
318 runcmd("git add .".split(), self.dir)
319 runcmd("git commit -a --allow-empty -m bitbake_patching_started".split(), self.dir)
326 for encoding in ['utf-8', 'latin-1']:
331 … if line.startswith('Index: ') or line.startswith('diff -') or line.startswith('---'):
347 result = result.decode('utf-8')
354 from_commit_re = re.compile(r'^From [a-z0-9]{40} .*')
362 # Remove any [PATCH][oe-core] etc.
375 … # format. Without e.g. a python-dateutils dependency we can't do a whole lot more
379 elif not author and line.lower().startswith('signed-off-by: '):
385 # We don't want the From <commit> line - if it's present it will break rebasing
400 …if firstline and not firstline.startswith(('#', 'Index:', 'Upstream-Status:')) and len(firstline) …
411 cmd += ['-c', 'user.name="%s"' % commituser]
413 cmd += ['-c', 'user.email="%s"' % commitemail]
427 … shellcmd = ["git", "log", "--format=email", "--follow", "--diff-filter=A", "--", patchfile]
428 out = runcmd(["sh", "-c", " ".join(shellcmd)], os.path.dirname(patchfile))
453 cmd += ["commit", "-F", tmpfile]
456 cmd.append('--author="%s"' % author)
458 cmd.append('--date="%s"' % date)
467 … shellcmd = ["git", "format-patch", "--no-signature", "--no-numbered", startcommit, "-o", tempdir]
469 shellcmd.append('--')
471 out = runcmd(["sh", "-c", " ".join(shellcmd)], tree)
474 for encoding in ['utf-8', 'latin-1']:
481 outfile = line.split()[-1].strip()
500 def _applypatch(self, patch, force = False, reverse = False, run = True): argument
505 shellcmd.append('-R')
510 return "sh" + "-c" + " ".join(shellcmd)
512 return runcmd(["sh", "-c", " ".join(shellcmd)], self.dir)
515 reporoot = (runcmd("git rev-parse --show-toplevel".split(), self.dir) or '').strip()
517 raise Exception("Cannot get repository root for directory %s" % self.dir)
519 hooks_dir_backup = hooks_dir + '.devtool-orig'
525 commithook = os.path.join(hooks_dir, 'commit-msg')
526 applyhook = os.path.join(hooks_dir, 'applypatch-msg')
536 shellcmd = [patchfilevar, "git", "--work-tree=%s" % reporoot]
537 self.gitCommandUserOptions(shellcmd, self.commituser, self.commitemail)
538 shellcmd += ["am", "-3", "--keep-cr", "--no-scissors", "-p%s" % patch['strippath']]
543 shellcmd = ["git", "--work-tree=%s" % reporoot, "am", "--abort"]
544 runcmd(["sh", "-c", " ".join(shellcmd)], self.dir)
548 shellcmd = ["git", "--work-tree=%s" % reporoot, "reset", "--hard", "HEAD"]
549 runcmd(["sh", "-c", " ".join(shellcmd)], self.dir)
551 shellcmd = ["git", "--work-tree=%s" % reporoot, "clean", "-f"]
552 runcmd(["sh", "-c", " ".join(shellcmd)], self.dir)
555 shellcmd = ["git", "--git-dir=%s" % reporoot, "apply", "-p%s" % patch['strippath']]
560 output = PatchTree._applypatch(self, patch, force, reverse, run)
562 shellcmd = ["git", "add", "-f", "-A", "."]
563 output += runcmd(["sh", "-c", " ".join(shellcmd)], self.dir)
565 shellcmd = ["git", "reset", "HEAD", self.patchdir]
566 output += runcmd(["sh", "-c", " ".join(shellcmd)], self.dir)
568 … (tmpfile, shellcmd) = self.prepareCommit(patch['file'], self.commituser, self.commitemail)
571 output += runcmd(["sh", "-c", " ".join(shellcmd)], self.dir)
582 def _runcmd(self, args, run = True): argument
583 quiltrc = self.d.getVar('QUILTRCFILE')
585 return ["quilt"] + ["--quiltrc"] + [quiltrc] + args
586 runcmd(["quilt"] + ["--quiltrc"] + [quiltrc] + args, self.dir)
588 def _quiltpatchpath(self, file): argument
589 return os.path.join(self.dir, "patches", os.path.basename(file))
592 def __init__(self, dir, d): argument
593 PatchSet.__init__(self, dir, d)
594 self.initialized = False
595 p = os.path.join(self.dir, 'patches')
599 def Clean(self): argument
601 # make sure that patches/series file exists before quilt pop to keep quilt-0.67 happy
602 open(os.path.join(self.dir, "patches","series"), 'a').close()
603 self._runcmd(["pop", "-a", "-f"])
604 oe.path.remove(os.path.join(self.dir, "patches","series"))
607 self.initialized = True
609 def InitFromDir(self): argument
610 # read series -> self.patches
611 seriespath = os.path.join(self.dir, 'patches', 'series')
612 if not os.path.exists(self.dir):
613 raise NotFoundError(self.dir)
619 patch["quiltfile"] = self._quiltpatchpath(parts[0])
623 self.patches.append(patch)
625 # determine which patches are applied -> self._current
627 output = runcmd(["quilt", "applied"], self.dir)
635 for patch in self.patches:
636 if os.path.basename(patch["quiltfile"]) == output[-1]:
637 self._current = self.patches.index(patch)
638 self.initialized = True
640 def Import(self, patch, force = None): argument
641 if not self.initialized:
642 self.InitFromDir()
643 PatchSet.Import(self, patch, force)
644 oe.path.symlink(patch["file"], self._quiltpatchpath(patch["file"]), force=True)
645 with open(os.path.join(self.dir, "patches", "series"), "a") as f:
646 f.write(os.path.basename(patch["file"]) + " -p" + patch["strippath"] + "\n")
647 patch["quiltfile"] = self._quiltpatchpath(patch["file"])
654 self.patches.insert(self._current or 0, patch)
657 def Push(self, force = False, all = False, run = True): argument
658 # quilt push [-f]
662 args.append("-f")
664 args.append("-a")
666 return self._runcmd(args, run)
668 self._runcmd(args)
670 if self._current is not None:
671 self._current = self._current + 1
673 self._current = 0
675 def Pop(self, force = None, all = None): argument
676 # quilt pop [-f]
679 args.append("-f")
681 args.append("-a")
683 self._runcmd(args)
685 if self._current == 0:
686 self._current = None
688 if self._current is not None:
689 self._current = self._current - 1
691 def Refresh(self, **kwargs): member in QuiltTree
693 patch = self.patches[kwargs["patch"]]
700 patch["file"] = bb.fetch2.localpath(patch["remote"], self.d)
704 …raise PatchError("Unable to do a remote refresh of %s, unsupported remote url scheme %s." % (os.pa…
706 # quilt refresh
707 args = ["refresh"]
711 args.append(os.path.basename(self.patches[kwargs["patch"]]["quiltfile"]))
712 self._runcmd(args)
715 def __init__(self, patchset, terminal): argument
718 def Resolve(self): argument
721 def Revert(self): argument
724 def Finalize(self): argument
728 def __init__(self, patchset, terminal): argument
729 self.patchset = patchset
730 self.terminal = terminal
732 def Resolve(self): argument
734 os.chdir(self.patchset.dir)
736 self.patchset.Push()
746 def __init__(self, patchset, terminal): argument
747 self.patchset = patchset
748 self.terminal = terminal
752 def Resolve(self): argument
754 os.chdir(self.patchset.dir)
756 self.patchset.Push(False)
759 patchcmd = self.patchset.Push(True, False, False)
761 t = self.patchset.d.getVar('T')
770 … f.write("echo 'Run \"quilt refresh\" when patch is corrected, press CTRL+D to exit.'\n")
775 …self.terminal("bash --rcfile " + rcfile, 'Patch Rejects: Please fix patch rejects manually', self.…
779 # refresh on each.
780 oldpatchset = self.patchset
781 self.patchset = oldpatchset.__class__(self.patchset.dir, self.patchset.d)
783 for patch in self.patchset.patches:
794 # user change? remote refresh
795 … self.patchset.Refresh(remote=True, patch=self.patchset.patches.index(patch))
798 … raise PatchError("Patch application failed, and user did not fix and refresh the patch.")