Show More
@@ -1,125 +1,122 b'' | |||
|
1 | 1 | # common code for the convert extension |
|
2 | 2 | |
|
3 | 3 | class NoRepo(Exception): pass |
|
4 | 4 | |
|
5 | 5 | class commit(object): |
|
6 | 6 | def __init__(self, author, date, desc, parents, branch=None, rev=None, |
|
7 | 7 | copies={}): |
|
8 | 8 | self.rev = None |
|
9 | 9 | self.branch = None |
|
10 | 10 | self.author = author |
|
11 | 11 | self.date = date |
|
12 | if desc and not desc.isspace(): | |
|
13 | self.desc = desc | |
|
14 | else: | |
|
15 | self.desc = '*** empty log message ***' | |
|
12 | self.desc = desc | |
|
16 | 13 | self.parents = parents |
|
17 | 14 | self.branch = branch |
|
18 | 15 | self.rev = rev |
|
19 | 16 | self.copies = copies |
|
20 | 17 | |
|
21 | 18 | class converter_source(object): |
|
22 | 19 | """Conversion source interface""" |
|
23 | 20 | |
|
24 | 21 | def __init__(self, ui, path, rev=None): |
|
25 | 22 | """Initialize conversion source (or raise NoRepo("message") |
|
26 | 23 | exception if path is not a valid repository)""" |
|
27 | 24 | self.ui = ui |
|
28 | 25 | self.path = path |
|
29 | 26 | self.rev = rev |
|
30 | 27 | |
|
31 | 28 | self.encoding = 'utf-8' |
|
32 | 29 | |
|
33 | 30 | def setrevmap(self, revmap): |
|
34 | 31 | """set the map of already-converted revisions""" |
|
35 | 32 | pass |
|
36 | 33 | |
|
37 | 34 | def getheads(self): |
|
38 | 35 | """Return a list of this repository's heads""" |
|
39 | 36 | raise NotImplementedError() |
|
40 | 37 | |
|
41 | 38 | def getfile(self, name, rev): |
|
42 | 39 | """Return file contents as a string""" |
|
43 | 40 | raise NotImplementedError() |
|
44 | 41 | |
|
45 | 42 | def getmode(self, name, rev): |
|
46 | 43 | """Return file mode, eg. '', 'x', or 'l'""" |
|
47 | 44 | raise NotImplementedError() |
|
48 | 45 | |
|
49 | 46 | def getchanges(self, version): |
|
50 | 47 | """Return sorted list of (filename, id) tuples for all files changed in rev. |
|
51 | 48 | |
|
52 | 49 | id just tells us which revision to return in getfile(), e.g. in |
|
53 | 50 | git it's an object hash.""" |
|
54 | 51 | raise NotImplementedError() |
|
55 | 52 | |
|
56 | 53 | def getcommit(self, version): |
|
57 | 54 | """Return the commit object for version""" |
|
58 | 55 | raise NotImplementedError() |
|
59 | 56 | |
|
60 | 57 | def gettags(self): |
|
61 | 58 | """Return the tags as a dictionary of name: revision""" |
|
62 | 59 | raise NotImplementedError() |
|
63 | 60 | |
|
64 | 61 | def recode(self, s, encoding=None): |
|
65 | 62 | if not encoding: |
|
66 | 63 | encoding = self.encoding or 'utf-8' |
|
67 | 64 | |
|
68 | 65 | try: |
|
69 | 66 | return s.decode(encoding).encode("utf-8") |
|
70 | 67 | except: |
|
71 | 68 | try: |
|
72 | 69 | return s.decode("latin-1").encode("utf-8") |
|
73 | 70 | except: |
|
74 | 71 | return s.decode(encoding, "replace").encode("utf-8") |
|
75 | 72 | |
|
76 | 73 | class converter_sink(object): |
|
77 | 74 | """Conversion sink (target) interface""" |
|
78 | 75 | |
|
79 | 76 | def __init__(self, ui, path): |
|
80 | 77 | """Initialize conversion sink (or raise NoRepo("message") |
|
81 | 78 | exception if path is not a valid repository)""" |
|
82 | 79 | raise NotImplementedError() |
|
83 | 80 | |
|
84 | 81 | def getheads(self): |
|
85 | 82 | """Return a list of this repository's heads""" |
|
86 | 83 | raise NotImplementedError() |
|
87 | 84 | |
|
88 | 85 | def revmapfile(self): |
|
89 | 86 | """Path to a file that will contain lines |
|
90 | 87 | source_rev_id sink_rev_id |
|
91 | 88 | mapping equivalent revision identifiers for each system.""" |
|
92 | 89 | raise NotImplementedError() |
|
93 | 90 | |
|
94 | 91 | def authorfile(self): |
|
95 | 92 | """Path to a file that will contain lines |
|
96 | 93 | srcauthor=dstauthor |
|
97 | 94 | mapping equivalent authors identifiers for each system.""" |
|
98 | 95 | return None |
|
99 | 96 | |
|
100 | 97 | def putfile(self, f, e, data): |
|
101 | 98 | """Put file for next putcommit(). |
|
102 | 99 | f: path to file |
|
103 | 100 | e: '', 'x', or 'l' (regular file, executable, or symlink) |
|
104 | 101 | data: file contents""" |
|
105 | 102 | raise NotImplementedError() |
|
106 | 103 | |
|
107 | 104 | def delfile(self, f): |
|
108 | 105 | """Delete file for next putcommit(). |
|
109 | 106 | f: path to file""" |
|
110 | 107 | raise NotImplementedError() |
|
111 | 108 | |
|
112 | 109 | def putcommit(self, files, parents, commit): |
|
113 | 110 | """Create a revision with all changed files listed in 'files' |
|
114 | 111 | and having listed parents. 'commit' is a commit object containing |
|
115 | 112 | at a minimum the author, date, and message for this changeset. |
|
116 | 113 | Called after putfile() and delfile() calls. Note that the sink |
|
117 | 114 | repository is not told to update itself to a particular revision |
|
118 | 115 | (or even what that revision would be) before it receives the |
|
119 | 116 | file data.""" |
|
120 | 117 | raise NotImplementedError() |
|
121 | 118 | |
|
122 | 119 | def puttags(self, tags): |
|
123 | 120 | """Put tags into sink. |
|
124 | 121 | tags: {tagname: sink_rev_id, ...}""" |
|
125 | 122 | raise NotImplementedError() |
General Comments 0
You need to be logged in to leave comments.
Login now