Esempio n. 1
0
            public SvnListViewItem(SvnListEventArgs result)
            {
                Result = result;
                Text   = result.Name;
                SubItems.Add(result.Path);
                SubItems.Add(result.Entry.Revision.ToString());
                SubItems.Add(result.Entry.Author);

                var sizeUnit = "bytes";
                var size     = (decimal)result.Entry.FileSize;

                if (size > 1024)
                {
                    size /= 1024; sizeUnit = "KB";
                }
                if (size > 1024)
                {
                    size /= 1024; sizeUnit = "MB";
                }
                if (size > 1024)
                {
                    size /= 1024; sizeUnit = "GB";
                }
                size = Math.Round(size, 2);
                SubItems.Add((size > 0) ? size.ToString() + sizeUnit : string.Empty);

                SubItems.Add(result.Entry.Time.ToString("dd/MM/yyyy HH:mm:ss"));
            }
Esempio n. 2
0
        private ListViewItem GetDisplayItem(SvnListEventArgs result)
        {
            var item = new SvnListViewItem(result);

            item.ImageKey = GetFileKey(result);
            return(item);
        }
Esempio n. 3
0
        private void ExportDirectoryListItem(SvnListEventArgs e, SvnRevision revision, string destinationPath)
        {
            if (_g.StopRequested)
            {
                e.Cancel = true;
                return;
            }
            destinationPath = Path.Combine(destinationPath, e.Path);
            var  source = new SvnUriTarget(e.Uri, revision);
            bool exists;

            if (e.Entry.NodeKind == SvnNodeKind.Directory)
            {
                exists = Directory.Exists(destinationPath);
                if (!exists)
                {
                    Directory.CreateDirectory(destinationPath);
                }
            }
            else
            {
                exists = File.Exists(destinationPath);
                _g.Svn.Export(source, destinationPath, _infiniteOverwriteExport);
            }
            if (destinationPath != _g.WorkingDir)
            {
                _g.Svn.Add(destinationPath, _forceAdd);
                _g.Interaction.Trace((exists ? ActionModified : ActionCreated) + destinationPath);
            }
            CopyProperties(source, destinationPath);
        }
Esempio n. 4
0
        internal bool DeleteBranch(SvnListEventArgs selectedBranch)
        {
            try
            {
                if (selectedBranch != null)
                {
                    using (SvnClient client = new SvnClient())
                    {
                        // Bind the SharpSvn UI to our client for SSL certificate and credentials
                        SvnUIBindArgs bindArgs = new SvnUIBindArgs();
                        SvnUI.Bind(client, bindArgs);

                        SvnDeleteArgs arg = new SvnDeleteArgs();
                        arg.LogMessage = "ADMIN-0: Branch Deleted";

                        return(client.RemoteDelete(selectedBranch.Uri, arg));
                    }
                }
                return(false);
            }
            catch (Exception)
            {
                throw;
            }
        }
Esempio n. 5
0
        internal bool CreateTag(SvnListEventArgs selectedTrunk, string tagName)
        {
            try
            {
                if (selectedTrunk != null)
                {
                    using (SvnClient client = new SvnClient())
                    {
                        // Bind the SharpSvn UI to our client for SSL certificate and credentials
                        SvnUIBindArgs bindArgs = new SvnUIBindArgs();
                        SvnUI.Bind(client, bindArgs);

                        string relativeComponentPath = selectedTrunk.BaseUri.AbsoluteUri;

                        Uri tagUri = new Uri(relativeComponentPath + "tags/" + tagName);

                        SvnTarget source = SvnTarget.FromUri(selectedTrunk.Uri);

                        SvnCopyArgs arg = new SvnCopyArgs();
                        arg.CreateParents = false;
                        arg.LogMessage    = string.Format("ADMIN-0: Tag Created from Trunk");

                        return(client.RemoteCopy(source, tagUri, arg));
                    }
                }
                return(false);
            }
            catch (Exception)
            {
                throw;
            }
        }
Esempio n. 6
0
        internal bool CreateBranch(SvnListEventArgs selectedTag, string branchName)
        {
            try
            {
                if (selectedTag != null)
                {
                    using (SvnClient client = new SvnClient())
                    {
                        // Bind the SharpSvn UI to our client for SSL certificate and credentials
                        SvnUIBindArgs bindArgs = new SvnUIBindArgs();
                        SvnUI.Bind(client, bindArgs);

                        string relativeComponentPath = string.Join(string.Empty, selectedTag.BaseUri.Segments.Take(selectedTag.BaseUri.Segments.Count() - 1).ToArray());
                        string server = selectedTag.BaseUri.GetComponents(UriComponents.SchemeAndServer, UriFormat.SafeUnescaped);

                        Uri barnchUri = new Uri(server + relativeComponentPath + "branches/project/" + branchName);

                        SvnTarget source = SvnTarget.FromUri(selectedTag.Uri);

                        SvnCopyArgs arg = new SvnCopyArgs();
                        arg.CreateParents = false;
                        arg.LogMessage    = string.Format("ADMIN-0: Branch Created from Tag {0}", selectedTag.Name);

                        return(client.RemoteCopy(source, barnchUri, arg));
                    }
                }
                return(false);
            }
            catch (Exception)
            {
                throw;
            }
        }
