return
}
+func (r Repo) Rebase(head string, base string, onto string) (out []byte, err error) {
+ out, err = r.gitCmd("rebase", "--onto="+onto, base, head)
+ return
+}
+
func (r Repo) DisablePush() (err error) {
node := "config.origin.pushurl"
_, err = r.gitCmd("config", node, "http://localhost/fail")
main = MainSyncPatches
loadConfig = true
loadXSA = true
+ case "backport":
+ main = MainBackport
+ loadConfig = true
+ loadXSA = true
case "sync-branch":
main = MainSyncBranch
loadConfig = true
loadXSA = true
-
case "test-apply":
main = MainTestApply
loadConfig = true
return
}
+func (r *Recipe) Backport(prefix string, to XenVersion) (err error) {
+
+ _, fromBase, fromBranch := BranchName(prefix, r.xsa, r.XenVersion)
+ _, toBase, toBranch := BranchName(prefix, r.xsa, to)
+
+ backport := func(tree Tree) (err error) {
+ xr := G.repos.XenRepos[tree]
+
+
+ // git checkout -b xsa/NNN/$to xsa/NNN/$from
+ if err = xr.MakeBranch(toBranch, fromBranch); err != nil {
+ return fmt.Errorf("Making branch %v based on branch %v\n",
+ toBranch, fromBranch)
+ }
+
+ // git rebase --onto=xsa/NNN/$to-baseline $from-baseline $to-baseline
+ if _, err = xr.Rebase(toBranch, fromBase, toBase); err != nil {
+ return fmt.Errorf("Rebase failed. Finish rebase for %v and continue.", to)
+ }
+
+ return
+ }
+
+ err = r.ForEachTree(backport)
+ return
+}
+
+
+
func (r *Recipe) Build(prefix string) (err error) {
_, _, branch := r.branchName(prefix)
return true
}
+func Story206Backport(st *SystemTest) bool {
+ fmt.Print(" xsatool 206 backport [master to 4.8] [should fail]\n")
+ if MainHarness("206", "backport") == 0 {
+ st.Errorf("Expected master->4.8 backport to fail, but succeeded!")
+ return false
+ }
+
+ // Check to see that the partial bits we expect were actually done
+ // - .git/rebase-apply exists
+ // - How many patches had been applied? (0)
+
+ // Fake things up:
+ // - git rebase --abort
+ // - git checkout -B xsa/NNN/4.8 xsa/NNN/4.8-baseline
+ // - git am 4.8 patch series
+
+ return true
+}
+
func Story206(st *SystemTest) bool {
fmt.Print("Starting XSA-206 'story'\n")
// xsatool 206 init xen
return false
}
- return true
-
// Test only 'master' patches
- if !Story206TestMaster(st) {
+ if false && !Story206TestMaster(st) {
return false
}
// 206 Backport (should fail at 4.8. 4.7, and 4.6; NOT 4.5)
+ if !Story206Backport(st) {
+ return false
+ }
// 206 sync-patches
import (
"fmt"
+ "sort"
)
func sync(xsa *XSAMeta, args []string, sync bool) (ret int) {
return
}
+
+// xsatool NNN backport
+func MainBackport(xsa *XSAMeta, args []string) (ret int) {
+ // Starting with master - 1, look for branches that don't have patches
+
+ if !sort.IsSorted(xsa.SupportedVersions) {
+ fmt.Print("Internal error: SupportedVersions not sorted!\n")
+ return 1
+ }
+
+ var from XenVersion
+ for _, to := range xsa.SupportedVersions {
+ if to == XenVersionMaster ||
+ xsa.RepoHasPatches(to) {
+ from = to
+ continue
+ }
+
+ fmt.Printf("Backporting from %v to %v\n", from, to)
+
+ r := xsa.GetRecipe(from)
+
+ if err := r.Backport("xsa", to); err != nil {
+ fmt.Printf("Backporting from %v to %v: %v\n",
+ from, to, err)
+ return 1
+ }
+
+ fmt.Printf("Successfully rebased from %v to %v. Please check it over.\n",
+ from, to)
+ return 0
+
+ // For if we ever add an "automatic build test option" instead
+ // from = to
+ }
+
+ fmt.Printf("Not implemented\n")
+ return 1
+}
+
+// xsatool NNN backport-fixup [version]