From e862d409e16eb668242d2a26f950613d7ac0f82a Mon Sep 17 00:00:00 2001 From: =?utf8?q?Bar=C4=B1=C5=9F=20Metin?= Date: Wed, 16 Jun 2010 13:02:12 +0200 Subject: [PATCH] add module-diff command --- module-diff | 1 + module-tools.py | 83 ++++++++++++++++++++++++++++++++++++++++++++----- 2 files changed, 77 insertions(+), 7 deletions(-) create mode 120000 module-diff diff --git a/module-diff b/module-diff new file mode 120000 index 00000000..323e9ad8 --- /dev/null +++ b/module-diff @@ -0,0 +1 @@ +module-tools.py \ No newline at end of file diff --git a/module-tools.py b/module-tools.py index 7ce0bdc0..0aa635e0 100755 --- a/module-tools.py +++ b/module-tools.py @@ -832,9 +832,13 @@ that for other purposes than tagging""" % options.workdir found_tagname = old_svn_tag_name if (found and need_it) or (not found and not need_it): - print "OK " + if self.options.verbose: + print "OK", + if found: print "- found" + else: print "- not found" else: - print "KO" + if self.options.verbose: + print "KO" if found: raise Exception, "tag (%s) is already there" % tagname else: @@ -999,6 +1003,43 @@ n: move to next file"""%locals() self.html_print_end() +############################## + def do_diff (self): + self.init_module_dir() + self.revert_module_dir() + self.update_module_dir() + spec_dict = self.spec_dict() + self.show_dict(spec_dict) + + # side effects + tag_name = self.tag_name(spec_dict) + old_svn_tag_name = self.tag_name(spec_dict, old_svn_name=True) + + # sanity check + tag_name = self.check_tag(tag_name, need_it=True, old_svn_tag_name=old_svn_tag_name) + + if self.options.verbose: + print 'Getting diff' + diff_output = self.repository.diff_with_tag(tag_name) + + if self.options.list: + if diff_output: + print self.name + else: + thename=self.friendly_name() + do_print=False + if self.options.www and diff_output: + self.html_store_title("Diffs in module %s (%s) : %d chars"%(\ + thename,self.last_tag(spec_dict),len(diff_output))) + + self.html_store_raw ('

< (left) %s

' % tag_name) + self.html_store_raw ('

> (right) %s

' % thename) + self.html_store_pre (diff_output) + elif not self.options.www: + print 'x'*30,'module',thename + print 'x'*20,'<',tag_name + print 'x'*20,'>',thename + print diff_output ############################## # store and restitute html fragments @@ -1042,8 +1083,7 @@ n: move to next file"""%locals() def html_dump_header(title): nowdate=time.strftime("%Y-%m-%d") nowtime=time.strftime("%H:%M (%Z)") - print """ - + print """ %s @@ -1173,6 +1213,10 @@ Branches: if mode in ["diff","version"] : parser.add_option("-W","--www", action="store", dest="www", default=False, help="export diff in html format, e.g. -W trunk") + + if mode == "diff" : + parser.add_option("-l","--list", action="store_true", dest="list", default=False, + help="just list modules that exhibit differences") default_modules_list=os.path.dirname(sys.argv[0])+"/modules.list" parser.add_option("-n","--dry-run",action="store_true",dest="dry_run",default=False, @@ -1212,7 +1256,13 @@ Branches: sys.exit(1) Module.init_homedir(options) + + + modules=[ Module(modname,options) for modname in args ] + # hack: create a dummy Module to store errors/warnings + error_module = Module('__errors__',options) + for module in modules: if len(args)>1 and mode not in Main.silent_modes: print '========================================',module.friendly_name() @@ -1221,9 +1271,28 @@ Branches: try: method(module) except Exception,e: - import traceback - traceback.print_exc() - print 'Skipping module %s: '%modname,e + if options.www: + title=' Skipping module %s - failure: %s '%\ + (module.friendly_name(), str(e)) + error_module.html_store_title(title) + else: + import traceback + traceback.print_exc() + print 'Skipping module %s: '%modname,e + + if options.www: + if mode == "diff": + modetitle="Changes to tag in %s"%options.www + elif mode == "version": + modetitle="Latest tags in %s"%options.www + modules.append(error_module) + error_module.html_dump_header(modetitle) + for module in modules: + module.html_dump_toc() + Module.html_dump_middle() + for module in modules: + module.html_dump_body() + Module.html_dump_footer() #################### if __name__ == "__main__" : -- 2.47.0