Mercurial > hg
comparison mercurial/patch.py @ 23432:27af986a332b
patch.difffeatureopts: add a feature for diff.git
This deserves to be its own feature -- indeed, this is often the only feature
several commands care about.
author | Siddharth Agarwal <sid0@fb.com> |
---|---|
date | Tue, 18 Nov 2014 17:10:14 -0800 |
parents | 10223d2278f4 |
children | 41dd76b3facb |
comparison
equal
deleted
inserted
replaced
23431:10223d2278f4 | 23432:27af986a332b |
---|---|
1562 '''return diffopts with all features supported and parsed''' | 1562 '''return diffopts with all features supported and parsed''' |
1563 return difffeatureopts(ui, opts=opts, untrusted=untrusted, section=section) | 1563 return difffeatureopts(ui, opts=opts, untrusted=untrusted, section=section) |
1564 | 1564 |
1565 diffopts = diffallopts | 1565 diffopts = diffallopts |
1566 | 1566 |
1567 def difffeatureopts(ui, opts=None, untrusted=False, section='diff'): | 1567 def difffeatureopts(ui, opts=None, untrusted=False, section='diff', git=False): |
1568 '''return diffopts with only opted-in features parsed''' | 1568 '''return diffopts with only opted-in features parsed |
1569 | |
1570 Features: | |
1571 - git: git-style diffs | |
1572 ''' | |
1569 def get(key, name=None, getter=ui.configbool, forceplain=None): | 1573 def get(key, name=None, getter=ui.configbool, forceplain=None): |
1570 if opts: | 1574 if opts: |
1571 v = opts.get(key) | 1575 v = opts.get(key) |
1572 if v: | 1576 if v: |
1573 return v | 1577 return v |
1575 return forceplain | 1579 return forceplain |
1576 return getter(section, name or key, None, untrusted=untrusted) | 1580 return getter(section, name or key, None, untrusted=untrusted) |
1577 | 1581 |
1578 buildopts = { | 1582 buildopts = { |
1579 'text': opts and opts.get('text'), | 1583 'text': opts and opts.get('text'), |
1580 'git': get('git'), | |
1581 'nodates': get('nodates'), | 1584 'nodates': get('nodates'), |
1582 'nobinary': get('nobinary'), | 1585 'nobinary': get('nobinary'), |
1583 'noprefix': get('noprefix', forceplain=False), | 1586 'noprefix': get('noprefix', forceplain=False), |
1584 'showfunc': get('show_function', 'showfunc'), | 1587 'showfunc': get('show_function', 'showfunc'), |
1585 'ignorews': get('ignore_all_space', 'ignorews'), | 1588 'ignorews': get('ignore_all_space', 'ignorews'), |
1586 'ignorewsamount': get('ignore_space_change', 'ignorewsamount'), | 1589 'ignorewsamount': get('ignore_space_change', 'ignorewsamount'), |
1587 'ignoreblanklines': get('ignore_blank_lines', 'ignoreblanklines'), | 1590 'ignoreblanklines': get('ignore_blank_lines', 'ignoreblanklines'), |
1588 'context': get('unified', getter=ui.config), | 1591 'context': get('unified', getter=ui.config), |
1589 } | 1592 } |
1593 | |
1594 if git: | |
1595 buildopts['git'] = get('git') | |
1590 | 1596 |
1591 return mdiff.diffopts(**buildopts) | 1597 return mdiff.diffopts(**buildopts) |
1592 | 1598 |
1593 def diff(repo, node1=None, node2=None, match=None, changes=None, opts=None, | 1599 def diff(repo, node1=None, node2=None, match=None, changes=None, opts=None, |
1594 losedatafn=None, prefix=''): | 1600 losedatafn=None, prefix=''): |