comparison mercurial/commands.py @ 1728:9b92b71d5dd7

add -w and -p options to diff. this is for issue 126.
author Vadim Gelfer <vadim.gelfer@gmail.com>
date Wed, 15 Feb 2006 10:39:47 -0800
parents 55017891051b
children 251729df9cc6
comparison
equal deleted inserted replaced
1722:681c5c211b92 1728:9b92b71d5dd7
259 return open(make_filename(repo, r, pat, node, total, seqno, revwidth, 259 return open(make_filename(repo, r, pat, node, total, seqno, revwidth,
260 pathname), 260 pathname),
261 mode) 261 mode)
262 262
263 def dodiff(fp, ui, repo, node1, node2, files=None, match=util.always, 263 def dodiff(fp, ui, repo, node1, node2, files=None, match=util.always,
264 changes=None, text=False): 264 changes=None, text=False, opts={}):
265 if not changes: 265 if not changes:
266 changes = repo.changes(node1, node2, files, match=match) 266 changes = repo.changes(node1, node2, files, match=match)
267 modified, added, removed, deleted, unknown = changes 267 modified, added, removed, deleted, unknown = changes
268 if files: 268 if files:
269 modified, added, removed = map(lambda x: filterfiles(files, x), 269 modified, added, removed = map(lambda x: filterfiles(files, x),
294 change = repo.changelog.read(node1) 294 change = repo.changelog.read(node1)
295 mmap = repo.manifest.read(change[0]) 295 mmap = repo.manifest.read(change[0])
296 date1 = util.datestr(change[2]) 296 date1 = util.datestr(change[2])
297 297
298 diffopts = ui.diffopts() 298 diffopts = ui.diffopts()
299 showfunc = diffopts['showfunc'] 299 showfunc = opts.get('show_function') or diffopts['showfunc']
300 ignorews = diffopts['ignorews'] 300 ignorews = opts.get('ignore_all_space') or diffopts['ignorews']
301 for f in modified: 301 for f in modified:
302 to = None 302 to = None
303 if f in mmap: 303 if f in mmap:
304 to = repo.file(f).read(mmap[f]) 304 to = repo.file(f).read(mmap[f])
305 tn = read(f) 305 tn = read(f)
1138 raise util.Abort(_("too many revisions to diff")) 1138 raise util.Abort(_("too many revisions to diff"))
1139 1139
1140 fns, matchfn, anypats = matchpats(repo, pats, opts) 1140 fns, matchfn, anypats = matchpats(repo, pats, opts)
1141 1141
1142 dodiff(sys.stdout, ui, repo, node1, node2, fns, match=matchfn, 1142 dodiff(sys.stdout, ui, repo, node1, node2, fns, match=matchfn,
1143 text=opts['text']) 1143 text=opts['text'], opts=opts)
1144 1144
1145 def doexport(ui, repo, changeset, seqno, total, revwidth, opts): 1145 def doexport(ui, repo, changeset, seqno, total, revwidth, opts):
1146 node = repo.lookup(changeset) 1146 node = repo.lookup(changeset)
1147 parents = [p for p in repo.changelog.parents(node) if p != nullid] 1147 parents = [p for p in repo.changelog.parents(node) if p != nullid]
1148 if opts['switch_parent']: 1148 if opts['switch_parent']:
2335 "^diff": 2335 "^diff":
2336 (diff, 2336 (diff,
2337 [('r', 'rev', [], _('revision')), 2337 [('r', 'rev', [], _('revision')),
2338 ('a', 'text', None, _('treat all files as text')), 2338 ('a', 'text', None, _('treat all files as text')),
2339 ('I', 'include', [], _('include names matching the given patterns')), 2339 ('I', 'include', [], _('include names matching the given patterns')),
2340 ('X', 'exclude', [], _('exclude names matching the given patterns'))], 2340 ('p', 'show-function', None,
2341 _('show which function each change is in')),
2342 ('w', 'ignore-all-space', None,
2343 _('ignore white space when comparing lines')),
2344 ('X', 'exclude', [],
2345 _('exclude names matching the given patterns'))],
2341 _('hg diff [-a] [-I] [-X] [-r REV1 [-r REV2]] [FILE]...')), 2346 _('hg diff [-a] [-I] [-X] [-r REV1 [-r REV2]] [FILE]...')),
2342 "^export": 2347 "^export":
2343 (export, 2348 (export,
2344 [('o', 'output', '', _('print output to file with formatted name')), 2349 [('o', 'output', '', _('print output to file with formatted name')),
2345 ('a', 'text', None, _('treat all files as text')), 2350 ('a', 'text', None, _('treat all files as text')),