Mercurial > hg4j
annotate src/org/tmatesoft/hg/internal/WorkingDirFileWriter.java @ 624:507602cb4fb3
FIXMEs and TODOs: pay some technical debt
author | Artem Tikhomirov <tikhomirov.artem@gmail.com> |
---|---|
date | Mon, 20 May 2013 20:34:33 +0200 |
parents | bd5926e24aa3 |
children | 6526d8adbc0f |
rev | line source |
---|---|
525
0be5be8d57e9
Repository checkout support, first iteration
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
1 /* |
0be5be8d57e9
Repository checkout support, first iteration
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
2 * Copyright (c) 2012-2013 TMate Software Ltd |
0be5be8d57e9
Repository checkout support, first iteration
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
3 * |
0be5be8d57e9
Repository checkout support, first iteration
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
4 * This program is free software; you can redistribute it and/or modify |
0be5be8d57e9
Repository checkout support, first iteration
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
5 * it under the terms of the GNU General Public License as published by |
0be5be8d57e9
Repository checkout support, first iteration
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
6 * the Free Software Foundation; version 2 of the License. |
0be5be8d57e9
Repository checkout support, first iteration
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
7 * |
0be5be8d57e9
Repository checkout support, first iteration
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
8 * This program is distributed in the hope that it will be useful, |
0be5be8d57e9
Repository checkout support, first iteration
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
0be5be8d57e9
Repository checkout support, first iteration
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
0be5be8d57e9
Repository checkout support, first iteration
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
11 * GNU General Public License for more details. |
0be5be8d57e9
Repository checkout support, first iteration
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
12 * |
0be5be8d57e9
Repository checkout support, first iteration
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
13 * For information on how to redistribute this software under |
0be5be8d57e9
Repository checkout support, first iteration
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
14 * the terms of a license other than GNU General Public License |
0be5be8d57e9
Repository checkout support, first iteration
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
15 * contact TMate Software at support@hg4j.com |
0be5be8d57e9
Repository checkout support, first iteration
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
16 */ |
0be5be8d57e9
Repository checkout support, first iteration
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
17 package org.tmatesoft.hg.internal; |
0be5be8d57e9
Repository checkout support, first iteration
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
18 |
580
bd5926e24aa3
Respect unix flags for checkout/revert
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
572
diff
changeset
|
19 import static org.tmatesoft.hg.util.LogFacility.Severity.Warn; |
bd5926e24aa3
Respect unix flags for checkout/revert
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
572
diff
changeset
|
20 |
525
0be5be8d57e9
Repository checkout support, first iteration
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
21 import java.io.File; |
0be5be8d57e9
Repository checkout support, first iteration
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
22 import java.io.FileOutputStream; |
0be5be8d57e9
Repository checkout support, first iteration
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
23 import java.io.IOException; |
0be5be8d57e9
Repository checkout support, first iteration
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
24 import java.nio.ByteBuffer; |
0be5be8d57e9
Repository checkout support, first iteration
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
25 import java.nio.channels.FileChannel; |
0be5be8d57e9
Repository checkout support, first iteration
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
26 |
0be5be8d57e9
Repository checkout support, first iteration
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
27 import org.tmatesoft.hg.repo.HgDataFile; |
580
bd5926e24aa3
Respect unix flags for checkout/revert
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
572
diff
changeset
|
28 import org.tmatesoft.hg.repo.HgManifest; |
525
0be5be8d57e9
Repository checkout support, first iteration
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
29 import org.tmatesoft.hg.util.ByteChannel; |
0be5be8d57e9
Repository checkout support, first iteration
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
30 import org.tmatesoft.hg.util.CancelledException; |
526
2f9ed6bcefa2
Initial support for Revert command with accompanying minor refactoring
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
525
diff
changeset
|
31 import org.tmatesoft.hg.util.LogFacility.Severity; |
525
0be5be8d57e9
Repository checkout support, first iteration
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
32 import org.tmatesoft.hg.util.Path; |
0be5be8d57e9
Repository checkout support, first iteration
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
33 |
0be5be8d57e9
Repository checkout support, first iteration
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
34 /** |
0be5be8d57e9
Repository checkout support, first iteration
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
35 * |
0be5be8d57e9
Repository checkout support, first iteration
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
36 * @author Artem Tikhomirov |
0be5be8d57e9
Repository checkout support, first iteration
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
37 * @author TMate Software Ltd. |
0be5be8d57e9
Repository checkout support, first iteration
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
38 */ |
0be5be8d57e9
Repository checkout support, first iteration
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
39 public class WorkingDirFileWriter implements ByteChannel { |
0be5be8d57e9
Repository checkout support, first iteration
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
40 |
0be5be8d57e9
Repository checkout support, first iteration
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
41 |
526
2f9ed6bcefa2
Initial support for Revert command with accompanying minor refactoring
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
525
diff
changeset
|
42 private final Internals hgRepo; |
580
bd5926e24aa3
Respect unix flags for checkout/revert
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
572
diff
changeset
|
43 private final boolean execCap, symlinkCap; |
bd5926e24aa3
Respect unix flags for checkout/revert
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
572
diff
changeset
|
44 private final FileSystemHelper fileFlagsHelper; |
525
0be5be8d57e9
Repository checkout support, first iteration
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
45 private File dest; |
0be5be8d57e9
Repository checkout support, first iteration
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
46 private FileChannel destChannel; |
0be5be8d57e9
Repository checkout support, first iteration
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
47 private int totalBytesWritten; |
580
bd5926e24aa3
Respect unix flags for checkout/revert
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
572
diff
changeset
|
48 private ByteArrayChannel linkChannel; |
bd5926e24aa3
Respect unix flags for checkout/revert
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
572
diff
changeset
|
49 private int fmode; |
525
0be5be8d57e9
Repository checkout support, first iteration
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
50 |
526
2f9ed6bcefa2
Initial support for Revert command with accompanying minor refactoring
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
525
diff
changeset
|
51 public WorkingDirFileWriter(Internals internalRepo) { |
2f9ed6bcefa2
Initial support for Revert command with accompanying minor refactoring
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
525
diff
changeset
|
52 hgRepo = internalRepo; |
580
bd5926e24aa3
Respect unix flags for checkout/revert
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
572
diff
changeset
|
53 execCap = Internals.checkSupportsExecutables(internalRepo.getRepo().getWorkingDir()); |
bd5926e24aa3
Respect unix flags for checkout/revert
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
572
diff
changeset
|
54 symlinkCap = Internals.checkSupportsSymlinks(internalRepo.getRepo().getWorkingDir()); |
bd5926e24aa3
Respect unix flags for checkout/revert
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
572
diff
changeset
|
55 if (symlinkCap || execCap) { |
bd5926e24aa3
Respect unix flags for checkout/revert
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
572
diff
changeset
|
56 fileFlagsHelper = new FileSystemHelper(internalRepo.getSessionContext()); |
bd5926e24aa3
Respect unix flags for checkout/revert
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
572
diff
changeset
|
57 } else { |
bd5926e24aa3
Respect unix flags for checkout/revert
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
572
diff
changeset
|
58 fileFlagsHelper = null; |
bd5926e24aa3
Respect unix flags for checkout/revert
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
572
diff
changeset
|
59 } |
525
0be5be8d57e9
Repository checkout support, first iteration
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
60 } |
0be5be8d57e9
Repository checkout support, first iteration
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
61 |
572
becd2a1310a2
Report file object in case of error to be helpful as much as possible
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
526
diff
changeset
|
62 /** |
580
bd5926e24aa3
Respect unix flags for checkout/revert
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
572
diff
changeset
|
63 * Writes content of specified file revision into local filesystem, or create a symlink according to flags. |
bd5926e24aa3
Respect unix flags for checkout/revert
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
572
diff
changeset
|
64 * Executable bit is set if specified and filesystem supports it. |
572
becd2a1310a2
Report file object in case of error to be helpful as much as possible
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
526
diff
changeset
|
65 */ |
580
bd5926e24aa3
Respect unix flags for checkout/revert
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
572
diff
changeset
|
66 public void processFile(HgDataFile df, int fileRevIndex, HgManifest.Flags flags) throws IOException { |
525
0be5be8d57e9
Repository checkout support, first iteration
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
67 try { |
0be5be8d57e9
Repository checkout support, first iteration
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
68 prepare(df.getPath()); |
580
bd5926e24aa3
Respect unix flags for checkout/revert
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
572
diff
changeset
|
69 if (flags != HgManifest.Flags.Link) { |
bd5926e24aa3
Respect unix flags for checkout/revert
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
572
diff
changeset
|
70 destChannel = new FileOutputStream(dest).getChannel(); |
bd5926e24aa3
Respect unix flags for checkout/revert
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
572
diff
changeset
|
71 } else { |
bd5926e24aa3
Respect unix flags for checkout/revert
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
572
diff
changeset
|
72 linkChannel = new ByteArrayChannel(); |
bd5926e24aa3
Respect unix flags for checkout/revert
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
572
diff
changeset
|
73 } |
525
0be5be8d57e9
Repository checkout support, first iteration
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
74 df.contentWithFilters(fileRevIndex, this); |
0be5be8d57e9
Repository checkout support, first iteration
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
75 } catch (CancelledException ex) { |
526
2f9ed6bcefa2
Initial support for Revert command with accompanying minor refactoring
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
525
diff
changeset
|
76 hgRepo.getSessionContext().getLog().dump(getClass(), Severity.Error, ex, "Our impl doesn't throw cancellation"); |
580
bd5926e24aa3
Respect unix flags for checkout/revert
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
572
diff
changeset
|
77 } finally { |
bd5926e24aa3
Respect unix flags for checkout/revert
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
572
diff
changeset
|
78 if (flags != HgManifest.Flags.Link) { |
bd5926e24aa3
Respect unix flags for checkout/revert
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
572
diff
changeset
|
79 destChannel.close(); |
bd5926e24aa3
Respect unix flags for checkout/revert
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
572
diff
changeset
|
80 destChannel = null; |
bd5926e24aa3
Respect unix flags for checkout/revert
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
572
diff
changeset
|
81 // leave dest in case anyone enquires with #getDestinationFile |
bd5926e24aa3
Respect unix flags for checkout/revert
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
572
diff
changeset
|
82 } |
525
0be5be8d57e9
Repository checkout support, first iteration
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
83 } |
580
bd5926e24aa3
Respect unix flags for checkout/revert
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
572
diff
changeset
|
84 if (linkChannel != null && symlinkCap) { |
bd5926e24aa3
Respect unix flags for checkout/revert
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
572
diff
changeset
|
85 assert flags == HgManifest.Flags.Link; |
bd5926e24aa3
Respect unix flags for checkout/revert
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
572
diff
changeset
|
86 fileFlagsHelper.createSymlink(dest.getParentFile(), dest.getName(), linkChannel.toArray()); |
bd5926e24aa3
Respect unix flags for checkout/revert
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
572
diff
changeset
|
87 } else if (flags == HgManifest.Flags.Exec && execCap) { |
bd5926e24aa3
Respect unix flags for checkout/revert
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
572
diff
changeset
|
88 fileFlagsHelper.setExecutableBit(dest.getParentFile(), dest.getName()); |
bd5926e24aa3
Respect unix flags for checkout/revert
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
572
diff
changeset
|
89 } |
bd5926e24aa3
Respect unix flags for checkout/revert
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
572
diff
changeset
|
90 // Although HgWCStatusCollector treats 644 (`hg manifest -v`) and 664 (my fs) the same, it's better |
bd5926e24aa3
Respect unix flags for checkout/revert
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
572
diff
changeset
|
91 // to detect actual flags here |
bd5926e24aa3
Respect unix flags for checkout/revert
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
572
diff
changeset
|
92 fmode = flags.fsMode(); // default to one from manifest |
bd5926e24aa3
Respect unix flags for checkout/revert
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
572
diff
changeset
|
93 if (fileFlagsHelper != null) { |
bd5926e24aa3
Respect unix flags for checkout/revert
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
572
diff
changeset
|
94 // if neither execBit nor link is supported by fs, it's unlikely file mode is supported, too. |
bd5926e24aa3
Respect unix flags for checkout/revert
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
572
diff
changeset
|
95 try { |
bd5926e24aa3
Respect unix flags for checkout/revert
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
572
diff
changeset
|
96 fmode = fileFlagsHelper.getFileMode(dest, fmode); |
bd5926e24aa3
Respect unix flags for checkout/revert
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
572
diff
changeset
|
97 } catch (IOException ex) { |
bd5926e24aa3
Respect unix flags for checkout/revert
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
572
diff
changeset
|
98 // Warn, we've got default value and can live with it |
bd5926e24aa3
Respect unix flags for checkout/revert
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
572
diff
changeset
|
99 hgRepo.getSessionContext().getLog().dump(getClass(), Warn, ex, "Failed get file access rights"); |
bd5926e24aa3
Respect unix flags for checkout/revert
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
572
diff
changeset
|
100 } |
bd5926e24aa3
Respect unix flags for checkout/revert
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
572
diff
changeset
|
101 } |
525
0be5be8d57e9
Repository checkout support, first iteration
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
102 } |
0be5be8d57e9
Repository checkout support, first iteration
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
103 |
0be5be8d57e9
Repository checkout support, first iteration
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
104 public void prepare(Path fname) throws IOException { |
0be5be8d57e9
Repository checkout support, first iteration
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
105 String fpath = fname.toString(); |
526
2f9ed6bcefa2
Initial support for Revert command with accompanying minor refactoring
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
525
diff
changeset
|
106 dest = new File(hgRepo.getRepo().getWorkingDir(), fpath); |
525
0be5be8d57e9
Repository checkout support, first iteration
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
107 if (fpath.indexOf('/') != -1) { |
0be5be8d57e9
Repository checkout support, first iteration
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
108 dest.getParentFile().mkdirs(); |
0be5be8d57e9
Repository checkout support, first iteration
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
109 } |
580
bd5926e24aa3
Respect unix flags for checkout/revert
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
572
diff
changeset
|
110 destChannel = null; |
bd5926e24aa3
Respect unix flags for checkout/revert
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
572
diff
changeset
|
111 linkChannel = null; |
525
0be5be8d57e9
Repository checkout support, first iteration
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
112 totalBytesWritten = 0; |
580
bd5926e24aa3
Respect unix flags for checkout/revert
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
572
diff
changeset
|
113 fmode = 0; |
525
0be5be8d57e9
Repository checkout support, first iteration
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
114 } |
0be5be8d57e9
Repository checkout support, first iteration
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
115 |
0be5be8d57e9
Repository checkout support, first iteration
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
116 public int write(ByteBuffer buffer) throws IOException, CancelledException { |
580
bd5926e24aa3
Respect unix flags for checkout/revert
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
572
diff
changeset
|
117 final int written; |
bd5926e24aa3
Respect unix flags for checkout/revert
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
572
diff
changeset
|
118 if (linkChannel != null) { |
bd5926e24aa3
Respect unix flags for checkout/revert
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
572
diff
changeset
|
119 written = linkChannel.write(buffer); |
bd5926e24aa3
Respect unix flags for checkout/revert
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
572
diff
changeset
|
120 } else { |
bd5926e24aa3
Respect unix flags for checkout/revert
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
572
diff
changeset
|
121 written = destChannel.write(buffer); |
bd5926e24aa3
Respect unix flags for checkout/revert
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
572
diff
changeset
|
122 } |
525
0be5be8d57e9
Repository checkout support, first iteration
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
123 totalBytesWritten += written; |
0be5be8d57e9
Repository checkout support, first iteration
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
124 return written; |
0be5be8d57e9
Repository checkout support, first iteration
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
125 } |
0be5be8d57e9
Repository checkout support, first iteration
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
126 |
580
bd5926e24aa3
Respect unix flags for checkout/revert
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
572
diff
changeset
|
127 /** |
bd5926e24aa3
Respect unix flags for checkout/revert
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
572
diff
changeset
|
128 * Information purposes only, to find out trouble location if {@link #processFile(HgDataFile, int)} fails |
bd5926e24aa3
Respect unix flags for checkout/revert
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
572
diff
changeset
|
129 */ |
bd5926e24aa3
Respect unix flags for checkout/revert
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
572
diff
changeset
|
130 public File getDestinationFile() { |
bd5926e24aa3
Respect unix flags for checkout/revert
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
572
diff
changeset
|
131 return dest; |
525
0be5be8d57e9
Repository checkout support, first iteration
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
132 } |
0be5be8d57e9
Repository checkout support, first iteration
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
133 |
0be5be8d57e9
Repository checkout support, first iteration
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
134 public int bytesWritten() { |
0be5be8d57e9
Repository checkout support, first iteration
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
135 return totalBytesWritten; |
0be5be8d57e9
Repository checkout support, first iteration
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
136 } |
580
bd5926e24aa3
Respect unix flags for checkout/revert
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
572
diff
changeset
|
137 |
bd5926e24aa3
Respect unix flags for checkout/revert
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
572
diff
changeset
|
138 public int fmode() { |
bd5926e24aa3
Respect unix flags for checkout/revert
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
572
diff
changeset
|
139 return fmode; |
bd5926e24aa3
Respect unix flags for checkout/revert
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
572
diff
changeset
|
140 } |
bd5926e24aa3
Respect unix flags for checkout/revert
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
572
diff
changeset
|
141 |
bd5926e24aa3
Respect unix flags for checkout/revert
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
572
diff
changeset
|
142 public int mtime() { |
bd5926e24aa3
Respect unix flags for checkout/revert
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
572
diff
changeset
|
143 return (int) (dest.lastModified() / 1000); |
bd5926e24aa3
Respect unix flags for checkout/revert
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
572
diff
changeset
|
144 } |
525
0be5be8d57e9
Repository checkout support, first iteration
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
145 } |