public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
* [gentoo-commits] portage r15185 - main/trunk/bin
@ 2010-01-10 14:41 Fabian Groffen (grobian)
  0 siblings, 0 replies; only message in thread
From: Fabian Groffen (grobian) @ 2010-01-10 14:41 UTC (permalink / raw
  To: gentoo-commits

Author: grobian
Date: 2010-01-10 14:41:10 +0000 (Sun, 10 Jan 2010)
New Revision: 15185

Modified:
   main/trunk/bin/repoman
Log:
Add Bazaar (bzr) support for repoman, test-driven by Fauli (Christian Faulhammer)

Modified: main/trunk/bin/repoman
===================================================================
--- main/trunk/bin/repoman	2010-01-09 15:29:51 UTC (rev 15184)
+++ main/trunk/bin/repoman	2010-01-10 14:41:10 UTC (rev 15185)
@@ -483,11 +483,13 @@
 	vcs = "svn"
 elif os.path.isdir(os.path.join(portdir_overlay, ".git")):
 	vcs = "git"
+elif os.path.isdir(os.path.join(portdir_overlay, ".bzr")):
+	vcs = "bzr"
 
 vcs_local_opts = repoman_settings.get("REPOMAN_VCS_LOCAL_OPTS", "").split()
 vcs_global_opts = repoman_settings.get("REPOMAN_VCS_GLOBAL_OPTS")
 if vcs_global_opts is None:
-	if vcs != "git":
+	if vcs not in ["git", "bzr"]:
 		vcs_global_opts = "-q"
 	else:
 		vcs_global_opts = ""
@@ -925,6 +927,11 @@
 		mynew = [elem[repo_subdir_len:] for elem in mynew \
 			if elem[:repo_subdir_len] == repo_subdir]
 	mynew = ["./" + elem[:-1] for elem in mynew]
+elif vcs == "bzr":
+	bzrstatus = os.popen("bzr status -S").readlines()
+	mychanged = [ "./" + elem.split()[-1:][0].split('/')[-1:][0] for elem in bzrstatus if elem and elem[1:2] == "M" ]
+	mynew     = [ "./" + elem.split()[-1:][0].split('/')[-1:][0] for elem in bzrstatus if elem and ( elem[1:2] == "NK" or elem[0:1] == "R" ) ]
+
 if vcs:
 	new_ebuilds.update(x for x in mynew if x.endswith(".ebuild"))
 	modified_changelogs.update(x for x in chain(mychanged, mynew) \
@@ -1094,12 +1101,14 @@
 					os.path.join(x, os.path.basename(l[:-1])))
 		myf.close()
 
-	if vcs in ("cvs", "svn") and check_ebuild_notadded:
+	if vcs in ("cvs", "svn", "bzr") and check_ebuild_notadded:
 		try:
 			if vcs == "cvs":
 				myf=open(checkdir+"/CVS/Entries","r")
 			if vcs == "svn":
 				myf = os.popen("svn status --depth=files --verbose " + checkdir)
+			if vcs == "bzr":
+				myf = os.popen("bzr status -S " + checkdir)
 			myl = myf.readlines()
 			myf.close()
 			for l in myl:
@@ -1120,6 +1129,12 @@
 					l = l.split()[-1]
 					if l[-7:] == ".ebuild":
 						eadded.append(os.path.basename(l[:-7]))
+				if vcs == "bzr":
+					if l[1:2] == "?":
+						continue
+					l = l.split()[-1]
+					if l[-7:] == ".ebuild":
+						eadded.append(os.path.basename(l[:-7]))
 			if vcs == "svn":
 				myf = os.popen("svn status " + checkdir)
 				myl=myf.readlines()
@@ -1130,12 +1145,16 @@
 						if l[-7:] == ".ebuild":
 							eadded.append(os.path.basename(l[:-7]))
 		except IOError:
-			if options.mode == 'commit' and vcs == "cvs":
-				stats["CVS/Entries.IO_error"] += 1
-				fails["CVS/Entries.IO_error"].append(checkdir+"/CVS/Entries")
-			if options.mode == 'commit' and vcs == "svn":
-				stats["svn.IO_error"] += 1
-				fails["svn.IO_error"].append(checkdir+"svn info")
+			if options.mode == 'commit':
+				if vcs == "cvs":
+					stats["CVS/Entries.IO_error"] += 1
+					fails["CVS/Entries.IO_error"].append(checkdir+"/CVS/Entries")
+				elif vcs == "svn":
+					stats["svn.IO_error"] += 1
+					fails["svn.IO_error"].append(checkdir)
+				elif vcs == "bzr":
+					stats["bzr.IO_error"] += 1
+					fails["bzr.IO_error"].append(checkdir)
 			continue
 
 	mf = Manifest(checkdir, repoman_settings["DISTDIR"])
@@ -1304,7 +1323,7 @@
 		if stat.S_IMODE(os.stat(full_path).st_mode) & 0o111:
 			stats["file.executable"] += 1
 			fails["file.executable"].append(x+"/"+y+".ebuild")
-		if vcs in ("cvs", "svn") and check_ebuild_notadded and y not in eadded:
+		if vcs in ("cvs", "svn", "bzr") and check_ebuild_notadded and y not in eadded:
 			#ebuild not added to vcs
 			stats["ebuild.notadded"]=stats["ebuild.notadded"]+1
 			fails["ebuild.notadded"].append(x+"/"+y+".ebuild")
@@ -1949,7 +1968,16 @@
 		myf = os.popen("git ls-files --others")
 		myunadded = [ "./" + elem[:-1] for elem in myf ]
 		myf.close()
+	if vcs == "bzr":
+		try:
+			bzrstatus=os.popen("bzr status -S").readlines()
+			myunadded = [ "./"+elem.rstrip().split()[1].split('/')[-1:][0] for elem in bzrstatus if elem.startswith("?") or elem[0:2] == " D" ]
+		except SystemExit as e:
+			raise  # TODO propogate this
+		except:
+			err("Error retrieving bzr info; exiting.")
 
+
 	myautoadd=[]
 	if myunadded:
 		for x in range(len(myunadded)-1,-1,-1):
@@ -1967,18 +1995,22 @@
 		if options.pretend:
 			if vcs == "cvs":
 				print("(cvs add "+" ".join(myautoadd)+")")
-			if vcs == "svn":
+			elif vcs == "svn":
 				print("(svn add "+" ".join(myautoadd)+")")
 			elif vcs == "git":
 				print("(git add "+" ".join(myautoadd)+")")
+			elif vcs == "bzr":
+				print("(bzr add "+" ".join(myautoadd)+")")
 			retval=0
 		else:
 			if vcs == "cvs":
 				retval=os.system("cvs add "+" ".join(myautoadd))
-			if vcs == "svn":
+			elif vcs == "svn":
 				retval=os.system("svn add "+" ".join(myautoadd))
 			elif vcs == "git":
 				retval=os.system("git add "+" ".join(myautoadd))
+			elif vcs == "bzr":
+				retval=os.system("bzr add "+" ".join(myautoadd))
 		if retval:
 			writemsg_level("!!! Exiting on %s (shell) error code: %s\n" % \
 				(vcs, retval), level=logging.ERROR, noiselevel=-1)
@@ -2043,6 +2075,14 @@
 				if elem[:repo_subdir_len] == repo_subdir]
 		myremoved = ["./" + elem[:-1] for elem in myremoved]
 