Esempio n. 7
0
        internal SvnComponent(SvnListEventArgs component)
        {
            this.Path = component.Uri.AbsoluteUri;
            this.Name = component.Name;

            this.SetType();
        }
Esempio n. 8
0
        private string GetFileKey(SvnListEventArgs result)
        {
            var key = result.Entry.NodeKind == SvnNodeKind.File ? Path.GetExtension(result.Name) : DIR;

            if (key != DIR && !imgFileTypes.Images.ContainsKey(key))
            {
                imgFileTypes.Images.Add(key, _icons.GetFileTypeIcon(key));
            }
            return(key);
        }
Esempio n. 9
0
        public RepositoryListItem(RepositoryListView view, SharpSvn.Remote.ISvnRepositoryListItem listItem, SvnOrigin dirOrigin, IFileIconMapper iconMapper)
            : base(view)
        {
            if (listItem == null)
            {
                throw new ArgumentNullException("listItem");
            }
            else if (dirOrigin == null)
            {
                throw new ArgumentNullException("dirOrigin");
            }

            SvnDirEntry entry    = listItem.Entry;
            Uri         entryUri = listItem.Uri;

            _entry  = entry;
            _origin = new SvnOrigin(entryUri, dirOrigin);

            string name = SvnTools.GetFileName(entryUri);

            bool isFile = (entry.NodeKind == SvnNodeKind.File);

            string extension = isFile ? Path.GetExtension(name) : "";

            if (iconMapper != null)
            {
                if (isFile)
                {
                    ImageIndex = iconMapper.GetIconForExtension(extension);
                }
                else
                {
                    ImageIndex = iconMapper.DirectoryIcon;
                }
            }

            SvnLockInfo      lockInfo = null;
            SvnListEventArgs lea      = listItem as SvnListEventArgs;

            if (lea != null)
            {
                lockInfo = lea.Lock;
            }

            SetValues(
                name,
                IsFolder ? RepositoryStrings.ExplorerDirectoryName : view.Context.GetService <IFileIconMapper>().GetFileType(extension),
                entry.Revision.ToString(),
                entry.Author,
                IsFolder ? "" : entry.FileSize.ToString(),
                entry.Time.ToLocalTime().ToString("g"),
                (lockInfo != null) ? lockInfo.Owner : "");
        }
Esempio n. 10
0
        internal string GetNewTagName(SvnListEventArgs selectedTrunk)
        {
            try
            {
                string proposeName = string.Empty;
                if (selectedTrunk != null)
                {
                    string relativeComponentPath = string.Join(string.Empty, selectedTrunk.BaseUri.Segments.Take(selectedTrunk.BaseUri.Segments.Count() - 1).ToArray());
                    string server = selectedTrunk.BaseUri.GetComponents(UriComponents.SchemeAndServer, UriFormat.SafeUnescaped);

                    SvnUriTarget tagUri = new SvnUriTarget(server + relativeComponentPath + "trunk");

                    List <SvnListEventArgs> tagList = this.GetFolderList(tagUri);

                    if (tagList == null || tagList.Count <= 0)
                    {
                        proposeName = "1.0.0";
                    }
                    else
                    {
                        string tagName;
                        int    tagIndex          = 100;
                        var    tagListDescending = tagList.OrderByDescending(t => t.Name);
                        foreach (SvnListEventArgs tag in tagListDescending)
                        {
                            tagName = tag.Name.Replace(".", string.Empty);
                            if (int.TryParse(tagName, out tagIndex))
                            {
                                tagIndex++;
                                break;
                            }
                        }

                        foreach (char tagChar in tagIndex.ToString())
                        {
                            if (string.IsNullOrWhiteSpace(proposeName))
                            {
                                proposeName = tagChar.ToString();
                            }
                            else
                            {
                                proposeName += "." + tagChar;
                            }
                        }
                    }
                }
                return(proposeName);
            }
            catch (Exception)
            {
                throw;
            }
        }
