##// END OF EJS Templates
py3: make test-bisect.t bytes-safe
py3: make test-bisect.t bytes-safe

File last commit:

r35599:154754d1 default
r36847:4eb3bf22 default
Show More
autodiff.py
50 lines | 1.4 KiB | text/x-python | PythonLexer
Patrick Mezard
patch: support diff data loss detection and upgrade...
r10189 # Extension dedicated to test patch.diff() upgrade modes
Gregory Szorc
tests/autodiff.py: use absolute_import
r27281
from __future__ import absolute_import
from mercurial import (
error,
patch,
Yuya Nishihara
registrar: move cmdutil.command to registrar module (API)...
r32337 registrar,
Gregory Szorc
tests/autodiff.py: use absolute_import
r27281 scmutil,
)
Patrick Mezard
patch: support diff data loss detection and upgrade...
r10189
Gregory Szorc
tests: declare commands using decorator
r21254 cmdtable = {}
Yuya Nishihara
registrar: move cmdutil.command to registrar module (API)...
r32337 command = registrar.command(cmdtable)
Gregory Szorc
tests: declare commands using decorator
r21254
Pulkit Goyal
tests: make autodiff.py work on Python 3...
r35599 @command(b'autodiff',
[(b'', b'git', b'', b'git upgrade mode (yes/no/auto/warn/abort)')],
b'[OPTION]... [FILE]...')
Patrick Mezard
patch: support diff data loss detection and upgrade...
r10189 def autodiff(ui, repo, *pats, **opts):
Siddharth Agarwal
tests/autodiff.py: explicitly only honor feature diffopts...
r23692 diffopts = patch.difffeatureopts(ui, opts)
Pulkit Goyal
tests: make autodiff.py work on Python 3...
r35599 git = opts.get(b'git', b'no')
Patrick Mezard
patch: support diff data loss detection and upgrade...
r10189 brokenfiles = set()
losedatafn = None
Pulkit Goyal
tests: make autodiff.py work on Python 3...
r35599 if git in (b'yes', b'no'):
diffopts.git = git == b'yes'
Patrick Mezard
patch: support diff data loss detection and upgrade...
r10189 diffopts.upgrade = False
Pulkit Goyal
tests: make autodiff.py work on Python 3...
r35599 elif git == b'auto':
Patrick Mezard
patch: support diff data loss detection and upgrade...
r10189 diffopts.git = False
diffopts.upgrade = True
Pulkit Goyal
tests: make autodiff.py work on Python 3...
r35599 elif git == b'warn':
Patrick Mezard
patch: support diff data loss detection and upgrade...
r10189 diffopts.git = False
diffopts.upgrade = True
def losedatafn(fn=None, **kwargs):
brokenfiles.add(fn)
return True
Pulkit Goyal
tests: make autodiff.py work on Python 3...
r35599 elif git == b'abort':
Patrick Mezard
patch: support diff data loss detection and upgrade...
r10189 diffopts.git = False
diffopts.upgrade = True
def losedatafn(fn=None, **kwargs):
Pulkit Goyal
tests: make autodiff.py work on Python 3...
r35599 raise error.Abort(b'losing data for %s' % fn)
Patrick Mezard
patch: support diff data loss detection and upgrade...
r10189 else:
Pulkit Goyal
tests: make autodiff.py work on Python 3...
r35599 raise error.Abort(b'--git must be yes, no or auto')
Patrick Mezard
patch: support diff data loss detection and upgrade...
r10189
Matt Mackall
scmutil: move revsingle/pair/range from cmdutil...
r14319 node1, node2 = scmutil.revpair(repo, [])
Matt Mackall
scmutil: switch match users to supplying contexts...
r14671 m = scmutil.match(repo[node2], pats, opts)
Patrick Mezard
patch: support diff data loss detection and upgrade...
r10189 it = patch.diff(repo, node1, node2, match=m, opts=diffopts,
losedatafn=losedatafn)
for chunk in it:
ui.write(chunk)
for fn in sorted(brokenfiles):
Pulkit Goyal
tests: make autodiff.py work on Python 3...
r35599 ui.write((b'data lost for: %s\n' % fn))