##// END OF EJS Templates
convert: empty log messages are OK as of 7f5c3fb0a37d
convert: empty log messages are OK as of 7f5c3fb0a37d

File last commit:

r5024:79634388 default
r5024:79634388 default
Show More
common.py
122 lines | 3.9 KiB | text/x-python | PythonLexer
Brendan Cully
Split convert extension into common and repository type modules
r4536 # common code for the convert extension
class NoRepo(Exception): pass
class commit(object):
Bryan O'Sullivan
convert: make commit constructor clearer and less magical
r5012 def __init__(self, author, date, desc, parents, branch=None, rev=None,
copies={}):
Brendan Cully
convert: record the source revision in the changelog
r4873 self.rev = None
self.branch = None
Bryan O'Sullivan
convert: make commit constructor clearer and less magical
r5012 self.author = author
self.date = date
Bryan O'Sullivan
convert: empty log messages are OK as of 7f5c3fb0a37d
r5024 self.desc = desc
Bryan O'Sullivan
convert: make commit constructor clearer and less magical
r5012 self.parents = parents
self.branch = branch
self.rev = rev
self.copies = copies
Brendan Cully
Split convert extension into common and repository type modules
r4536
class converter_source(object):
"""Conversion source interface"""
Brendan Cully
convert: add -r argument specifying latest revision to convert
r4760 def __init__(self, ui, path, rev=None):
Brendan Cully
Split convert extension into common and repository type modules
r4536 """Initialize conversion source (or raise NoRepo("message")
exception if path is not a valid repository)"""
Brendan Cully
convert: move some code into common init function
r4810 self.ui = ui
self.path = path
self.rev = rev
self.encoding = 'utf-8'
Brendan Cully
convert: export revmap to source....
r4812
def setrevmap(self, revmap):
"""set the map of already-converted revisions"""
Brendan Cully
convert: svn: use revmap to parse only new revisions in incremental conversions
r4813 pass
Brendan Cully
Split convert extension into common and repository type modules
r4536
def getheads(self):
"""Return a list of this repository's heads"""
raise NotImplementedError()
def getfile(self, name, rev):
"""Return file contents as a string"""
raise NotImplementedError()
def getmode(self, name, rev):
"""Return file mode, eg. '', 'x', or 'l'"""
raise NotImplementedError()
def getchanges(self, version):
"""Return sorted list of (filename, id) tuples for all files changed in rev.
id just tells us which revision to return in getfile(), e.g. in
git it's an object hash."""
raise NotImplementedError()
def getcommit(self, version):
"""Return the commit object for version"""
raise NotImplementedError()
def gettags(self):
"""Return the tags as a dictionary of name: revision"""
raise NotImplementedError()
Brendan Cully
convert: ove recode method into converter_source
r4759 def recode(self, s, encoding=None):
if not encoding:
Brendan Cully
convert: move some code into common init function
r4810 encoding = self.encoding or 'utf-8'
Thomas Arendsen Hein
removed trailing whitespace
r4957
Brendan Cully
convert: ove recode method into converter_source
r4759 try:
return s.decode(encoding).encode("utf-8")
except:
try:
return s.decode("latin-1").encode("utf-8")
except:
return s.decode(encoding, "replace").encode("utf-8")
Brendan Cully
Split convert extension into common and repository type modules
r4536 class converter_sink(object):
"""Conversion sink (target) interface"""
def __init__(self, ui, path):
"""Initialize conversion sink (or raise NoRepo("message")
exception if path is not a valid repository)"""
raise NotImplementedError()
def getheads(self):
"""Return a list of this repository's heads"""
raise NotImplementedError()
Bryan O'Sullivan
convert: rename mapfile to revmapfile, so we can map more than just revs
r5011 def revmapfile(self):
Brendan Cully
Split convert extension into common and repository type modules
r4536 """Path to a file that will contain lines
source_rev_id sink_rev_id
mapping equivalent revision identifiers for each system."""
raise NotImplementedError()
Edouard Gomez
convert extension: Add support for username mapping...
r4589 def authorfile(self):
"""Path to a file that will contain lines
srcauthor=dstauthor
mapping equivalent authors identifiers for each system."""
Brendan Cully
convert: fix various authormap handling bugs
r4590 return None
Edouard Gomez
convert extension: Add support for username mapping...
r4589
Brendan Cully
Split convert extension into common and repository type modules
r4536 def putfile(self, f, e, data):
"""Put file for next putcommit().
f: path to file
e: '', 'x', or 'l' (regular file, executable, or symlink)
data: file contents"""
raise NotImplementedError()
def delfile(self, f):
"""Delete file for next putcommit().
f: path to file"""
raise NotImplementedError()
def putcommit(self, files, parents, commit):
"""Create a revision with all changed files listed in 'files'
and having listed parents. 'commit' is a commit object containing
at a minimum the author, date, and message for this changeset.
Called after putfile() and delfile() calls. Note that the sink
repository is not told to update itself to a particular revision
(or even what that revision would be) before it receives the
file data."""
raise NotImplementedError()
def puttags(self, tags):
"""Put tags into sink.
tags: {tagname: sink_rev_id, ...}"""
raise NotImplementedError()