Mercurial > jhg
comparison cmdline/org/tmatesoft/hg/console/Status.java @ 93:d55d4eedfc57
Switch to Path instead of String in filenames returned by various status operations
author | Artem Tikhomirov <tikhomirov.artem@gmail.com> |
---|---|
date | Thu, 27 Jan 2011 21:15:21 +0100 |
parents | 61eedab3eb3e |
children | af1f3b78b918 |
comparison
equal
deleted
inserted
replaced
92:bf304cb14247 | 93:d55d4eedfc57 |
---|---|
25 | 25 |
26 import org.tmatesoft.hg.core.Nodeid; | 26 import org.tmatesoft.hg.core.Nodeid; |
27 import org.tmatesoft.hg.core.Path; | 27 import org.tmatesoft.hg.core.Path; |
28 import org.tmatesoft.hg.repo.HgDataFile; | 28 import org.tmatesoft.hg.repo.HgDataFile; |
29 import org.tmatesoft.hg.repo.HgRepository; | 29 import org.tmatesoft.hg.repo.HgRepository; |
30 import org.tmatesoft.hg.repo.HgStatusInspector; | |
30 import org.tmatesoft.hg.repo.Internals; | 31 import org.tmatesoft.hg.repo.Internals; |
31 import org.tmatesoft.hg.repo.StatusCollector; | 32 import org.tmatesoft.hg.repo.StatusCollector; |
32 import org.tmatesoft.hg.repo.StatusCollector.Record; | 33 import org.tmatesoft.hg.repo.StatusCollector.Record; |
33 import org.tmatesoft.hg.repo.WorkingCopyStatusCollector; | 34 import org.tmatesoft.hg.repo.WorkingCopyStatusCollector; |
34 | 35 |
115 sortAndPrint('I', r.getIgnored()); | 116 sortAndPrint('I', r.getIgnored()); |
116 sortAndPrint('C', r.getClean()); | 117 sortAndPrint('C', r.getClean()); |
117 sortAndPrint('!', r.getMissing()); | 118 sortAndPrint('!', r.getMissing()); |
118 } | 119 } |
119 | 120 |
120 private static void sortAndPrint(char prefix, List<String> ul) { | 121 private static void sortAndPrint(char prefix, List<Path> ul) { |
121 sortAndPrint(prefix, ul, null); | 122 sortAndPrint(prefix, ul, null); |
122 } | 123 } |
123 private static void sortAndPrint(char prefix, List<String> ul, Map<String, String> copies) { | 124 private static void sortAndPrint(char prefix, List<Path> ul, Map<Path, Path> copies) { |
124 ArrayList<String> sortList = new ArrayList<String>(ul); | 125 ArrayList<Path> sortList = new ArrayList<Path>(ul); |
125 Collections.sort(sortList); | 126 Collections.sort(sortList); |
126 for (String s : sortList) { | 127 for (Path s : sortList) { |
127 System.out.print(prefix); | 128 System.out.print(prefix); |
128 System.out.print(' '); | 129 System.out.print(' '); |
129 System.out.println(s); | 130 System.out.println(s); |
130 if (copies != null && copies.containsKey(s)) { | 131 if (copies != null && copies.containsKey(s)) { |
131 System.out.println(" " + copies.get(s)); | 132 System.out.println(" " + copies.get(s)); |
141 final Nodeid nid = Nodeid.fromAscii(b, 0, b.length); | 142 final Nodeid nid = Nodeid.fromAscii(b, 0, b.length); |
142 System.out.println(s + " : " + n.length(nid)); | 143 System.out.println(s + " : " + n.length(nid)); |
143 } | 144 } |
144 } | 145 } |
145 | 146 |
146 private static class StatusDump implements StatusCollector.Inspector { | 147 private static class StatusDump implements HgStatusInspector { |
147 public boolean hideStatusPrefix = false; // hg status -n option | 148 public boolean hideStatusPrefix = false; // hg status -n option |
148 public boolean showCopied = true; // -C | 149 public boolean showCopied = true; // -C |
149 public boolean showIgnored = true; // -i | 150 public boolean showIgnored = true; // -i |
150 public boolean showClean = true; // -c | 151 public boolean showClean = true; // -c |
151 | 152 |
152 public void modified(String fname) { | 153 public void modified(Path fname) { |
153 print('M', fname); | 154 print('M', fname); |
154 } | 155 } |
155 | 156 |
156 public void added(String fname) { | 157 public void added(Path fname) { |
157 print('A', fname); | 158 print('A', fname); |
158 } | 159 } |
159 | 160 |
160 public void copied(String fnameOrigin, String fnameAdded) { | 161 public void copied(Path fnameOrigin, Path fnameAdded) { |
161 added(fnameAdded); | 162 added(fnameAdded); |
162 if (showCopied) { | 163 if (showCopied) { |
163 print(' ', fnameOrigin); | 164 print(' ', fnameOrigin); |
164 } | 165 } |
165 } | 166 } |
166 | 167 |
167 public void removed(String fname) { | 168 public void removed(Path fname) { |
168 print('R', fname); | 169 print('R', fname); |
169 } | 170 } |
170 | 171 |
171 public void clean(String fname) { | 172 public void clean(Path fname) { |
172 if (showClean) { | 173 if (showClean) { |
173 print('C', fname); | 174 print('C', fname); |
174 } | 175 } |
175 } | 176 } |
176 | 177 |
177 public void missing(String fname) { | 178 public void missing(Path fname) { |
178 print('!', fname); | 179 print('!', fname); |
179 } | 180 } |
180 | 181 |
181 public void unknown(String fname) { | 182 public void unknown(Path fname) { |
182 print('?', fname); | 183 print('?', fname); |
183 } | 184 } |
184 | 185 |
185 public void ignored(String fname) { | 186 public void ignored(Path fname) { |
186 if (showIgnored) { | 187 if (showIgnored) { |
187 print('I', fname); | 188 print('I', fname); |
188 } | 189 } |
189 } | 190 } |
190 | 191 |
191 private void print(char status, String fname) { | 192 private void print(char status, Path fname) { |
192 if (!hideStatusPrefix) { | 193 if (!hideStatusPrefix) { |
193 System.out.print(status); | 194 System.out.print(status); |
194 System.out.print(' '); | 195 System.out.print(' '); |
195 } | 196 } |
196 System.out.println(fname); | 197 System.out.println(fname); |