Mercurial > hg
changeset 4810:c2d529f288a1
convert: move some code into common init function
author | Brendan Cully <brendan@kublai.com> |
---|---|
date | Thu, 05 Jul 2007 12:08:48 -0700 |
parents | 4582c28e2874 |
children | f7c8222920ee |
files | hgext/convert/common.py hgext/convert/cvs.py hgext/convert/git.py hgext/convert/subversion.py |
diffstat | 4 files changed, 13 insertions(+), 17 deletions(-) [+] |
line wrap: on
line diff
--- a/hgext/convert/common.py Thu Jul 05 12:00:43 2007 -0700 +++ b/hgext/convert/common.py Thu Jul 05 12:08:48 2007 -0700 @@ -17,7 +17,11 @@ def __init__(self, ui, path, rev=None): """Initialize conversion source (or raise NoRepo("message") exception if path is not a valid repository)""" - pass + self.ui = ui + self.path = path + self.rev = rev + + self.encoding = 'utf-8' def getheads(self): """Return a list of this repository's heads""" @@ -48,7 +52,7 @@ def recode(self, s, encoding=None): if not encoding: - encoding = hasattr(self, 'encoding') and self.encoding or 'utf-8' + encoding = self.encoding or 'utf-8' try: return s.decode(encoding).encode("utf-8")
--- a/hgext/convert/cvs.py Thu Jul 05 12:00:43 2007 -0700 +++ b/hgext/convert/cvs.py Thu Jul 05 12:08:48 2007 -0700 @@ -9,9 +9,6 @@ def __init__(self, ui, path, rev=None): super(convert_cvs, self).__init__(ui, path, rev=rev) - self.path = path - self.ui = ui - self.rev = rev cvs = os.path.join(path, "CVS") if not os.path.exists(cvs): raise NoRepo("couldn't open CVS repo %s" % path)
--- a/hgext/convert/git.py Thu Jul 05 12:00:43 2007 -0700 +++ b/hgext/convert/git.py Thu Jul 05 12:08:48 2007 -0700 @@ -15,11 +15,7 @@ path += "/.git" if not os.path.exists(path + "/objects"): raise NoRepo("couldn't open GIT repo %s" % path) - self.path = path - self.ui = ui - self.rev = rev - self.encoding = 'utf-8' def getheads(self): if not self.rev:
--- a/hgext/convert/subversion.py Thu Jul 05 12:00:43 2007 -0700 +++ b/hgext/convert/subversion.py Thu Jul 05 12:08:48 2007 -0700 @@ -86,7 +86,6 @@ ui.warn(msg) raise NoRepo(msg) - self.ui = ui self.encoding = locale.getpreferredencoding() latest = None if rev: @@ -123,9 +122,9 @@ self.last_changed = self.latest(self.module, latest) - self.head = self.rev(self.last_changed) + self.head = self.revid(self.last_changed) - def rev(self, revnum, module=None): + def revid(self, revnum, module=None): if not module: module = self.module return (u"svn:%s%s@%s" % (self.uuid, module, revnum)).decode(self.encoding) @@ -227,7 +226,7 @@ copyfrom = {} # Map of entrypath, revision for finding source of deleted revisions. copies = {} entries = [] - rev = self.rev(revnum) + rev = self.revid(revnum) parents = [] try: branch = self.module.split("/")[-1] @@ -245,7 +244,7 @@ # ent.copyfrom_rev may not be the actual last revision prev = self.latest(ent.copyfrom_path, ent.copyfrom_rev) self.modulemap[prev] = ent.copyfrom_path - parents = [self.rev(prev, ent.copyfrom_path)] + parents = [self.revid(prev, ent.copyfrom_path)] self.ui.note('found parent of branch %s at %d: %s\n' % \ (self.module, prev, ent.copyfrom_path)) else: @@ -465,13 +464,13 @@ if 'branches' in paths and 'trunk' in paths: self.module += '/trunk' lt = self.latest(self.module, self.last_changed) - self.head = self.rev(lt) + self.head = self.revid(lt) self.heads = [self.head] branches = svn.client.ls(rpath + '/branches', optrev, False, self.ctx) for branch in branches.keys(): module = '/branches/' + branch brevnum = self.latest(module, self.last_changed) - brev = self.rev(brevnum, module) + brev = self.revid(brevnum, module) self.ui.note('found branch %s at %d\n' % (branch, brevnum)) self.heads.append(brev) else: @@ -540,7 +539,7 @@ source = ent.copyfrom_path rev = ent.copyfrom_rev tag = path.split('/', 2)[2] - tags[tag] = self.rev(rev, module=source) + tags[tag] = self.revid(rev, module=source) start = self.revnum(self.head) try: