Esempio n. 1
0
		/// <summary>Initialize a new rename operation.</summary>
		/// <remarks>Initialize a new rename operation.</remarks>
		/// <param name="src">operation to read and delete the source.</param>
		/// <param name="dst">operation to create (or overwrite) the destination.</param>
		protected internal RefRename(RefUpdate src, RefUpdate dst)
		{
			source = src;
			destination = dst;
			string cmd = string.Empty;
			if (source.GetName().StartsWith(Constants.R_HEADS) && destination.GetName().StartsWith
				(Constants.R_HEADS))
			{
				cmd = "Branch: ";
			}
			SetRefLogMessage(cmd + "renamed " + Repository.ShortenRefName(source.GetName()) +
				 " to " + Repository.ShortenRefName(destination.GetName()));
		}
Esempio n. 2
0
        /// <summary>Initialize a new rename operation.</summary>
        /// <remarks>Initialize a new rename operation.</remarks>
        /// <param name="src">operation to read and delete the source.</param>
        /// <param name="dst">operation to create (or overwrite) the destination.</param>
        protected internal RefRename(RefUpdate src, RefUpdate dst)
        {
            source      = src;
            destination = dst;
            string cmd = string.Empty;

            if (source.GetName().StartsWith(Constants.R_HEADS) && destination.GetName().StartsWith
                    (Constants.R_HEADS))
            {
                cmd = "Branch: ";
            }
            SetRefLogMessage(cmd + "renamed " + Repository.ShortenRefName(source.GetName()) +
                             " to " + Repository.ShortenRefName(destination.GetName()));
        }
Esempio n. 3
0
        /// <returns>
        /// true if the
        /// <code>Constants#HEAD</code>
        /// reference needs to be linked
        /// to the new destination name.
        /// </returns>
        /// <exception cref="System.IO.IOException">
        /// the current value of
        /// <code>HEAD</code>
        /// cannot be read.
        /// </exception>
        protected internal virtual bool NeedToUpdateHEAD()
        {
            Ref head = source.GetRefDatabase().GetRef(Constants.HEAD);

            if (head.IsSymbolic())
            {
                head = head.GetTarget();
                return(head.GetName().Equals(source.GetName()));
            }
            return(false);
        }
Esempio n. 4
0
		/// <exception cref="System.IO.IOException"></exception>
		private void Delete(RefUpdate @ref, RefUpdate.Result expected, bool exists, bool 
			removed)
		{
			NUnit.Framework.Assert.AreEqual(exists, db.GetAllRefs().ContainsKey(@ref.GetName()));
			NUnit.Framework.Assert.AreEqual(expected, @ref.Delete());
			NUnit.Framework.Assert.AreEqual(!removed, db.GetAllRefs().ContainsKey(@ref.GetName()));
		}
Esempio n. 5
0
 private bool RenameLog(RefUpdate src, RefUpdate dst)
 {
     FilePath srcLog = refdb.GetLogWriter().LogFor(src.GetName());
     FilePath dstLog = refdb.GetLogWriter().LogFor(dst.GetName());
     if (!srcLog.Exists())
     {
         return true;
     }
     if (!Rename(srcLog, dstLog))
     {
         return false;
     }
     try
     {
         int levels = RefDirectory.LevelsIn(src.GetName()) - 2;
         RefDirectory.Delete(srcLog, levels);
         return true;
     }
     catch (IOException)
     {
         Rename(dstLog, srcLog);
         return false;
     }
 }
Esempio n. 6
0
        private bool LinkHEAD(RefUpdate target)
        {
            try
            {
                RefUpdate u = ((RefDirectoryUpdate)refdb.NewUpdate(Constants.HEAD, false));
                u.DisableRefLog();
                switch (u.Link(target.GetName()))
                {
                    case RefUpdate.Result.NEW:
                    case RefUpdate.Result.FORCED:
                    case RefUpdate.Result.NO_CHANGE:
                    {
                        return true;
                    }

                    default:
                    {
                        return false;
                        break;
                    }
                }
            }
            catch (IOException)
            {
                return false;
            }
        }