diff -ur viewvc-1.0.1/lib/config.py viewvc-1.0.1-patched/lib/config.py --- viewvc-1.0.1/lib/config.py 2006-04-04 05:11:02.000000000 +0200 +++ viewvc-1.0.1-patched/lib/config.py 2006-09-06 15:21:20.241486000 +0200 @@ -215,6 +215,8 @@ self.options.use_cvsgraph = 0 self.options.cvsgraph_path = '' self.options.cvsgraph_conf = "cvsgraph.conf" + self.options.cvsgraph_useropt = 0 + self.options.cvsgraph_opt = 0 self.options.use_re_search = 0 self.options.use_pagesize = 0 self.options.limit_changes = 100 diff -ur viewvc-1.0.1/lib/viewvc.py viewvc-1.0.1-patched/lib/viewvc.py --- viewvc-1.0.1/lib/viewvc.py 2006-07-21 00:11:36.000000000 +0200 +++ viewvc-1.0.1-patched/lib/viewvc.py 2006-09-06 22:22:12.864421000 +0200 @@ -14,7 +14,7 @@ # # ----------------------------------------------------------------------- -__version__ = '1.0.1' +__version__ = '1.0.1-cvsgraph-patch' # this comes from our library; measure the startup time import debug @@ -664,6 +664,13 @@ 'revision' : _re_validate_revnum, 'content-type' : _re_validate_mimetype, + # for cvsgraph + 'gflip' : _re_validate_number, + 'gbbox' : _re_validate_number, + 'gstrip' : _re_validate_number, + 'gleft' : _re_validate_number, + 'gmaxtag' : _re_validate_number, + # for query 'branch' : _validate_regex, 'branch_match' : _re_validate_alpha, @@ -2165,6 +2172,50 @@ request.server.header() generate_page(request, "annotate", data) +def cvsgraph_make_reqopt(request, opt, mask): + # Return a config option normal/inverted depending on http query + cfg = request.cfg + if request.query_dict.has_key(opt): + return mask ^ (int(cfg.options.cvsgraph_opt) & mask) + else: + return int(cfg.options.cvsgraph_opt) & mask + +def cvsgraph_reqopts(request): + # Build a config set combining the static config and the http query + cfg = request.cfg + reqopt = cvsgraph_make_reqopt(request, 'gflip', 1) + reqopt = reqopt | cvsgraph_make_reqopt(request, 'gbbox', 2) + reqopt = reqopt | cvsgraph_make_reqopt(request, 'gleft', 16) + + if request.query_dict.has_key('gstrip'): + if request.query_dict.get('gstrip') == '2': + reqopt = reqopt | 4 + elif request.query_dict.get('gstrip') == '3': + reqopt = reqopt | 12 + else: + reqopt = reqopt | (int(cfg.options.cvsgraph_opt) & 12) + + return reqopt + +def cvsgraph_extraopts(request): + # Build a set of -O options for controling cvsgraph's behavior + cfg = request.cfg + opts = cvsgraph_reqopts(request) + ep = '-O' + if opts & 1: + ep = ep + ';upside_down=true' + if opts & 2: + ep = ep + ';branch_dupbox=true' + if opts & 4: + ep = ep + ';strip_untagged=true' + if opts & 8: + ep = ep + ';strip_first_rev=true' + if opts & 16: + ep = ep + ';left_right=true' + if request.query_dict.has_key('gmaxtag') and (int(cfg.options.cvsgraph_opt) & 32): + ep = ep + ';rev_maxtags=' + request.query_dict['gmaxtag'] + return ep + ';' + def view_cvsgraph_image(request): "output the image rendered by cvsgraph" # this function is derived from cgi/cvsgraphmkimg.cgi @@ -2180,10 +2231,18 @@ 'cvsgraph')), ("-c", _install_path(cfg.options.cvsgraph_conf), "-r", request.repos.rootpath, + "-q", cvsgraph_extraopts(request), rcsfile), 'rb', 0) copy_stream(fp) fp.close() +def cvsgraph_query(request, id, value): + # Build a http querystring part for embedding in the "Get new image" button + if request.query_dict.has_key(id): + return '&' + id + '=' + value + else: + return '' + def view_cvsgraph(request): "output a page containing an image rendered by cvsgraph" @@ -2194,6 +2253,44 @@ data = common_template_data(request) + # gflip -> Flip graph upside down + # gbbox -> Add branchbox on each side of a trunk + # gleft -> Draw left/right or right/left + # gmaxtag -> Maximum tags per revisionbox + # chkg* -> Variables that influence the template's layout + # gquery -> The get query on the "Get new image" button + opts = cvsgraph_reqopts(request) + chkgflip = chkgbbox = chkgleft = chkmaxtag = '0' + + if request.query_dict.has_key('gflip'): + chkgflip = '1' + if request.query_dict.has_key('gbbox'): + chkgbbox = '1' + if request.query_dict.has_key('gleft'): + chkgleft = '1' + + if opts & 12 == 12: + chkgstrip = '3' + elif opts & 12 == 4: + chkgstrip = '2' + else: + chkgstrip = '1' + + gquery = ( cvsgraph_query(request, 'gflip', '1') + + cvsgraph_query(request, 'gbbox', '1') + + cvsgraph_query(request, 'gleft', '1') + + cvsgraph_query(request, 'gstrip', chkgstrip)) + + if (int(cfg.options.cvsgraph_opt) & 32): + chkmaxtag = '1'; + if request.query_dict.has_key('gmaxtag'): + gmaxtag = request.query_dict['gmaxtag'] + gquery = gquery + cvsgraph_query(request, 'gmaxtag', gmaxtag) + else: + gmaxtag = '0' + else: + gmaxtag = '0' + # Required only if cvsgraph needs to find it's supporting libraries. # Uncomment and set accordingly if required. #os.environ['LD_LIBRARY_PATH'] = '/usr/lib:/usr/local/lib' @@ -2206,7 +2303,8 @@ # Create an image map rcsfile = request.repos.rcsfile(request.path_parts) fp = popen.popen(os.path.join(cfg.options.cvsgraph_path, 'cvsgraph'), - ("-i", + ("-i", "-x4", + "-q", cvsgraph_extraopts(request), "-c", _install_path(cfg.options.cvsgraph_conf), "-r", request.repos.rootpath, "-x", "x", @@ -2227,9 +2325,17 @@ data.update({ 'imagemap' : fp, - 'imagesrc' : imagesrc, + 'imagesrc' : imagesrc + gquery, + 'thispage' : request.get_url(view_func=view_cvsgraph, params={}), + 'chkgflip' : chkgflip, + 'chkgbbox' : chkgbbox, + 'chkgstrip' : chkgstrip, + 'chkgleft' : chkgleft, + 'chkmaxtag' : chkmaxtag, + 'gmaxtag' : gmaxtag, }) + # FIXME: BS - We should add an 'expire' and 'nocache' header here... request.server.header() generate_page(request, "graph", data) diff -ur viewvc-1.0.1/templates/graph.ezt viewvc-1.0.1-patched/templates/graph.ezt --- viewvc-1.0.1/templates/graph.ezt 2005-09-28 19:06:16.000000000 +0200 +++ viewvc-1.0.1-patched/templates/graph.ezt 2006-09-06 22:22:49.776720000 +0200 @@ -14,5 +14,50 @@ src="[imagesrc]" alt="Revisions of [where]" /> +[is cfg.options.cvsgraph_useropt "1"] +

