diff -ur viewvc-1.0.4\lib\config.py viewvc-1.0.4-patched\lib\config.py --- viewvc-1.0.4\lib\config.py 2006-04-04 05:11:02.000000000 +0200 +++ viewvc-1.0.4-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.4\lib\viewvc.py viewvc-1.0.4-patched\lib\viewvc.py --- viewvc-1.0.4\lib\viewvc.py 2006-07-21 00:11:36.000000000 +0200 +++ viewvc-1.0.4-patched\lib\viewvc.py 2006-09-06 22:22:12.864421000 +0200 @@ -664,6 +664,14 @@ 'revision' : _re_validate_revnum, 'content-type' : _re_validate_mimetype, + # for cvsgraph + 'init' : _re_validate_alpha, + '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, @@ -2174,6 +2182,52 @@ 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 + else: + return 0 + +def cvsgraph_reqopts(request): + # Build a config set combining the static config and the http query + cfg = request.cfg + if (not request.query_dict.has_key('init')): + return cfg.options.cvsgraph_opt + 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 + + 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 @@ -2189,10 +2243,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" @@ -2203,6 +2265,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 top/bottom + # 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') or ((not request.query_dict.has_key('init')) and (int(cfg.options.cvsgraph_opt) & 1)): + chkgflip = '1' + if request.query_dict.has_key('gbbox') or ((not request.query_dict.has_key('init')) and (int(cfg.options.cvsgraph_opt) & 2)): + chkgbbox = '1' + if request.query_dict.has_key('gleft') or ((not request.query_dict.has_key('init')) and (int(cfg.options.cvsgraph_opt) & 16)): + 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' @@ -2215,7 +2315,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", @@ -2236,9 +2337,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.4\templates\graph.ezt viewvc-1.0.4-patched\templates\graph.ezt --- viewvc-1.0.4\templates\graph.ezt 2005-09-28 19:06:16.000000000 +0200 +++ viewvc-1.0.4-patched\templates\graph.ezt 2006-09-06 22:22:49.776720000 +0200 @@ -14,5 +14,46 @@ src="[imagesrc]" alt="Revisions of [where]" /> +[is cfg.options.cvsgraph_useropt "1"] +
+
+