summaryrefslogtreecommitdiff
path: root/hgext/convert/common.py
diff options
context:
space:
mode:
Diffstat (limited to 'hgext/convert/common.py')
-rw-r--r--hgext/convert/common.py82
1 files changed, 24 insertions, 58 deletions
diff --git a/hgext/convert/common.py b/hgext/convert/common.py
index e30ef2d..29b01b5 100644
--- a/hgext/convert/common.py
+++ b/hgext/convert/common.py
@@ -11,8 +11,6 @@ import cPickle as pickle
from mercurial import util
from mercurial.i18n import _
-propertycache = util.propertycache
-
def encodeargs(args):
def encodearg(s):
lines = base64.encodestring(s)
@@ -76,7 +74,7 @@ class converter_source(object):
def getheads(self):
"""Return a list of this repository's heads"""
- raise NotImplementedError
+ raise NotImplementedError()
def getfile(self, name, rev):
"""Return a pair (data, mode) where data is the file content
@@ -84,7 +82,7 @@ class converter_source(object):
identifier returned by a previous call to getchanges(). Raise
IOError to indicate that name was deleted in rev.
"""
- raise NotImplementedError
+ raise NotImplementedError()
def getchanges(self, version):
"""Returns a tuple of (files, copies).
@@ -95,18 +93,18 @@ class converter_source(object):
copies is a dictionary of dest: source
"""
- raise NotImplementedError
+ raise NotImplementedError()
def getcommit(self, version):
"""Return the commit object for version"""
- raise NotImplementedError
+ raise NotImplementedError()
def gettags(self):
"""Return the tags as a dictionary of name: revision
Tag names must be UTF-8 strings.
"""
- raise NotImplementedError
+ raise NotImplementedError()
def recode(self, s, encoding=None):
if not encoding:
@@ -116,10 +114,10 @@ class converter_source(object):
return s.encode("utf-8")
try:
return s.decode(encoding).encode("utf-8")
- except UnicodeError:
+ except:
try:
return s.decode("latin-1").encode("utf-8")
- except UnicodeError:
+ except:
return s.decode(encoding, "replace").encode("utf-8")
def getchangedfiles(self, rev, i):
@@ -133,7 +131,7 @@ class converter_source(object):
This function is only needed to support --filemap
"""
- raise NotImplementedError
+ raise NotImplementedError()
def converted(self, rev, sinkrev):
'''Notify the source that a revision has been converted.'''
@@ -175,13 +173,13 @@ class converter_sink(object):
def getheads(self):
"""Return a list of this repository's heads"""
- raise NotImplementedError
+ raise NotImplementedError()
def revmapfile(self):
"""Path to a file that will contain lines
source_rev_id sink_rev_id
mapping equivalent revision identifiers for each system."""
- raise NotImplementedError
+ raise NotImplementedError()
def authorfile(self):
"""Path to a file that will contain lines
@@ -203,7 +201,7 @@ class converter_sink(object):
a particular revision (or even what that revision would be)
before it receives the file data.
"""
- raise NotImplementedError
+ raise NotImplementedError()
def puttags(self, tags):
"""Put tags into sink.
@@ -212,7 +210,7 @@ class converter_sink(object):
Return a pair (tag_revision, tag_parent_revision), or (None, None)
if nothing was changed.
"""
- raise NotImplementedError
+ raise NotImplementedError()
def setbranch(self, branch, pbranches):
"""Set the current branch name. Called before the first putcommit
@@ -245,10 +243,6 @@ class converter_sink(object):
"""
pass
- def hascommit(self, rev):
- """Return True if the sink contains rev"""
- raise NotImplementedError
-
class commandline(object):
def __init__(self, ui, command):
self.ui = ui
@@ -327,13 +321,15 @@ class commandline(object):
self.checkexit(status, ''.join(output))
return output
- @propertycache
- def argmax(self):
+ def getargmax(self):
+ if '_argmax' in self.__dict__:
+ return self._argmax
+
# POSIX requires at least 4096 bytes for ARG_MAX
- argmax = 4096
+ self._argmax = 4096
try:
- argmax = os.sysconf("SC_ARG_MAX")
- except (AttributeError, ValueError):
+ self._argmax = os.sysconf("SC_ARG_MAX")
+ except:
pass
# Windows shells impose their own limits on command line length,
@@ -343,11 +339,13 @@ class commandline(object):
# Since ARG_MAX is for command line _and_ environment, lower our limit
# (and make happy Windows shells while doing this).
- return argmax // 2 - 1
+
+ self._argmax = self._argmax / 2 - 1
+ return self._argmax
def limit_arglist(self, arglist, cmd, closestdin, *args, **kwargs):
cmdlen = len(self._cmdline(cmd, closestdin, *args, **kwargs))
- limit = self.argmax - cmdlen
+ limit = self.getargmax() - cmdlen
bytes = 0
fl = []
for fn in arglist:
@@ -385,12 +383,8 @@ class mapfile(dict):
raise
return
for i, line in enumerate(fp):
- line = line.splitlines()[0].rstrip()
- if not line:
- # Ignore blank lines
- continue
try:
- key, value = line.rsplit(' ', 1)
+ key, value = line.splitlines()[0].rsplit(' ', 1)
except ValueError:
raise util.Abort(
_('syntax error in %s(%d): key/value pair expected')
@@ -415,31 +409,3 @@ class mapfile(dict):
if self.fp:
self.fp.close()
self.fp = None
-
-def parsesplicemap(path):
- """Parse a splicemap, return a child/parents dictionary."""
- if not path:
- return {}
- m = {}
- try:
- fp = open(path, 'r')
- for i, line in enumerate(fp):
- line = line.splitlines()[0].rstrip()
- if not line:
- # Ignore blank lines
- continue
- try:
- child, parents = line.split(' ', 1)
- parents = parents.replace(',', ' ').split()
- except ValueError:
- raise util.Abort(_('syntax error in %s(%d): child parent1'
- '[,parent2] expected') % (path, i + 1))
- pp = []
- for p in parents:
- if p not in pp:
- pp.append(p)
- m[child] = pp
- except IOError, e:
- if e.errno != errno.ENOENT:
- raise
- return m