Anton Shestakov <av6@dwimlabs.net>, Tue, 05 Feb 2019 22:49:35 +0800
plugin: use configurable base URL instead of paths.default in repo hgrc
Let's hope we'll never need nested repos, or special cases, or anything else
ever. If we do, maybe make URL configurable for each repo.
--- a/config.py Sun Dec 16 11:17:34 2018 +0800
+++ b/config.py Tue Feb 05 22:49:35 2019 +0800
registry.String('/home/hg/repos/evolve',
"""Path to the evolve repo."""))
+conf.registerGlobalValue(Mercurial, 'hgweburl',
+ registry.String('https://www.mercurial-scm.org/repo',
+ """URL of the hgweb instance."""))
conf.registerGlobalValue(Mercurial, 'phaburl',
registry.String('https://phab.mercurial-scm.org',
"""URL of the phabricator instance."""))
--- a/plugin.py Sun Dec 16 11:17:34 2018 +0800
+++ b/plugin.py Tue Feb 05 22:49:35 2019 +0800
lines = ['%s %s %s' % (node, user, date)] + lines
- baseurl, err = self.hg.run(['-R', repo, 'paths', 'default'])
- url = "%s/rev/%s" % (baseurl.strip("\n/"), rev)
+ baseurl = self.registryValue('hgweburl').rstrip('/')
+ reponame = os.path.basename(os.path.normpath(repo))
+ url = '{}/{}/rev/{}'.format(baseurl, reponame, rev)
irc.replies(lines[:2] + [url], joiner=' - ')
--- a/test.py Sun Dec 16 11:17:34 2018 +0800
+++ b/test.py Tue Feb 05 22:49:35 2019 +0800
self.assertHelp('glossary')
- self.assertRegexp('main 0', 'Mercurial plugin 0\.1')
+ self.assertRegexp('main 0', 'Mercurial plugin 0\.1.*http.*/rev/0')
self.assertNotError('main null')