Пример #1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="SvnStatusResult"/> class.
        /// </summary>
        /// <param name="repositoryId">The UUID of the Subversion repository.</param>
        /// <param name="repositoryRoot">The repository root Uri.</param>
        /// <param name="lastChangedAuthor">The author of the last revision.</param>
        /// <param name="revision">The revision of the node.</param>
        /// <param name="lastChangedRevision">The last changed revision of the node.</param>
        /// <param name="uri">The full Uri of the node.</param>
        /// <param name="path">The path of the file. The local path if requisting working version,
        /// otherwise the name of the file at the specified version.</param>
        /// <param name="fullPath">The path in a normalized format.</param>
        /// <param name="svnStatus">The status of the Subversion node.</param>
        public SvnStatusResult(
            Guid repositoryId,
            Uri repositoryRoot,
            string lastChangedAuthor,
            long revision,
            long lastChangedRevision,
            Uri uri,
            string path,
            string fullPath,
            SvnStatus svnStatus)
        {
#pragma warning disable SA1123 // Do not place regions within elements
            #region DupFinder Exclusion
#pragma warning restore SA1123 // Do not place regions within elements

            repositoryRoot.NotNull(nameof(repositoryRoot));
            uri.NotNull(nameof(uri));
            path.NotNull(nameof(path));

            RepositoryId        = repositoryId;
            RepositoryRoot      = repositoryRoot;
            LastChangedAuthor   = lastChangedAuthor;
            LastChangedRevision = lastChangedRevision;
            Revision            = revision;
            Uri       = uri;
            Path      = path;
            FullPath  = fullPath;
            SvnStatus = svnStatus;

            #endregion
        }
Пример #2
0
        public AnkhStatus(SvnStatusEventArgs args)
        {
            if (args == null)
                throw new ArgumentNullException("args");

            _nodeKind = args.NodeKind;
            _localContentStatus = args.LocalContentStatus;
            _localCopied = args.LocalCopied;
            _localPropertyStatus = args.LocalPropertyStatus;
            _uri = args.Uri;

            if (args.WorkingCopyInfo != null)
            {
                _lastChangeTime = args.WorkingCopyInfo.LastChangeTime;
                _lastChangeRevision = args.WorkingCopyInfo.LastChangeRevision;
                _lastChangeAuthor = args.WorkingCopyInfo.LastChangeAuthor;
                _revision = args.WorkingCopyInfo.Revision;
                _changeList = args.WorkingCopyInfo.ChangeList;
                _localLocked = args.WorkingCopyInfo.LockToken != null;
            }

            _treeConflict = args.TreeConflict;
            if(_treeConflict != null)
                _treeConflict.Detach();
        }
Пример #3
0
        private StateIcon GetIcon(SvnStatusEventArgs status)
        {
            // TODO: Handle more special cases
            SvnStatus st = status.LocalContentStatus;

            bool localModified  = IsMod(status.LocalContentStatus) || IsMod(status.LocalPropertyStatus);
            bool remoteModified = IsMod(status.RemoteContentStatus) || IsMod(status.RemotePropertyStatus);

            if (localModified && remoteModified)
            {
                return(StateIcon.Collision);
            }
            else if (localModified)
            {
                return(StateIcon.Outgoing);
            }
            else if (remoteModified)
            {
                return(StateIcon.Incoming);
            }
            else
            {
                return(StateIcon.Blank);
            }
        }
Пример #4
0
        public SvnStatusData(SvnStatusEventArgs status)
        {
            if (status == null)
            {
                throw new ArgumentNullException("status");
            }

            _nodeKind            = status.NodeKind;
            _localNodeStatus     = status.LocalNodeStatus;
            _localTextStatus     = status.LocalTextStatus;
            _localPropertyStatus = status.LocalPropertyStatus;
            _localCopied         = status.LocalCopied;
            _uri             = status.Uri;
            _localFileExists = (status.FileLength >= 0);

            if (status.Versioned)
            {
                _lastChangeTime     = status.LastChangeTime;
                _lastChangeRevision = status.LastChangeRevision;
                _lastChangeAuthor   = status.LastChangeAuthor;
                _revision           = status.Revision;
                _changeList         = status.ChangeList;
                _localLocked        = status.LocalLock != null;
            }

            _conflicted = status.Conflicted;
            _movedHere  = (status.MovedFrom != null);
            _movedAway  = (status.MovedTo != null);
        }
