mirror of
https://github.com/python/cpython.git
synced 2025-08-28 04:35:02 +00:00
Support for more general diffing and retrieving any old revision.
Support for index formatting with local refs.
This commit is contained in:
parent
8cde0b47b8
commit
8bc49c8ad1
2 changed files with 65 additions and 17 deletions
|
@ -77,6 +77,7 @@ WIZVERSION = "0.3 (alpha)" # FAQ Wizard version
|
||||||
SH_RLOG = RCSBINDIR + "rlog %(file)s </dev/null 2>&1"
|
SH_RLOG = RCSBINDIR + "rlog %(file)s </dev/null 2>&1"
|
||||||
SH_RLOG_H = RCSBINDIR + "rlog -h %(file)s </dev/null 2>&1"
|
SH_RLOG_H = RCSBINDIR + "rlog -h %(file)s </dev/null 2>&1"
|
||||||
SH_RDIFF = RCSBINDIR + "rcsdiff -r%(prev)s -r%(rev)s %(file)s </dev/null 2>&1"
|
SH_RDIFF = RCSBINDIR + "rcsdiff -r%(prev)s -r%(rev)s %(file)s </dev/null 2>&1"
|
||||||
|
SH_REVISION = RCSBINDIR + "co -p%(rev)s %(file)s </dev/null 2>&1"
|
||||||
SH_LOCK = RCSBINDIR + "rcs -l %(file)s </dev/null 2>&1"
|
SH_LOCK = RCSBINDIR + "rcs -l %(file)s </dev/null 2>&1"
|
||||||
SH_CHECKIN = RCSBINDIR + "ci -u %(file)s <%(tfn)s 2>&1"
|
SH_CHECKIN = RCSBINDIR + "ci -u %(file)s <%(tfn)s 2>&1"
|
||||||
|
|
||||||
|
@ -91,6 +92,7 @@ T_SEARCH = FAQNAME + " Search Results"
|
||||||
T_RECENT = "What's New in the " + FAQNAME
|
T_RECENT = "What's New in the " + FAQNAME
|
||||||
T_SHOW = FAQNAME + " Entry"
|
T_SHOW = FAQNAME + " Entry"
|
||||||
T_LOG = "RCS log for %s entry" % FAQNAME
|
T_LOG = "RCS log for %s entry" % FAQNAME
|
||||||
|
T_REVISION = "RCS revision for %s entry" % FAQNAME
|
||||||
T_DIFF = "RCS diff for %s entry" % FAQNAME
|
T_DIFF = "RCS diff for %s entry" % FAQNAME
|
||||||
T_ADD = "Add an entry to the " + FAQNAME
|
T_ADD = "Add an entry to the " + FAQNAME
|
||||||
T_DELETE = "Deleting an entry from the " + FAQNAME
|
T_DELETE = "Deleting an entry from the " + FAQNAME
|
||||||
|
@ -142,7 +144,7 @@ HOME = """
|
||||||
/
|
/
|
||||||
<INPUT TYPE=radio NAME=querytype VALUE=regex>
|
<INPUT TYPE=radio NAME=querytype VALUE=regex>
|
||||||
Regular expression
|
Regular expression
|
||||||
/
|
/<BR>
|
||||||
<INPUT TYPE=radio NAME=querytype VALUE=anykeywords>
|
<INPUT TYPE=radio NAME=querytype VALUE=anykeywords>
|
||||||
Keywords (any)
|
Keywords (any)
|
||||||
/
|
/
|
||||||
|
@ -197,11 +199,15 @@ INDEX_ENTRY = """\
|
||||||
<LI><A HREF="%(FAQCGI)s?req=show&file=%(file)s">%(title)s</A>
|
<LI><A HREF="%(FAQCGI)s?req=show&file=%(file)s">%(title)s</A>
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
LOCAL_ENTRY = """\
|
||||||
|
<LI><A HREF="#%(sec)s.%(num)s">%(title)s</A>
|
||||||
|
"""
|
||||||
|
|
||||||
# Entry formatting
|
# Entry formatting
|
||||||
|
|
||||||
ENTRY_HEADER = """
|
ENTRY_HEADER = """
|
||||||
<HR>
|
<HR>
|
||||||
<H2>%(title)s</H2>
|
<H2><A NAME="%(sec)s.%(num)s">%(title)s</A></H2>
|
||||||
"""
|
"""
|
||||||
|
|
||||||
ENTRY_FOOTER = """
|
ENTRY_FOOTER = """
|
||||||
|
@ -240,8 +246,14 @@ Click on a revision line to see the diff between that revision and the
|
||||||
previous one.
|
previous one.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
REVISIONLINK = """\
|
||||||
|
<A HREF="%(FAQCGI)s?req=revision&file=%(file)s&rev=%(rev)s"
|
||||||
|
>%(line)s</A>\
|
||||||
|
"""
|
||||||
DIFFLINK = """\
|
DIFFLINK = """\
|
||||||
<A HREF="%(FAQCGI)s?req=diff&file=%(file)s&rev=%(rev)s">%(line)s</A>
|
(<A HREF="%(FAQCGI)s?req=diff&file=%(file)s&\
|
||||||
|
prev=%(prev)s&rev=%(rev)s"
|
||||||
|
>diff -r%(prev)s -r%(rev)s</A>)\
|
||||||
"""
|
"""
|
||||||
|
|
||||||
# Recently changed entries
|
# Recently changed entries
|
||||||
|
|
|
@ -110,6 +110,18 @@ def emphasize(line):
|
||||||
emphasize_prog = regex.compile(pat)
|
emphasize_prog = regex.compile(pat)
|
||||||
return regsub.gsub(emphasize_prog, '<I>\\1</I>', line)
|
return regsub.gsub(emphasize_prog, '<I>\\1</I>', line)
|
||||||
|
|
||||||
|
revparse_prog = None
|
||||||
|
|
||||||
|
def revparse(rev):
|
||||||
|
global revparse_prog
|
||||||
|
if not revparse_prog:
|
||||||
|
revparse_prog = regex.compile(
|
||||||
|
'^\([1-9][0-9]?[0-9]?\)\.\([1-9][0-9]?[0-9]?[0-9]?\)$')
|
||||||
|
if revparse_prog.match(rev) < 0:
|
||||||
|
return None
|
||||||
|
[major, minor] = map(string.atoi, revparse_prog.group(1, 2))
|
||||||
|
return major, minor
|
||||||
|
|
||||||
def load_cookies():
|
def load_cookies():
|
||||||
if not os.environ.has_key('HTTP_COOKIE'):
|
if not os.environ.has_key('HTTP_COOKIE'):
|
||||||
return {}
|
return {}
|
||||||
|
@ -440,12 +452,14 @@ class FaqWizard:
|
||||||
self.prologue(T_ALL)
|
self.prologue(T_ALL)
|
||||||
files = self.dir.list()
|
files = self.dir.list()
|
||||||
self.last_changed(files)
|
self.last_changed(files)
|
||||||
|
self.format_index(files, localrefs=1)
|
||||||
self.format_all(files)
|
self.format_all(files)
|
||||||
|
|
||||||
def do_compat(self):
|
def do_compat(self):
|
||||||
files = self.dir.list()
|
files = self.dir.list()
|
||||||
emit(COMPAT)
|
emit(COMPAT)
|
||||||
self.last_changed(files)
|
self.last_changed(files)
|
||||||
|
self.format_index(files, localrefs=1)
|
||||||
self.format_all(files, edit=0)
|
self.format_all(files, edit=0)
|
||||||
sys.exit(0)
|
sys.exit(0)
|
||||||
|
|
||||||
|
@ -483,7 +497,7 @@ class FaqWizard:
|
||||||
self.prologue(T_INDEX)
|
self.prologue(T_INDEX)
|
||||||
self.format_index(self.dir.list(), add=1)
|
self.format_index(self.dir.list(), add=1)
|
||||||
|
|
||||||
def format_index(self, files, add=0):
|
def format_index(self, files, add=0, localrefs=0):
|
||||||
sec = 0
|
sec = 0
|
||||||
for file in files:
|
for file in files:
|
||||||
try:
|
try:
|
||||||
|
@ -501,7 +515,10 @@ class FaqWizard:
|
||||||
except KeyError:
|
except KeyError:
|
||||||
title = "Untitled"
|
title = "Untitled"
|
||||||
emit(INDEX_SECTION, sec=sec, title=title)
|
emit(INDEX_SECTION, sec=sec, title=title)
|
||||||
emit(INDEX_ENTRY, entry)
|
if localrefs:
|
||||||
|
emit(LOCAL_ENTRY, entry)
|
||||||
|
else:
|
||||||
|
emit(INDEX_ENTRY, entry)
|
||||||
if sec:
|
if sec:
|
||||||
if add:
|
if add:
|
||||||
emit(INDEX_ADDSECTION, sec=sec)
|
emit(INDEX_ADDSECTION, sec=sec)
|
||||||
|
@ -587,13 +604,23 @@ class FaqWizard:
|
||||||
if line[:1] == '=' and len(line) >= 40 and \
|
if line[:1] == '=' and len(line) >= 40 and \
|
||||||
line == line[0]*len(line):
|
line == line[0]*len(line):
|
||||||
del lines[-1]
|
del lines[-1]
|
||||||
|
headrev = None
|
||||||
for line in lines:
|
for line in lines:
|
||||||
if entry and athead and line[:9] == 'revision ':
|
if entry and athead and line[:9] == 'revision ':
|
||||||
rev = string.strip(line[9:])
|
rev = string.strip(line[9:])
|
||||||
if rev != '1.1':
|
mami = revparse(rev)
|
||||||
emit(DIFFLINK, entry, rev=rev, line=line)
|
if not mami:
|
||||||
else:
|
|
||||||
print line
|
print line
|
||||||
|
else:
|
||||||
|
emit(REVISIONLINK, entry, rev=rev, line=line)
|
||||||
|
if mami[1] > 1:
|
||||||
|
prev = "%d.%d" % (mami[0], mami[1]-1)
|
||||||
|
emit(DIFFLINK, entry, prev=prev, rev=rev)
|
||||||
|
if headrev:
|
||||||
|
emit(DIFFLINK, entry, prev=rev, rev=headrev)
|
||||||
|
else:
|
||||||
|
headrev = rev
|
||||||
|
print
|
||||||
athead = 0
|
athead = 0
|
||||||
else:
|
else:
|
||||||
athead = 0
|
athead = 0
|
||||||
|
@ -605,18 +632,27 @@ class FaqWizard:
|
||||||
print line
|
print line
|
||||||
print '</PRE>'
|
print '</PRE>'
|
||||||
|
|
||||||
def do_diff(self):
|
def do_revision(self):
|
||||||
entry = self.dir.open(self.ui.file)
|
entry = self.dir.open(self.ui.file)
|
||||||
rev = self.ui.rev
|
rev = self.ui.rev
|
||||||
r = regex.compile(
|
mami = revparse(rev)
|
||||||
'^\([1-9][0-9]?[0-9]?\)\.\([1-9][0-9]?[0-9]?[0-9]?\)$')
|
if not mami:
|
||||||
if r.match(rev) < 0:
|
|
||||||
self.error("Invalid revision number: %s." % `rev`)
|
self.error("Invalid revision number: %s." % `rev`)
|
||||||
[major, minor] = map(string.atoi, r.group(1, 2))
|
self.prologue(T_REVISION, entry)
|
||||||
if minor == 1:
|
self.shell(interpolate(SH_REVISION, entry, rev=rev))
|
||||||
self.error("No previous revision.")
|
|
||||||
return
|
def do_diff(self):
|
||||||
prev = '%d.%d' % (major, minor-1)
|
entry = self.dir.open(self.ui.file)
|
||||||
|
prev = self.ui.prev
|
||||||
|
rev = self.ui.rev
|
||||||
|
mami = revparse(rev)
|
||||||
|
if not mami:
|
||||||
|
self.error("Invalid revision number: %s." % `rev`)
|
||||||
|
if prev:
|
||||||
|
if not revparse(prev):
|
||||||
|
self.error("Invalid previous revision number: %s." % `prev`)
|
||||||
|
else:
|
||||||
|
prev = '%d.%d' % (mami[0], mami[1])
|
||||||
self.prologue(T_DIFF, entry)
|
self.prologue(T_DIFF, entry)
|
||||||
self.shell(interpolate(SH_RDIFF, entry, rev=rev, prev=prev))
|
self.shell(interpolate(SH_RDIFF, entry, rev=rev, prev=prev))
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue