コード例 #1
0
 /// <summary>
 /// Perform push operation between local and remote repository - set remote
 /// refs appropriately, send needed objects and update local tracking refs.
 /// </summary>
 /// <remarks>
 /// Perform push operation between local and remote repository - set remote
 /// refs appropriately, send needed objects and update local tracking refs.
 /// <p>
 /// When
 /// <see cref="Transport.IsDryRun()">Transport.IsDryRun()</see>
 /// is true, result of this operation is
 /// just estimation of real operation result, no real action is performed.
 /// </remarks>
 /// <param name="monitor">progress monitor used for feedback about operation.</param>
 /// <returns>result of push operation with complete status description.</returns>
 /// <exception cref="System.NotSupportedException">when push operation is not supported by provided transport.
 ///     </exception>
 /// <exception cref="NGit.Errors.TransportException">
 /// when some error occurred during operation, like I/O, protocol
 /// error, or local database consistency error.
 /// </exception>
 internal virtual PushResult Execute(ProgressMonitor monitor)
 {
     try
     {
         monitor.BeginTask(PROGRESS_OPENING_CONNECTION, ProgressMonitor.UNKNOWN);
         PushResult res = new PushResult();
         connection = transport.OpenPush();
         try
         {
             res.SetAdvertisedRefs(transport.GetURI(), connection.GetRefsMap());
             res.SetRemoteUpdates(toPush);
             monitor.EndTask();
             IDictionary <string, RemoteRefUpdate> preprocessed = PrepareRemoteUpdates();
             if (transport.IsDryRun())
             {
                 ModifyUpdatesForDryRun();
             }
             else
             {
                 if (!preprocessed.IsEmpty())
                 {
                     connection.Push(monitor, preprocessed);
                 }
             }
         }
         finally
         {
             connection.Close();
             res.AddMessages(connection.GetMessages());
         }
         if (!transport.IsDryRun())
         {
             UpdateTrackingRefs();
         }
         foreach (RemoteRefUpdate rru in toPush.Values)
         {
             TrackingRefUpdate tru = rru.GetTrackingRefUpdate();
             if (tru != null)
             {
                 res.Add(tru);
             }
         }
         return(res);
     }
     finally
     {
         walker.Release();
     }
 }