hgext/convert/common.py
changeset 10282 08a0f04b56bd
parent 10263 25e572394f5c
child 11134 33010ff1fd6f
equal deleted inserted replaced
10281:e7d3b509af8b 10282:08a0f04b56bd
    22 
    22 
    23 def decodeargs(s):
    23 def decodeargs(s):
    24     s = base64.decodestring(s)
    24     s = base64.decodestring(s)
    25     return pickle.loads(s)
    25     return pickle.loads(s)
    26 
    26 
    27 class MissingTool(Exception): pass
    27 class MissingTool(Exception):
       
    28     pass
    28 
    29 
    29 def checktool(exe, name=None, abort=True):
    30 def checktool(exe, name=None, abort=True):
    30     name = name or exe
    31     name = name or exe
    31     if not util.find_exe(exe):
    32     if not util.find_exe(exe):
    32         exc = abort and util.Abort or MissingTool
    33         exc = abort and util.Abort or MissingTool
    33         raise exc(_('cannot find required "%s" tool') % name)
    34         raise exc(_('cannot find required "%s" tool') % name)
    34 
    35 
    35 class NoRepo(Exception): pass
    36 class NoRepo(Exception):
       
    37     pass
    36 
    38 
    37 SKIPREV = 'SKIP'
    39 SKIPREV = 'SKIP'
    38 
    40 
    39 class commit(object):
    41 class commit(object):
    40     def __init__(self, author, date, desc, parents, branch=None, rev=None,
    42     def __init__(self, author, date, desc, parents, branch=None, rev=None,
   320         # details about cmd.exe limitations.
   322         # details about cmd.exe limitations.
   321 
   323 
   322         # Since ARG_MAX is for command line _and_ environment, lower our limit
   324         # Since ARG_MAX is for command line _and_ environment, lower our limit
   323         # (and make happy Windows shells while doing this).
   325         # (and make happy Windows shells while doing this).
   324 
   326 
   325         self._argmax = self._argmax/2 - 1
   327         self._argmax = self._argmax / 2 - 1
   326         return self._argmax
   328         return self._argmax
   327 
   329 
   328     def limit_arglist(self, arglist, cmd, *args, **kwargs):
   330     def limit_arglist(self, arglist, cmd, *args, **kwargs):
   329         limit = self.getargmax() - len(self._cmdline(cmd, *args, **kwargs))
   331         limit = self.getargmax() - len(self._cmdline(cmd, *args, **kwargs))
   330         bytes = 0
   332         bytes = 0
   365             return
   367             return
   366         for i, line in enumerate(fp):
   368         for i, line in enumerate(fp):
   367             try:
   369             try:
   368                 key, value = line.splitlines()[0].rsplit(' ', 1)
   370                 key, value = line.splitlines()[0].rsplit(' ', 1)
   369             except ValueError:
   371             except ValueError:
   370                 raise util.Abort(_('syntax error in %s(%d): key/value pair expected')
   372                 raise util.Abort(
   371                                  % (self.path, i+1))
   373                     _('syntax error in %s(%d): key/value pair expected')
       
   374                     % (self.path, i + 1))
   372             if key not in self:
   375             if key not in self:
   373                 self.order.append(key)
   376                 self.order.append(key)
   374             super(mapfile, self).__setitem__(key, value)
   377             super(mapfile, self).__setitem__(key, value)
   375         fp.close()
   378         fp.close()
   376 
   379