Mercurial > cpython-lru_cache-weakref
diff Tools/scripts/diff.py @ 33319:6d3bdd19beeb legacy-trunk
Patch #914575: difflib side by side diff support, diff.py s/b/s HTML option.
| author | Martin v. Löwis <martin@v.loewis.de> |
|---|---|
| date | Sun, 29 Aug 2004 16:34:40 +0000 |
| parents | 981fff7363b9 |
| children | ab588ce9e71f |
line wrap: on
line diff
--- a/Tools/scripts/diff.py Sun Aug 29 15:51:52 2004 +0000 +++ b/Tools/scripts/diff.py Sun Aug 29 16:34:40 2004 +0000 @@ -1,8 +1,9 @@ -""" Command line interface to difflib.py providing diffs in three formats: +""" Command line interface to difflib.py providing diffs in four formats: * ndiff: lists every line and highlights interline changes. -* context: highlights clusters of changes in a before/after format +* context: highlights clusters of changes in a before/after format. * unified: highlights clusters of changes in an inline format. +* html: generates side by side comparison with change highlights. """ @@ -14,6 +15,7 @@ parser = optparse.OptionParser(usage) parser.add_option("-c", action="store_true", default=False, help='Produce a context format diff (default)') parser.add_option("-u", action="store_true", default=False, help='Produce a unified format diff') + parser.add_option("-m", action="store_true", default=False, help='Produce HTML side by side diff (can use -c and -l in conjunction)') parser.add_option("-n", action="store_true", default=False, help='Produce a ndiff format diff') parser.add_option("-l", "--lines", type="int", default=3, help='Set number of context lines (default 3)') (options, args) = parser.parse_args() @@ -36,6 +38,8 @@ diff = difflib.unified_diff(fromlines, tolines, fromfile, tofile, fromdate, todate, n=n) elif options.n: diff = difflib.ndiff(fromlines, tolines) + elif options.m: + diff = difflib.HtmlDiff().make_file(fromlines,tolines,fromfile,tofile,context=options.c,numlines=n) else: diff = difflib.context_diff(fromlines, tolines, fromfile, tofile, fromdate, todate, n=n)
