Exemplo n.º 1
0
	def doRecovery(self):
		if not self.loadManifest():
			return False

		self.mListProject = self.mManifest.getProjects()
		if self.mListProject == None:
			return False

		if not self.mVerbose:
			self.initProgress(len(self.mListProject))

		for node in self.mManifest.getProjects():
			relPath = self.getProjectRelPath(node)
			srcPath = self.getAbsPath(relPath)
			destPath = os.path.join(self.mPathProjects, relPath + ".git")
			manager = GitSvnManager(srcPath, self.mVerbose)
			if not manager.doRecovery(destPath):
				return False

			if not self.mVerbose:
				self.addProgress()

		if not self.mVerbose:
			self.finishProgress()

		return True
Exemplo n.º 2
0
	def doCleanup(self):
		if not self.loadManifest():
			return False

		for node in self.mManifest.getProjects():
			pathname = self.getProjectAbsPath(node)
			self.prBrownInfo("Cleaning ", pathname)
			manager = GitSvnManager(pathname, self.mVerbose)
			if not manager.doGitClean(pathname):
				return False

		return True
Exemplo n.º 3
0
	def doPull(self, branch = "master"):
		if not self.loadManifest():
			return False

		self.mListProject = self.mManifest.getProjects()
		if self.mListProject == None:
			return False

		remote = self.mManifest.getRemoteName()
		if not remote:
			remote = "cavan-svn"

		if not self.mVerbose:
			self.initProgress(len(self.mListProject))

		for node in self.mManifest.getProjects():
			manager = GitSvnManager(self.getProjectAbsPath(node), self.mVerbose)
			if manager.gitCheckout(branch):
				if not manager.doExecGitCmd(["pull", remote, branch], of = "/dev/null", ef = "/dev/null"):
					self.prRedInfo("fetch %s failed" % manager.getRootPath())
					return False
			elif manager.hasBranch(branch):
				self.prRedInfo("checkout %s to %s failed" % (manager.getRootPath(), branch))
				return False

			if not self.mVerbose:
				self.addProgress()

		if not self.mVerbose:
			self.finishProgress()

		return True
Exemplo n.º 4
0
	def fetchProject(self):
		self.mLockProject.acquire()
		length = len(self.mListProject)
		if self.mErrorCount == 0 and length > 0:
			node = self.mListProject.pop(0)
		else:
			node = None
		self.mLockProject.release()

		if not node:
			return 0

		relPath = self.getProjectRelPath(node)
		srcPath = self.getAbsPath(relPath)

		destPath = os.path.join(self.mPathProjects, relPath + ".git")
		relDestPath = self.getRelPath(destPath)
		relDestPath = os.path.join(self.getRelRoot(relPath), relDestPath)

		manager = GitSvnManager(srcPath, self.mVerbose)
		manager.doRecovery(destPath)

		iResult = self.fetchProjectBase(manager, node[0])
		if iResult < 1:
			return iResult

		if not manager.isInitialized():
			self.mListEmpty.append(node)
			return iResult

		if not manager.doBackup(destPath):
			return -1

		return iResult
Exemplo n.º 5
0
	def doMerge(self, argv):
		if len(argv) > 1:
			branch = argv[0]
			destBranch = argv[1]
		else:
			if len(argv) > 0:
				branch = argv[0]
			else:
				branch = "master"
			destBranch = "cavan"

		if not self.getChoice("Merge branch %s to %s" % (branch, destBranch)):
			return False

		if not self.loadManifest():
			return False

		self.mListProject = self.mManifest.getProjects()
		if self.mListProject == None:
			return False

		if not self.mVerbose:
			self.initProgress(len(self.mListProject))

		for node in self.mManifest.getProjects():
			manager = GitSvnManager(self.getProjectAbsPath(node), self.mVerbose)
			if not manager.doGitMerge(branch, destBranch):
				self.prRedInfo("checkout %s to %s failed" % (manager.getRootPath(), branch))
				return False

			if not self.mVerbose:
				self.addProgress()

		if not self.mVerbose:
			self.finishProgress()

		return True
Exemplo n.º 6
0
	def doCheckout(self, argv):
		if len(argv) < 1:
			self.prRedInfo("Please give the branch name")
			return False

		branch = argv[0]

		if not self.loadManifest():
			return False

		self.mListProject = self.mManifest.getProjects()
		if self.mListProject == None:
			return False

		remote = self.mManifest.getRemoteName()
		if not remote:
			remote = "cavan-svn"

		if not self.mVerbose:
			self.initProgress(len(self.mListProject))

		for node in self.mManifest.getProjects():
			manager = GitSvnManager(self.getProjectAbsPath(node), self.mVerbose, name = None)
			if not manager.gitCheckout(branch):
				if manager.hasBranch(branch):
					self.prRedInfo("checkout %s to %s failed" % (manager.getRootPath(), branch))
					return False
				manager.doExecGitCmd(["checkout", "-b", branch, os.path.join(remote, branch)], of = "/dev/null", ef = "/dev/null")

			if not self.mVerbose:
				self.addProgress()

		if not self.mVerbose:
			self.finishProgress()

		return True
Exemplo n.º 7
0
	def fetchProjectBase(self, manager, name):
		url = os.path.join(self.mUrl, name)

		for count in range(2):
			if self.mErrorCount > 0:
				return -1

			if (manager.isInitialized() or manager.doInitBase(url)) and (manager.doSync(url) or manager.doDcommit(url)):
				self.addProgress()
				return 1

			if not self.doExecute(["svn", "info", url], of = "/dev/null"):
				return -1

			self.prRedInfo("Retry count = %d" % count)
			manager.removeSelf()

		self.mLockProject.acquire()
		tmpPathname = self.getTempProjectPath()
		self.mLockProject.release()

		if tmpPathname != None:
			if self.mVerbose:
				self.prRedInfo(url, " => ", tmpPathname)

			managerTemp = GitSvnManager(tmpPathname, self.mVerbose)
			if managerTemp.doInitBase(url) and managerTemp.doSync(url) and self.doExecute(["mv", managerTemp.getRootPath(), manager.getRootPath()]):
				self.addProgress()
				return 1

			managerTemp.removeSelf()

		self.prRedInfo("Checkout ", manager.getRootPath(), " Failed")

		self.mLockProject.acquire()
		self.mErrorCount = self.mErrorCount + 1
		file_append_line(self.mFileFailed, "%s => %s" % (manager.getRootPath(), url))
		self.mLockProject.release()

		return -1