Esempio n. 11
0
        public bool Validate(SvnListEventArgs result)
        {
            if (!MatchFilter(FileFilter, result.Name))
            {
                return(false);
            }
            if (!MatchFilter(AuthorFilter, result.Entry.Author))
            {
                return(false);
            }
            switch (Type)
            {
            case ValidatorType.Regex: return(_cachedRegex.IsMatch(Path.GetFileNameWithoutExtension(result.Name)));

            default: return(result.Name.IndexOf(SearchText, CaseSensitive ? StringComparison.Ordinal : StringComparison.OrdinalIgnoreCase) != -1);
            }
        }
Esempio n. 12
0
        internal string GetNewBranchName(SvnListEventArgs selectedTag, string projectName)
        {
            try
            {
                string proposeName = string.Empty;
                if (selectedTag != null)
                {
                    string relativeComponentPath = string.Join(string.Empty, selectedTag.BaseUri.Segments.Take(selectedTag.BaseUri.Segments.Count() - 1).ToArray());
                    string server = selectedTag.BaseUri.GetComponents(UriComponents.SchemeAndServer, UriFormat.SafeUnescaped);

                    SvnUriTarget barnchUri = new SvnUriTarget(server + relativeComponentPath + "branches/project");

                    List <SvnListEventArgs> branchList = this.GetFolderList(barnchUri);

                    int              count            = 1;
                    string           proposeNameIndex = selectedTag.Name + "." + count;
                    bool             newNameNotfound  = true;
                    SvnListEventArgs foundBranch;
                    while (newNameNotfound)
                    {
                        foundBranch = branchList.FirstOrDefault(b => b.Name.Contains(proposeNameIndex));
                        if (foundBranch == null)
                        {
                            newNameNotfound = false;
                        }
                        else
                        {
                            count++;
                            proposeNameIndex = selectedTag.Name + "." + count;
                        }
                    }

                    proposeName = proposeNameIndex + "_" + projectName + "_dev";
                }
                return(proposeName);
            }
            catch (Exception)
            {
                throw;
            }
        }
Esempio n. 13
0
        private void buttonDeleteProjectBranch_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                TreeViewItem selectedFolderView = treeViewComponent.SelectedItem as TreeViewItem;
                if (selectedFolderView != null)
                {
                    TreeViewItem selectedParentFolderView = this.GetSelectedTreeViewItemParent(selectedFolderView);
                    if (selectedParentFolderView != null)
                    {
                        SvnListEventArgs selectedFolder_parentFolder = selectedParentFolderView.Tag as SvnListEventArgs;

                        if (selectedFolder_parentFolder.Name == "project")
                        {
                            SvnListEventArgs selectedFolder = selectedFolderView.Tag as SvnListEventArgs;

                            MessageBoxResult result = ModernDialog.ShowMessage("[" + selectedFolder.Name + "] Are you sure?", "Branch Deleting", MessageBoxButton.YesNo);

                            if (result == MessageBoxResult.Yes)
                            {
                                if (myIfsSvn.DeleteBranch(selectedFolder))
                                {
                                    selectedParentFolderView.IsExpanded = false;
                                    selectedParentFolderView.IsExpanded = true;

                                    ModernDialog.ShowMessage("[" + selectedFolder.Name + "] Deleted.", "Branch Deleted", MessageBoxButton.OK);
                                }
                            }
                        }
                    }
                }
            }
            catch (Exception)
            {
            }
        }
Esempio n. 14
0
 internal void SetSelectedTag(SvnListEventArgs tag)
 {
     this.selectedTag        = tag;
     textBoxSelectedTag.Text = this.selectedTag.Name;
 }
Esempio n. 15
0
 private static BranchInfo MapToBranchInfo(SvnListEventArgs svnItem)
 {
     //Collection<SvnLogEventArgs> logItems;
     //var svnLogArgs = new SvnLogArgs {Limit = 3};
     //_client.GetLog(svnItem.EntryUri, svnLogArgs, out logItems);
     var branchInfo = new BranchInfo
         {
             Name = svnItem.Path,
             LastRevision =
                 new RevisionInfo
                     {
                         Author = svnItem.Entry.Author,
                         Created = svnItem.Entry.Time,
                         Revision = svnItem.Entry.Revision
                     },
             //LastRevisions = logItems.Select(MapToRevisionInfo)
         };
     return branchInfo;
 }
