##// END OF EJS Templates
revlog: subclass the new `repository.iverifyproblem` Protocol class...
revlog: subclass the new `repository.iverifyproblem` Protocol class This is the same transformation as 3a90a6fd710d did for dirstate, but the CamelCase naming was already cleaned up here. We shouldn't have to explicitly subclass, but I'm doing so to test the interplay of regular attributes and the `attrs` class. Also, PyCharm has a nifty feature that puts a jump point in the gutter to navigate back and forth between the base class and subclasses (and override functions and base class functions) when there's an explicit subclassing. Additionally, PyCharm will immediately flag signature mismatches without a 40m pytype run.

File last commit:

r49730:6000f5b2 default
r53365:4ef6dbc2 default
Show More
autodiff.py
65 lines | 1.5 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 mercurial import (
error,
Martin von Zweigbergk
errors: raise InputError from revpair() iff revset provided by the user...
r48929 logcmdutil,
Gregory Szorc
tests/autodiff.py: use absolute_import
r27281 patch,
Pulkit Goyal
py3: use pycompat.byteskwargs() in tests/autodiff.py...
r37386 pycompat,
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
Augie Fackler
formatting: blacken the codebase...
r43346
@command(
b'autodiff',
Pulkit Goyal
tests: make autodiff.py work on Python 3...
r35599 [(b'', b'git', b'', b'git upgrade mode (yes/no/auto/warn/abort)')],
Augie Fackler
formatting: blacken the codebase...
r43346 b'[OPTION]... [FILE]...',
)
Patrick Mezard
patch: support diff data loss detection and upgrade...
r10189 def autodiff(ui, repo, *pats, **opts):
Pulkit Goyal
py3: use pycompat.byteskwargs() in tests/autodiff.py...
r37386 opts = pycompat.byteskwargs(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
Augie Fackler
formatting: blacken the codebase...
r43346
Patrick Mezard
patch: support diff data loss detection and upgrade...
r10189 def losedatafn(fn=None, **kwargs):
brokenfiles.add(fn)
return True
Augie Fackler
formatting: blacken the codebase...
r43346
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
Augie Fackler
formatting: blacken the codebase...
r43346
Patrick Mezard
patch: support diff data loss detection and upgrade...
r10189 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)
Augie Fackler
formatting: blacken the codebase...
r43346
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
Martin von Zweigbergk
errors: raise InputError from revpair() iff revset provided by the user...
r48929 ctx1, ctx2 = logcmdutil.revpair(repo, [])
Martin von Zweigbergk
tests: use context-return revpair() in autodiff...
r37275 m = scmutil.match(ctx2, pats, opts)
Augie Fackler
formatting: blacken the codebase...
r43346 it = patch.diff(
repo,
ctx1.node(),
ctx2.node(),
match=m,
opts=diffopts,
losedatafn=losedatafn,
)
Patrick Mezard
patch: support diff data loss detection and upgrade...
r10189 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))