Remove push refs to gerrit feature

This is in preparation to move to separate merger process, which
will not have access to the trigger.  Similar functionality can
be obtained using the new replication feature, and docs have been
updated to that effect.

Change-Id: I9397f7eb8466af464c8e7adb02d0a8d3eff04f9f
diff --git a/NEWS.rst b/NEWS.rst
index bbaa2a2..52f5c4f 100644
--- a/NEWS.rst
+++ b/NEWS.rst
@@ -1,3 +1,10 @@
+Since 2.0.0:
+
+* The push_change_refs option which specified that Zuul refs should be
+  pushed to Gerrit has been removed.  Similar functionality may be
+  obtained using the replication feature.  See the Triggers
+  documentation for details.
+
 Since 1.3.0:
 
 * The Jenkins launcher is replaced with Gearman launcher.  An internal
diff --git a/doc/source/triggers.rst b/doc/source/triggers.rst
index 17c93ab..21aab13 100644
--- a/doc/source/triggers.rst
+++ b/doc/source/triggers.rst
@@ -49,32 +49,11 @@
 described in :ref:`launchers`.
 
 These references need to be made available via a Git repository that
-is available to Jenkins.  You may accomplish this by either allowing
-Zuul to push the references back to Gerrit, in which case you may
-simply use the Gerrit Git repository.  If you do not have access to
-the Gerrit repository, or would prefer Zuul not push its refs there,
-you may directly serve the Git repositories that Zuul uses, and
-configure Jenkins to use those.  Instructions for each of these
-alternatives are in the following sections.
-
-Pushing to Gerrit
-"""""""""""""""""
-
-If you want to push Zuul refs back to Gerrit, set the following
-permissions for your project (or ``All-Projects``) in Gerrit (where
-``CI Tools`` is a group of which the user you created above is a
-member)::
-
-    [access "refs/zuul/*"]
-            create = group CI Tools
-            push = +force CI Tools
-            pushMerge = group CI Tools
-            forgeAuthor = group CI Tools
-    [access "refs/for/refs/zuul/*"]
-            pushMerge = group CI Tools
-
-And set ``push_change_refs`` to ``true`` in the ``zuul`` section of
-zuul.conf.
+is available to Jenkins.  You may accomplish this by either serving
+Zuul's git repositories directly, allowing Zuul to push the references
+back to Gerrit, or pushing the references to a third location.
+Instructions for each of these alternatives are in the following
+sections.
 
 Serving Zuul Git Repos
 """"""""""""""""""""""
@@ -102,6 +81,33 @@
 happens).  They are, however, suitable for automated systems that
 respond to Zuul triggers.
 
+Pushing to Gerrit
+"""""""""""""""""
+
+If you want to push Zuul refs back to Gerrit, set the following
+permissions for your project (or ``All-Projects``) in Gerrit (where
+``CI Tools`` is a group of which the user you created above is a
+member)::
+
+    [access "refs/zuul/*"]
+            create = group CI Tools
+            push = +force CI Tools
+            pushMerge = group CI Tools
+            forgeAuthor = group CI Tools
+    [access "refs/for/refs/zuul/*"]
+            pushMerge = group CI Tools
+
+And set the following in ``zuul.conf``:
+
+  [replication]
+    url1=ssh://user@review.example.com:29418/
+
+Pushing to Another Location
+"""""""""""""""""""""""""""
+
+Simply set one or more destination URLs in the ``replication`` section
+of zuul.conf as above.
+
 Timer
 -----
 
diff --git a/doc/source/zuul.rst b/doc/source/zuul.rst
index b4adc4d..d2b394b 100644
--- a/doc/source/zuul.rst
+++ b/doc/source/zuul.rst
@@ -110,12 +110,6 @@
   Optional: Value to pass to `git config user.name`.
   ``git_user_name=zuul``
 
-**push_change_refs**
-  Boolean value (``true`` or ``false``) that determines if Zuul should
-  push change refs to the git origin server for the git repositories in
-  git_dir.
-  ``push_change_refs=true``
-
 **report_times**
   Boolean value (``true`` or ``false``) that determines if Zuul should
   include elapsed times for each job in the textual report.
diff --git a/tests/fixtures/zuul.conf b/tests/fixtures/zuul.conf
index 0cf27e1..f77e07e 100644
--- a/tests/fixtures/zuul.conf
+++ b/tests/fixtures/zuul.conf
@@ -11,7 +11,6 @@
 git_dir=/tmp/zuul-test/git
 git_user_email=zuul@example.com
 git_user_name=zuul
-push_change_refs=true
 url_pattern=http://logs.example.com/{change.number}/{change.patchset}/{pipeline.name}/{job.name}/{build.number}
 job_name_in_report=true
 zuul_url=http://zuul.example.com/p
diff --git a/zuul/merger.py b/zuul/merger.py
index 09011ae..a580a21 100644
--- a/zuul/merger.py
+++ b/zuul/merger.py
@@ -147,14 +147,11 @@
 class Merger(object):
     log = logging.getLogger("zuul.Merger")
 
-    def __init__(self, trigger, working_root, push_refs, sshkey, email,
-                 username, replicate_urls):
-        self.trigger = trigger
+    def __init__(self, working_root, sshkey, email, username, replicate_urls):
         self.repos = {}
         self.working_root = working_root
         if not os.path.exists(working_root):
             os.makedirs(working_root)
-        self.push_refs = push_refs
         if sshkey:
             self._makeSSHWrapper(sshkey)
         self.email = email
@@ -307,19 +304,6 @@
             refspecs = replicate_refspecs.get(i.change.project, [])
             refspecs.append('%s:%s' % (ref, ref))
             replicate_refspecs[i.change.project] = refspecs
-            if self.push_refs:
-                # Push the results upstream to the zuul ref after
-                # they are created.
-                try:
-                    repo.push(ref, ref)
-                    complete = self.trigger.waitForRefSha(i.change.project,
-                                                          ref)
-                except:
-                    self.log.exception("Unable to push %s" % ref)
-                    return False
-                if not complete:
-                    self.log.error("Ref %s did not show up in repo" % ref)
-                    return False
             project_branches.append((i.change.project, i.change.branch))
         self.replicateRefspecs(replicate_refspecs)
         return commit
diff --git a/zuul/scheduler.py b/zuul/scheduler.py
index 9186ff3..73034c7 100644
--- a/zuul/scheduler.py
+++ b/zuul/scheduler.py
@@ -367,11 +367,6 @@
         else:
             merge_name = None
 
-        if self.config.has_option('zuul', 'push_change_refs'):
-            push_refs = self.config.getboolean('zuul', 'push_change_refs')
-        else:
-            push_refs = False
-
         replicate_urls = []
         if self.config.has_section('replication'):
             for k, v in self.config.items('replication'):
@@ -385,10 +380,8 @@
         # TODO: The merger should have an upstream repo independent of
         # triggers, and then each trigger should provide a fetch
         # location.
-        self.merger = merger.Merger(self.triggers['gerrit'],
-                                    merge_root, push_refs,
-                                    sshkey, merge_email, merge_name,
-                                    replicate_urls)
+        self.merger = merger.Merger(merge_root, sshkey, merge_email,
+                                    merge_name, replicate_urls)
         for project in self.layout.projects.values():
             url = self.triggers['gerrit'].getGitUrl(project)
             self.merger.addProject(project, url)