Mercurial > jhg
comparison src/org/tmatesoft/hg/core/HgCheckoutCommand.java @ 527:47b7bedf0569
Tests for present HgCheckoutCommand functionality. Update branch information on checkout. Use UTF8 encoding for the branch file
author | Artem Tikhomirov <tikhomirov.artem@gmail.com> |
---|---|
date | Tue, 15 Jan 2013 19:46:19 +0100 |
parents | 2f9ed6bcefa2 |
children | ca56a36c2eea |
comparison
equal
deleted
inserted
replaced
526:2f9ed6bcefa2 | 527:47b7bedf0569 |
---|---|
14 * the terms of a license other than GNU General Public License | 14 * the terms of a license other than GNU General Public License |
15 * contact TMate Software at support@hg4j.com | 15 * contact TMate Software at support@hg4j.com |
16 */ | 16 */ |
17 package org.tmatesoft.hg.core; | 17 package org.tmatesoft.hg.core; |
18 | 18 |
19 import static org.tmatesoft.hg.repo.HgRepositoryFiles.Branch; | |
19 import static org.tmatesoft.hg.repo.HgRepositoryFiles.Dirstate; | 20 import static org.tmatesoft.hg.repo.HgRepositoryFiles.Dirstate; |
20 | 21 |
21 import java.io.File; | 22 import java.io.File; |
22 import java.io.FileOutputStream; | 23 import java.io.FileOutputStream; |
23 import java.io.IOException; | 24 import java.io.IOException; |
25 import java.io.OutputStreamWriter; | |
24 import java.nio.channels.FileChannel; | 26 import java.nio.channels.FileChannel; |
25 | 27 |
26 import org.tmatesoft.hg.internal.DirstateBuilder; | 28 import org.tmatesoft.hg.internal.DirstateBuilder; |
29 import org.tmatesoft.hg.internal.EncodingHelper; | |
27 import org.tmatesoft.hg.internal.Experimental; | 30 import org.tmatesoft.hg.internal.Experimental; |
28 import org.tmatesoft.hg.internal.Internals; | 31 import org.tmatesoft.hg.internal.Internals; |
29 import org.tmatesoft.hg.internal.WorkingDirFileWriter; | 32 import org.tmatesoft.hg.internal.WorkingDirFileWriter; |
30 import org.tmatesoft.hg.repo.HgDataFile; | 33 import org.tmatesoft.hg.repo.HgDataFile; |
31 import org.tmatesoft.hg.repo.HgInvalidRevisionException; | 34 import org.tmatesoft.hg.repo.HgInvalidRevisionException; |
128 dirstateBuilder.serialize(dirstate); | 131 dirstateBuilder.serialize(dirstate); |
129 dirstate.close(); | 132 dirstate.close(); |
130 } catch (IOException ex) { | 133 } catch (IOException ex) { |
131 throw new HgIOException("Can't write down new directory state", ex, dirstateFile); | 134 throw new HgIOException("Can't write down new directory state", ex, dirstateFile); |
132 } | 135 } |
133 // FIXME write down branch file | 136 String branchName = repo.getChangelog().range(revisionToCheckout, revisionToCheckout).get(0).branch(); |
137 assert branchName != null; | |
138 if (!HgRepository.DEFAULT_BRANCH_NAME.equals(branchName)) { | |
139 File branchFile = internalRepo.getRepositoryFile(Branch); | |
140 try { | |
141 // branch file is UTF-8, see http://mercurial.selenic.com/wiki/EncodingStrategy#UTF-8_strings | |
142 OutputStreamWriter ow = new OutputStreamWriter(new FileOutputStream(branchFile), EncodingHelper.getUTF8()); | |
143 ow.write(branchName); | |
144 ow.close(); | |
145 } catch (IOException ex) { | |
146 throw new HgIOException("Can't write down branch information", ex, branchFile); | |
147 } | |
148 } | |
134 } catch (HgRuntimeException ex) { | 149 } catch (HgRuntimeException ex) { |
135 throw new HgLibraryFailureException(ex); | 150 throw new HgLibraryFailureException(ex); |
136 } | 151 } |
137 } | 152 } |
138 | 153 |