Mercurial > hg
comparison hgext/convert/common.py @ 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 | 15a3cbfc6568 |
children | a5209b0487e0 |
comparison
equal
deleted
inserted
replaced
4809:4582c28e2874 | 4810:c2d529f288a1 |
---|---|
15 """Conversion source interface""" | 15 """Conversion source interface""" |
16 | 16 |
17 def __init__(self, ui, path, rev=None): | 17 def __init__(self, ui, path, rev=None): |
18 """Initialize conversion source (or raise NoRepo("message") | 18 """Initialize conversion source (or raise NoRepo("message") |
19 exception if path is not a valid repository)""" | 19 exception if path is not a valid repository)""" |
20 pass | 20 self.ui = ui |
21 self.path = path | |
22 self.rev = rev | |
23 | |
24 self.encoding = 'utf-8' | |
21 | 25 |
22 def getheads(self): | 26 def getheads(self): |
23 """Return a list of this repository's heads""" | 27 """Return a list of this repository's heads""" |
24 raise NotImplementedError() | 28 raise NotImplementedError() |
25 | 29 |
46 """Return the tags as a dictionary of name: revision""" | 50 """Return the tags as a dictionary of name: revision""" |
47 raise NotImplementedError() | 51 raise NotImplementedError() |
48 | 52 |
49 def recode(self, s, encoding=None): | 53 def recode(self, s, encoding=None): |
50 if not encoding: | 54 if not encoding: |
51 encoding = hasattr(self, 'encoding') and self.encoding or 'utf-8' | 55 encoding = self.encoding or 'utf-8' |
52 | 56 |
53 try: | 57 try: |
54 return s.decode(encoding).encode("utf-8") | 58 return s.decode(encoding).encode("utf-8") |
55 except: | 59 except: |
56 try: | 60 try: |