Пример #5
0
 /// <summary>
 /// Create non-locked, non-copied item with status specified
 /// </summary>
 /// <param name="allStatuses"></param>
 private SvnStatusData(SvnStatus allStatuses)
 {
     _localNodeStatus     = allStatuses;
     _localTextStatus     = SvnStatus.None;
     _localPropertyStatus = SvnStatus.None;
     //_localLocked = false;
     //_localCopied = false;
 }
Пример #6
0
        private LocalItemStatus ToStatus(SvnStatus svn)
        {
            LocalItemStatus status;

            if (!Enum.TryParse(svn.ToString(), true, out status))
            {
                status = LocalItemStatus.Unknown;
            }
            return(status);
        }
Пример #7
0
        private bool IsMod(SvnStatus svnStatus)
        {
            switch (svnStatus)
            {
            case SvnStatus.None:
            case SvnStatus.Normal:
                return(false);

            default:
                return(true);
            }
        }
        public void SvnStatusCommand()
        {
            SvnStatus    task      = new SvnStatus();
            const string localPath = @"c:\code";

            task.LocalPath = localPath;

            string expectedCommand = String.Format("status \"{0}\" --xml --non-interactive --no-auth-cache", localPath);
            string actualCommand   = TaskUtility.GetToolTaskCommand(task);

            Assert.AreEqual(expectedCommand, actualCommand);
        }
Пример #9
0
        public void SvnStatusCommand()
        {
            var          context   = new Cake.VersionReader.Tests.Fakes.FakeCakeContext();
            SvnStatus    task      = new SvnStatus(context.CakeContext);
            const string localPath = @"c:\code";

            task.LocalPath = localPath;

            string expectedCommand = String.Format("status \"{0}\" --xml --non-interactive --no-auth-cache", localPath);
            string actualCommand   = TaskUtility.GetToolTaskCommand(task);

            Assert.AreEqual(expectedCommand, actualCommand);
        }
Пример #10
0
        private static FileStatus MapStatus(SvnStatus svnStatus)
        {
            switch (svnStatus)
            {
            case SvnStatus.Incomplete:
                break;

            case SvnStatus.External:
                break;

            case SvnStatus.Obstructed:
                break;

            case SvnStatus.Ignored:
                return(FileStatus.New);

            case SvnStatus.Conflicted:
            case SvnStatus.Merged:
            case SvnStatus.Modified:
                return(FileStatus.Modified);

            case SvnStatus.Replaced:
                return(FileStatus.New);

            case SvnStatus.Deleted:
                return(FileStatus.Modified);    // not sure

            case SvnStatus.Missing:
                return(FileStatus.NotExist);

            case SvnStatus.Added:
                return(FileStatus.New);

            case SvnStatus.Normal:
                break;

            case SvnStatus.NotVersioned:
                return(FileStatus.New);

            case SvnStatus.None:
                return(FileStatus.NotExist);

            case SvnStatus.Zero:
                break;

            default:
                throw new ArgumentOutOfRangeException(nameof(svnStatus), svnStatus, null);
            }

            throw new ArgumentOutOfRangeException(nameof(svnStatus), svnStatus, null);
        }
Пример #11
0
        static StatusKind ToStatusKind(SvnStatus kind)
        {
            switch (kind)
            {
            case SvnStatus.Added:
                return(StatusKind.Added);

            case SvnStatus.Conflicted:
                return(StatusKind.Conflicted);

            case SvnStatus.Deleted:
                return(StatusKind.Deleted);

            case SvnStatus.External:
                return(StatusKind.External);

            case SvnStatus.Ignored:
                return(StatusKind.Ignored);

            case SvnStatus.Incomplete:
                return(StatusKind.Incomplete);

            case SvnStatus.Merged:
                return(StatusKind.Merged);

            case SvnStatus.Missing:
                return(StatusKind.Missing);

            case SvnStatus.Modified:
                return(StatusKind.Modified);

            case SvnStatus.Normal:
                return(StatusKind.Normal);

            case SvnStatus.NotVersioned:
                return(StatusKind.Unversioned);

            case SvnStatus.Obstructed:
                return(StatusKind.Obstructed);

            case SvnStatus.Replaced:
                return(StatusKind.Replaced);

            default:
                return(StatusKind.None);
            }
        }
