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
# 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):
if not os.path.isdir (self.moddir):
self.run_fatal("svn up -N %s"%self.moddir)
if not os.path.isdir (self.moddir):
- print 'Cannot find %s - check module name'%self.moddir
- sys.exit(1)
+ raise Exception, 'Cannot find %s - check module name'%self.moddir
def init_subdir (self,fullpath):
if self.options.verbose:
try:
return glob("%s/*.spec"%self.edge_dir())[0]
except:
- print 'Cannot guess specfile for module %s'%self.name
- sys.exit(1)
+ raise Exception, 'Cannot guess specfile for module %s'%self.name
def all_specnames (self):
return glob("%s/*.spec"%self.edge_dir())
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)
spec_dict[self.module_version_varname],
spec_dict[self.module_taglevel_varname])
except KeyError,err:
- print 'Something is wrong with module %s, cannot determine %s - exiting'%(self.name,err)
- sys.exit(1)
+ raise Exception, 'Something is wrong with module %s, cannot determine %s - exiting'%(self.name,err)
def tag_url (self, spec_dict):
return "%s/tags/%s"%(self.mod_url(),self.tag_name(spec_dict))
if self.options.verbose: print 'exists - OK'
else:
if self.options.verbose: print 'KO'
- print 'Could not find %s URL %s'%(message,url)
- sys.exit(1)
+ raise Exception, 'Could not find %s URL %s'%(message,url)
+
def check_svnpath_not_exists (self, url, message):
if self.options.fast_checks:
return
if self.options.verbose: print 'does not exist - OK'
else:
if self.options.verbose: print 'KO'
- print '%s URL %s already exists - exiting'%(message,url)
- sys.exit(1)
+ raise Exception, '%s URL %s already exists - exiting'%(message,url)
# locate specfile, parse it, check it and show values
incremented = int(rightmost)+1
new_trunk_name="%s.%d"%(leftpart,incremented)
except:
- print 'Cannot figure next branch name from %s - exiting'%version
- sys.exit(1)
+ raise Exception, 'Cannot figure next branch name from %s - exiting'%version
# record starting point tagname
latest_tag_name = self.tag_name(spec_dict)
if answer is True:
break
elif answer is False:
- sys.exit(1)
+ raise Exception,"User quit"
elif answer == 'd':
print '<<<< %s'%tag_url
print '>>>> %s'%edge_url
parser.add_option("-c","--no-changelog", action="store_false", dest="changelog", default=True,
help="do not update changelog section in specfile when tagging")
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,
print '========================================',module.friendly_name()
# call the method called do_<mode>
method=Module.__dict__["do_%s"%mode]
- method(module)
+ try:
+ method(module)
+ except Exception,e:
+ print 'Skipping failed %s - %r'%(modname,e)
if __name__ == "__main__" :
try: