Sat Jul 23 22:54:35 UTC 2005 Alberto Bertogli * Implement file history (a "focused" version of shortlog). diff -rN -u old-darcsweb/darcsweb.cgi new-darcsweb/darcsweb.cgi --- old-darcsweb/darcsweb.cgi 2016-02-10 05:21:15.000000000 +0000 +++ new-darcsweb/darcsweb.cgi 2016-02-10 05:21:15.000000000 +0000 @@ -273,8 +273,12 @@ | headfilediff """ % { "myreponame": config.myreponame, 'hash': h, 'fname': f } - print '

' + if f: + print """ +| filehistory + """ % { "myreponame": config.myreponame, 'fname': f } + print '

' def print_plain_header(): print "Content-type: text/plain\n" @@ -475,13 +479,26 @@ return handler -def get_last_patches(last = 15, topi = 0): +def get_last_patches(last = 15, topi = 0, fname = None): """Gets the last N patches from the repo, returns a patch list. If "topi" is specified, then it will return the N patches that preceeded the patch number topi in the list. It sounds messy but it's quite - simple. FIXME: there's probably a more efficient way of doing this.""" + simple. You can optionally pass a filename and only changes that + affect it will be returned. FIXME: there's probably a more efficient + way of doing this.""" + + # darcs calculate last first, and then filters the filename, + # so it's not so simple to combine them; that's why we do so much + # special casing here toget = last + topi - handler = get_changes_handler("-s --last=%d" % toget) + + if fname: + if fname[0] == '/': fname = fname[1:] + s = "-s " + fname + else: + s = "-s --last=%d" % toget + + handler = get_changes_handler(s) # return the list of all the patch objects return handler.get_list()[topi:toget] @@ -531,10 +548,19 @@ print '
' % color + escape(l) + '
' -def print_shortlog(last = 50, topi = 0): - ps = get_last_patches(last, topi) - print '
shortlog
' \ - % config.myreponame +def print_shortlog(last = 50, topi = 0, fname = None): + ps = get_last_patches(last, topi, fname) + + if fname: + title = '' % \ + (config.myreponame, fname) + title += 'history for file %s' % fname + title += '' + else: + title = 'shortlog' \ + % config.myreponame + + print '
%s
' % title print '' if topi != 0: @@ -542,8 +568,14 @@ ntopi = topi - last if ntopi < 0: ntopi = 0 - print '' % \ - (config.myreponame, ntopi) + print '' alt = False for p in ps: @@ -574,11 +606,14 @@ if len(ps) >= last: # only show if we've not shown them all already - print """ - - """ % (config.myreponame, topi + last) + print '' print "
...
' + if fname: + print '...' \ + % (config.myreponame, ntopi, fname) + else: + print '...' \ + % (config.myreponame, ntopi) + print '
- ... -
' + if fname: + print '...' \ + % (config.myreponame, topi + last, fname) + else: + print '...' \ + % (config.myreponame, topi + last) + print '
" @@ -878,9 +913,11 @@ if show_diff: print """ - - diff - + + + diff | + history + """ % { 'myreponame': config.myreponame, 'hash': p.hash, @@ -946,7 +983,10 @@ if f in dlist: print """ %(f)s - tree + + history | + tree + """ % { 'myrname': config.myreponame, 'f': f, @@ -955,7 +995,10 @@ else: print """ %(f)s - headblob + + history | + headblob + """ % { 'myrname': config.myreponame, 'f': f, @@ -1004,6 +1047,11 @@ print_shortlog(topi = topi) print_footer() +def do_filehistory(topi, f): + print_header() + print_navbar(f = fname) + print_shortlog(topi = topi, fname = fname) + print_footer() def do_log(topi): print_header() @@ -1223,6 +1271,13 @@ else: topi = 0 do_shortlog(topi) +elif action == "filehistory": + if form.has_key("topi"): + topi = int(filter_num(form["topi"].value)) + else: + topi = 0 + fname = filter_file(form["f"].value) + do_filehistory(topi, fname) elif action == "log": if form.has_key("topi"): topi = int(filter_num(form["topi"].value))