Esempio n. 16
0
 private static bool IsBranch(SvnListEventArgs svnItem)
 {
     return svnItem.Entry.NodeKind == SvnNodeKind.Directory &&
            !string.IsNullOrEmpty(svnItem.Path);
 }
        private void LoadStaticcompornetList(BackgroundWorker worker, DoWorkEventArgs e, SearchArguments arg)
        {
            using (SvnClient client = new SvnClient())
            {
                // Bind the SharpSvn UI to our client for SSL certificate and credentials
                SvnUIBindArgs bindArgs = new SvnUIBindArgs();
                SvnUI.Bind(client, bindArgs);

                Collection <SvnListEventArgs> componentList;
                client.GetList(arg.ComponentListUri, out componentList);

                SvnListEventArgs root = componentList.Single(c => c.Name == arg.ComponentListUri.FileName);
                componentList.Remove(root);

                double currentProgress   = 0;
                double progressIncrement = 0;
                int    itemcount         = componentList.Count();
                if (itemcount > 0)
                {
                    progressIncrement = 100.00 / itemcount;
                }

                MemoryStream ms = new MemoryStream();
                StreamReader rs;
                SvnUriTarget deployIniUrl;
                foreach (SvnListEventArgs component in componentList)
                {
                    if (worker.CancellationPending)
                    {
                        e.Cancel = true;
                    }
                    else
                    {
                        currentProgress += progressIncrement;
                        worker.ReportProgress(Convert.ToInt32(currentProgress));

                        if (string.IsNullOrWhiteSpace(component.Path) == false)
                        {
                            deployIniUrl = new SvnUriTarget(component.Uri + @"trunk/deploy.ini");

                            ms.SetLength(0);
                            if (client.Write(deployIniUrl, ms, new SvnWriteArgs()
                            {
                                ThrowOnError = false
                            }))
                            {
                                ms.Position = 0;
                                rs          = new StreamReader(ms);
                                string fileContent = rs.ReadToEnd();

                                int startIndex = fileContent.IndexOf("\r\n[Connections]\r\n");
                                if (startIndex != -1)
                                {
                                    startIndex += "\r\n[Connections]\r\n".Length;
                                    int endIndex = fileContent.IndexOf("[", startIndex);
                                    if (endIndex == -1)
                                    {
                                        endIndex = fileContent.Length;
                                    }

                                    fileContent = fileContent.Substring(startIndex, endIndex - startIndex);

                                    string[]      componentArray      = fileContent.Split(new string[] { "\r\n" }, StringSplitOptions.RemoveEmptyEntries);
                                    List <string> componentStaticList = new List <string>();
                                    foreach (string componentValue in componentArray)
                                    {
                                        if (componentValue.Contains("STATIC"))
                                        {
                                            componentStaticList.Add(componentValue.Substring(0, componentValue.IndexOf("=STATIC")).ToLowerInvariant());
                                        }
                                    }

                                    arg.ComponentDictionary.Add(component.Name, componentStaticList);
                                }
                            }
                        }
                    }
                }
            }
        }
Esempio n. 18
0
 private void Args_List(object sender, SvnListEventArgs e)
 {
     throw new NotImplementedException();
 }
Esempio n. 19
0
 private void PrintAllFile(SvnListEventArgs e, string basepath)
 {
     if (e.Entry.NodeKind == SvnNodeKind.File)
     {
         string path = (basepath + "/" + e.Path).Replace("%23", "#").Replace("%20", " ");
         Print(string.Format("{0} : {1}", e.Entry.Time, path));
         AddFileToDownload(path);
         FC++;
         UpdateStatus();
         lock (_sync)
         {
             if (exit)
                 return;
         }
     }
     if (e.Entry.NodeKind == SvnNodeKind.Directory && e.Name != "")
     {
         Collection<SvnListEventArgs> list = new Collection<SvnListEventArgs>();
         string path = basepath + "/" + e.Name.Replace("#", "%23").Replace(" ", "%20");
         client.GetList(path, out list);
         int count = 0;
         foreach (SvnListEventArgs entry in list)
         {
             if (count++ != 0) //ignore .. basefolder
                 PrintAllFile(entry, path);
             lock (_sync)
             {
                 if (exit)
                     return;
             }
         }
     }
 }
 internal void SetSelectedTrunk(SvnListEventArgs trunk)
 {
     this.selectedTrunk  = trunk;
     textBoxTagName.Text = myIfsSvn.GetNewTagName(this.selectedTrunk);
 }
Esempio n. 21
0
 private void listHandler(object sender, SvnListEventArgs e)
 {
     Log.LogMessage(MessageImportance.Normal, "{0} - {1}",
         e.BasePath, e.Path);
     ItemsList.Add(string.Format("{0}{1}", e.BasePath, e.Path));
 }
Esempio n. 22
0
 internal SvnProject(SvnListEventArgs project)
 {
     this.Path = project.Uri.AbsoluteUri;
     this.Name = project.Name;
 }