repoman: simplify digestgen and gpgsign loops
authorZac Medico <zmedico@gentoo.org>
Sat, 15 Oct 2011 03:21:18 +0000 (20:21 -0700)
committerZac Medico <zmedico@gentoo.org>
Sat, 15 Oct 2011 03:21:18 +0000 (20:21 -0700)
We can re-use the vcs_files_to_cps() function from commit
9c9145a9e3c2d8d1bcebf791ce2188add656fee2.

bin/repoman

index 4a157e5360c3d3ced11dd5237084a3a22075c7ac..ebe06f8ad9566a279b5f59d245b873f4429c59d0 100755 (executable)
@@ -2648,87 +2648,25 @@ else:
                        portage.util.write_atomic(x, b''.join(mylines),
                                mode='wb')
 
+       if repolevel == 1:
+               print(green("RepoMan sez:"), "\"You're rather crazy... "
+                       "doing the entire repository.\"\n")
+
        if vcs in ('cvs', 'svn') and (myupdates or myremoved):
-               myfiles = myupdates + myremoved
-               for x in range(len(myfiles)-1, -1, -1):
-                       if myfiles[x].count("/") < 4-repolevel:
-                               del myfiles[x]
-               mydone=[]
-               if repolevel==3:   # In a package dir
-                       repoman_settings["O"] = startdir
+
+               for x in sorted(vcs_files_to_cps(
+                       chain(myupdates, myremoved, mymanifests))):
+                       repoman_settings["O"] = os.path.join(repodir, x)
                        digestgen(mysettings=repoman_settings, myportdb=portdb)
-               elif repolevel==2: # In a category dir
-                       for x in myfiles:
-                               xs=x.split("/")
-                               if len(xs) < 4-repolevel:
-                                       continue
-                               if xs[0]==".":
-                                       xs=xs[1:]
-                               if xs[0] in mydone:
-                                       continue
-                               mydone.append(xs[0])
-                               repoman_settings["O"] = os.path.join(startdir, xs[0])
-                               if not os.path.isdir(repoman_settings["O"]):
-                                       continue
-                               digestgen(mysettings=repoman_settings, myportdb=portdb)
-               elif repolevel==1: # repo-cvsroot
-                       print(green("RepoMan sez:"), "\"You're rather crazy... doing the entire repository.\"\n")
-                       for x in myfiles:
-                               xs=x.split("/")
-                               if len(xs) < 4-repolevel:
-                                       continue
-                               if xs[0]==".":
-                                       xs=xs[1:]
-                               if "/".join(xs[:2]) in mydone:
-                                       continue
-                               mydone.append("/".join(xs[:2]))
-                               repoman_settings["O"] = os.path.join(startdir, xs[0], xs[1])
-                               if not os.path.isdir(repoman_settings["O"]):
-                                       continue
-                               digestgen(mysettings=repoman_settings, myportdb=portdb)
-               else:
-                       print(red("I'm confused... I don't know where I am!"))
-                       sys.exit(1)
 
        signed = False
        if sign_manifests:
                signed = True
-               myfiles = myupdates + myremoved + mymanifests
                try:
-                       if repolevel==3:   # In a package dir
-                               repoman_settings["O"] = "."
+                       for x in sorted(vcs_files_to_cps(
+                               chain(myupdates, myremoved, mymanifests))):
+                               repoman_settings["O"] = os.path.join(repodir, x)
                                gpgsign(os.path.join(repoman_settings["O"], "Manifest"))
-                       elif repolevel==2: # In a category dir
-                               mydone=[]
-                               for x in myfiles:
-                                       xs=x.split("/")
-                                       if len(xs) < 4-repolevel:
-                                               continue
-                                       if xs[0]==".":
-                                               xs=xs[1:]
-                                       if xs[0] in mydone:
-                                               continue
-                                       mydone.append(xs[0])
-                                       repoman_settings["O"] = os.path.join(".", xs[0])
-                                       if not os.path.isdir(repoman_settings["O"]):
-                                               continue
-                                       gpgsign(os.path.join(repoman_settings["O"], "Manifest"))
-                       elif repolevel==1: # repo-cvsroot
-                               print(green("RepoMan sez:"), "\"You're rather crazy... doing the entire repository.\"\n")
-                               mydone=[]
-                               for x in myfiles:
-                                       xs=x.split("/")
-                                       if len(xs) < 4-repolevel:
-                                               continue
-                                       if xs[0]==".":
-                                               xs=xs[1:]
-                                       if "/".join(xs[:2]) in mydone:
-                                               continue
-                                       mydone.append("/".join(xs[:2]))
-                                       repoman_settings["O"] = os.path.join(".", xs[0], xs[1])
-                                       if not os.path.isdir(repoman_settings["O"]):
-                                               continue
-                                       gpgsign(os.path.join(repoman_settings["O"], "Manifest"))
                except portage.exception.PortageException as e:
                        portage.writemsg("!!! %s\n" % str(e))
                        portage.writemsg("!!! Disabled FEATURES='sign'\n")