private bool renameLog(RefUpdate src, RefUpdate dst)
        {
            FileInfo srcLog = _refdb.logFor(src.getName());
            FileInfo dstLog = _refdb.logFor(dst.getName());

            if (!srcLog.Exists)
            {
                return(true);
            }

            if (!rename(srcLog.FullName, dstLog.FullName))
            {
                return(false);
            }

            // There be dragons



            try
            {
                int levels = RefDirectory.levelsIn(src.getName()) - 2;
                RefDirectory.delete(srcLog, levels);
                return(true);
            }
            catch (IOException)
            {
                rename(dstLog.FullName, srcLog.FullName);
                return(false);
            }
        }
예제 #2
0
        /// <summary>
        /// Initialize a new rename operation.
        /// </summary>
        /// <param name="src">operation to read and delete the source.</param>
        /// <param name="dst">operation to create (or overwrite) the destination.</param>
        protected RefRename(RefUpdate src, RefUpdate dst) {
            source = src;
            destination = dst;

            Repository repo = destination.getRepository();
            string cmd = "";
            if (source.getName().StartsWith(Constants.R_HEADS)
                && destination.getName().StartsWith(Constants.R_HEADS))
                cmd = "Branch: ";
            setRefLogMessage(cmd + "renamed "
                             + repo.ShortenRefName(source.getName()) + " to "
                             + repo.ShortenRefName(destination.getName()));
        }
예제 #3
0
        /// <summary>
        /// Initialize a new rename operation.
        /// </summary>
        /// <param name="src">operation to read and delete the source.</param>
        /// <param name="dst">operation to create (or overwrite) the destination.</param>
        protected RefRename(RefUpdate src, RefUpdate dst)
        {
            source      = src;
            destination = dst;

            Repository repo = destination.getRepository();
            string     cmd  = "";

            if (source.getName().StartsWith(Constants.R_HEADS) &&
                destination.getName().StartsWith(Constants.R_HEADS))
            {
                cmd = "Branch: ";
            }
            setRefLogMessage(cmd + "renamed "
                             + repo.ShortenRefName(source.getName()) + " to "
                             + repo.ShortenRefName(destination.getName()));
        }
예제 #4
0
        /// <returns>
        /// true if the {@code Constants#HEAD} reference needs to be linked
        /// to the new destination name.
        /// </returns>
        protected bool needToUpdateHEAD()
        {
            Ref head = source.getRefDatabase().getRef(Constants.HEAD);

            if (head.isSymbolic())
            {
                head = head.getTarget();
                return(head.getName().Equals(source.getName()));
            }
            return(false);
        }
        private bool linkHEAD(RefUpdate target)
        {
            try
            {
                RefUpdate u = _refdb.newUpdate(Constants.HEAD, false);
                u.disableRefLog();
                switch (u.link(target.getName()))
                {
                case RefUpdate.RefUpdateResult.NEW:
                case RefUpdate.RefUpdateResult.FORCED:
                case RefUpdate.RefUpdateResult.NO_CHANGE:
                    return(true);

                default:
                    return(false);
                }
            }
            catch (IOException)
            {
                return(false);
            }
        }
        private bool renameLog(RefUpdate src, RefUpdate dst)
        {
            FileInfo srcLog = _refdb.logFor(src.getName());
            FileInfo dstLog = _refdb.logFor(dst.getName());

            if (!srcLog.Exists)
                return true;

            if (!rename(srcLog.FullName, dstLog.FullName))
                return false;

            // There be dragons

            try
            {
                int levels = RefDirectory.levelsIn(src.getName()) - 2;
                RefDirectory.delete(srcLog, levels);
                return true;
            }
            catch (IOException)
            {
                rename(dstLog.FullName, srcLog.FullName);
                return false;
            }
        }
 private bool linkHEAD(RefUpdate target)
 {
     try
     {
         RefUpdate u = _refdb.newUpdate(Constants.HEAD, false);
         u.disableRefLog();
         switch (u.link(target.getName()))
         {
             case RefUpdate.RefUpdateResult.NEW:
             case RefUpdate.RefUpdateResult.FORCED:
             case RefUpdate.RefUpdateResult.NO_CHANGE:
                 return true;
             default:
                 return false;
         }
     }
     catch (IOException e)
     {
         return false;
     }
 }