Mercurial > jhg
comparison src/org/tmatesoft/hg/internal/COWTransaction.java @ 621:99ad1e3a4e4d
RevlogStream: be aware of existence (not HgDataFile), facilitate use of an added HgDataFile over a commit; Rollback: be more sensitive about file changes (file size is not enough: write/rollback leaves it intact); tests
author | Artem Tikhomirov <tikhomirov.artem@gmail.com> |
---|---|
date | Sat, 18 May 2013 22:23:57 +0200 |
parents | 65c01508f002 |
children | 4ec2d44e2bf3 |
comparison
equal
deleted
inserted
replaced
620:272ecffccc8a | 621:99ad1e3a4e4d |
---|---|
46 | 46 |
47 @Override | 47 @Override |
48 public File prepare(File f) throws HgIOException { | 48 public File prepare(File f) throws HgIOException { |
49 if (!f.exists()) { | 49 if (!f.exists()) { |
50 record(f, null); | 50 record(f, null); |
51 return f; | 51 try { |
52 f.getParentFile().mkdirs(); | |
53 f.createNewFile(); | |
54 return f; | |
55 } catch (IOException ex) { | |
56 throw new HgIOException("Failed to create new file", ex, f); | |
57 } | |
52 } | 58 } |
53 if (known(f)) { | 59 if (known(f)) { |
54 return f; | 60 return f; |
55 } | 61 } |
56 final File parentDir = f.getParentFile(); | 62 final File parentDir = f.getParentFile(); |
121 if (e.backup != null) { | 127 if (e.backup != null) { |
122 if (!e.backup.renameTo(e.origin)) { | 128 if (!e.backup.renameTo(e.origin)) { |
123 String msg = String.format("Transaction rollback failed, could not rename backup %s back to %s", e.backup.getName(), e.origin.getName()); | 129 String msg = String.format("Transaction rollback failed, could not rename backup %s back to %s", e.backup.getName(), e.origin.getName()); |
124 throw new HgIOException(msg, e.origin); | 130 throw new HgIOException(msg, e.origin); |
125 } | 131 } |
132 // renameTo() doesn't update timestamp, while the rest of the code relies | |
133 // on file timestamp to detect revlog changes. Rollback *is* a change, | |
134 // even if it brings the old state. | |
135 e.origin.setLastModified(System.currentTimeMillis()); | |
126 } | 136 } |
127 success.add(e); | 137 success.add(e); |
128 it.remove(); | 138 it.remove(); |
129 } | 139 } |
130 } | 140 } |