bool HistoryView::getLaneParentsChilds(SCRef sha, int x, SList p, SList c) { ListViewDelegate* lvd = static_cast<ListViewDelegate*>(itemDelegate()); uint lane = x / lvd->laneWidth(); int t = getLaneType(sha, lane); if (t == EMPTY || t == -1) return false; // first find the parents p.clear(); QString root; if (!isFreeLane(t)) { p = git->revLookup(sha, fh)->parents(); // pointer cannot be NULL root = sha; } else { SCRef par(git->getLaneParent(sha, lane)); if (par.isEmpty()) { dbs("ASSERT getLaneParentsChilds: parent not found"); return false; } p.append(par); root = p.first(); } // then find children c = git->getChilds(root); return true; }
bool CommitImpl::getFiles(SList selFiles) { // check for files to commit selFiles.clear(); QTreeWidgetItemIterator it(treeWidgetFiles); while (*it) { if ((*it)->checkState(0) == Qt::Checked) selFiles.append((*it)->text(0)); ++it; } return !selFiles.isEmpty(); }
bool Annotate::setAnnotation(SCRef diff, SCRef author, SCList prevAnn, SList newAnn, int ofs) { newAnn.clear(); QStringList::const_iterator cur(prevAnn.constBegin()); QString line; int idx = 0, num, lineNumStart, lineNumEnd; int curLineNum = 1; // warning, starts from 1 instead of 0 bool inHeader = true; while (getNextSection(diff, idx, line, "\n")) { char firstChar = line.at(0).toLatin1(); if (inHeader) { if (firstChar == '@') inHeader = false; else continue; } switch (firstChar) { case '@': // an unified diff fragment header has form '@@ -a,b +c,d @@' // where 'a' is old file line number and 'b' is old file // number of lines of the hunk, 'c' and 'd' are the same // for new file. If the file does not have enough lines // then also the form '@@ -a +c @@' is used. if (ofs == 0) lineNumStart = line.indexOf('-') + 1; else // in this case we are given diff fragments with // faked small files that span the fragment plus // some padding. So we use 'c' instead of 'a' to // find the beginning of our patch in the faked file, // this value will be offsetted by ofs later lineNumStart = line.indexOf('+') + 1; lineNumEnd = line.indexOf(',', lineNumStart); if (lineNumEnd == -1) // small file case lineNumEnd = line.indexOf(' ', lineNumStart); num = line.mid(lineNumStart, lineNumEnd - lineNumStart).toInt(); num -= ofs; // offset for range filter computation // diff lines start from 1, 0 is empty file, // instead QValueList::at() starts from 0 if (num < 0 || num > prevAnn.size()) { dbp("ASSERT setAnnotation: start line number is %1", num); isError = true; return false; } for ( ; curLineNum < num; ++curLineNum) { newAnn.append(*cur); ++cur; } break; case '+': newAnn.append(author); break; case '-': if (curLineNum > prevAnn.size()) { dbp("ASSERT setAnnotation: remove end of " "file, diff is %1", diff); isError = true; return false; } else { ++cur; ++curLineNum; } break; case '\\': // diff(1) produces a "\ No newline at end of file", but the // message is locale dependent, so just test the space after '\' if (line[1] == ' ') break; // fall through default: if (curLineNum > prevAnn.size()) { dbp("ASSERT setAnnotation: end of " "file reached, diff is %1", diff); isError = true; return false; } else { newAnn.append(*cur); ++cur; ++curLineNum; } break; } } // copy the tail for ( ; curLineNum <= prevAnn.size(); ++curLineNum) { newAnn.append(*cur); ++cur; } return true; }