Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/patch.py @ 23433:41dd76b3facb
patch.difffeatureopts: add a feature for whitespace diffopts
These aren't exactly format-breaking features -- just ones for which patches
applied to a repo will produce incorrect commits, In any case, some commands
like record and annotate only care about this feature.
author | Siddharth Agarwal <sid0@fb.com> |
---|---|
date | Tue, 18 Nov 2014 17:09:26 -0800 |
parents | 27af986a332b |
children | 60300a4c0ae5 |
comparison
equal
deleted
inserted
replaced
23432:27af986a332b | 23433:41dd76b3facb |
---|---|
1558 class GitDiffRequired(Exception): | 1558 class GitDiffRequired(Exception): |
1559 pass | 1559 pass |
1560 | 1560 |
1561 def diffallopts(ui, opts=None, untrusted=False, section='diff'): | 1561 def diffallopts(ui, opts=None, untrusted=False, section='diff'): |
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 git=True, whitespace=True) | |
1564 | 1565 |
1565 diffopts = diffallopts | 1566 diffopts = diffallopts |
1566 | 1567 |
1567 def difffeatureopts(ui, opts=None, untrusted=False, section='diff', git=False): | 1568 def difffeatureopts(ui, opts=None, untrusted=False, section='diff', git=False, |
1569 whitespace=False): | |
1568 '''return diffopts with only opted-in features parsed | 1570 '''return diffopts with only opted-in features parsed |
1569 | 1571 |
1570 Features: | 1572 Features: |
1571 - git: git-style diffs | 1573 - git: git-style diffs |
1574 - whitespace: whitespace options like ignoreblanklines and ignorews | |
1572 ''' | 1575 ''' |
1573 def get(key, name=None, getter=ui.configbool, forceplain=None): | 1576 def get(key, name=None, getter=ui.configbool, forceplain=None): |
1574 if opts: | 1577 if opts: |
1575 v = opts.get(key) | 1578 v = opts.get(key) |
1576 if v: | 1579 if v: |
1583 'text': opts and opts.get('text'), | 1586 'text': opts and opts.get('text'), |
1584 'nodates': get('nodates'), | 1587 'nodates': get('nodates'), |
1585 'nobinary': get('nobinary'), | 1588 'nobinary': get('nobinary'), |
1586 'noprefix': get('noprefix', forceplain=False), | 1589 'noprefix': get('noprefix', forceplain=False), |
1587 'showfunc': get('show_function', 'showfunc'), | 1590 'showfunc': get('show_function', 'showfunc'), |
1588 'ignorews': get('ignore_all_space', 'ignorews'), | |
1589 'ignorewsamount': get('ignore_space_change', 'ignorewsamount'), | |
1590 'ignoreblanklines': get('ignore_blank_lines', 'ignoreblanklines'), | |
1591 'context': get('unified', getter=ui.config), | 1591 'context': get('unified', getter=ui.config), |
1592 } | 1592 } |
1593 | 1593 |
1594 if git: | 1594 if git: |
1595 buildopts['git'] = get('git') | 1595 buildopts['git'] = get('git') |
1596 if whitespace: | |
1597 buildopts['ignorews'] = get('ignore_all_space', 'ignorews') | |
1598 buildopts['ignorewsamount'] = get('ignore_space_change', | |
1599 'ignorewsamount') | |
1600 buildopts['ignoreblanklines'] = get('ignore_blank_lines', | |
1601 'ignoreblanklines') | |
1596 | 1602 |
1597 return mdiff.diffopts(**buildopts) | 1603 return mdiff.diffopts(**buildopts) |
1598 | 1604 |
1599 def diff(repo, node1=None, node2=None, match=None, changes=None, opts=None, | 1605 def diff(repo, node1=None, node2=None, match=None, changes=None, opts=None, |
1600 losedatafn=None, prefix=''): | 1606 losedatafn=None, prefix=''): |