Пример #12
0
        static bool IgnoreStatus(SvnStatus localContentStatus, SvnStatus remoteContentStatus)
        {
            switch (localContentStatus)
            {
            case SvnStatus.NotVersioned:
            case SvnStatus.Ignored:
            case SvnStatus.External:     // External root will be handled inside
                return(remoteContentStatus == SvnStatus.None);

            case SvnStatus.None:
                // Hide remote locked files
                return(remoteContentStatus == SvnStatus.None);

            default:
                return(false);
            }
        }
Пример #13
0
        bool ShouldIgnore(SvnItem item)
        {
            while (item != null)
            {
                SvnStatus lc = item.Status.LocalNodeStatus;
                if (lc == SvnStatus.Ignored)
                {
                    return(true);
                }
                else if (lc != SvnStatus.NotVersioned)
                {
                    return(false);
                }

                item = item.Parent;
            }
            return(false);
        }
Пример #14
0
        public static string SvnStatus(this ICakeContext context,
                                       string localPath)
        {
            List <SvnResultsStatus> results = new List <SvnResultsStatus>();
            SvnStatus task = new SvnStatus(context)
            {
                LocalPath = localPath
            };

            string actualCommand  = GetToolTaskCommand(task);
            string actualCommand2 = GetToolTaskToolPath(task);

            var bOk = task.Execute();

            if (task.StandardError.Length > 0)
            {
                //-- fail
            }

            return(task.StandardOutput);
        }
Пример #15
0
        public void Commit_CommitFile()
        {
            SvnSandBox sbox = new SvnSandBox(this);

            sbox.Create(SandBoxRepository.AnkhSvnCases);
            string WcPath = sbox.Wc;

            string filepath = Path.Combine(WcPath, "Form.cs");

            using (StreamWriter w = new StreamWriter(filepath))
                w.Write("Moo");

            SvnCommitArgs a = new SvnCommitArgs();

            a.Depth = SvnDepth.Empty;

            Assert.That(this.Client.Commit(filepath, a));

            SvnStatus status = this.GetSvnStatus(filepath);

            Assert.That(status, Is.EqualTo(SvnStatus.None), "File not committed");
        }
Пример #16
0
        private static char StatusToChar(SvnStatus status)
        {
            char c = '.';

            switch (status)
            {
            case SvnStatus.Added: c = 'A'; break;

            case SvnStatus.Conflicted: c = 'C'; break;

            case SvnStatus.Deleted: c = 'D'; break;

            case SvnStatus.External: c = 'X'; break;

            case SvnStatus.Ignored: c = 'I'; break;

            case SvnStatus.Incomplete: c = '*'; break;

            case SvnStatus.Merged: c = 'G'; break;

            case SvnStatus.Missing: c = '!'; break;

            case SvnStatus.Modified: c = 'M'; break;

            case SvnStatus.None: c = ' '; break;

            case SvnStatus.Normal: c = '-'; break;

            case SvnStatus.NotVersioned: c = '?'; break;

            case SvnStatus.Obstructed: c = 'O'; break;

            case SvnStatus.Replaced: c = 'R'; break;

            case SvnStatus.Zero: c = '0'; break;
            }
            return(c);
        }
