private HgManifestNode(HgManifestTreeNodeType type, string name, HgPath path, HgNodeID? nodeID) { Type = type; Name = name; Path = path; NodeID = nodeID; }
public HgFile(HgPath path, HgRevlogEntry entry, byte[] data, HgFileCopyInfo copyInfo) { Path = path; Entry = entry; Data = data; CopyInfo = copyInfo; }
public HgRollupFileDiffInfo(HgPath file, bool isBinary, HgUnifiedDiff diff, int additions, int removals) { File = file; Diff = diff; IsBinary = isBinary; Additions = additions; Removals = removals; }
public virtual HgFilelog CreateFilelog(HgPath hgPath) { var filelogIndexName = hgPath.FullPath + ".i"; var filelogDataName = hgPath.FullPath + ".d"; var revlog = CreateRevlog(filelogIndexName, filelogDataName); return new HgFilelog(revlog, hgPath, new HgRevlogReader(revlog, FileSystem)); }
private static string[] GetRoots(IVsSolution solution) { return(GetProjectFiles(solution) .Where(x => !String.IsNullOrEmpty(x)) .Select(x => Path.GetDirectoryName(x)) .Select(x => HgPath.FindRepositoryRoot(x)) .Distinct() .ToArray()); }
public HgManifestFileEntry GetFile(HgPath path) { var file = !string.IsNullOrWhiteSpace(path.FileName) && filesCache.ContainsKey(path) ? filesCache[path] : null; return file; }
public string GetBranch(string path) { var branch = ""; var root = HgPath.FindRepositoryRoot(path); lock (SyncRoot) { items.TryGetValue(root, out branch); } return(branch); }
private void OnAfterOpenProject(IVsHierarchy hierarchy) { var files = VisualHgSolution.GetProjectFiles(hierarchy); foreach (var root in files.Select(x => HgPath.FindRepositoryRoot(x)).Distinct()) { repository.UpdateRootStatus(root); } AddIf(VisualHgOptions.Global.AddFilesOnLoad, files); UpdateLastSeenProjectDirectory(hierarchy); }
public override HgFilelog GetFilelog(HgPath hgPath) { var hglfPath = HgPath.Combine(".hglf", hgPath); var standinFilelog = underlyingStore.GetFilelog(hglfPath); if(standinFilelog == null) return underlyingStore.GetFilelog(hgPath); var standinRevlogReader = new HgRevlogReader(standinFilelog.Revlog, FileSystem); var largefileRevlog = new HgLargefilesEnabledRevlog(standinFilelog.Revlog, standinRevlogReader, StoreBasePath); standinFilelog = new HgLargefilesEnabledFilelog(largefileRevlog, hglfPath, standinRevlogReader); return standinFilelog; }
private HgBundleFile BuildBundleFile(HgRepository hgRepository, HgRevset hgRevset, string path) { // TODO: Do not bundle files without chunks log.Debug("bundling {0}", path); var hgPath = new HgPath(path); var hgFilelog = hgRepository.GetFilelog(hgPath); if(hgFilelog == null) return null; var filelogRevset = new HgRevset(hgFilelog.Revlog.Entries.Where(fre => hgRevset.Contains(fre.LinkRevision))); var hgBundleGroup = BuildBundleGroup(hgRepository, hgFilelog.Revlog, filelogRevset); var hgBundleFile = new HgBundleFile(hgPath, hgBundleGroup); return hgBundleFile; }
public override HgFilelog GetFilelog(HgPath hgPath) { // // According to http://mercurial.selenic.com/wiki/fncacheRepoFormat: // // The fncache file may contain duplicates or inexistent entries (this can happen when using the strip or rollback commmands). // // So there's no need to enlist it in a transaction or somesuch var filelogIndexPath = "data/" + hgPath.FullPath.TrimStart('/') + ".i"; var filelogDataPath = "data/" + hgPath.FullPath.TrimStart('/') + ".d"; var hgRevlog = GetRevlog(hgPathEncoder.EncodePath(filelogIndexPath), hgPathEncoder.EncodePath(filelogDataPath)); if(hgRevlog == null) { fnCache.Remove(filelogIndexPath); fnCache.Remove(filelogDataPath); return null; } // if if(!fnCache.Contains(filelogIndexPath)) { using(var streamWriter = new StreamWriter(FileSystem.OpenOrCreateWrite(fnCacheFilePath), Encoder.Local)) { streamWriter.BaseStream.Seek(0, SeekOrigin.End); streamWriter.Write(hgPathEncoder.EncodeDirectory(filelogIndexPath) + '\n'); } // using fnCache.Add(filelogIndexPath); } // if if(!fnCache.Contains(filelogDataPath) && !hgRevlog.InlineData) { using(var fileStream = new FileStream(fnCacheFilePath, FileMode.OpenOrCreate, FileAccess.Write, FileShare.None)) using(var streamWriter = new StreamWriter(fileStream, Encoder.Local)) { streamWriter.BaseStream.Seek(0, SeekOrigin.End); streamWriter.Write(hgPathEncoder.EncodeDirectory(filelogDataPath) + '\n'); } // using fnCache.Add(filelogDataPath); } // if return new HgFilelog(hgRevlog, hgPath, new HgRevlogReader(hgRevlog, FileSystem)); }
public static bool Matches(string fileName, HgFileStatus pattern) { if (String.IsNullOrEmpty(fileName)) { return(false); } if (HgPath.IsDirectory(fileName)) { return(false); } var visualHgService = Package.GetGlobalService(typeof(VisualHgService)) as VisualHgService; var status = visualHgService.GetFileStatus(fileName); return(Matches(status, pattern)); }
public HgManifestTree GetManifestTreeNode(HgRepository hgRepository, HgManifestEntry hgManifestEntry, HgPath hgPath) { var separators = hgPath.FullPath.Count(c => c == '/'); var paths = hgManifestEntry.Files. Select(f => new { file = f, separators = f.Path.FullPath.Count(c => c == '/') }). Where(f => f.file.Path.FullPath.StartsWith(hgPath.FullPath)). ToList(); var directories = paths. Where(d => d.separators > separators). Select(d => d.file.Path.FullPath.SubstringBeforeNth("/", separators)). Distinct(). Select(d => HgManifestNode.Directory(new HgPath(d))). ToList(); var files = paths. Where(f => f.separators == separators). Select(f => HgManifestNode.File(f.file.Path, f.file.FilelogNodeID)). ToList(); var subrepositories = hgRepository.GetSubrepositories(hgManifestEntry). Select(s => new { subrepository = s, separators = s.Path.FullPath.Count(c => c == '/') }). Where(s => s.subrepository.Path.FullPath.StartsWith(hgPath.FullPath) && s.separators == separators). Select(s => HgManifestNode.Subrepository(s.subrepository.Path, s.subrepository.NodeID)). ToList(); return new HgManifestTree(hgPath, directories.Append(files).Append(subrepositories)); }
public static void ShowDiffWindow(string fileName) { var root = HgPath.FindRepositoryRoot(fileName); var parent = GetOriginalFileName(fileName); var temp = Hg.CreateParentRevisionTempFile(parent, root); var revision = Hg.GetParentRevision(root) ?? "(parent revision)"; var tempName = GetDisplayName(parent, revision, root); var name = GetDisplayName(fileName, root); var diffTool = GetDiffTool(); diffTool.Exited += (s, e) => DeleteFile(temp); try { diffTool.Start(temp, fileName, tempName, name, root); } catch (InvalidOperationException) { MessageBox.Show(Resources.DiffToolNotFound + "\n\n" + diffTool.FileName, Resources.MessageBoxCaption, MessageBoxButtons.OK, MessageBoxIcon.Error); } }
public HgFilelog GetFilelog(HgPath hgPath) { return Store.GetFilelog(hgPath); }
public IList<HgChangeset> GetFileHistory(HgPath path, HgNodeID? startFilelogNodeID = null) { var filelog = GetFilelog(path); if(filelog == null) return null; var changesetNodeIDs = GetFileHistory(filelog, startFilelogNodeID ?? filelog.Revlog.Entries.Last().NodeID); var revsetManager = new HgRevsetManager(); var revset = revsetManager.GetRevset(this, changesetNodeIDs); return GetChangesets(revset).OrderByDescending(c => c.Metadata.Revision).ToList(); }
public override HgFilelog CreateFilelog(HgPath hgPath) { return underlyingStore.CreateFilelog(hgPath); }
public HgLargefilesEnabledFilelog(HgRevlog revlog, HgPath path, HgRevlogReader revlogReader) : base(revlog, path, revlogReader) { }
public HgSubrepository(HgPath path, string repositoryPath, HgNodeID nodeID) { Path = path; RepositoryPath = repositoryPath; NodeID = nodeID; }
public override bool Matches(HgPath hgPath) { return hgPath.FullPath.TrimStart('/') == pattern.TrimStart('/'); }
public string GetEncodedData(HgPath path) { return EncodePath("data/" + path.FullPath.TrimStart('/')); }
public HgCommitFileEntry(HgNodeID firstParentNodeID, HgNodeID secondParentNodeID, HgPath path, byte[] content) : base(firstParentNodeID, secondParentNodeID) { Path = path; Content = content; }
public int GetHashCode(string s) { return (Comparer.GetHashCode(Path.GetFileName(s)) ^ Comparer.GetHashCode(HgPath.FindRepositoryRoot(s))); }
public HgManifestTreeNode(HgPath hgPath, HgNodeID fileNodeID) : this(hgPath, "", HgManifestTreeNodeType.Subrepository) { FileNodeID = fileNodeID; }
private HgManifestTreeNode(HgPath hgPath, string name, HgManifestTreeNodeType type) { Path = hgPath; Name = name; Type = type; }
public HgBundleFile(HgPath path, IEnumerable<HgChunk> file) { Path = path; File = file; }
public HgAnnotation GetAnnotation(HgPath path, HgNodeID? startFilelogNodeID = null) { var fileHistory = repository.GetFileHistory(path, startFilelogNodeID).OrderBy(c => c.Metadata.Revision).ToList(); var prev = ""; var diffGenerator = new HgDiffGenerator(); var annotationLines = new LinkedList<HgAnnotationLine>(); var manifestEntries = repository. GetManifestEntries(new HgRevset(fileHistory.Select(f => repository.Manifest.Revlog.GetEntry(f.ManifestNodeID)))). ToDictionary(me => me.Metadata.NodeID, me => me); foreach(var changeset in fileHistory) { var manifest = manifestEntries[changeset.ManifestNodeID]; var current = Encoding.UTF8.GetString( repository.GetFile(manifest.GetFile(path)).Data); var diff = diffGenerator.Diff(prev, current); LinkedListNode<HgAnnotationLine> annotationLine = null; // before first for(var i = 0; i < diff.Lines.Count; ++i) { if(diff.Lines[i].Unchanged) { annotationLine = annotationLine == null ? annotationLines.First : annotationLine.Next; continue; } // if if(diff.Lines[i].Removed) { if(annotationLine == null) { annotationLines.RemoveFirst(); } // if else { if(annotationLine.Next != null) annotationLines.Remove(annotationLine.Next); } // else } else { if(annotationLine == null) { annotationLines.AddFirst(new HgAnnotationLine(changeset, diff.Lines[i].Content)); annotationLine = annotationLines.First; } else { annotationLines.AddAfter(annotationLine, new HgAnnotationLine(changeset, diff.Lines[i].Content)); annotationLine = annotationLine.Next; } } } // for prev = current; } // foreach /* var lines = prev.Split('\n'); Debug.Assert( lines.Length == annotationLines.Count, string.Format("Annotation line count mismatch: {0} in annotation vs {1} in file", annotationLines.Count, lines.Length));*/ return new HgAnnotation(path, annotationLines); }
private HgRollupFileDiffInfo GetHgRollupFileDiffInfo(HgPath hgPath, bool isBinary, HgUnifiedDiff hgUnifiedDiff) { var additions = hgUnifiedDiff == null ? 0 : hgUnifiedDiff.Hunks.SelectMany(h => h.Lines).Count(l => l.Added); var removals = hgUnifiedDiff == null ? 0 : hgUnifiedDiff.Hunks.SelectMany(h => h.Lines).Count(l => l.Removed); return new HgRollupFileDiffInfo(hgPath, isBinary, hgUnifiedDiff, additions, removals); }
private static string GetDisplayName(string fileName, string root) { return(HgPath.StripRoot(fileName, root)); }
public HgFileCopyInfo(HgPath path, HgNodeID nodeID) { Path = path; NodeID = nodeID; }
public HgFilelog(HgRevlog revlog, HgPath path, HgRevlogReader revlogReader) : base(revlog, revlogReader) { Path = path; }
public HgDataFile(HgPath path, string storeRelativePath, long length) { Path = path; StoreRelativePath = storeRelativePath; Length = length; }
public HgManifestTree(HgPath path, IEnumerable<HgManifestNode> nodes) { Path = path; Nodes = new ReadOnlyCollection<HgManifestNode>(new List<HgManifestNode>(nodes)); }
public HgChangesetFileDetails(HgPath path, HgChangesetFileOperation operation, HgRollupFileDiffInfo diff) { Path = path; Operation = operation; Diff = diff; }
public abstract bool Matches(HgPath hgPath);
public override bool Matches(HgPath hgPath) { throw new System.NotImplementedException(); }
public override bool Matches(HgPath hgPath) { return regex.IsMatch(hgPath.FullPath.TrimStart('/')); }