core: some more line limiting
This commit is contained in:
parent
8432630146
commit
ea9583aea0
1 changed files with 27 additions and 15 deletions
|
|
@ -71,15 +71,14 @@ class MercurialProtocol(protocol.ProcessProtocol):
|
|||
log.debug(_('Mercurial command succeed'))
|
||||
self._deferred.callback(data)
|
||||
else:
|
||||
msg = _(u"Can't complete Mercurial command (error code: {code}): {message}").format(
|
||||
code = reason.value.exitCode,
|
||||
message = data)
|
||||
msg = (_(u"Can't complete Mercurial command (error code: {code}): {message}")
|
||||
.format(code = reason.value.exitCode, message = data))
|
||||
log.warning(msg)
|
||||
self._deferred.errback(Failure(RuntimeError(msg)))
|
||||
|
||||
@classmethod
|
||||
def run(cls, path, command, *args, **kwargs):
|
||||
"""Create a new MercurialRegisterProtocol and execute the given mercurialctl command.
|
||||
"""Create a new MercurialRegisterProtocol and execute the given mercurial command.
|
||||
|
||||
@param path(unicode): path to the repository
|
||||
@param command(unicode): command to run
|
||||
|
|
@ -113,7 +112,8 @@ class MercurialHandler(object):
|
|||
try:
|
||||
MercurialProtocol.hg = which('hg')[0]
|
||||
except IndexError:
|
||||
raise exceptions.NotFound(_(u"Mercurial executable (hg) not found, can't use Mercurial handler"))
|
||||
raise exceptions.NotFound(_(u"Mercurial executable (hg) not found, "
|
||||
u"can't use Mercurial handler"))
|
||||
self.host = host
|
||||
self._m = host.plugins['MERGE_REQUESTS']
|
||||
self._m.register('mercurial', self, self.data_types, SHORT_DESC)
|
||||
|
|
@ -125,7 +125,8 @@ class MercurialHandler(object):
|
|||
return d
|
||||
|
||||
def export(self, repository):
|
||||
return MercurialProtocol.run(repository, 'export', '-g', '-r', 'outgoing()', '--encoding=utf-8')
|
||||
return MercurialProtocol.run(repository, 'export', '-g', '-r', 'outgoing()',
|
||||
'--encoding=utf-8')
|
||||
|
||||
def import_(self, repository, data, data_type, item_id, service, node, extra):
|
||||
parsed_data = self.parse(data)
|
||||
|
|
@ -134,8 +135,10 @@ class MercurialHandler(object):
|
|||
parsed_name = re.sub(ur'[^\w -.]', u'', parsed_name, flags=re.UNICODE)[:40]
|
||||
except Exception:
|
||||
parsed_name = u''
|
||||
name = u'mr_{item_id}_{parsed_name}'.format(item_id=item_id, parsed_name=parsed_name)
|
||||
return MercurialProtocol.run(repository, 'qimport', '-g', '--name', name, '--encoding=utf-8', '-', stdin=data)
|
||||
name = u'mr_{item_id}_{parsed_name}'.format(item_id=item_id,
|
||||
parsed_name=parsed_name)
|
||||
return MercurialProtocol.run(repository, 'qimport', '-g', '--name', name,
|
||||
'--encoding=utf-8', '-', stdin=data)
|
||||
|
||||
def parse(self, data, data_type=None):
|
||||
lines = data.splitlines()
|
||||
|
|
@ -160,15 +163,18 @@ class MercurialHandler(object):
|
|||
if not elems:
|
||||
continue
|
||||
last = elems[-1]
|
||||
if last.startswith(u'<') and last.endswith(u'>') and u'@' in last:
|
||||
if (last.startswith(u'<') and last.endswith(u'>')
|
||||
and u'@' in last):
|
||||
patch[self._m.META_EMAIL] = elems.pop()[1:-1]
|
||||
patch[self._m.META_AUTHOR] = u' '.join(elems)
|
||||
elif line.startswith(u'# Date '):
|
||||
time_data = line[7:].split()
|
||||
if len(time_data) != 2:
|
||||
log.warning(_(u'unexpected time data: {data}').format(data=line[7:]))
|
||||
log.warning(_(u'unexpected time data: {data}')
|
||||
.format(data=line[7:]))
|
||||
continue
|
||||
patch[self._m.META_TIMESTAMP] = int(time_data[0]) + int(time_data[1])
|
||||
patch[self._m.META_TIMESTAMP] = (int(time_data[0])
|
||||
+ int(time_data[1]))
|
||||
elif line.startswith(u'# Node ID '):
|
||||
patch[self._m.META_HASH] = line[10:]
|
||||
elif line.startswith(u'# Parent '):
|
||||
|
|
|
|||
Loading…
Reference in a new issue