##// END OF EJS Templates
convert: allow the converter_source to say "skip this revision"...
convert: allow the converter_source to say "skip this revision" If getchanges returns a string, it's assumed to be the id of an already converted revision. We map the current revision to the same revision this converted revision was mapped to. To allow skipping a root revision, getchanges can return the special string 'hg-convert-skipped-revision' (a.k.a. common.SKIPREV), which hopefully won't clash with any real id. The converter_source is responsible for rewriting the parents of the commit objects to make sure the revision graph makes sense.

File last commit:

r4859:8c5aca85 default
r5374:e7108742 default
Show More
win32text.py
45 lines | 1.3 KiB | text/x-python | PythonLexer
Lee Cantey
Correct inadvertent line ending change.
r4859 from mercurial import util, ui
from mercurial.i18n import gettext as _
import re
# regexp for single LF without CR preceding.
re_single_lf = re.compile('(^|[^\r])\n', re.MULTILINE)
def dumbdecode(s, cmd):
# warn if already has CRLF in repository.
# it might cause unexpected eol conversion.
# see issue 302:
# http://www.selenic.com/mercurial/bts/issue302
if '\r\n' in s:
u = ui.ui()
u.warn(_('WARNING: file in repository already has CRLF line ending \n'
' which does not need eol conversion by win32text plugin.\n'
' Please reconsider encode/decode setting in'
' mercurial.ini or .hg/hgrc\n'
' before next commit.\n'))
# replace single LF to CRLF
return re_single_lf.sub('\\1\r\n', s)
def dumbencode(s, cmd):
return s.replace('\r\n', '\n')
def clevertest(s, cmd):
if '\0' in s: return False
return True
def cleverdecode(s, cmd):
if clevertest(s, cmd):
return dumbdecode(s, cmd)
return s
def cleverencode(s, cmd):
if clevertest(s, cmd):
return dumbencode(s, cmd)
return s
util.filtertable.update({
'dumbdecode:': dumbdecode,
'dumbencode:': dumbencode,
'cleverdecode:': cleverdecode,
'cleverencode:': cleverencode,
})