comparison src/com/tmate/hgkit/ll/LocalHgRepo.java @ 20:11cfabe692b3

Status operation for two repository revisions (no local dir involved)
author Artem Tikhomirov <tikhomirov.artem@gmail.com>
date Tue, 04 Jan 2011 02:08:25 +0100
parents 02ee376bee79
children e929cecae4e1
comparison
equal deleted inserted replaced
19:40532cdc92fc 20:11cfabe692b3
1 /* 1 /*
2 * Copyright (c) 2010 Artem Tikhomirov 2 * Copyright (c) 2010, 2011 Artem Tikhomirov
3 */ 3 */
4 package com.tmate.hgkit.ll; 4 package com.tmate.hgkit.ll;
5 5
6 import java.io.BufferedReader; 6 import java.io.BufferedReader;
7 import java.io.File; 7 import java.io.File;
44 public String getLocation() { 44 public String getLocation() {
45 return repoLocation; 45 return repoLocation;
46 } 46 }
47 47
48 @Override 48 @Override
49 public void status(int rev1, int rev2, StatusInspector inspector) { 49 public void status(int rev1, int rev2, final StatusInspector inspector) {
50 throw HgRepository.notImplemented(); 50 final HashMap<String, Nodeid> idsMap = new HashMap<String, Nodeid>();
51 final HashMap<String, String> flagsMap = new HashMap<String, String>();
52 HgManifest.Inspector collect = new HgManifest.Inspector() {
53
54
55 public boolean next(Nodeid nid, String fname, String flags) {
56 idsMap.put(fname, nid);
57 flagsMap.put(fname, flags);
58 return true;
59 }
60
61 public boolean end(int revision) {
62 return false;
63 }
64
65 public boolean begin(int revision, Nodeid nid) {
66 return true;
67 }
68 };
69 getManifest().walk(rev1, rev1, collect);
70
71 HgManifest.Inspector compare = new HgManifest.Inspector() {
72
73 public boolean begin(int revision, Nodeid nid) {
74 return true;
75 }
76
77 public boolean next(Nodeid nid, String fname, String flags) {
78 Nodeid nidR1 = idsMap.remove(fname);
79 String flagsR1 = flagsMap.remove(fname);
80 if (nidR1 == null) {
81 inspector.added(fname);
82 } else {
83 if (nidR1.compareTo(nid) == 0 && ((flags == null && flagsR1 == null) || flags.equals(flagsR1))) {
84 inspector.clean(fname);
85 } else {
86 inspector.modified(fname);
87 }
88 }
89 return true;
90 }
91
92 public boolean end(int revision) {
93 for (String fname : idsMap.keySet()) {
94 inspector.removed(fname);
95 }
96 if (idsMap.size() != flagsMap.size()) {
97 throw new IllegalStateException();
98 }
99 return false;
100 }
101 };
102 getManifest().walk(rev2, rev2, compare);
51 } 103 }
52 104
53 public void statusLocal(int rev1, StatusInspector inspector) { 105 public void statusLocal(int rev1, StatusInspector inspector) {
54 LinkedList<File> folders = new LinkedList<File>(); 106 LinkedList<File> folders = new LinkedList<File>();
55 final File rootDir = repoDir.getParentFile(); 107 final File rootDir = repoDir.getParentFile();