diff src/org/tmatesoft/hg/internal/FNCacheFile.java @ 663:46b56864b483

Pull: phase2 - update phases from remote, fncache with added files. Tests
author Artem Tikhomirov <tikhomirov.artem@gmail.com>
date Wed, 10 Jul 2013 16:41:49 +0200
parents c75297c17867
children ae2d439fbed3
line wrap: on
line diff
--- a/src/org/tmatesoft/hg/internal/FNCacheFile.java	Wed Jul 10 11:53:19 2013 +0200
+++ b/src/org/tmatesoft/hg/internal/FNCacheFile.java	Wed Jul 10 16:41:49 2013 +0200
@@ -76,7 +76,7 @@
 	}
 	*/
 	
-	public void write() throws IOException {
+	public void write() throws IOException { // FIXME transaction! and HgIOException
 		if (addedDotI.isEmpty() && addedDotD.isEmpty()) {
 			return;
 		}
@@ -114,4 +114,34 @@
 	public void addData(Path p) {
 		addedDotD.add(p);
 	}
+
+	/**
+	 * Register new files with fncache if one is enabled for the repo, do nothing otherwise
+	 */
+	public static class Mediator {
+		private final Internals repo;
+		private FNCacheFile fncache;
+
+		public Mediator(Internals internalRepo) {
+			repo = internalRepo;
+		}
+		
+		public void registerNew(Path f, RevlogStream rs) {
+			if (fncache != null || repo.fncacheInUse()) {
+				if (fncache == null) {
+					fncache = new FNCacheFile(repo);
+				}
+				fncache.addIndex(f);
+				if (!rs.isInlineData()) {
+					fncache.addData(f);
+				}
+			}
+		}
+		
+		public void complete() throws IOException {
+			if (fncache != null) {
+				fncache.write();
+			}
+		}
+	}
 }