internal static unsafe Uri Utf8_PtrToUri(sbyte *ptr, SvnNodeKind nodeKind) { if (ptr == null) { return(null); } var url = Utf8_PtrToString(ptr); if (url == null) { return(null); } if (nodeKind == SvnNodeKind.Directory && !url.EndsWith("/", StringComparison.Ordinal)) { url += "/"; } if (Uri.TryCreate(url, UriKind.Absolute, out var uri)) { return(uri); } return(null); }
public void RefreshItem(SvnItem item, SvnNodeKind nodeKind) { if (item == null) { throw new ArgumentNullException("item"); } RefreshPath(item.FullPath, nodeKind); var updateItem = (ISvnItemUpdate)item; if (!updateItem.IsStatusClean()) { // Ok, the status update did not refresh the item requesting to be refreshed // That means the item is not here or RefreshPath would have added it SvnItem other; if (Map.TryGetValue(item.FullPath, out other) && other != item) { updateItem.RefreshTo(other); // This item is no longer current; but we have the status anyway } else { Debug.Assert(false, "RefreshPath did not deliver up to date information", "The RefreshPath public api promises delivering up to date data, but none was received"); updateItem.RefreshTo(item.Exists ? NoSccStatus.NotVersioned : NoSccStatus.NotExisting, SvnNodeKind.Unknown); } } Debug.Assert(updateItem.IsStatusClean(), "The item requesting to be updated is updated"); }
private static string[] getItems(SvnClient client, SvnTarget folderTarget, SvnNodeKind tipoObjeto) { List <String> filesFound = new List <String>(); Collection <SvnListEventArgs> listResults; if (client.GetList(folderTarget, out listResults)) { foreach (SvnListEventArgs item in listResults) { if (item.Entry.NodeKind == tipoObjeto) { if (!String.IsNullOrEmpty(item.Path)) { filesFound.Add(item.Path); } } } return(filesFound.ToArray()); } else { throw new Exception("Failed to retrieve files via SharpSvn"); } }
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(); }
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); }
GitStatusData(NoSccStatus noSccStatus) { // TODO: Complete member initialization //this.noSccStatus = noSccStatus; _indexStatus = GitStatus.Normal; _workStatus = GitStatus.Normal; _kind = SvnNodeKind.Unknown; }
public PropertyDialog(SvnPropertyValue editItem, SvnNodeKind currentNodeKind) { InitializeComponent(); // Dialog is in Edit mode if the "existingItem" is not null. this._existingItem = editItem; _currentNodeKind = currentNodeKind; InitializeEditors(); }
private RepositoryTreeNode EnsureNodeUri(Uri uri, Uri repositoryUri, SvnNodeKind kind) { Uri nUri = SvnTools.GetNormalizedUri(uri); RepositoryTreeNode tn; if (!_nodeMap.TryGetValue(nUri, out tn)) { Uri parentUri = new Uri(uri, kind == SvnNodeKind.Directory ? "../" : "./"); if (parentUri == uri) { return(null); } RepositoryTreeNode parent = EnsureNodeUri(parentUri, repositoryUri, SvnNodeKind.Directory); if (parent != null) { tn = new RepositoryTreeNode(new SvnOrigin(uri, repositoryUri)); string name = uri.ToString(); tn.Text = tn.Origin.Target.FileName; if (IconMapper != null) { if (kind == SvnNodeKind.Directory) { tn.IconIndex = IconMapper.DirectoryIcon; } else { tn.IconIndex = IconMapper.GetIconForExtension(Path.GetExtension(name)); } } _nodeMap.Add(nUri, tn); tn.Preload(kind); SortedAddNode(parent.Nodes, tn); if (!parent.IsExpanded && IsLoading(nUri)) { parent.LoadExpand(); tn.EnsureVisible(); } else if (IsLoading(nUri)) { tn.EnsureVisible(); } } } return(tn); }
static string GetKindString(SvnNodeKind kind) { switch (kind) { case SvnNodeKind.Directory: return "directory "; case SvnNodeKind.File: return "file "; default: return null; } }
public SvnItem(string fullPath, NoSccStatus status, SvnNodeKind nodeKind) : base(fullPath) { if (status == null) { throw new ArgumentNullException("status"); } _enqueued = true; RefreshTo(status, nodeKind); _enqueued = false; }
void InitializeFromKind(SvnNodeKind nodeKind) { switch (nodeKind) // We assume the caller checked this for us { case SvnNodeKind.File: SetState(SvnItemState.IsDiskFile | SvnItemState.Exists, SvnItemState.IsDiskFolder); break; case SvnNodeKind.Directory: SetState(SvnItemState.IsDiskFolder | SvnItemState.Exists, SvnItemState.IsDiskFile | SvnItemState.ReadOnly | SvnItemState.MustLock); break; } }
public SvnItem(ISvnStatusCache context, string fullPath, NoSccStatus status, SvnNodeKind nodeKind) : base(fullPath) { if (context == null) { throw new ArgumentNullException("context"); } _context = context; _enqueued = true; RefreshTo(status, nodeKind); _enqueued = false; }
public SimplifiedSvnChangeItem(BinaryReader binaryReader) { Revision = binaryReader.ReadInt64(); if (binaryReader.ReadBoolean()) { Path = binaryReader.ReadString(); } else { Path = null; } if (binaryReader.ReadBoolean()) { CopyFromPath = binaryReader.ReadString(); } else { CopyFromPath = null; } CopyFromRevision = binaryReader.ReadInt64(); byte act = binaryReader.ReadByte(); byte nodki = binaryReader.ReadByte(); switch (nodki) { case 1: NodeKind = SvnNodeKind.Directory; break; case 2: NodeKind = SvnNodeKind.File; break; case 3: NodeKind = SvnNodeKind.SymbolicLink; break; case 4: NodeKind = SvnNodeKind.None; break; case 5: NodeKind = SvnNodeKind.Unknown; break; default: NodeKind = SvnNodeKind.Unknown; break; } switch (act) { case 1: Action = SvnChangeAction.Add; break; case 2: Action = SvnChangeAction.Modify; break; case 3: Action = SvnChangeAction.Replace; break; case 4: Action = SvnChangeAction.Delete; break; default: Action = SvnChangeAction.None; break; } }
private FileType ConvertFrom(SvnNodeKind nodeKind) { switch (nodeKind) { case SvnNodeKind.File: return(FileType.Text); case SvnNodeKind.Directory: return(FileType.Directory); default: return(FileType.None); } }
static string GetKindString(SvnNodeKind kind) { switch (kind) { case SvnNodeKind.Directory: return("directory "); case SvnNodeKind.File: return("file "); default: return(null); } }
public GitStatusData(GitStatusEventArgs status) { if (status == null) { throw new ArgumentNullException("status"); } _conflicted = status.Conflicted; _indexStatus = status.IndexStatus; _workStatus = status.WorkingDirectoryStatus; _ignored = status.Ignored; _conflicted = status.Conflicted; _kind = (SvnNodeKind)(int)status.NodeKind; _modified = status.IndexModified || status.WorkingDirectoryModified; }
internal void Preload(SvnNodeKind kind) { if (kind == SvnNodeKind.Directory) { if (Nodes.Count == 0 && _dummy == null) { _dummy = new RepositoryTreeNode(RawUri, true); _dummy.Name = _dummy.Text = "<dummy>"; Nodes.Add(_dummy); } } else { _loaded = true; } }
internal unsafe void Ensure() { if (_ensured || _status == null) { return; } _ensured = true; svn_wc_status2_t.__Internal *status2; var error = libsvnsharp_wc_private.svn_wc__status2_from_3( (void **)&status2, svn_wc_status3_t.__CreateInstance(_status.backwards_compatibility_baton), _client.CtxHandle.wc_ctx, _status.local_abspath, _pool.Handle, _pool.Handle); if (error != null) { throw SvnException.Create(error); } var entry = svn_wc_entry_t.__CreateInstance(status2->entry); _entry = entry; _revision = entry.revision; _nodeKind = (SvnNodeKind)entry.kind; _schedule = (SvnSchedule)entry.schedule; _copied = entry.copied; _deleted = entry.deleted; _absent = entry.absent; _incomplete = entry.incomplete; _copyFromRev = entry.copyfrom_rev; _textTime = SvnBase.DateTimeFromAprTime(entry.text_time); _lastChangeRev = entry.cmt_rev; _lastChangeTime = SvnBase.DateTimeFromAprTime(entry.cmt_date); _lockTime = SvnBase.DateTimeFromAprTime(entry.lock_creation_date); _hasProperties = entry.has_props; _hasPropertyChanges = entry.has_prop_mods; _wcSize = entry.working_size; _keepLocal = entry.keep_local; _depth = (SvnDepth)entry.depth; }
internal static SvnKind ToSvnKind(this SvnNodeKind nodeKind) { switch (nodeKind) { case SvnNodeKind.None: return(SvnKind.None); case SvnNodeKind.File: return(SvnKind.File); case SvnNodeKind.Directory: return(SvnKind.Directory); case SvnNodeKind.SymbolicLink: return(SvnKind.SymbolicLink); default: return(SvnKind.Unknown); } }
void RefreshTo(NoSccStatus status, SvnNodeKind nodeKind) { _cookie = NextCookie(); _statusDirty = XBool.False; SvnItemState set = SvnItemState.None; SvnItemState unset = SvnItemState.Modified | SvnItemState.Added | SvnItemState.HasCopyOrigin | SvnItemState.Deleted | SvnItemState.ContentConflicted | SvnItemState.Ignored | SvnItemState.Obstructed | SvnItemState.Replaced | SvnItemState.Versioned | SvnItemState.SvnDirty | SvnItemState.PropertyModified | SvnItemState.PropertiesConflicted | SvnItemState.Conflicted | SvnItemState.Obstructed | SvnItemState.MustLock | SvnItemState.IsWCRoot | SvnItemState.HasProperties | SvnItemState.HasLockToken | SvnItemState.HasCopyOrigin | SvnItemState.MovedHere; switch (status) { case NoSccStatus.NotExisting: SetState(set, SvnItemState.Exists | SvnItemState.ReadOnly | SvnItemState.IsDiskFile | SvnItemState.IsDiskFolder | SvnItemState.Versionable | unset); _status = SvnStatusData.NotExisting; break; case NoSccStatus.NotVersionable: unset |= SvnItemState.Versionable; goto case NoSccStatus.NotVersioned; // fall through case NoSccStatus.NotVersioned: SetState(SvnItemState.Exists | set, SvnItemState.None | unset); _status = SvnStatusData.NotVersioned; break; case NoSccStatus.Unknown: default: SetDirty(set | unset); _statusDirty = XBool.True; break; } InitializeFromKind(nodeKind); }
protected SimplifiedSvnChangeItem(SerializationInfo info, StreamingContext context) { Revision = info.GetInt64("rev"); CopyFromRevision = info.GetInt64("cfr"); Path = info.GetString("path"); CopyFromPath = info.GetString("cfp"); byte nodki = info.GetByte("nodki"); byte act = info.GetByte("act"); switch (nodki) { case 1: NodeKind = SvnNodeKind.Directory; break; case 2: NodeKind = SvnNodeKind.File; break; case 3: NodeKind = SvnNodeKind.SymbolicLink; break; case 4: NodeKind = SvnNodeKind.None; break; case 5: NodeKind = SvnNodeKind.Unknown; break; default: NodeKind = SvnNodeKind.Unknown; break; } switch (act) { case 1: Action = SvnChangeAction.Add; break; case 2: Action = SvnChangeAction.Modify; break; case 3: Action = SvnChangeAction.Replace; break; case 4: Action = SvnChangeAction.Delete; break; default: Action = SvnChangeAction.None; break; } }
public PropertyEditorDialog(Uri target, SvnRevision revision, bool revisionProps) : this(revisionProps ? string.Format(PropertyEditStrings.RevisionXPropertiesFromY, revision, target) : target.ToString()) { _currentNodeKind = SvnNodeKind.None; _revisionProps = revisionProps; }
public PropertyEditorDialog(SvnUriTarget target, bool revisionProps) : this(target.Uri, target.Revision, revisionProps) { _currentNodeKind = SvnNodeKind.None; _revisionProps = revisionProps; }
public PropertyEditorDialog(SvnItem svnItem) : this(svnItem.FullPath) { _currentNodeKind = svnItem.NodeKind; }
private static RepositoryItemNodeKind SvnNodeKind2ItemNodeKind(SvnNodeKind svnNodeKind) { switch (svnNodeKind) { case SvnNodeKind.File: return RepositoryItemNodeKind.File; case SvnNodeKind.Directory: return RepositoryItemNodeKind.Directory; } return RepositoryItemNodeKind.Unknown; }
/// <summary> /// Gets the kind of the allowed node. /// </summary> /// <returns></returns> /// <remarks>This code assumes .File and .Directory are bitflags</remarks> public virtual bool AllowNodeKind(SvnNodeKind kind) { return true; }
public override bool AllowNodeKind(SvnNodeKind kind) { return kind == SvnNodeKind.Directory; }
public SvnItem CreateItem(string fullPath, NoSccStatus status, SvnNodeKind nodeKind) { return(new SvnItem(fullPath, status, nodeKind)); }
GitItem CreateItem(string fullPath, NoSccStatus status, SvnNodeKind nodeKind) { return(new GitItem(this, fullPath, status, nodeKind)); }
public SimplifiedSvnChangeItem(long revision, string path, SvnChangeAction action, SvnNodeKind nodeKind, string copyFromPath, long copyFromRevision) : this(revision, path, action, nodeKind) { CopyFromPath = copyFromPath; CopyFromRevision = copyFromRevision; }
public SimplifiedSvnChangeItem(long revision, string path, SvnChangeAction action, SvnNodeKind nodeKind) { Revision = revision; Path = path; Action = action; NodeKind = nodeKind; }
protected bool SvnCanAddPath(string fullpath, SvnNodeKind nodeKind) { using (SvnSccContext svn = new SvnSccContext(Context)) { // Determine if we could add fullname if (!svn.CouldAdd(fullpath, nodeKind)) { if (svn.BelowAdminDir(fullpath)) _batchErrors.Add(string.Format(Resources.SvnPathXBlocked, fullpath)); else _batchErrors.Add(string.Format(Resources.PathXBlocked, fullpath)); return false; } else return true; } }
void ISvnItemUpdate.RefreshTo(NoSccStatus status, SvnNodeKind nodeKind) { Debug.Assert(status != NoSccStatus.Unknown); _ticked = false; RefreshTo(status, nodeKind); }
public override bool AllowNodeKind(SvnNodeKind kind) { return(kind == SvnNodeKind.File); }
/// <summary> /// Refreshes the specified path using the specified depth /// </summary> /// <param name="path">A normalized path</param> /// <param name="pathKind"></param> /// <param name="depth"></param> /// <remarks> /// If the path is a file and depth is greater that <see cref="SvnDepth.Empty"/> the parent folder is walked instead. /// /// <para>This method guarantees that after calling it at least one up-to-date item exists /// in the statusmap for <paramref name="path"/>. If we can not find information we create /// an unspecified item /// </para> /// </remarks> void RefreshPath(string path, SvnNodeKind pathKind) { if (string.IsNullOrEmpty(path)) { throw new ArgumentNullException("path"); } var walkPath = path; var walkingDirectory = false; switch (pathKind) { case SvnNodeKind.Directory: walkingDirectory = true; break; case SvnNodeKind.File: walkPath = SvnTools.GetNormalizedDirectoryName(path); walkingDirectory = true; break; default: try { if (File.Exists(path)) // ### Not long path safe { pathKind = SvnNodeKind.File; goto case SvnNodeKind.File; } } catch (PathTooLongException) { /* Fall through */ } break; } var args = new SvnStatusArgs(); args.Depth = SvnDepth.Children; args.RetrieveAllEntries = true; args.RetrieveIgnoredEntries = true; args.ThrowOnError = false; lock (_lock) { ISvnDirectoryUpdate updateDir; SvnItem walkItem = null; // We get more information for free, lets use that to update other items DirectoryMap.TryGetValue(walkPath, out var directory); if (null != directory) { updateDir = directory; updateDir.TickAll(); } else { // No existing directory instance, let's create one directory = new SvnDirectory(walkPath); updateDir = directory = GetDirectory(walkPath); DirectoryMap[walkPath] = directory; } bool ok; var statSelf = false; var noWcAtAll = false; // Don't retry file open/read operations on failure. These would only delay the result // (default number of delays = 100) using (new SharpSvn.Implementation.SvnFsOperationRetryOverride(0)) { ok = _client.Status(walkPath, args, RefreshCallback); } if (directory != null) { walkItem = directory.Directory; // Might have changed via casing } if (!statSelf && null != walkItem) { if (((ISvnItemUpdate)walkItem).ShouldRefresh()) { statSelf = true; } else if (walkingDirectory && !walkItem.IsVersioned) { statSelf = true; } } if (statSelf) { // Svn did not stat the items for us.. Let's make something up if (walkingDirectory) { StatDirectory(walkPath, directory, noWcAtAll); } else { // Just stat the item passed and nothing else in the Depth.Empty case if (walkItem == null) { var truepath = SvnTools.GetTruePath(walkPath); // Gets the on-disk casing if it exists StoreItem(walkItem = CreateItem(truepath ?? walkPath, (truepath != null) ? NoSccStatus.NotVersioned : NoSccStatus.NotExisting, SvnNodeKind.Unknown)); } else { ((ISvnItemUpdate)walkItem).RefreshTo(walkItem.Exists ? NoSccStatus.NotVersioned : NoSccStatus.NotExisting, SvnNodeKind.Unknown); } } } if (directory != null) { foreach (ISvnItemUpdate item in directory) { if (item.IsItemTicked()) // These items were not found in the stat calls { item.RefreshTo(NoSccStatus.NotExisting, SvnNodeKind.Unknown); } } if (updateDir.ScheduleForCleanup) { ScheduleForCleanup(directory); // Handles removing already deleted items } // We keep them cached for the current command only } SvnItem pathItem; // We promissed to return an updated item for the specified path; check if we updated it if (!Map.TryGetValue(path, out pathItem)) { // We did not; it does not even exist in the cache StoreItem(pathItem = CreateItem(path, NoSccStatus.NotExisting)); if (directory != null) { updateDir.Store(pathItem); ScheduleForCleanup(directory); } } else { ISvnItemUpdate update = pathItem; if (!update.IsStatusClean()) { update.RefreshTo(NoSccStatus.NotExisting, SvnNodeKind.Unknown); // We did not see it in the walker if (directory != null) { ((ISvnDirectoryUpdate)directory).Store(pathItem); ScheduleForCleanup(directory); } } } } }
public PropertyDialog(SvnNodeKind currentNodeKind) : this(null, currentNodeKind) { }
/// <summary> /// Determines all directories OR files at <url> /// </summary> /// <param name="url">URL of the SVN Repository</param> /// <returns>List of directories or files. Null if url is invalid.</returns> /// //TODO: Liste<string, string> mit lokalem pfad und tatsächlichem pfad (svn:external) //-> artifact to clean = lokales verzeichnis //-> watermark = tatsächliches verzeichnis public Dictionary <string, string> GetItems(string svnUrl, ItemType itemType, bool recursive, string versionSpec) { SvnNodeKind searchedItemType = SvnNodeKind.Unknown; if (itemType == ItemType.Directory) { searchedItemType = SvnNodeKind.Directory; } else if (itemType == ItemType.File) { searchedItemType = SvnNodeKind.File; } SvnListArgs args = new SvnListArgs(); args.Revision = ConvertToRevsion(versionSpec); args.IncludeExternals = true; if (recursive) { args.Depth = SvnDepth.Infinity; } else { args.Depth = SvnDepth.Children; } var svnRootPath = _svn.GetRepositoryRoot(new Uri(svnUrl)); Collection <SvnListEventArgs> contents; Dictionary <string, string> ret = new Dictionary <string, string>(); try { if (_svn.GetList(new Uri(svnUrl), args, out contents)) { foreach (SvnListEventArgs item in contents) { //first entry is always empty if (!string.IsNullOrEmpty(item.Path) && item.Entry.NodeKind == searchedItemType) { if (string.IsNullOrEmpty(item.ExternalTarget)) { ret.Add(string.Format("{0}/{1}", svnUrl, item.Path), string.Format("{0}/{1}", svnUrl, item.Path)); } else { //Substring cuts the obosolte / at beginning //ret.Add(string.Format("{0}{1}/{2}", svnRootPath, item.BasePath.Substring(1), item.Path)); ret.Add(string.Format("{0}{1}/{2}", svnRootPath, item.BasePath.Substring(1), item.Path), string.Format("{0}/{1}/{2}", svnUrl, item.ExternalTarget, item.Path)); } } } } return(ret); } catch (SvnFileSystemException) { return(ret); } }
public override bool AllowNodeKind(SvnNodeKind kind) { return kind == SvnNodeKind.File; }