diff --git a/ChangeLog b/ChangeLog index d73d543dc..49f82fc65 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ + * Added revision command for finding out the revision of the files + in a running bot; also added __revision__ strings with $Id$ values + so CVS would be happy to keep such information for us :) + * Fixed bug #848475 -- bad error message from regexp-expecting commands. diff --git a/src/Misc.py b/src/Misc.py index ed8eb12ac..6da57e1bb 100755 --- a/src/Misc.py +++ b/src/Misc.py @@ -191,12 +191,46 @@ class Misc(callbacks.Privmsg): """ irc.reply(msg, conf.version) + def revision(self, irc, msg, args): + """[] + + Gives the latest revision of . If isn't given, gives + the revision of all supybot modules. + """ + name = privmsgs.getArgs(args, required=0, optional=1) + if name: + try: + module = sys.modules[name] + except KeyError: + irc.error(msg, 'I couldn\'t find a module named %s' % name) + return + if hasattr(module, '__revision__'): + irc.reply(msg, module.__revision__) + else: + irc.error(msg, 'Module %s has no __revision__.' % name) + else: + def getVersion(s): + return s.split(None, 3)[2] + names = {} + dirs = map(os.path.abspath, conf.pluginDirs) + for (name, module) in sys.modules.iteritems(): + if hasattr(module, '__revision__'): + if 'supybot' in module.__file__: + names[name] = getVersion(module.__revision__) + else: + for dir in dirs: + if dir in module.__file__: + names[name] = getVersion(module.__revision__) + break + L = ['%s: %s' % (k, v) for (k, v) in names.items()] + irc.reply(msg, utils.commaAndify(L)) + def source(self, irc, msg, args): """takes no arguments Returns a URL saying where to get SupyBot. """ - irc.reply(msg, 'My source is at http://www.sf.net/projects/supybot/') + irc.reply(msg, 'My source is at http://supybot.sf.net/') def logfilesize(self, irc, msg, args): """[] diff --git a/test/test_Misc.py b/test/test_Misc.py index a7649c939..8e303eb08 100644 --- a/test/test_Misc.py +++ b/test/test_Misc.py @@ -150,6 +150,10 @@ class MiscTestCase(ChannelPluginTestCase, PluginDocumentation): def testApropos(self): self.assertNotError('apropos f') self.assertError('apropos asldkfjasdlkfja') + + def testRevision(self): + self.assertNotError('revision Misc') + self.assertNotError('revision')