self.CommonPrepare()
self.PrepareBranch()
self.GitCheckout("master")
- self.GitSVNRebase()
+ self.vc.Pull()
class GetTags(Step):
def RunStep(self):
self.GitCreateBranch(self._config["BRANCHNAME"])
-
- # Get remote tags.
- tags = filter(lambda s: re.match(r"^svn/tags/[\d+\.]+$", s),
- self.GitRemotes())
-
- # Remove 'svn/tags/' prefix.
- self["tags"] = map(lambda s: s[9:], tags)
+ self["tags"] = self.vc.GetTags()
class GetOldestUntaggedVersion(Step):
def RunStep(self):
# Get the lkgr after the tag candidate and before the next tag candidate.
- candidate_svn = self.GitSVNFindSVNRev(self["candidate"])
+ candidate_svn = self.vc.GitSvn(self["candidate"])
if self["next"]:
- next_svn = self.GitSVNFindSVNRev(self["next"])
+ next_svn = self.vc.GitSvn(self["next"])
else:
# Don't include the version change commit itself if there is no upper
# limit yet.
return True
# Let's check if the lkgr is at least three hours old.
- self["lkgr"] = self.GitSVNFindGitHash(lkgr_svn)
+ self["lkgr"] = self.vc.SvnGit(lkgr_svn)
if not self["lkgr"]:
print "Couldn't find git hash for lkgr %s" % lkgr_svn
self.CommonCleanup()
def RunStep(self):
if not self._options.dry_run:
self.GitReset(self["lkgr"])
- self.GitSVNTag(self["candidate_version"])
+ self.vc.Tag(self["candidate_version"])
class CleanUp(Step):
VERSION_BRANCH = "auto-bump-up-version"
+#TODO(machenbach): Add vc interface that works on git mirror.
class Preparation(Step):
MESSAGE = "Preparation."
pass
+class VCInterface(object):
+ def InjectStep(self, step):
+ self.step=step
+
+ def Pull(self):
+ raise NotImplementedError()
+
+ def Fetch(self):
+ raise NotImplementedError()
+
+ def GetTags(self):
+ raise NotImplementedError()
+
+ def GetBranches(self):
+ raise NotImplementedError()
+
+ def GitSvn(self, hsh, branch=""):
+ raise NotImplementedError()
+
+ def SvnGit(self, rev, branch=""):
+ raise NotImplementedError()
+
+ def RemoteMasterBranch(self):
+ raise NotImplementedError()
+
+ def RemoteCandidateBranch(self):
+ raise NotImplementedError()
+
+ def RemoteBranch(self, name):
+ raise NotImplementedError()
+
+ def Land(self):
+ raise NotImplementedError()
+
+ def CLLand(self):
+ raise NotImplementedError()
+
+ # TODO(machenbach): There is some svn knowledge in this interface. In svn,
+ # tag and commit are different remote commands, while in git we would commit
+ # and tag locally and then push/land in one unique step.
+ def Tag(self, tag):
+ raise NotImplementedError()
+
+
+class GitSvnInterface(VCInterface):
+ def Pull(self):
+ self.step.GitSVNRebase()
+
+ def Fetch(self):
+ self.step.GitSVNFetch()
+
+ def GetTags(self):
+ # Get remote tags.
+ tags = filter(lambda s: re.match(r"^svn/tags/[\d+\.]+$", s),
+ self.step.GitRemotes())
+
+ # Remove 'svn/tags/' prefix.
+ return map(lambda s: s[9:], tags)
+
+ def GetBranches(self):
+ # Get relevant remote branches, e.g. "svn/3.25".
+ branches = filter(lambda s: re.match(r"^svn/\d+\.\d+$", s),
+ self.step.GitRemotes())
+ # Remove 'svn/' prefix.
+ return map(lambda s: s[4:], branches)
+
+ def GitSvn(self, hsh, branch=""):
+ return self.step.GitSVNFindSVNRev(hsh, branch)
+
+ def SvnGit(self, rev, branch=""):
+ return self.step.GitSVNFindGitHash(rev, branch)
+
+ def RemoteMasterBranch(self):
+ return "svn/bleeding_edge"
+
+ def RemoteCandidateBranch(self):
+ return "svn/trunk"
+
+ def RemoteBranch(self, name):
+ return "svn/%s" % name
+
+ def Land(self):
+ return self.step.GitSVNDCommit()
+
+ def CLLand(self):
+ return self.step.GitDCommit()
+
+ def Tag(self, tag):
+ self.step.GitSVNTag(tag)
+
+
+
class Step(GitRecipesMixin):
def __init__(self, text, number, config, state, options, handler):
self._text = text
self._state = state
self._options = options
self._side_effect_handler = handler
+ self.vc = GitSvnInterface()
+ self.vc.InjectStep(self)
# The testing configuration might set a different default cwd.
self.default_cwd = self._config.get("DEFAULT_CWD") or DEFAULT_CWD
self["current_branch"] = self.GitCurrentBranch()
# Fetch unfetched revisions.
- self.GitSVNFetch()
+ self.vc.Fetch()
def PrepareBranch(self):
# Delete the branch that will be created later if it exists already.
# Non-patched versions only have three numbers followed by the "(based
# on...) comment."
push_pattern += " (based"
- branch = "" if parent_hash else branch or "svn/trunk"
+ branch = "" if parent_hash else branch or self.vc.RemoteCandidateBranch()
return self.GitLog(n=1, format="%H", grep=push_pattern,
parent_hash=parent_hash, branch=branch)
self.InitialEnvironmentChecks(self.default_cwd)
if self._options.revert_bleeding_edge:
+ # FIXME(machenbach): Make revert bleeding_edge obsolete?
self["merge_to_branch"] = "bleeding_edge"
elif self._options.branch:
self["merge_to_branch"] = self._options.branch
def RunStep(self):
self.GitCreateBranch(self.Config("BRANCHNAME"),
- "svn/%s" % self["merge_to_branch"])
+ self.vc.RemoteBranch(self["merge_to_branch"]))
class SearchArchitecturePorts(Step):
# Search for commits which matches the "Port rXXX" pattern.
git_hashes = self.GitLog(reverse=True, format="%H",
grep="Port r%d" % int(revision),
- branch="svn/bleeding_edge")
+ branch=self.vc.RemoteMasterBranch())
for git_hash in git_hashes.splitlines():
- svn_revision = self.GitSVNFindSVNRev(git_hash, "svn/bleeding_edge")
+ svn_revision = self.vc.GitSvn(git_hash, self.vc.RemoteMasterBranch())
if not svn_revision: # pragma: no cover
self.Die("Cannot determine svn revision for %s" % git_hash)
revision_title = self.GitLog(n=1, format="%s", git_hash=git_hash)
def RunStep(self):
self["patch_commit_hashes"] = []
for revision in self["full_revision_list"]:
- next_hash = self.GitSVNFindGitHash(revision, "svn/bleeding_edge")
+ next_hash = self.vc.SvnGit(revision, self.vc.RemoteMasterBranch())
if not next_hash: # pragma: no cover
self.Die("Cannot determine git hash for r%s" % revision)
self["patch_commit_hashes"].append(next_hash)
self.GitCheckout(self.Config("BRANCHNAME"))
self.WaitForLGTM()
self.GitPresubmit()
- self.GitDCommit()
-
-
-class PrepareSVN(Step):
- MESSAGE = "Determine svn commit revision."
-
- def RunStep(self):
- if self._options.revert_bleeding_edge:
- return
- self.GitSVNFetch()
- commit_hash = self.GitLog(n=1, format="%H", grep=self["new_commit_msg"],
- branch="svn/%s" % self["merge_to_branch"])
- if not commit_hash: # pragma: no cover
- self.Die("Unable to map git commit to svn revision.")
- self["svn_revision"] = self.GitSVNFindSVNRev(commit_hash)
- print "subversion revision number is r%s" % self["svn_revision"]
+ self.vc.CLLand()
class TagRevision(Step):
if self._options.revert_bleeding_edge:
return
print "Creating tag svn/tags/%s" % self["version"]
- if self["merge_to_branch"] == "trunk":
- self["to_url"] = "trunk"
- else:
- self["to_url"] = "branches/%s" % self["merge_to_branch"]
- self.SVN("copy -r %s https://v8.googlecode.com/svn/%s "
- "https://v8.googlecode.com/svn/tags/%s -m "
- "\"Tagging version %s\""
- % (self["svn_revision"], self["to_url"],
- self["version"], self["version"]))
+ self.vc.Tag(self["version"])
class CleanUp(Step):
if not self._options.revert_bleeding_edge:
print "*** SUMMARY ***"
print "version: %s" % self["version"]
- print "branch: %s" % self["to_url"]
- print "svn revision: %s" % self["svn_revision"]
+ print "branch: %s" % self["merge_to_branch"]
if self["revision_list"]:
print "patches: %s" % self["revision_list"]
CommitLocal,
UploadStep,
CommitRepository,
- PrepareSVN,
TagRevision,
CleanUp,
]
MESSAGE = "Create a fresh branch."
def RunStep(self):
- self.GitCreateBranch(self.Config("BRANCHNAME"), "svn/bleeding_edge")
+ self.GitCreateBranch(self.Config("BRANCHNAME"),
+ self.vc.RemoteMasterBranch())
class PreparePushRevision(Step):
def RunStep(self):
if self._options.revision:
- self["push_hash"] = self.GitSVNFindGitHash(self._options.revision)
+ self["push_hash"] = self.vc.SvnGit(self._options.revision)
else:
self["push_hash"] = self.GitLog(n=1, format="%H", git_hash="HEAD")
if not self["push_hash"]: # pragma: no cover
if not last_push_be_svn: # pragma: no cover
self.Die("Could not retrieve bleeding edge revision for trunk push %s"
% last_push)
- last_push_bleeding_edge = self.GitSVNFindGitHash(last_push_be_svn)
+ last_push_bleeding_edge = self.vc.SvnGit(last_push_be_svn)
if not last_push_bleeding_edge: # pragma: no cover
self.Die("Could not retrieve bleeding edge git hash for trunk push %s"
% last_push)
MESSAGE = "Get latest bleeding edge version."
def RunStep(self):
- self.GitCheckoutFile(VERSION_FILE, "svn/bleeding_edge")
+ self.GitCheckoutFile(VERSION_FILE, self.vc.RemoteMasterBranch())
# Store latest version.
self.ReadAndPersistVersion("latest_")
if SortingKey(self["trunk_version"]) < SortingKey(self["latest_version"]):
# If the version on bleeding_edge is newer than on trunk, use it.
- self.GitCheckoutFile(VERSION_FILE, "svn/bleeding_edge")
+ self.GitCheckoutFile(VERSION_FILE, self.vc.RemoteMasterBranch())
self.ReadAndPersistVersion()
if self.Confirm(("Automatically increment BUILD_NUMBER? (Saying 'n' will "
"started.")
def RunStep(self):
- self.GitSVNFetch()
- self.GitCheckout("svn/bleeding_edge")
+ self.vc.Fetch()
+ self.GitCheckout(self.vc.RemoteMasterBranch())
class SquashCommits(Step):
def RunStep(self):
# Instead of relying on "git rebase -i", we'll just create a diff, because
# that's easier to automate.
- TextToFile(self.GitDiff("svn/trunk", self["push_hash"]),
+ TextToFile(self.GitDiff(self.vc.RemoteCandidateBranch(),
+ self["push_hash"]),
self.Config("PATCH_FILE"))
# Convert the ChangeLog entry to commit message format.
# Retrieve svn revision for showing the used bleeding edge revision in the
# commit message.
- self["svn_revision"] = self.GitSVNFindSVNRev(self["push_hash"])
+ self["svn_revision"] = self.vc.GitSvn(self["push_hash"])
suffix = PUSH_MESSAGE_SUFFIX % int(self["svn_revision"])
text = MSub(r"^(Version \d+\.\d+\.\d+)$", "\\1%s" % suffix, text)
MESSAGE = "Create a new branch from trunk."
def RunStep(self):
- self.GitCreateBranch(self.Config("TRUNKBRANCH"), "svn/trunk")
+ self.GitCreateBranch(self.Config("TRUNKBRANCH"),
+ self.vc.RemoteCandidateBranch())
class ApplyChanges(Step):
# The change log has been modified by the patch. Reset it to the version
# on trunk and apply the exact changes determined by this PrepareChangeLog
# step above.
- self.GitCheckoutFile(self.Config("CHANGELOG_FILE"), "svn/trunk")
+ self.GitCheckoutFile(self.Config("CHANGELOG_FILE"),
+ self.vc.RemoteCandidateBranch())
changelog_entry = FileToText(self.Config("CHANGELOG_ENTRY_FILE"))
old_change_log = FileToText(self.Config("CHANGELOG_FILE"))
new_change_log = "%s\n\n\n%s" % (changelog_entry, old_change_log)
def RunStep(self):
# The version file has been modified by the patch. Reset it to the version
# on trunk and apply the correct version.
- self.GitCheckoutFile(VERSION_FILE, "svn/trunk")
+ self.GitCheckoutFile(VERSION_FILE, self.vc.RemoteCandidateBranch())
self.SetVersion(os.path.join(self.default_cwd, VERSION_FILE), "new_")
MESSAGE = "Commit to SVN."
def RunStep(self):
- result = self.GitSVNDCommit()
+ result = self.vc.Land()
+ # TODO(machenbach): Remove/improve this logic before the git switch.
if not result: # pragma: no cover
self.Die("'git svn dcommit' failed.")
result = filter(lambda x: re.search(r"^Committed r[0-9]+", x),
MESSAGE = "Tag the new revision."
def RunStep(self):
- self.GitSVNTag(self["version"])
+ self.vc.Tag(self["version"])
class CleanUp(Step):
def GetReleaseDict(
self, git_hash, bleeding_edge_rev, branch, version, patches, cl_body):
- revision = self.GitSVNFindSVNRev(git_hash)
+ revision = self.vc.GitSvn(git_hash)
return {
# The SVN revision on the branch.
"revision": revision,
tag_text = self.SVN("log https://v8.googlecode.com/svn/tags -v --limit 20")
releases = []
for (tag, revision) in re.findall(BLEEDING_EDGE_TAGS_RE, tag_text):
- git_hash = self.GitSVNFindGitHash(revision)
+ git_hash = self.vc.SvnGit(revision)
# Add bleeding edge release. It does not contain patches or a code
# review link, as tags are not uploaded.
return releases
def GetReleasesFromBranch(self, branch):
- self.GitReset("svn/%s" % branch)
+ self.GitReset(self.vc.RemoteBranch(branch))
+ # TODO(machenbach): Rename this when switching to the git mirror.
if branch == 'bleeding_edge':
return self.GetReleasesFromBleedingEdge()
def RunStep(self):
self.GitCreateBranch(self._config["BRANCHNAME"])
- # Get relevant remote branches, e.g. "svn/3.25".
- branches = filter(lambda s: re.match(r"^svn/\d+\.\d+$", s),
- self.GitRemotes())
- # Remove 'svn/' prefix.
- branches = map(lambda s: s[4:], branches)
-
+ branches = self.vc.GetBranches()
releases = []
if self._options.branch == 'recent':
# Get only recent development on trunk, beta and stable.
Cmd("git cl presubmit", "Presubmit successfull\n"),
Cmd("git cl dcommit -f --bypass-hooks", "Closing issue\n",
cb=VerifySVNCommit),
- Cmd("git svn fetch", ""),
- Cmd(("git log -1 --format=%%H --grep=\"%s\" svn/trunk"
- % msg.replace("\"", "\\\"")), "hash6"),
- Cmd("git svn find-rev hash6", "1324"),
- Cmd(("svn copy -r 1324 https://v8.googlecode.com/svn/trunk "
- "https://v8.googlecode.com/svn/tags/3.22.5.1 -m "
- "\"Tagging version 3.22.5.1\""), ""),
+ Cmd("git svn tag 3.22.5.1 -m \"Tagging version 3.22.5.1\"", ""),
Cmd("git checkout -f some_branch", ""),
Cmd("git branch -D %s" % TEST_CONFIG["BRANCHNAME"], ""),
])