Esempio n. 1
0
bool Lanes::isFork(const CGitHash& sha, bool& isDiscontinuity) {

	int pos = findNextSha(sha, 0);
	isDiscontinuity = (activeLane != pos);
	if (pos == -1) // new branch case
		return false;

	return (findNextSha(sha, pos + 1) != -1);
/*
	int cnt = 0;
	while (pos != -1) {
		cnt++;
		pos = findNextSha(sha, pos + 1);
//		if (isDiscontinuity)
//			isDiscontinuity = (activeLane != pos);
	}
	return (cnt > 1);
*/
}
Esempio n. 2
0
void Lanes::setFork(const CGitHash& sha) {

	int rangeStart, rangeEnd, idx;
	rangeStart = rangeEnd = idx = findNextSha(sha, 0);

	while (idx != -1) {
		rangeEnd = idx;
		typeVec[idx] = TAIL;
		idx = findNextSha(sha, idx + 1);
	}
	typeVec[activeLane] = NODE;

	int& startT = typeVec[rangeStart];
	int& endT = typeVec[rangeEnd];

	if (startT == NODE)
		startT = NODE_L;

	if (endT == NODE)
		endT = NODE_R;

	if (startT == TAIL)
		startT = TAIL_L;

	if (endT == TAIL)
		endT = TAIL_R;

	for (int i = rangeStart + 1; i < rangeEnd; ++i) {

		int& t = typeVec[i];

		if (t == NOT_ACTIVE)
			t = CROSS;

		else if (t == EMPTY)
			t = CROSS_EMPTY;
	}
}
Esempio n. 3
0
void Lanes::changeActiveLane(const CGitHash& sha) {

	int& t = typeVec[activeLane];
	if (t == INITIAL || isBoundary(t))
		t = EMPTY;
	else
		t = NOT_ACTIVE;

	int idx = findNextSha(sha, 0); // find first sha
	if (idx != -1)
		typeVec[idx] = ACTIVE; // called before setBoundary()
	else
		idx = add(BRANCH, sha, activeLane); // new branch

	activeLane = idx;
}
Esempio n. 4
0
void Lanes::setMerge(const CGitHashList& parents) {
// setFork() must be called before setMerge()

	if (boundary)
		return; // handle as a simple active line

	int& t = typeVec[activeLane];
	bool wasFork   = (t == NODE);
	bool wasFork_L = (t == NODE_L);
	bool wasFork_R = (t == NODE_R);
	bool startJoinWasACross = false, endJoinWasACross = false;
	bool endWasEmptyCross = false;

	t = NODE;

	int rangeStart = activeLane, rangeEnd = activeLane;
	CGitHashList::const_iterator it(parents.cbegin());
	for (++it; it != parents.cend(); ++it) { // skip first parent

		int idx = findNextSha(*it, 0);
		if (idx != -1) {

			if (idx > rangeEnd) {

				rangeEnd = idx;
				endJoinWasACross = typeVec[idx] == CROSS;
			}

			if (idx < rangeStart) {

				rangeStart = idx;
				startJoinWasACross = typeVec[idx] == CROSS;
			}

			typeVec[idx] = JOIN;
		}
		else
			rangeEnd = add(HEAD, *it, rangeEnd + 1, endWasEmptyCross);
	}
	int& startT = typeVec[rangeStart];
	int& endT = typeVec[rangeEnd];

	if (startT == NODE && !wasFork && !wasFork_R)
		startT = NODE_L;

	if (endT == NODE && !wasFork && !wasFork_L)
		endT = NODE_R;

	if (startT == JOIN && !startJoinWasACross)
		startT = JOIN_L;

	if (endT == JOIN && !endJoinWasACross)
		endT = JOIN_R;

	if (startT == HEAD)
		startT = HEAD_L;

	if (endT == HEAD && !endWasEmptyCross)
		endT = HEAD_R;

	for (int i = rangeStart + 1; i < rangeEnd; ++i) {

		int& t2 = typeVec[i];

		if (t2 == NOT_ACTIVE)
			t2 = CROSS;

		else if (t2 == EMPTY)
			t2 = CROSS_EMPTY;

		else if (t2 == TAIL_R || t2 == TAIL_L)
			t2 = TAIL;
	}
}