Пример #17
0
        static VersionStatus ConvertStatus(SvnSchedule schedule, SvnStatus status)
        {
            switch (schedule)
            {
            case SvnSchedule.Add: return(VersionStatus.Versioned | VersionStatus.ScheduledAdd);

            case SvnSchedule.Delete: return(VersionStatus.Versioned | VersionStatus.ScheduledDelete);

            case SvnSchedule.Replace: return(VersionStatus.Versioned | VersionStatus.ScheduledReplace);
            }

            switch (status)
            {
            case SvnStatus.None: return(VersionStatus.Versioned);

            case SvnStatus.Normal: return(VersionStatus.Versioned);

            case SvnStatus.NotVersioned: return(VersionStatus.Unversioned);

            case SvnStatus.Modified: return(VersionStatus.Versioned | VersionStatus.Modified);

            case SvnStatus.Merged: return(VersionStatus.Versioned | VersionStatus.Modified);

            case SvnStatus.Conflicted: return(VersionStatus.Versioned | VersionStatus.Conflicted);

            case SvnStatus.Ignored: return(VersionStatus.Unversioned | VersionStatus.Ignored);

            case SvnStatus.Obstructed: return(VersionStatus.Versioned);

            case SvnStatus.Added: return(VersionStatus.Versioned | VersionStatus.ScheduledAdd);

            case SvnStatus.Deleted: return(VersionStatus.Versioned | VersionStatus.ScheduledDelete);

            case SvnStatus.Replaced: return(VersionStatus.Versioned | VersionStatus.ScheduledReplace);
            }

            return(VersionStatus.Unversioned);
        }
Пример #18
0
        public void Commit_BasicCommit()
        {
            SvnSandBox sbox = new SvnSandBox(this);

            sbox.Create(SandBoxRepository.AnkhSvnCases);
            string WcPath = sbox.Wc;

            string filepath = Path.Combine(WcPath, "Form.cs");

            using (StreamWriter w = new StreamWriter(filepath))
                w.Write("Moo");

            SvnCommitResult info;



            Assert.That(this.Client.Commit(WcPath, out info));

            Assert.That(info, Is.Not.Null);

            SvnStatus status = this.GetSvnStatus(filepath);

            Assert.That(status, Is.EqualTo(SvnStatus.None), "File not committed");
        }
Пример #19
0
 /// <summary>
 /// Create non-locked, non-copied item with status specified
 /// </summary>
 /// <param name="allStatuses"></param>
 private AnkhStatus(SvnStatus allStatuses)
 {
     _localContentStatus = allStatuses;
     _localPropertyStatus = SvnStatus.None;
     //_localLocked = false;
     //_localCopied = false;
 }
Пример #20
0
		static VersionStatus ConvertStatus (SvnSchedule schedule, SvnStatus status)
		{
			switch (schedule) {
				case SvnSchedule.Add: return VersionStatus.Versioned | VersionStatus.ScheduledAdd;
				case SvnSchedule.Delete: return VersionStatus.Versioned | VersionStatus.ScheduledDelete;
				case SvnSchedule.Replace: return VersionStatus.Versioned | VersionStatus.ScheduledReplace;
			}

			switch (status) {
				case SvnStatus.None: return VersionStatus.Versioned;
				case SvnStatus.Normal: return VersionStatus.Versioned;
				case SvnStatus.NotVersioned: return VersionStatus.Unversioned;
				case SvnStatus.Modified: return VersionStatus.Versioned | VersionStatus.Modified;
				case SvnStatus.Merged: return VersionStatus.Versioned | VersionStatus.Modified;
				case SvnStatus.Conflicted: return VersionStatus.Versioned | VersionStatus.Conflicted;
				case SvnStatus.Ignored: return VersionStatus.Unversioned | VersionStatus.Ignored;
				case SvnStatus.Obstructed: return VersionStatus.Versioned;
				case SvnStatus.Added: return VersionStatus.Versioned | VersionStatus.ScheduledAdd;
				case SvnStatus.Deleted: return VersionStatus.Versioned | VersionStatus.ScheduledDelete;
				case SvnStatus.Replaced: return VersionStatus.Versioned | VersionStatus.ScheduledReplace;
			}

			return VersionStatus.Unversioned;
		}
Пример #21
0
 static string CombineChange(SvnStatus svnStatus, SvnStatus svnStatus_2)
 {
     return(svnStatus.ToString() + " " + svnStatus_2.ToString());
 }