+	if vcs == "bzr":
+		bzrstatus = os.popen("bzr status -S").readlines()
+		mychanged = [ "./" + elem.split()[-1:][0].split('/')[-1:][0] for elem in bzrstatus if elem and elem[1:2] == "M" ]
+		mynew     = [ "./" + elem.split()[-1:][0].split('/')[-1:][0] for elem in bzrstatus if elem and ( elem[1:2] in "NK" or elem[0:1] == "R" ) ]
+		myremoved = [ "./" + elem.split()[-1:][0].split('/')[-1:][0] for elem in bzrstatus if elem.startswith("-") ]
+		myremoved = [ "./" + elem.split()[-3:-2][0].split('/')[-1:][0] for elem in bzrstatus if elem and ( elem[1:2] == "K" or elem[0:1] == "R" ) ]
+		# Bazaar expands nothing.
+
 	if vcs:
 		if not (mychanged or mynew or myremoved):
 			print(green("RepoMan sez:"), "\"Doing nothing is not always good for QA.\"")
@@ -2085,9 +2125,9 @@
 			myheaders.append(myfile)
 
 	print("* %s files being committed..." % green(str(len(myupdates))), end=' ')
-	if vcs == 'git':
-		# With git, there's never any keyword expansion, so there's
-		# no need to regenerate manifests and all files will be
+	if vcs in ('git', 'bzr'):
+		# With git and bzr, there's never any keyword expansion, so
+		# there's no need to regenerate manifests and all files will be
 		# committed in one big commit at the end.
 		print()
 	else:
@@ -2141,7 +2181,7 @@
 		commitmessage += ", RepoMan options: --force"
 	commitmessage += ")"
 
-	if vcs != 'git' and (myupdates or myremoved):
+	if vcs not in ['git', 'bzr'] and (myupdates or myremoved):
 		myfiles = myupdates + myremoved
 		if not myheaders and "sign" not in repoman_settings.features:
 			myfiles += mymanifests
@@ -2234,7 +2274,7 @@
 			write_atomic(x, "".join(mylines))
 
 	manifest_commit_required = True
-	if vcs != 'git' and (myupdates or myremoved):
+	if vcs not in ['git', 'bzr'] and (myupdates or myremoved):
 		myfiles = myupdates + myremoved
 		for x in range(len(myfiles)-1, -1, -1):
 			if myfiles[x].count("/") < 4-repolevel:
@@ -2377,10 +2417,10 @@
 					level=logging.ERROR, noiselevel=-1)
 				sys.exit(retval)
 
-	if vcs == 'git' or manifest_commit_required or signed:
+	if vcs in ['git', 'bzr'] or manifest_commit_required or signed:
 
 		myfiles = mymanifests[:]
-		if vcs == 'git':
+		if vcs in ['git', 'bzr']:
 			myfiles += myupdates
 			myfiles += myremoved
 		myfiles.sort()




^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2010-01-10 14:41 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-01-10 14:41 [gentoo-commits] portage r15185 - main/trunk/bin Fabian Groffen (grobian)

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox