Implement "multidir" configuration entries.
Wed Nov 9 00:17:31 UTC 2005 Alberto Bertogli <albertogli@telpin.com.ar>
* Implement "multidir" configuration entries.
This patch implements a special configuration entry called "multidir" that can
be useful when you have a lot of repositories in the same directory and don't
want to create an entry for each one.
{
hunk ./config.py.sample 78
+#
+# If you have several repositories in a single directory and don't want to
+# create a configuration entry for each one, you can use a "multidir" entry,
+# which serves as a "template" for all the repositories in that directory.
+# The name is taken from the directory, and inside the variables the string
+# "%(name)s" gets expanded to the it.
+#
+
+class multi1:
+ multidir = '/usr/local/src'
+ repodesc = 'Repository for %(name)s'
+ repourl = 'http://auriga.wearlab.de/~alb/repos/%(name)s'
+ repoencoding = 'latin1'
+
+
hunk ./darcsweb.cgi 1737
+ expand_multi_config(all_configs)
hunk ./darcsweb.cgi 1768
+def expand_multi_config(config):
+ """Expand configuration entries that serve as "template" to others;
+ this make it easier to have a single directory with all the repos,
+ because they don't need specific entries in the configuration anymore.
+ """
+
+ for conf in dir(config):
+ if conf.startswith('__'):
+ continue
+ c = config.__getattribute__(conf)
+ if 'multidir' not in dir(c):
+ continue
+
+ entries = os.listdir(c.multidir)
+ for name in entries:
+ rdir = c.multidir + '/' + name
+ desc = c.repodesc % { 'name': name }
+ url = c.repourl % { 'name': name }
+ class tmp_config:
+ reponame = name
+ repodir = rdir
+ repodesc = desc
+ repourl = url
+ repoencoding = c.repoencoding
+ if 'footer' in dir(c):
+ footer = c.footer
+ config.__setattr__(name, tmp_config)
+
hunk ./darcsweb.cgi 1798
+ expand_multi_config(all_configs)
}