comparison src/org/tmatesoft/hg/core/HgCommitCommand.java @ 705:b4242b7e7dfe

Merge command: implement conflict resolution alternatives
author Artem Tikhomirov <tikhomirov.artem@gmail.com>
date Thu, 15 Aug 2013 18:43:50 +0200
parents 6526d8adbc0f
children 4ffc17c0b534
comparison
equal deleted inserted replaced
704:7743a9c10bfa 705:b4242b7e7dfe
18 18
19 import static org.tmatesoft.hg.repo.HgRepository.NO_REVISION; 19 import static org.tmatesoft.hg.repo.HgRepository.NO_REVISION;
20 20
21 import java.io.IOException; 21 import java.io.IOException;
22 22
23 import org.tmatesoft.hg.internal.COWTransaction;
24 import org.tmatesoft.hg.internal.CommitFacility; 23 import org.tmatesoft.hg.internal.CommitFacility;
25 import org.tmatesoft.hg.internal.CompleteRepoLock; 24 import org.tmatesoft.hg.internal.CompleteRepoLock;
26 import org.tmatesoft.hg.internal.FileContentSupplier; 25 import org.tmatesoft.hg.internal.FileContentSupplier;
27 import org.tmatesoft.hg.internal.Internals; 26 import org.tmatesoft.hg.internal.Internals;
28 import org.tmatesoft.hg.internal.Transaction; 27 import org.tmatesoft.hg.internal.Transaction;
110 Record status = sc.status(HgRepository.WORKING_COPY); 109 Record status = sc.status(HgRepository.WORKING_COPY);
111 if (status.getModified().size() == 0 && status.getAdded().size() == 0 && status.getRemoved().size() == 0) { 110 if (status.getModified().size() == 0 && status.getAdded().size() == 0 && status.getRemoved().size() == 0) {
112 newRevision = Nodeid.NULL; 111 newRevision = Nodeid.NULL;
113 return new Outcome(Kind.Failure, "nothing to add"); 112 return new Outcome(Kind.Failure, "nothing to add");
114 } 113 }
115 CommitFacility cf = new CommitFacility(Internals.getInstance(repo), parentRevs[0], parentRevs[1]); 114 final Internals implRepo = Internals.getInstance(repo);
115 CommitFacility cf = new CommitFacility(implRepo, parentRevs[0], parentRevs[1]);
116 for (Path m : status.getModified()) { 116 for (Path m : status.getModified()) {
117 HgDataFile df = repo.getFileNode(m); 117 HgDataFile df = repo.getFileNode(m);
118 cf.add(df, new WorkingCopyContent(df)); 118 cf.add(df, new WorkingCopyContent(df));
119 } 119 }
120 for (Path a : status.getAdded()) { 120 for (Path a : status.getAdded()) {
129 HgDataFile df = repo.getFileNode(r); 129 HgDataFile df = repo.getFileNode(r);
130 cf.forget(df); 130 cf.forget(df);
131 } 131 }
132 cf.branch(detectBranch()); 132 cf.branch(detectBranch());
133 cf.user(detectUser()); 133 cf.user(detectUser());
134 Transaction.Factory trFactory = new COWTransaction.Factory(); 134 Transaction.Factory trFactory = implRepo.getTransactionFactory();
135 Transaction tr = trFactory.create(repo); 135 Transaction tr = trFactory.create(repo);
136 try { 136 try {
137 newRevision = cf.commit(message, tr); 137 newRevision = cf.commit(message, tr);
138 tr.commit(); 138 tr.commit();
139 } catch (RuntimeException ex) { 139 } catch (RuntimeException ex) {