autoland: refactor: inline hg commands (bug 1349997); r?gps draft
authorbyron jones <glob@mozilla.com>
Thu, 23 Mar 2017 14:23:03 +0800
changeset 10581 bd85285478902b1aa677376d85b637e34e58fc3b
parent 10580 ce521a3cd1b288b2b9bd00361abb519637f9466e
child 10582 9bbf0f558e53f71d20c36403f167ff579a98232d
push id1595
push userbjones@mozilla.com
push dateFri, 31 Mar 2017 04:09:17 +0000
reviewersgps
bugs1349997
autoland: refactor: inline hg commands (bug 1349997); r?gps Now that things are closer to where we want them, inline the hg commands into their respective methods. MozReview-Commit-ID: Av2gLu4R6hT
autoland/autoland/transplant.py
--- a/autoland/autoland/transplant.py
+++ b/autoland/autoland/transplant.py
@@ -56,31 +56,53 @@ class Transplant:
     def __init__(self, hg_repo, tree, destination, rev):
         self.hg_repo = hg_repo
         self.tree = tree
         self.destination = destination
         self.source_rev = rev
 
     def push_try(self, trysyntax):
         self.update_repo()
-        rev = self.push_to_try(trysyntax)
+
+        if not trysyntax.startswith("try: "):
+            trysyntax = "try: %s" % trysyntax
+        rev = self.run_hg_cmds([
+            [
+                '--encoding=utf-8',
+                '--config', 'ui.allowemptycommit=true',
+                'commit',
+                '-m', trysyntax
+            ],
+            ['push', '-r', '.', '-f', 'try'],
+            ['log', '-r', 'tip', '-T', '{node|short}'],
+        ])
+
         self.strip_drafts()
         return rev
 
     def push_bookmark(self, commit_descriptions, bookmark):
         remote_tip = self.update_repo()
+
         rev = self.apply_changes(remote_tip, commit_descriptions)
-        self.push_bookmark_to_repo(bookmark)
+        self.run_hg_cmds([
+            ['bookmark', bookmark],
+            ['push', '-B', bookmark, self.destination],
+        ])
+
         self.strip_drafts()
         return rev
 
     def push(self, commit_descriptions):
         remote_tip = self.update_repo()
+
         rev = self.apply_changes(remote_tip, commit_descriptions)
-        self.push_to_repo()
+        self.run_hg_cmds([
+            ['push', '-r', 'tip', self.destination]
+        ])
+
         self.strip_drafts()
         return rev
 
     def update_repo(self):
         # Obtain remote tip. We assume there is only a single head.
         remote_tip = self.get_remote_tip()
 
         # Strip any lingering draft changesets.
@@ -213,34 +235,8 @@ class Transplant:
             logger.error('unexpected outgoing commits:')
             for commit in outgoing:
                 logger.error('outgoing: %s: %s' % (commit[1], commit[5]))
 
             raise Exception("We're sorry - something has gone wrong while "
                             "rewriting or rebasing your commits. The commits "
                             "being pushed no longer match what was requested. "
                             "Please file a bug.")
-
-    def push_to_try(self, trysyntax):
-        if not trysyntax.startswith("try: "):
-            trysyntax = "try: %s" % trysyntax
-        return self.run_hg_cmds([
-            [
-                '--encoding=utf-8',
-                '--config', 'ui.allowemptycommit=true',
-                'commit',
-                '-m', trysyntax
-            ],
-            ['push', '-r', '.', '-f', 'try'],
-            ['log', '-r', 'tip', '-T', '{node|short}'],
-        ])
-
-    def push_bookmark_to_repo(self, bookmark):
-        self.run_hg_cmds([
-            ['bookmark', bookmark],
-            ['push', '-B', bookmark, self.destination],
-        ])
-
-    def push_to_repo(self):
-        self.run_hg_cmds([
-            ['push', '-r', 'tip', self.destination]
-        ])
-