Пример #22
0
        // 点击“获取本地表状态”按钮
        private void btnGetLocalExcelFileState_Click(object sender, EventArgs e)
        {
            FileState fileState = Utils.GetFileState(AppValues.LocalExcelFilePath);

            if (fileState == FileState.Inexist)
            {
                MessageBox.Show("本地表已不存在,请勿在使用本工具时对母表进行操作", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            SvnException       svnException   = null;
            SvnStatusEventArgs localFileState = OperateSvnHelper.GetLocalFileState(AppValues.LocalExcelFilePath, out svnException);

            if (svnException == null)
            {
                SvnInfoEventArgs svnFileInfo = OperateSvnHelper.GetSvnFileInfo(AppValues.SvnExcelFilePath, out svnException);
                if (svnException == null)
                {
                    // 本地表的版本号
                    long localFileRevision = localFileState.LastChangeRevision;
                    // 本地表文件相较SVN中的状态
                    SvnStatus svnStatus = localFileState.LocalContentStatus;

                    // SVN中的母表的版本号
                    long svnFileRevision = svnFileInfo.LastChangeRevision;
                    // 最后修改时间
                    DateTime svnFileChangeTime = svnFileInfo.LastChangeTime;
                    // 最后修改者
                    string svnFileChangeAuthor = svnFileInfo.LastChangeAuthor;

                    StringBuilder infoStringBuilder = new StringBuilder();
                    infoStringBuilder.Append("本地路径:").AppendLine(AppValues.LocalExcelFilePath);
                    infoStringBuilder.Append("SVN路径:").AppendLine(AppValues.SvnExcelFilePath);
                    infoStringBuilder.Append("本地版本号:").AppendLine(localFileRevision.ToString());
                    infoStringBuilder.Append("SVN版本号:").AppendLine(svnFileRevision.ToString());
                    infoStringBuilder.Append("SVN版本最后修改时间:").AppendLine(svnFileChangeTime.ToLocalTime().ToString());
                    infoStringBuilder.Append("SVN版本最后修改者:").AppendLine(svnFileChangeAuthor);
                    infoStringBuilder.Append("本地文件是否被打开:").AppendLine(fileState == FileState.IsOpen ? "是" : "否");
                    if (svnFileInfo.Lock != null)
                    {
                        infoStringBuilder.AppendLine("SVN中此文件是否被锁定:是");
                        infoStringBuilder.Append("锁定者:").AppendLine(svnFileInfo.Lock.Owner);
                        infoStringBuilder.Append("锁定时间:").AppendLine(svnFileInfo.Lock.CreationTime.ToLocalTime().ToString());
                        infoStringBuilder.Append("锁定原因:").AppendLine(svnFileInfo.Lock.Comment);
                    }
                    infoStringBuilder.Append("本地文件相较SVN中的状态:").Append(svnStatus.ToString()).Append("(").Append(OperateSvnHelper.GetSvnStatusDescription(svnStatus)).AppendLine(")");
                    infoStringBuilder.Append("本地文件是否是SVN中最新版本且本地内容未作修改:").AppendLine(localFileRevision == svnFileRevision && svnStatus == SvnStatus.Normal ? "是" : "否");

                    MessageBox.Show(infoStringBuilder.ToString(), "本地表状态信息", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                else
                {
                    MessageBox.Show(string.Concat("无法获取SVN中母表信息,错误原因为:", svnException.Message), "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
            }
            else
            {
                MessageBox.Show(string.Concat("无法获取本地表状态,错误原因为:", svnException.Message), "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
        }
Пример #23
0
        private static void GetFileVersion(IVSSItem vssFile, IVSSVersion vssVersion, SvnClient svnClient)
        {
            numFilesHandled++;
            string dir = string.Format("{0}{1}", repoDIR, vssFile.Spec.Substring(1)).Replace("/", "\\");

            dir = Path.GetDirectoryName(dir);
            string  filePath    = Path.Combine(dir, vssFile.Name);
            VSSItem versionItem = vssVersion.VSSItem;

            try
            {
                migrateLog.DebugFormat("Fetching VSSItem: {0}, Version: {1}", versionItem.Spec, versionItem.VersionNumber);

                if (versionItem.Type != (int)VSSItemType.VSSITEM_PROJECT)
                {
                    versionItem.Get(ref filePath,
                                    (int)
                                    (VSSFlags.VSSFLAG_USERRONO | VSSFlags.VSSFLAG_CMPFAIL | VSSFlags.VSSFLAG_GETYES |
                                     VSSFlags.VSSFLAG_REPREPLACE | VSSFlags.VSSFLAG_TIMEMOD));

                    //kill them *.scc files worth for nothing
                    string[] files = Directory.GetFiles(dir, "*.scc", SearchOption.TopDirectoryOnly);
                    foreach (string file in files)
                    {
                        File.SetAttributes(file, FileAttributes.Normal);
                        File.Delete(file);
                    }
                }

                else
                {
                    Directory.CreateDirectory(filePath);
                }


                //This seems to fail rather often on binary files and directories, so dont let us use it on them

                if (versionItem.Type != (int)VSSItemType.VSSITEM_PROJECT)
                {
                    if (!versionItem.Binary)
                    {
                        migrateLog.DebugFormat("Diffing ...");
                        if (versionItem.get_IsDifferent(filePath))
                        {
                            migrateLog.WarnFormat(
                                "Files should not be different for version {0}; possible corruption in file {1}:{0}",
                                versionItem.VersionNumber, versionItem.Spec);
                        }
                    }
                }
            }
            catch (COMException e)
            {
                if (e.ErrorCode == -2147166575)
                {
                    // VSS file's checkbox "keep only latest version" is checked therefore no file could be fetched
                    // so that calling versionItem.Get(...) results in an exception
                    migrateLog.WarnFormat(
                        "Version {0} of file {1} not stored in VSS. File has option 'Keep only latest version' (see file's properties) enabled in VSS",
                        versionItem.VersionNumber, versionItem.Spec);
                }
                else
                {
                    throw;
                }
            }

            VssBindingRemover.RemoveBindings(filePath);

            Collection <SvnStatusEventArgs> svnStatus;

            svnClient.GetStatus(filePath, out svnStatus);

            if (svnStatus.Count == 1)
            {
                SvnStatus fileStatus = svnStatus[0].LocalContentStatus;
                if (fileStatus == SvnStatus.Normal)
                {
                    migrateLog.WarnFormat("No modification detected for {0}:{1}", vssVersion.VSSItem.Spec,
                                          vssVersion.VersionNumber);
                    return;
                }
                if (fileStatus == SvnStatus.NotVersioned || fileStatus == SvnStatus.Incomplete ||
                    fileStatus == SvnStatus.Missing)
                {
                    try
                    {
                        svnClient.Add(filePath);
                    }
                    catch (SvnException e)
                    {
                        if (!e.ToString().Contains("already under version"))
                        {
                            throw;
                        }
                    }
                }
            }
            else
            {
                //Should never get here because we're always looking for the results of an individual file; only display a message
                migrateLog.WarnFormat("Invalid svn status detected for {0}:{1}", vssVersion.VSSItem.Spec,
                                      vssVersion.VersionNumber);
                migrateLog.WarnFormat("Status count was: {0}", svnStatus.Count);
                return;
            }
            //simply continue as expected
        }
Пример #24
0
 private static char StatusToChar(SvnStatus status)
 {
     char c = '.';
     switch (status)
     {
         case SvnStatus.Added: c = 'A'; break;
         case SvnStatus.Conflicted: c = 'C'; break;
         case SvnStatus.Deleted: c = 'D'; break;
         case SvnStatus.External: c = 'X'; break;
         case SvnStatus.Ignored: c = 'I'; break;
         case SvnStatus.Incomplete: c = '*'; break;
         case SvnStatus.Merged: c = 'G'; break;
         case SvnStatus.Missing: c = '!'; break;
         case SvnStatus.Modified: c = 'M'; break;
         case SvnStatus.None: c = ' '; break;
         case SvnStatus.Normal: c = '-'; break;
         case SvnStatus.NotVersioned: c = '?'; break;
         case SvnStatus.Obstructed: c = 'O'; break;
         case SvnStatus.Replaced: c = 'R'; break;
         case SvnStatus.Zero: c = '0'; break;
     }
     return c;
 }
Пример #25
0
 static string CombineChange(SvnStatus svnStatus, SvnStatus svnStatus_2)
 {
     return svnStatus.ToString() + " " + svnStatus_2.ToString();
 }
Пример #26
0
        /// <summary>
        /// Combines the statuses to a single PendingChangeKind status for UI purposes
        /// </summary>
        /// <param name="nodeStatus">The content status.</param>
        /// <param name="textStatus"></param>
        /// <param name="propertyStatus">The property status.</param>
        /// <param name="treeConflict">if set to <c>true</c> [tree conflict].</param>
        /// <param name="item">The item or null if no on disk representation is availavke</param>
        /// <returns></returns>
        public static PendingChangeKind CombineStatus(SvnStatus nodeStatus, SvnStatus textStatus, SvnStatus propertyStatus, bool treeConflict, SvnItem item)
        {
            // item can be null!
            if (treeConflict || (item != null && item.IsTreeConflicted))
            {
                return(PendingChangeKind.TreeConflict);
            }
            else if (nodeStatus == SvnStatus.Conflicted || propertyStatus == SvnStatus.Conflicted)
            {
                return(PendingChangeKind.Conflicted);
            }

            switch (nodeStatus)
            {
            case SvnStatus.NotVersioned:
                if (item != null)
                {
                    if (item.IsIgnored)
                    {
                        return(PendingChangeKind.Ignored);
                    }
                    else if (item.InSolution)
                    {
                        return(item.IsSccExcluded ? PendingChangeKind.Ignored : PendingChangeKind.New);
                    }
                }
                return(PendingChangeKind.None);

            case SvnStatus.Modified:
                if (textStatus == SvnStatus.Modified)
                {
                    return(PendingChangeKind.Modified);
                }
                else
                {
                    break;     // Property modified
                }

            case SvnStatus.Replaced:
                return(PendingChangeKind.Replaced);

            case SvnStatus.Added:
                if (item != null && item.HasCopyableHistory)
                {
                    if (item.IsMoved)
                    {
                        if (item.Status.LocalTextStatus == SvnStatus.Normal)
                        {
                            return(PendingChangeKind.Moved);
                        }
                        else
                        {
                            return(PendingChangeKind.ModifiedMove);
                        }
                    }
                    else
                    {
                        if (item.Status.LocalTextStatus == SvnStatus.Normal)
                        {
                            return(PendingChangeKind.Copied);
                        }
                        else
                        {
                            return(PendingChangeKind.ModifiedCopy);
                        }
                    }
                }

                return(PendingChangeKind.Added);

            case SvnStatus.Deleted:
                if (item != null && item.Exists && item.InSolution && !item.IsSccExcluded)
                {
                    return(PendingChangeKind.DeletedNew);
                }
                return(PendingChangeKind.Deleted);

            case SvnStatus.Missing:
                if (item != null && item.IsCasingConflicted)
                {
                    return(PendingChangeKind.WrongCasing);
                }
                else
                {
                    return(PendingChangeKind.Missing);
                }

            case SvnStatus.Obstructed:
                return(PendingChangeKind.Obstructed);

            case SvnStatus.Incomplete:
                return(PendingChangeKind.Incomplete);

            case SvnStatus.None:
            case SvnStatus.Normal:
            case SvnStatus.Ignored:
                // No usefull status / No change
                break;

            case SvnStatus.External:
                return(PendingChangeKind.None);

            case SvnStatus.Zero:
            case SvnStatus.Conflicted:
            case SvnStatus.Merged:
            default:     // Give error on missed values
                throw new ArgumentOutOfRangeException("contentStatus", nodeStatus, "Invalid content status");
            }

            switch (propertyStatus)
            {
            case SvnStatus.Modified:
                return(PendingChangeKind.PropertyModified);

            case SvnStatus.Normal:
            case SvnStatus.None:
                // No usefull status / No change
                break;

            case SvnStatus.Zero:
            case SvnStatus.Conflicted:
            default:     // Give error on missed values
                throw new ArgumentOutOfRangeException("propertyStatus", propertyStatus, "Invalid content status");
            }

            if (item != null)
            {
                if (item.IsDocumentDirty)
                {
                    return(PendingChangeKind.EditorDirty);
                }
                else if (item.IsLocked)
                {
                    return(PendingChangeKind.LockedOnly);
                }
            }

            return(PendingChangeKind.None);
        }
Пример #27
0
    /// <summary>
    /// 获取某个本地文件相较SVN中状态的描述
    /// </summary>
    public static string GetSvnStatusDescription(SvnStatus svnStatus)
    {
        switch (svnStatus)
        {
        case SvnStatus.Zero:
            // Zero value. Never used by Subversion
            return("无法获取状态");

        case SvnStatus.None:
            // does not exist
            return("文件不存在");

        case SvnStatus.NotVersioned:
            // is not a versioned thing in this wc
            return("本地文件不被SVN管理");

        case SvnStatus.Normal:
            // exists, but uninteresting
            return("本地文件与SVN中对应版本的内容完全一致");

        case SvnStatus.Added:
            // is scheduled for addition
            return("SVN中不存在该本地文件,但在本地已将此文件标记为需要上传至SVN");

        case SvnStatus.Missing:
            // under v.c., but is missing
            return("SVN中存在此文件,但在本地已将其删除");

        case SvnStatus.Deleted:
            // scheduled for deletion
            return("已在本地将此文件标记为要在SVN中删除");

        case SvnStatus.Modified:
            // text or props have been modified
            return("本地文件相较SVN中对应版本的内容已发生变动");

        case SvnStatus.Conflicted:
            // local mods received conflicting repos mods
            return("本地文件相较SVN中对应的文件发生变动并且无法合并已引发冲突");

        case SvnStatus.Ignored:
            // is unversioned but configured to be ignored
            return("此文件被设置为SVN忽略对其管理");

        case SvnStatus.Replaced:
            // was deleted and then re-added
            return("此文件被删除后重新添加");

        case SvnStatus.Merged:
            // local mods received repos mods
            return("此文件与SVN中最新版本文件内容不同但成功合并");

        // an unversioned resource is in the way of the versioned resource
        case SvnStatus.Obstructed:
        // an unversioned path populated by an svn:externals property
        case SvnStatus.External:
        // a directory doesn't contain a complete entries list
        case SvnStatus.Incomplete:
            return("SVN状态异常");

        default:
            return(string.Empty);
        }
    }
        private static StatusKind ToStatusKind(SvnStatus kind)
        {
            switch (kind)
            {
                case SvnStatus.Added:
                    return StatusKind.Added;

                case SvnStatus.Conflicted:
                    return StatusKind.Conflicted;

                case SvnStatus.Deleted:
                    return StatusKind.Deleted;

                case SvnStatus.External:
                    return StatusKind.External;

                case SvnStatus.Ignored:
                    return StatusKind.Ignored;

                case SvnStatus.Incomplete:
                    return StatusKind.Incomplete;

                case SvnStatus.Merged:
                    return StatusKind.Merged;

                case SvnStatus.Missing:
                    return StatusKind.Missing;

                case SvnStatus.Modified:
                    return StatusKind.Modified;

                case SvnStatus.Normal:
                    return StatusKind.Normal;

                case SvnStatus.NotVersioned:
                    return StatusKind.Unversioned;

                case SvnStatus.Obstructed:
                    return StatusKind.Obstructed;

                case SvnStatus.Replaced:
                    return StatusKind.Replaced;

                default:
                    return StatusKind.None;
            }
        }
Пример #29
0
 private bool IsMod(SvnStatus svnStatus)
 {
     switch (svnStatus)
     {
         case SvnStatus.None:
         case SvnStatus.Normal:
             return false;
         default:
             return true;
     }
 }