(no commit message)
[build.git] / module-tools.py
index 1c2ec66..594f81c 100755 (executable)
@@ -48,6 +48,13 @@ def prompt (question,default=True,other_choices=[],allow_outside=False):
     except:
         raise
 
+def default_editor():
+    try:
+        editor = os.environ['EDITOR']
+    except:
+        editor = "emacs"
+    return editor
+
 class Command:
     def __init__ (self,command,options):
         self.command=command
@@ -66,7 +73,7 @@ class Command:
             sys.stdout.flush()
         retcod=os.system(self.command + " &> " + self.tmp)
         if retcod != 0:
-            print "FAILED ! -- output quoted below "
+            print "FAILED ! -- out+err below (command was %s)"%self.command
             os.system("cat " + self.tmp)
             print "FAILED ! -- end of quoted output"
         elif self.options.verbose:
@@ -143,7 +150,7 @@ class Module:
 
 
     # for parsing module spec name:branch
-    matcher_branch_spec=re.compile("\A(?P<name>[\w-]+):(?P<branch>[\w\.]+)\Z")
+    matcher_branch_spec=re.compile("\A(?P<name>[\w-]+):(?P<branch>[\w\.-]+)\Z")
     matcher_rpm_define=re.compile("%(define|global)\s+(\S+)\s+(\S*)\s*")
 
     def __init__ (self,module_spec,options):
@@ -364,8 +371,8 @@ that for other purposes than tagging"""%topdir
                 for (key,was_changed) in changed.iteritems():
                     if not was_changed:
                         if self.options.debug:
-                            print 'rewriting missed %s as %s'%(key,patch_dict[key])
-                        new.write('%%define %s %s\n'%(key,patch_dict[key]))
+                            print 'rewriting missing %s as %s'%(key,patch_dict[key])
+                        new.write('\n%%define %s %s\n'%(key,patch_dict[key]))
             spec.close()
             new.close()
             os.rename(newspecfile,specfile)
@@ -392,9 +399,9 @@ that for other purposes than tagging"""%topdir
                 if re.compile('%changelog').match(line):
                     dateformat="* %a %b %d %Y"
                     datepart=time.strftime(dateformat)
-                    logpart="%s <%s> - %s %s"%(Module.config['username'],
+                    logpart="%s <%s> - %s"%(Module.config['username'],
                                                  Module.config['email'],
-                                                 oldtag,newtag)
+                                                 newtag)
                     new.write(datepart+" "+logpart+"\n")
                     for logline in self.unignored_lines(logfile):
                         new.write("- " + logline)
@@ -691,6 +698,8 @@ Please write a changelog for this new tag in the section above
             buildname=Module.config['build']
         except:
             buildname="build"
+        if self.options.build_branch:
+            buildname+=":"+self.options.build_branch
         build = Module(buildname,self.options)
         build.init_moddir()
         build.init_edge_dir()
@@ -895,8 +904,10 @@ More help:
         if mode == "tag" :
             parser.add_option("-c","--no-changelog", action="store_false", dest="changelog", default=True,
                               help="do not update changelog section in specfile when tagging")
+            parser.add_option("-b","--build-branch", action="store", dest="build_branch", default=None,
+                              help="specify a build branch; used for locating the *tags*.mk files where adoption is to take place")
         if mode == "tag" or mode == "sync" :
-            parser.add_option("-e","--editor", action="store", dest="editor", default="emacs",
+            parser.add_option("-e","--editor", action="store", dest="editor", default=default_editor(),
                               help="specify editor")
         if mode == "sync" :
             parser.add_option("-m","--message", action="store", dest="message", default=None,
@@ -949,7 +960,7 @@ More help:
             try:
                 method(module)
             except Exception,e:
-                print 'Skipping failed %s - %r'%(modname,e)
+                print 'Skipping failed %s: '%modname,e
 
 if __name__ == "__main__" :
     try: