示例#1
0
        public IEnumerator <FileVersionInfo> GetEnumerator()
        {
            int  i = 0;
            bool previousIsBranch = false;

            foreach (FileHistoryInfo historyInfo in History)
            {
                if (historyInfo.Type != HistoryInfoType.File)
                {
                    continue;
                }

                if (!previousIsBranch)
                {
                    byte[] revisionData = DXVCSHelpers.TryToDecompressData(data[i]);
                    int    version;
                    if (Diff.IsDiffs(revisionData, out version))
                    {
                        Encoding       encoding;
                        string         fileText    = DXVCSHelpers.ReadTextFromByte(revisionData, out encoding);
                        var            splitterStr = DXVCSHelpers.DetectTextSplitter(fileText);
                        byte[]         curSplitter = encoding.GetBytes(splitterStr);
                        DiffByteItem[] diffs       = Diff.BytesToDiffs(revisionData);
                        revisionData = Diff.GetDataFromDiff(previousData, diffs, curSplitter);
                    }
                    previousData = revisionData;
                }
                previousIsBranch = historyInfo.Message == "Branch";
                i++;

                yield return(new FileVersionInfo(historyInfo.Version, historyInfo.ActionDate, historyInfo.User, historyInfo.Comment, previousData));
            }
        }
示例#2
0
        static string[] GetFileLines(byte[] data)
        {
            Encoding encoding = null;
            string   text     = DXVCSHelpers.ReadTextFromByte(data, out encoding);

            return(StringsDiff.GetTextLines(text));
        }
示例#3
0
        public IEnumerator <FileVersionInfo> GetEnumerator()
        {
            int  i = 0;
            bool previousIsBranch = false;

            foreach (FileHistoryInfo historyInfo in History)
            {
                if (historyInfo.Type != HistoryInfoType.File)
                {
                    continue;
                }

                if (!previousIsBranch)
                {
                    byte[] revisionData = DXVCSHelpers.TryToDecompressData(data[i]);
                    int    version;
                    bool   binDiff;
                    if (Diff.IsDiffs(revisionData, out version, out binDiff))
                    {
                        byte[]         curSplitter;
                        DiffByteItem[] diffs = Diff.BytesToDiffs(revisionData, binDiff, out curSplitter);
                        revisionData = Diff.GetDataFromDiff(previousData, diffs, curSplitter);
                    }
                    previousData = revisionData;
                }
                previousIsBranch = historyInfo.Message == "Branch";
                i++;

                yield return(new FileVersionInfo(historyInfo.Version, historyInfo.ActionDate, historyInfo.User, historyInfo.Comment, previousData));
            }
        }
示例#4
0
        public void GetLatestVersion(string vcsFile, string fileName) {
            if (string.IsNullOrEmpty(vcsFile))
                throw new ArgumentException("vcsFile");

            if (string.IsNullOrEmpty(fileName))
                throw new ArgumentException("path");

            byte[] data = DXVCSHelpers.TryToDecompressData(service.GetFileData(vcsFile, null));
            File.WriteAllBytes(fileName, data);
        }
示例#5
0
 public bool GetLocalFileModified(FileStateInfo info, string localPath, string vcsPath, DateTime projectDate, out FileBaseInfoState fileState, DateTime lastWrite)
 {
     try {
         using (Stream fileStream = fileSystem.OpenRead(localPath)) {
             byte[] localHash  = DXVCSHelpers.GetHashMD5(fileStream);
             bool   hashEquals = DXVCSHelpers.BytesAreEquals(localHash, info.Hash);
             fileState = FileBaseInfoState.Modified;
             return(!hashEquals);
         }
     }
     catch (IOException) {
         fileState = FileBaseInfoState.Locked;
         return(false);
     }
 }
示例#6
0
        public void Get(string vcsFile, string fileName, DateTime timestamp)
        {
            if (string.IsNullOrEmpty(vcsFile))
            {
                throw new ArgumentException("vcsFile");
            }

            if (string.IsNullOrEmpty(fileName))
            {
                throw new ArgumentException("path");
            }

            byte[] data = DXVCSHelpers.TryToDecompressData(Service.GetFileData(vcsFile, timestamp));
            File.WriteAllBytes(fileName, data);
        }
示例#7
0
 void QueueAll(string id, int blockIndex, AutoResetEvent getDataEvent, AutoResetEvent decompressEvent, AutoResetEvent saveEvent,
               string[] localPath, string[] path, DateTime[] fileTime, bool[] doCheckOut, bool[] setNormal, bool[] fileExists, Queue <Exception> exceptionQueue, double step)
 {
     byte[][] data;
     try {
         try {
             do
             {
                 data = Service.GetBlockData(id, blockIndex, false);
             } while (data == null);
             decompressEvent.WaitOne();
         }
         finally {
             getDataEvent.Set();
         }
         try {
             for (int i = 0; i < data.Length; i++)
             {
                 if (data[i] == null)
                 {
                     continue;
                 }
                 data[i] = DXVCSHelpers.TryToDecompressData(data[i]);
             }
             saveEvent.WaitOne();
         }
         finally {
             decompressEvent.Set();
         }
         try {
             for (int i = 0; i < data.Length; i++)
             {
                 if (data[i] == null || localPath[i] == null || path[i] == null || doCheckOut[i])
                 {
                     if (localPath[i] != null && fileSystem.Exists(localPath[i]))
                     {
                         if (setNormal[i])
                         {
                             fileSystem.SetAttributes(localPath[i], FileAttributes.Normal);
                         }
                         else
                         {
                             fileSystem.SetAttributes(localPath[i], FileAttributes.ReadOnly);
                         }
                     }
                     continue;
                 }
                 GetLatestReplaceFile(new FileDataLocation(path[i], localPath[i], data[i]), fileTime[i], fileExists[i], null);
                 if ((setNormal[i]) && localPath[i] != null && fileSystem.Exists(localPath[i]))
                 {
                     fileSystem.SetAttributes(localPath[i], FileAttributes.Normal);
                 }
             }
         }
         finally {
             saveEvent.Set();
         }
     }
     catch (DXVCSGetNextTimeoutException) { }
     catch (Exception ex) {
         lock (exceptionQueue) {
             exceptionQueue.Enqueue(ex);
         }
     }
 }