comparison src/com/tmate/hgkit/console/Status.java @ 18:02ee376bee79

status operation against current working directory
author Artem Tikhomirov <tikhomirov.artem@gmail.com>
date Mon, 03 Jan 2011 20:42:52 +0100
parents 382cfe9463db
children 11cfabe692b3
comparison
equal deleted inserted replaced
17:571e1b2cc3f7 18:02ee376bee79
1 /* 1 /*
2 * Copyright (c) 2010 Artem Tikhomirov 2 * Copyright (c) 2010 Artem Tikhomirov
3 */ 3 */
4 package com.tmate.hgkit.console; 4 package com.tmate.hgkit.console;
5
6 import static com.tmate.hgkit.ll.HgRepository.TIP;
5 7
6 import com.tmate.hgkit.fs.RepositoryLookup; 8 import com.tmate.hgkit.fs.RepositoryLookup;
7 import com.tmate.hgkit.ll.HgRepository; 9 import com.tmate.hgkit.ll.HgRepository;
8 import com.tmate.hgkit.ll.LocalHgRepo; 10 import com.tmate.hgkit.ll.LocalHgRepo;
9 11
21 System.err.printf("Can't find repository in: %s\n", hgRepo.getLocation()); 23 System.err.printf("Can't find repository in: %s\n", hgRepo.getLocation());
22 return; 24 return;
23 } 25 }
24 System.out.println(hgRepo.getLocation()); 26 System.out.println(hgRepo.getLocation());
25 ((LocalHgRepo) hgRepo).loadDirstate().dump(); 27 ((LocalHgRepo) hgRepo).loadDirstate().dump();
28 //hgRepo.status(TIP, TIP, new StatusDump());
29 final StatusDump dump = new StatusDump();
30 dump.showIgnored = false;
31 dump.showClean = false;
32 ((LocalHgRepo) hgRepo).statusLocal(TIP, dump);
33 }
34
35 private static class StatusDump implements HgRepository.StatusInspector {
36 public boolean hideStatusPrefix = false; // hg status -n option
37 public boolean showCopied = true; // -C
38 public boolean showIgnored = true; // -i
39 public boolean showClean = true; // -c
40
41 public void modified(String fname) {
42 print('M', fname);
43 }
44
45 public void added(String fname) {
46 print('A', fname);
47 }
48
49 public void copied(String fnameOrigin, String fnameAdded) {
50 added(fnameAdded);
51 if (showCopied) {
52 print(' ', fnameOrigin);
53 }
54 }
55
56 public void removed(String fname) {
57 print('R', fname);
58 }
59
60 public void clean(String fname) {
61 if (showClean) {
62 print('C', fname);
63 }
64 }
65
66 public void missing(String fname) {
67 print('!', fname);
68 }
69
70 public void unknown(String fname) {
71 print('?', fname);
72 }
73
74 public void ignored(String fname) {
75 if (showIgnored) {
76 print('I', fname);
77 }
78 }
79
80 private void print(char status, String fname) {
81 if (!hideStatusPrefix) {
82 System.out.print(status);
83 System.out.print(' ');
84 }
85 System.out.println(fname);
86 }
26 } 87 }
27 } 88 }