+

+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + [is chkmaxtag "1"] + + + + + [end] + + + +
Flip the graph
Add/remove a branch box at the end of each trunk
Draw tree left to right or right to left
Show all revisions
Strip all but first non-tagged revisions
Strip all non-tagged revisions
Show limited number of tags (0=all)

+

+

+

+[end] + [include "include/footer.ezt"] diff -ur viewvc-1.0.1/viewvc.conf.dist viewvc-1.0.1-patched/viewvc.conf.dist --- viewvc-1.0.1/viewvc.conf.dist 2006-04-04 05:11:02.000000000 +0200 +++ viewvc-1.0.1-patched/viewvc.conf.dist 2006-09-06 15:10:59.037728000 +0200 @@ -489,6 +489,27 @@ cvsgraph_conf = cvsgraph.conf # +# Enable user selectable image generation. +# With this option, users will get a set of check-/radio-boxes under +# the graph, which can be used to alter the image's layout. +# +cvsgraph_useropt = 1 + +# +# Options for cvsgraph's default behavior which can be changed +# in the graph display. Set the options to a sum of the following +# flags: +# 1 - Show upside down +# 2 - Add a brachbox at the head of each trunk +# 4 - Strip all but first untagged revisions +# 8 - Strip all untagged revisions (implies previous) +# 16 - Draw the tree left-to-right or right-to-left +# 32 - Allow limit on max tags displayed (adds text-input) +# All other bits reserved for future use. +# +cvsgraph_opt = 12 + +# # Set to enable regular expression search of all files in a directory # # WARNING: