Thu Mar 27 01:02:58 UTC 2008 Alberto Bertogli <albertito@gmail.com>
* Add an option to change the display name of the repository
It can be used to avoid clashes in multidir entries.
Thanks to Dan Muller for the idea and alternative implementation.
diff -rN -u old-darcsweb/config.py.sample new-darcsweb/config.py.sample
--- old-darcsweb/config.py.sample 2015-10-30 11:52:42.000000000 +0000
+++ new-darcsweb/config.py.sample 2015-10-30 11:52:42.000000000 +0000
@@ -144,7 +144,8 @@
# 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.
+# "%(name)s" gets expanded to the it. If displayname is set, "%(dname)s" gets
+# expanded to it; otherwise it's the same as "%(name)s".
#
# If you set multidir_deep to True (note the capitalization) then all
# subdirectories are searched for darcs repositories. Subdirectories starting
@@ -160,6 +161,11 @@
repourl = 'http://example.com/repos/%(name)s/'
repoencoding = 'latin1'
+ # if you want to change the display name of the repositories (i.e. the
+ # name it will have on the listings, urls, etc.), you can set it here.
+ # You can use "%(name)s" expansion, see above.
+ #displayname = "local/%(name)s"
+
# optional, see above
#repoprojurl = 'http://example.com/projects/%(name)s/'
diff -rN -u old-darcsweb/darcsweb.cgi new-darcsweb/darcsweb.cgi
--- old-darcsweb/darcsweb.cgi 2015-10-30 11:52:42.000000000 +0000
+++ new-darcsweb/darcsweb.cgi 2015-10-30 11:52:42.000000000 +0000
@@ -2246,6 +2246,15 @@
if name in c.exclude:
continue
+ # set the display name at the beginning, so it can be
+ # used by the other replaces
+ if 'displayname' in dir(c):
+ dname = c.displayname % { 'name': name }
+ else:
+ dname = name
+
+ rep_dict = { 'name': name, 'dname': dname }
+
if 'autoexclude' in dir(c) and c.autoexclude:
dpath = fulldir + \
'/_darcs/third_party/darcsweb'
@@ -2258,9 +2267,9 @@
if os.access(dpath, os.R_OK):
desc = open(dpath).readline().rstrip("\n")
else:
- desc = c.repodesc % { 'name': name }
+ desc = c.repodesc % rep_dict
else:
- desc = c.repodesc % { 'name': name }
+ desc = c.repodesc % rep_dict
if 'autourl' in dir(c) and c.autourl:
dpath = fulldir + \
@@ -2268,9 +2277,9 @@
if os.access(dpath, os.R_OK):
url = open(dpath).readline().rstrip("\n")
else:
- url = c.repourl % { 'name': name }
+ url = c.repourl % rep_dict
else:
- url = c.repourl % { 'name': name }
+ url = c.repourl % rep_dict
if 'autoprojurl' in dir(c) and c.autoprojurl:
dpath = fulldir + \
@@ -2278,17 +2287,17 @@
if os.access(dpath, os.R_OK):
projurl = open(dpath).readline().rstrip("\n")
elif 'repoprojurl' in dir(c):
- projurl = c.repoprojurl % {'name': name}
+ projurl = c.repoprojurl % rep_dict
else:
projurl = None
elif 'repoprojurl' in dir(c):
- projurl = c.repoprojurl % { 'name': name }
+ projurl = c.repoprojurl % rep_dict
else:
projurl = None
rdir = fulldir
class tmp_config:
- reponame = name
+ reponame = dname
repodir = rdir
repodesc = desc
repourl = url
@@ -2298,7 +2307,8 @@
if 'footer' in dir(c):
footer = c.footer
- config.__setattr__(name, tmp_config)
+ # index by display name to avoid clashes
+ config.__setattr__(dname, tmp_config)
def fill_config(name = None):
import config as all_configs