diff src/org/tmatesoft/hg/repo/CommitFacility.java @ 586:73c20c648c1f

HgCommitCommand initial support
author Artem Tikhomirov <tikhomirov.artem@gmail.com>
date Fri, 26 Apr 2013 18:38:41 +0200
parents ca56a36c2eea
children 41218d84842a
line wrap: on
line diff
--- a/src/org/tmatesoft/hg/repo/CommitFacility.java	Thu Apr 25 17:53:44 2013 +0200
+++ b/src/org/tmatesoft/hg/repo/CommitFacility.java	Fri Apr 26 18:38:41 2013 +0200
@@ -28,6 +28,7 @@
 import java.util.TreeMap;
 import java.util.TreeSet;
 
+import org.tmatesoft.hg.core.HgCommitCommand;
 import org.tmatesoft.hg.core.HgRepositoryLockException;
 import org.tmatesoft.hg.core.Nodeid;
 import org.tmatesoft.hg.internal.ByteArrayChannel;
@@ -44,6 +45,8 @@
 
 /**
  * WORK IN PROGRESS
+ * Name: CommitObject, FutureCommit or PendingCommit
+ * Only public API now: {@link HgCommitCommand}. TEMPORARILY lives in the oth.repo public packages, until code interdependencies are resolved
  * 
  * @author Artem Tikhomirov
  * @author TMate Software Ltd.
@@ -54,7 +57,7 @@
 	private final int p1Commit, p2Commit;
 	private Map<Path, Pair<HgDataFile, ByteDataSupplier>> files = new LinkedHashMap<Path, Pair<HgDataFile, ByteDataSupplier>>();
 	private Set<Path> removals = new TreeSet<Path>();
-	private String branch;
+	private String branch, user;
 
 	public CommitFacility(HgRepository hgRepo, int parentCommit) {
 		this(hgRepo, parentCommit, NO_REVISION);
@@ -90,6 +93,10 @@
 		branch = branchName;
 	}
 	
+	public void user(String userName) {
+		user = userName;
+	}
+	
 	public Nodeid commit(String message) throws HgRepositoryLockException {
 		
 		final HgChangelog clog = repo.getChangelog();
@@ -172,6 +179,7 @@
 		final ChangelogEntryBuilder changelogBuilder = new ChangelogEntryBuilder();
 		changelogBuilder.setModified(files.keySet());
 		changelogBuilder.branch(branch == null ? HgRepository.DEFAULT_BRANCH_NAME : branch);
+		changelogBuilder.user(String.valueOf(user));
 		byte[] clogContent = changelogBuilder.build(manifestRev, message);
 		RevlogStreamWriter changelogWriter = new RevlogStreamWriter(repo.getSessionContext(), clog.content);
 		Nodeid changesetRev = changelogWriter.addRevision(clogContent, clogRevisionIndex, p1Commit, p2Commit);
@@ -210,6 +218,9 @@
 
 	// unlike DataAccess (which provides structured access), this one 
 	// deals with a sequence of bytes, when there's no need in structure of the data
+	// FIXME java.nio.ReadableByteChannel or ByteStream/ByteSequence(read, length, reset)
+	// SHALL be inline with util.ByteChannel, reading bytes from HgDataFile, preferably DataAccess#readBytes(BB) to match API,
+	// and a wrap for ByteVector
 	public interface ByteDataSupplier { // TODO look if can resolve DataAccess in HgCloneCommand visibility issue
 		// FIXME needs lifecycle, e.g. for supplier that reads from WC
 		int read(ByteBuffer buf);