Mercurial > hg > easyhg
comparison filestates.cpp @ 163:5c262ac73948
* First cut of work on merge/resolve logic
author | Chris Cannam |
---|---|
date | Fri, 03 Dec 2010 19:35:04 +0000 |
parents | 087d7cdde662 |
children | f16fe0db11f3 |
comparison
equal
deleted
inserted
replaced
162:910c2c5d1873 | 163:5c262ac73948 |
---|---|
36 } | 36 } |
37 | 37 |
38 FileStates::State FileStates::charToState(QChar c, bool *ok) | 38 FileStates::State FileStates::charToState(QChar c, bool *ok) |
39 { | 39 { |
40 // Note that InConflict does not correspond to a stat char -- it's | 40 // Note that InConflict does not correspond to a stat char -- it's |
41 // reported separately, by resolve --list -- stat reports files in | 41 // reported separately, by resolve --list, which shows U for |
42 // conflict as M which means they will appear in more than one bin | 42 // Unresolved -- stat reports files in conflict as M, which means |
43 // if we handle them naively. | 43 // they will appear in more than one bin if we handle them |
44 // naively. 'u' is also used by stat as the command option for | |
45 // Unknown, but the stat output uses ? for these so there's no | |
46 // ambiguity in parsing. | |
44 | 47 |
45 //!!! -- but InConflict isn't actually handled elsewhere, it's | |
46 //!!! -- only a placeholder really at the moment | |
47 if (ok) *ok = true; | 48 if (ok) *ok = true; |
48 if (c == 'M') return Modified; | 49 if (c == 'M') return Modified; |
49 if (c == 'A') return Added; | 50 if (c == 'A') return Added; |
50 if (c == 'R') return Removed; | 51 if (c == 'R') return Removed; |
51 if (c == '!') return Missing; | 52 if (c == '!') return Missing; |
53 if (c == 'U') return InConflict; | |
52 if (c == '?') return Unknown; | 54 if (c == '?') return Unknown; |
53 if (c == 'C') return Clean; | 55 if (c == 'C') return Clean; |
54 if (ok) *ok = false; | 56 if (ok) *ok = false; |
55 return Unknown; | 57 return Unknown; |
56 } | 58 } |
71 void FileStates::parseStates(QString text) | 73 void FileStates::parseStates(QString text) |
72 { | 74 { |
73 text.replace("\r\n", "\n"); | 75 text.replace("\r\n", "\n"); |
74 | 76 |
75 clearBuckets(); | 77 clearBuckets(); |
78 m_stateMap.clear(); | |
76 | 79 |
77 QStringList lines = text.split("\n", QString::SkipEmptyParts); | 80 QStringList lines = text.split("\n", QString::SkipEmptyParts); |
78 | 81 |
79 foreach (QString line, lines) { | 82 foreach (QString line, lines) { |
80 | 83 |
86 bool ok = false; | 89 bool ok = false; |
87 State s = charToState(c, &ok); | 90 State s = charToState(c, &ok); |
88 if (!ok) continue; | 91 if (!ok) continue; |
89 | 92 |
90 QString file = line.right(line.length() - 2); | 93 QString file = line.right(line.length() - 2); |
91 QStringList *bucket = stateToBucket(s); | 94 m_stateMap[file] = s; |
95 } | |
96 | |
97 foreach (QString file, m_stateMap.keys()) { | |
98 | |
99 QStringList *bucket = stateToBucket(m_stateMap[file]); | |
92 bucket->push_back(file); | 100 bucket->push_back(file); |
93 m_stateMap[file] = s; | |
94 } | 101 } |
95 | 102 |
96 DEBUG << "FileStates: " << m_modified.size() << " modified, " << m_added.size() | 103 DEBUG << "FileStates: " << m_modified.size() << " modified, " << m_added.size() |
97 << " added, " << m_removed.size() << " removed, " << m_missing.size() | 104 << " added, " << m_removed.size() << " removed, " << m_missing.size() |
98 << " missing, " << m_inConflict.size() << " in conflict, " | 105 << " missing, " << m_inConflict.size() << " in conflict, " |