Show More
@@ -1,365 +1,371 | |||||
1 | # monotone.py - monotone support for the convert extension |
|
1 | # monotone.py - monotone support for the convert extension | |
2 | # |
|
2 | # | |
3 | # Copyright 2008, 2009 Mikkel Fahnoe Jorgensen <mikkel@dvide.com> and |
|
3 | # Copyright 2008, 2009 Mikkel Fahnoe Jorgensen <mikkel@dvide.com> and | |
4 | # others |
|
4 | # others | |
5 | # |
|
5 | # | |
6 | # This software may be used and distributed according to the terms of the |
|
6 | # This software may be used and distributed according to the terms of the | |
7 | # GNU General Public License version 2 or any later version. |
|
7 | # GNU General Public License version 2 or any later version. | |
|
8 | from __future__ import absolute_import | |||
8 |
|
9 | |||
9 |
import os |
|
10 | import os | |
10 | from mercurial import util, error |
|
11 | import re | |
11 | from common import NoRepo, commit, converter_source, checktool |
|
12 | ||
12 | from common import commandline |
|
13 | from mercurial import ( | |
|
14 | error, | |||
|
15 | util, | |||
|
16 | ) | |||
13 | from mercurial.i18n import _ |
|
17 | from mercurial.i18n import _ | |
14 |
|
18 | |||
15 | class monotone_source(converter_source, commandline): |
|
19 | from . import common | |
|
20 | ||||
|
21 | class monotone_source(common.converter_source, common.commandline): | |||
16 | def __init__(self, ui, path=None, revs=None): |
|
22 | def __init__(self, ui, path=None, revs=None): | |
17 | converter_source.__init__(self, ui, path, revs) |
|
23 | common.converter_source.__init__(self, ui, path, revs) | |
18 | if revs and len(revs) > 1: |
|
24 | if revs and len(revs) > 1: | |
19 | raise error.Abort(_('monotone source does not support specifying ' |
|
25 | raise error.Abort(_('monotone source does not support specifying ' | |
20 | 'multiple revs')) |
|
26 | 'multiple revs')) | |
21 | commandline.__init__(self, ui, 'mtn') |
|
27 | common.commandline.__init__(self, ui, 'mtn') | |
22 |
|
28 | |||
23 | self.ui = ui |
|
29 | self.ui = ui | |
24 | self.path = path |
|
30 | self.path = path | |
25 | self.automatestdio = False |
|
31 | self.automatestdio = False | |
26 | self.revs = revs |
|
32 | self.revs = revs | |
27 |
|
33 | |||
28 | norepo = NoRepo(_("%s does not look like a monotone repository") |
|
34 | norepo = common.NoRepo(_("%s does not look like a monotone repository") | |
29 | % path) |
|
35 | % path) | |
30 | if not os.path.exists(os.path.join(path, '_MTN')): |
|
36 | if not os.path.exists(os.path.join(path, '_MTN')): | |
31 | # Could be a monotone repository (SQLite db file) |
|
37 | # Could be a monotone repository (SQLite db file) | |
32 | try: |
|
38 | try: | |
33 | f = file(path, 'rb') |
|
39 | f = file(path, 'rb') | |
34 | header = f.read(16) |
|
40 | header = f.read(16) | |
35 | f.close() |
|
41 | f.close() | |
36 | except IOError: |
|
42 | except IOError: | |
37 | header = '' |
|
43 | header = '' | |
38 | if header != 'SQLite format 3\x00': |
|
44 | if header != 'SQLite format 3\x00': | |
39 | raise norepo |
|
45 | raise norepo | |
40 |
|
46 | |||
41 | # regular expressions for parsing monotone output |
|
47 | # regular expressions for parsing monotone output | |
42 | space = r'\s*' |
|
48 | space = r'\s*' | |
43 | name = r'\s+"((?:\\"|[^"])*)"\s*' |
|
49 | name = r'\s+"((?:\\"|[^"])*)"\s*' | |
44 | value = name |
|
50 | value = name | |
45 | revision = r'\s+\[(\w+)\]\s*' |
|
51 | revision = r'\s+\[(\w+)\]\s*' | |
46 | lines = r'(?:.|\n)+' |
|
52 | lines = r'(?:.|\n)+' | |
47 |
|
53 | |||
48 | self.dir_re = re.compile(space + "dir" + name) |
|
54 | self.dir_re = re.compile(space + "dir" + name) | |
49 | self.file_re = re.compile(space + "file" + name + |
|
55 | self.file_re = re.compile(space + "file" + name + | |
50 | "content" + revision) |
|
56 | "content" + revision) | |
51 | self.add_file_re = re.compile(space + "add_file" + name + |
|
57 | self.add_file_re = re.compile(space + "add_file" + name + | |
52 | "content" + revision) |
|
58 | "content" + revision) | |
53 | self.patch_re = re.compile(space + "patch" + name + |
|
59 | self.patch_re = re.compile(space + "patch" + name + | |
54 | "from" + revision + "to" + revision) |
|
60 | "from" + revision + "to" + revision) | |
55 | self.rename_re = re.compile(space + "rename" + name + "to" + name) |
|
61 | self.rename_re = re.compile(space + "rename" + name + "to" + name) | |
56 | self.delete_re = re.compile(space + "delete" + name) |
|
62 | self.delete_re = re.compile(space + "delete" + name) | |
57 | self.tag_re = re.compile(space + "tag" + name + "revision" + |
|
63 | self.tag_re = re.compile(space + "tag" + name + "revision" + | |
58 | revision) |
|
64 | revision) | |
59 | self.cert_re = re.compile(lines + space + "name" + name + |
|
65 | self.cert_re = re.compile(lines + space + "name" + name + | |
60 | "value" + value) |
|
66 | "value" + value) | |
61 |
|
67 | |||
62 | attr = space + "file" + lines + space + "attr" + space |
|
68 | attr = space + "file" + lines + space + "attr" + space | |
63 | self.attr_execute_re = re.compile(attr + '"mtn:execute"' + |
|
69 | self.attr_execute_re = re.compile(attr + '"mtn:execute"' + | |
64 | space + '"true"') |
|
70 | space + '"true"') | |
65 |
|
71 | |||
66 | # cached data |
|
72 | # cached data | |
67 | self.manifest_rev = None |
|
73 | self.manifest_rev = None | |
68 | self.manifest = None |
|
74 | self.manifest = None | |
69 | self.files = None |
|
75 | self.files = None | |
70 | self.dirs = None |
|
76 | self.dirs = None | |
71 |
|
77 | |||
72 | checktool('mtn', abort=False) |
|
78 | common.checktool('mtn', abort=False) | |
73 |
|
79 | |||
74 | def mtnrun(self, *args, **kwargs): |
|
80 | def mtnrun(self, *args, **kwargs): | |
75 | if self.automatestdio: |
|
81 | if self.automatestdio: | |
76 | return self.mtnrunstdio(*args, **kwargs) |
|
82 | return self.mtnrunstdio(*args, **kwargs) | |
77 | else: |
|
83 | else: | |
78 | return self.mtnrunsingle(*args, **kwargs) |
|
84 | return self.mtnrunsingle(*args, **kwargs) | |
79 |
|
85 | |||
80 | def mtnrunsingle(self, *args, **kwargs): |
|
86 | def mtnrunsingle(self, *args, **kwargs): | |
81 | kwargs['d'] = self.path |
|
87 | kwargs['d'] = self.path | |
82 | return self.run0('automate', *args, **kwargs) |
|
88 | return self.run0('automate', *args, **kwargs) | |
83 |
|
89 | |||
84 | def mtnrunstdio(self, *args, **kwargs): |
|
90 | def mtnrunstdio(self, *args, **kwargs): | |
85 | # Prepare the command in automate stdio format |
|
91 | # Prepare the command in automate stdio format | |
86 | command = [] |
|
92 | command = [] | |
87 | for k, v in kwargs.iteritems(): |
|
93 | for k, v in kwargs.iteritems(): | |
88 | command.append("%s:%s" % (len(k), k)) |
|
94 | command.append("%s:%s" % (len(k), k)) | |
89 | if v: |
|
95 | if v: | |
90 | command.append("%s:%s" % (len(v), v)) |
|
96 | command.append("%s:%s" % (len(v), v)) | |
91 | if command: |
|
97 | if command: | |
92 | command.insert(0, 'o') |
|
98 | command.insert(0, 'o') | |
93 | command.append('e') |
|
99 | command.append('e') | |
94 |
|
100 | |||
95 | command.append('l') |
|
101 | command.append('l') | |
96 | for arg in args: |
|
102 | for arg in args: | |
97 | command += "%s:%s" % (len(arg), arg) |
|
103 | command += "%s:%s" % (len(arg), arg) | |
98 | command.append('e') |
|
104 | command.append('e') | |
99 | command = ''.join(command) |
|
105 | command = ''.join(command) | |
100 |
|
106 | |||
101 | self.ui.debug("mtn: sending '%s'\n" % command) |
|
107 | self.ui.debug("mtn: sending '%s'\n" % command) | |
102 | self.mtnwritefp.write(command) |
|
108 | self.mtnwritefp.write(command) | |
103 | self.mtnwritefp.flush() |
|
109 | self.mtnwritefp.flush() | |
104 |
|
110 | |||
105 | return self.mtnstdioreadcommandoutput(command) |
|
111 | return self.mtnstdioreadcommandoutput(command) | |
106 |
|
112 | |||
107 | def mtnstdioreadpacket(self): |
|
113 | def mtnstdioreadpacket(self): | |
108 | read = None |
|
114 | read = None | |
109 | commandnbr = '' |
|
115 | commandnbr = '' | |
110 | while read != ':': |
|
116 | while read != ':': | |
111 | read = self.mtnreadfp.read(1) |
|
117 | read = self.mtnreadfp.read(1) | |
112 | if not read: |
|
118 | if not read: | |
113 | raise error.Abort(_('bad mtn packet - no end of commandnbr')) |
|
119 | raise error.Abort(_('bad mtn packet - no end of commandnbr')) | |
114 | commandnbr += read |
|
120 | commandnbr += read | |
115 | commandnbr = commandnbr[:-1] |
|
121 | commandnbr = commandnbr[:-1] | |
116 |
|
122 | |||
117 | stream = self.mtnreadfp.read(1) |
|
123 | stream = self.mtnreadfp.read(1) | |
118 | if stream not in 'mewptl': |
|
124 | if stream not in 'mewptl': | |
119 | raise error.Abort(_('bad mtn packet - bad stream type %s') % stream) |
|
125 | raise error.Abort(_('bad mtn packet - bad stream type %s') % stream) | |
120 |
|
126 | |||
121 | read = self.mtnreadfp.read(1) |
|
127 | read = self.mtnreadfp.read(1) | |
122 | if read != ':': |
|
128 | if read != ':': | |
123 | raise error.Abort(_('bad mtn packet - no divider before size')) |
|
129 | raise error.Abort(_('bad mtn packet - no divider before size')) | |
124 |
|
130 | |||
125 | read = None |
|
131 | read = None | |
126 | lengthstr = '' |
|
132 | lengthstr = '' | |
127 | while read != ':': |
|
133 | while read != ':': | |
128 | read = self.mtnreadfp.read(1) |
|
134 | read = self.mtnreadfp.read(1) | |
129 | if not read: |
|
135 | if not read: | |
130 | raise error.Abort(_('bad mtn packet - no end of packet size')) |
|
136 | raise error.Abort(_('bad mtn packet - no end of packet size')) | |
131 | lengthstr += read |
|
137 | lengthstr += read | |
132 | try: |
|
138 | try: | |
133 | length = long(lengthstr[:-1]) |
|
139 | length = long(lengthstr[:-1]) | |
134 | except TypeError: |
|
140 | except TypeError: | |
135 | raise error.Abort(_('bad mtn packet - bad packet size %s') |
|
141 | raise error.Abort(_('bad mtn packet - bad packet size %s') | |
136 | % lengthstr) |
|
142 | % lengthstr) | |
137 |
|
143 | |||
138 | read = self.mtnreadfp.read(length) |
|
144 | read = self.mtnreadfp.read(length) | |
139 | if len(read) != length: |
|
145 | if len(read) != length: | |
140 | raise error.Abort(_("bad mtn packet - unable to read full packet " |
|
146 | raise error.Abort(_("bad mtn packet - unable to read full packet " | |
141 | "read %s of %s") % (len(read), length)) |
|
147 | "read %s of %s") % (len(read), length)) | |
142 |
|
148 | |||
143 | return (commandnbr, stream, length, read) |
|
149 | return (commandnbr, stream, length, read) | |
144 |
|
150 | |||
145 | def mtnstdioreadcommandoutput(self, command): |
|
151 | def mtnstdioreadcommandoutput(self, command): | |
146 | retval = [] |
|
152 | retval = [] | |
147 | while True: |
|
153 | while True: | |
148 | commandnbr, stream, length, output = self.mtnstdioreadpacket() |
|
154 | commandnbr, stream, length, output = self.mtnstdioreadpacket() | |
149 | self.ui.debug('mtn: read packet %s:%s:%s\n' % |
|
155 | self.ui.debug('mtn: read packet %s:%s:%s\n' % | |
150 | (commandnbr, stream, length)) |
|
156 | (commandnbr, stream, length)) | |
151 |
|
157 | |||
152 | if stream == 'l': |
|
158 | if stream == 'l': | |
153 | # End of command |
|
159 | # End of command | |
154 | if output != '0': |
|
160 | if output != '0': | |
155 | raise error.Abort(_("mtn command '%s' returned %s") % |
|
161 | raise error.Abort(_("mtn command '%s' returned %s") % | |
156 | (command, output)) |
|
162 | (command, output)) | |
157 | break |
|
163 | break | |
158 | elif stream in 'ew': |
|
164 | elif stream in 'ew': | |
159 | # Error, warning output |
|
165 | # Error, warning output | |
160 | self.ui.warn(_('%s error:\n') % self.command) |
|
166 | self.ui.warn(_('%s error:\n') % self.command) | |
161 | self.ui.warn(output) |
|
167 | self.ui.warn(output) | |
162 | elif stream == 'p': |
|
168 | elif stream == 'p': | |
163 | # Progress messages |
|
169 | # Progress messages | |
164 | self.ui.debug('mtn: ' + output) |
|
170 | self.ui.debug('mtn: ' + output) | |
165 | elif stream == 'm': |
|
171 | elif stream == 'm': | |
166 | # Main stream - command output |
|
172 | # Main stream - command output | |
167 | retval.append(output) |
|
173 | retval.append(output) | |
168 |
|
174 | |||
169 | return ''.join(retval) |
|
175 | return ''.join(retval) | |
170 |
|
176 | |||
171 | def mtnloadmanifest(self, rev): |
|
177 | def mtnloadmanifest(self, rev): | |
172 | if self.manifest_rev == rev: |
|
178 | if self.manifest_rev == rev: | |
173 | return |
|
179 | return | |
174 | self.manifest = self.mtnrun("get_manifest_of", rev).split("\n\n") |
|
180 | self.manifest = self.mtnrun("get_manifest_of", rev).split("\n\n") | |
175 | self.manifest_rev = rev |
|
181 | self.manifest_rev = rev | |
176 | self.files = {} |
|
182 | self.files = {} | |
177 | self.dirs = {} |
|
183 | self.dirs = {} | |
178 |
|
184 | |||
179 | for e in self.manifest: |
|
185 | for e in self.manifest: | |
180 | m = self.file_re.match(e) |
|
186 | m = self.file_re.match(e) | |
181 | if m: |
|
187 | if m: | |
182 | attr = "" |
|
188 | attr = "" | |
183 | name = m.group(1) |
|
189 | name = m.group(1) | |
184 | node = m.group(2) |
|
190 | node = m.group(2) | |
185 | if self.attr_execute_re.match(e): |
|
191 | if self.attr_execute_re.match(e): | |
186 | attr += "x" |
|
192 | attr += "x" | |
187 | self.files[name] = (node, attr) |
|
193 | self.files[name] = (node, attr) | |
188 | m = self.dir_re.match(e) |
|
194 | m = self.dir_re.match(e) | |
189 | if m: |
|
195 | if m: | |
190 | self.dirs[m.group(1)] = True |
|
196 | self.dirs[m.group(1)] = True | |
191 |
|
197 | |||
192 | def mtnisfile(self, name, rev): |
|
198 | def mtnisfile(self, name, rev): | |
193 | # a non-file could be a directory or a deleted or renamed file |
|
199 | # a non-file could be a directory or a deleted or renamed file | |
194 | self.mtnloadmanifest(rev) |
|
200 | self.mtnloadmanifest(rev) | |
195 | return name in self.files |
|
201 | return name in self.files | |
196 |
|
202 | |||
197 | def mtnisdir(self, name, rev): |
|
203 | def mtnisdir(self, name, rev): | |
198 | self.mtnloadmanifest(rev) |
|
204 | self.mtnloadmanifest(rev) | |
199 | return name in self.dirs |
|
205 | return name in self.dirs | |
200 |
|
206 | |||
201 | def mtngetcerts(self, rev): |
|
207 | def mtngetcerts(self, rev): | |
202 | certs = {"author":"<missing>", "date":"<missing>", |
|
208 | certs = {"author":"<missing>", "date":"<missing>", | |
203 | "changelog":"<missing>", "branch":"<missing>"} |
|
209 | "changelog":"<missing>", "branch":"<missing>"} | |
204 | certlist = self.mtnrun("certs", rev) |
|
210 | certlist = self.mtnrun("certs", rev) | |
205 | # mtn < 0.45: |
|
211 | # mtn < 0.45: | |
206 | # key "test@selenic.com" |
|
212 | # key "test@selenic.com" | |
207 | # mtn >= 0.45: |
|
213 | # mtn >= 0.45: | |
208 | # key [ff58a7ffb771907c4ff68995eada1c4da068d328] |
|
214 | # key [ff58a7ffb771907c4ff68995eada1c4da068d328] | |
209 | certlist = re.split('\n\n key ["\[]', certlist) |
|
215 | certlist = re.split('\n\n key ["\[]', certlist) | |
210 | for e in certlist: |
|
216 | for e in certlist: | |
211 | m = self.cert_re.match(e) |
|
217 | m = self.cert_re.match(e) | |
212 | if m: |
|
218 | if m: | |
213 | name, value = m.groups() |
|
219 | name, value = m.groups() | |
214 | value = value.replace(r'\"', '"') |
|
220 | value = value.replace(r'\"', '"') | |
215 | value = value.replace(r'\\', '\\') |
|
221 | value = value.replace(r'\\', '\\') | |
216 | certs[name] = value |
|
222 | certs[name] = value | |
217 | # Monotone may have subsecond dates: 2005-02-05T09:39:12.364306 |
|
223 | # Monotone may have subsecond dates: 2005-02-05T09:39:12.364306 | |
218 | # and all times are stored in UTC |
|
224 | # and all times are stored in UTC | |
219 | certs["date"] = certs["date"].split('.')[0] + " UTC" |
|
225 | certs["date"] = certs["date"].split('.')[0] + " UTC" | |
220 | return certs |
|
226 | return certs | |
221 |
|
227 | |||
222 | # implement the converter_source interface: |
|
228 | # implement the converter_source interface: | |
223 |
|
229 | |||
224 | def getheads(self): |
|
230 | def getheads(self): | |
225 | if not self.revs: |
|
231 | if not self.revs: | |
226 | return self.mtnrun("leaves").splitlines() |
|
232 | return self.mtnrun("leaves").splitlines() | |
227 | else: |
|
233 | else: | |
228 | return self.revs |
|
234 | return self.revs | |
229 |
|
235 | |||
230 | def getchanges(self, rev, full): |
|
236 | def getchanges(self, rev, full): | |
231 | if full: |
|
237 | if full: | |
232 | raise error.Abort(_("convert from monotone does not support " |
|
238 | raise error.Abort(_("convert from monotone does not support " | |
233 | "--full")) |
|
239 | "--full")) | |
234 | revision = self.mtnrun("get_revision", rev).split("\n\n") |
|
240 | revision = self.mtnrun("get_revision", rev).split("\n\n") | |
235 | files = {} |
|
241 | files = {} | |
236 | ignoremove = {} |
|
242 | ignoremove = {} | |
237 | renameddirs = [] |
|
243 | renameddirs = [] | |
238 | copies = {} |
|
244 | copies = {} | |
239 | for e in revision: |
|
245 | for e in revision: | |
240 | m = self.add_file_re.match(e) |
|
246 | m = self.add_file_re.match(e) | |
241 | if m: |
|
247 | if m: | |
242 | files[m.group(1)] = rev |
|
248 | files[m.group(1)] = rev | |
243 | ignoremove[m.group(1)] = rev |
|
249 | ignoremove[m.group(1)] = rev | |
244 | m = self.patch_re.match(e) |
|
250 | m = self.patch_re.match(e) | |
245 | if m: |
|
251 | if m: | |
246 | files[m.group(1)] = rev |
|
252 | files[m.group(1)] = rev | |
247 | # Delete/rename is handled later when the convert engine |
|
253 | # Delete/rename is handled later when the convert engine | |
248 | # discovers an IOError exception from getfile, |
|
254 | # discovers an IOError exception from getfile, | |
249 | # but only if we add the "from" file to the list of changes. |
|
255 | # but only if we add the "from" file to the list of changes. | |
250 | m = self.delete_re.match(e) |
|
256 | m = self.delete_re.match(e) | |
251 | if m: |
|
257 | if m: | |
252 | files[m.group(1)] = rev |
|
258 | files[m.group(1)] = rev | |
253 | m = self.rename_re.match(e) |
|
259 | m = self.rename_re.match(e) | |
254 | if m: |
|
260 | if m: | |
255 | toname = m.group(2) |
|
261 | toname = m.group(2) | |
256 | fromname = m.group(1) |
|
262 | fromname = m.group(1) | |
257 | if self.mtnisfile(toname, rev): |
|
263 | if self.mtnisfile(toname, rev): | |
258 | ignoremove[toname] = 1 |
|
264 | ignoremove[toname] = 1 | |
259 | copies[toname] = fromname |
|
265 | copies[toname] = fromname | |
260 | files[toname] = rev |
|
266 | files[toname] = rev | |
261 | files[fromname] = rev |
|
267 | files[fromname] = rev | |
262 | elif self.mtnisdir(toname, rev): |
|
268 | elif self.mtnisdir(toname, rev): | |
263 | renameddirs.append((fromname, toname)) |
|
269 | renameddirs.append((fromname, toname)) | |
264 |
|
270 | |||
265 | # Directory renames can be handled only once we have recorded |
|
271 | # Directory renames can be handled only once we have recorded | |
266 | # all new files |
|
272 | # all new files | |
267 | for fromdir, todir in renameddirs: |
|
273 | for fromdir, todir in renameddirs: | |
268 | renamed = {} |
|
274 | renamed = {} | |
269 | for tofile in self.files: |
|
275 | for tofile in self.files: | |
270 | if tofile in ignoremove: |
|
276 | if tofile in ignoremove: | |
271 | continue |
|
277 | continue | |
272 | if tofile.startswith(todir + '/'): |
|
278 | if tofile.startswith(todir + '/'): | |
273 | renamed[tofile] = fromdir + tofile[len(todir):] |
|
279 | renamed[tofile] = fromdir + tofile[len(todir):] | |
274 | # Avoid chained moves like: |
|
280 | # Avoid chained moves like: | |
275 | # d1(/a) => d3/d1(/a) |
|
281 | # d1(/a) => d3/d1(/a) | |
276 | # d2 => d3 |
|
282 | # d2 => d3 | |
277 | ignoremove[tofile] = 1 |
|
283 | ignoremove[tofile] = 1 | |
278 | for tofile, fromfile in renamed.items(): |
|
284 | for tofile, fromfile in renamed.items(): | |
279 | self.ui.debug (_("copying file in renamed directory " |
|
285 | self.ui.debug (_("copying file in renamed directory " | |
280 | "from '%s' to '%s'") |
|
286 | "from '%s' to '%s'") | |
281 | % (fromfile, tofile), '\n') |
|
287 | % (fromfile, tofile), '\n') | |
282 | files[tofile] = rev |
|
288 | files[tofile] = rev | |
283 | copies[tofile] = fromfile |
|
289 | copies[tofile] = fromfile | |
284 | for fromfile in renamed.values(): |
|
290 | for fromfile in renamed.values(): | |
285 | files[fromfile] = rev |
|
291 | files[fromfile] = rev | |
286 |
|
292 | |||
287 | return (files.items(), copies, set()) |
|
293 | return (files.items(), copies, set()) | |
288 |
|
294 | |||
289 | def getfile(self, name, rev): |
|
295 | def getfile(self, name, rev): | |
290 | if not self.mtnisfile(name, rev): |
|
296 | if not self.mtnisfile(name, rev): | |
291 | return None, None |
|
297 | return None, None | |
292 | try: |
|
298 | try: | |
293 | data = self.mtnrun("get_file_of", name, r=rev) |
|
299 | data = self.mtnrun("get_file_of", name, r=rev) | |
294 | except Exception: |
|
300 | except Exception: | |
295 | return None, None |
|
301 | return None, None | |
296 | self.mtnloadmanifest(rev) |
|
302 | self.mtnloadmanifest(rev) | |
297 | node, attr = self.files.get(name, (None, "")) |
|
303 | node, attr = self.files.get(name, (None, "")) | |
298 | return data, attr |
|
304 | return data, attr | |
299 |
|
305 | |||
300 | def getcommit(self, rev): |
|
306 | def getcommit(self, rev): | |
301 | extra = {} |
|
307 | extra = {} | |
302 | certs = self.mtngetcerts(rev) |
|
308 | certs = self.mtngetcerts(rev) | |
303 | if certs.get('suspend') == certs["branch"]: |
|
309 | if certs.get('suspend') == certs["branch"]: | |
304 | extra['close'] = 1 |
|
310 | extra['close'] = 1 | |
305 | return commit( |
|
311 | return common.commit( | |
306 | author=certs["author"], |
|
312 | author=certs["author"], | |
307 | date=util.datestr(util.strdate(certs["date"], "%Y-%m-%dT%H:%M:%S")), |
|
313 | date=util.datestr(util.strdate(certs["date"], "%Y-%m-%dT%H:%M:%S")), | |
308 | desc=certs["changelog"], |
|
314 | desc=certs["changelog"], | |
309 | rev=rev, |
|
315 | rev=rev, | |
310 | parents=self.mtnrun("parents", rev).splitlines(), |
|
316 | parents=self.mtnrun("parents", rev).splitlines(), | |
311 | branch=certs["branch"], |
|
317 | branch=certs["branch"], | |
312 | extra=extra) |
|
318 | extra=extra) | |
313 |
|
319 | |||
314 | def gettags(self): |
|
320 | def gettags(self): | |
315 | tags = {} |
|
321 | tags = {} | |
316 | for e in self.mtnrun("tags").split("\n\n"): |
|
322 | for e in self.mtnrun("tags").split("\n\n"): | |
317 | m = self.tag_re.match(e) |
|
323 | m = self.tag_re.match(e) | |
318 | if m: |
|
324 | if m: | |
319 | tags[m.group(1)] = m.group(2) |
|
325 | tags[m.group(1)] = m.group(2) | |
320 | return tags |
|
326 | return tags | |
321 |
|
327 | |||
322 | def getchangedfiles(self, rev, i): |
|
328 | def getchangedfiles(self, rev, i): | |
323 | # This function is only needed to support --filemap |
|
329 | # This function is only needed to support --filemap | |
324 | # ... and we don't support that |
|
330 | # ... and we don't support that | |
325 | raise NotImplementedError |
|
331 | raise NotImplementedError | |
326 |
|
332 | |||
327 | def before(self): |
|
333 | def before(self): | |
328 | # Check if we have a new enough version to use automate stdio |
|
334 | # Check if we have a new enough version to use automate stdio | |
329 | version = 0.0 |
|
335 | version = 0.0 | |
330 | try: |
|
336 | try: | |
331 | versionstr = self.mtnrunsingle("interface_version") |
|
337 | versionstr = self.mtnrunsingle("interface_version") | |
332 | version = float(versionstr) |
|
338 | version = float(versionstr) | |
333 | except Exception: |
|
339 | except Exception: | |
334 | raise error.Abort(_("unable to determine mtn automate interface " |
|
340 | raise error.Abort(_("unable to determine mtn automate interface " | |
335 | "version")) |
|
341 | "version")) | |
336 |
|
342 | |||
337 | if version >= 12.0: |
|
343 | if version >= 12.0: | |
338 | self.automatestdio = True |
|
344 | self.automatestdio = True | |
339 | self.ui.debug("mtn automate version %s - using automate stdio\n" % |
|
345 | self.ui.debug("mtn automate version %s - using automate stdio\n" % | |
340 | version) |
|
346 | version) | |
341 |
|
347 | |||
342 | # launch the long-running automate stdio process |
|
348 | # launch the long-running automate stdio process | |
343 | self.mtnwritefp, self.mtnreadfp = self._run2('automate', 'stdio', |
|
349 | self.mtnwritefp, self.mtnreadfp = self._run2('automate', 'stdio', | |
344 | '-d', self.path) |
|
350 | '-d', self.path) | |
345 | # read the headers |
|
351 | # read the headers | |
346 | read = self.mtnreadfp.readline() |
|
352 | read = self.mtnreadfp.readline() | |
347 | if read != 'format-version: 2\n': |
|
353 | if read != 'format-version: 2\n': | |
348 | raise error.Abort(_('mtn automate stdio header unexpected: %s') |
|
354 | raise error.Abort(_('mtn automate stdio header unexpected: %s') | |
349 | % read) |
|
355 | % read) | |
350 | while read != '\n': |
|
356 | while read != '\n': | |
351 | read = self.mtnreadfp.readline() |
|
357 | read = self.mtnreadfp.readline() | |
352 | if not read: |
|
358 | if not read: | |
353 | raise error.Abort(_("failed to reach end of mtn automate " |
|
359 | raise error.Abort(_("failed to reach end of mtn automate " | |
354 | "stdio headers")) |
|
360 | "stdio headers")) | |
355 | else: |
|
361 | else: | |
356 | self.ui.debug("mtn automate version %s - not using automate stdio " |
|
362 | self.ui.debug("mtn automate version %s - not using automate stdio " | |
357 | "(automate >= 12.0 - mtn >= 0.46 is needed)\n" % version) |
|
363 | "(automate >= 12.0 - mtn >= 0.46 is needed)\n" % version) | |
358 |
|
364 | |||
359 | def after(self): |
|
365 | def after(self): | |
360 | if self.automatestdio: |
|
366 | if self.automatestdio: | |
361 | self.mtnwritefp.close() |
|
367 | self.mtnwritefp.close() | |
362 | self.mtnwritefp = None |
|
368 | self.mtnwritefp = None | |
363 | self.mtnreadfp.close() |
|
369 | self.mtnreadfp.close() | |
364 | self.mtnreadfp = None |
|
370 | self.mtnreadfp = None | |
365 |
|
371 |
@@ -1,151 +1,150 | |||||
1 | #require test-repo |
|
1 | #require test-repo | |
2 |
|
2 | |||
3 | $ cd "$TESTDIR"/.. |
|
3 | $ cd "$TESTDIR"/.. | |
4 |
|
4 | |||
5 | $ hg files 'set:(**.py)' | sed 's|\\|/|g' | xargs python contrib/check-py3-compat.py |
|
5 | $ hg files 'set:(**.py)' | sed 's|\\|/|g' | xargs python contrib/check-py3-compat.py | |
6 | contrib/check-code.py not using absolute_import |
|
6 | contrib/check-code.py not using absolute_import | |
7 | contrib/check-code.py requires print_function |
|
7 | contrib/check-code.py requires print_function | |
8 | contrib/debugshell.py not using absolute_import |
|
8 | contrib/debugshell.py not using absolute_import | |
9 | contrib/hgfixes/fix_bytes.py not using absolute_import |
|
9 | contrib/hgfixes/fix_bytes.py not using absolute_import | |
10 | contrib/hgfixes/fix_bytesmod.py not using absolute_import |
|
10 | contrib/hgfixes/fix_bytesmod.py not using absolute_import | |
11 | contrib/hgfixes/fix_leftover_imports.py not using absolute_import |
|
11 | contrib/hgfixes/fix_leftover_imports.py not using absolute_import | |
12 | contrib/import-checker.py not using absolute_import |
|
12 | contrib/import-checker.py not using absolute_import | |
13 | contrib/import-checker.py requires print_function |
|
13 | contrib/import-checker.py requires print_function | |
14 | contrib/memory.py not using absolute_import |
|
14 | contrib/memory.py not using absolute_import | |
15 | contrib/perf.py not using absolute_import |
|
15 | contrib/perf.py not using absolute_import | |
16 | contrib/python-hook-examples.py not using absolute_import |
|
16 | contrib/python-hook-examples.py not using absolute_import | |
17 | contrib/revsetbenchmarks.py not using absolute_import |
|
17 | contrib/revsetbenchmarks.py not using absolute_import | |
18 | contrib/revsetbenchmarks.py requires print_function |
|
18 | contrib/revsetbenchmarks.py requires print_function | |
19 | contrib/showstack.py not using absolute_import |
|
19 | contrib/showstack.py not using absolute_import | |
20 | contrib/synthrepo.py not using absolute_import |
|
20 | contrib/synthrepo.py not using absolute_import | |
21 | contrib/win32/hgwebdir_wsgi.py not using absolute_import |
|
21 | contrib/win32/hgwebdir_wsgi.py not using absolute_import | |
22 | doc/check-seclevel.py not using absolute_import |
|
22 | doc/check-seclevel.py not using absolute_import | |
23 | doc/gendoc.py not using absolute_import |
|
23 | doc/gendoc.py not using absolute_import | |
24 | doc/hgmanpage.py not using absolute_import |
|
24 | doc/hgmanpage.py not using absolute_import | |
25 | hgext/__init__.py not using absolute_import |
|
25 | hgext/__init__.py not using absolute_import | |
26 | hgext/color.py not using absolute_import |
|
26 | hgext/color.py not using absolute_import | |
27 | hgext/convert/__init__.py not using absolute_import |
|
27 | hgext/convert/__init__.py not using absolute_import | |
28 | hgext/convert/bzr.py not using absolute_import |
|
28 | hgext/convert/bzr.py not using absolute_import | |
29 | hgext/convert/common.py not using absolute_import |
|
29 | hgext/convert/common.py not using absolute_import | |
30 | hgext/convert/convcmd.py not using absolute_import |
|
30 | hgext/convert/convcmd.py not using absolute_import | |
31 | hgext/convert/cvs.py not using absolute_import |
|
31 | hgext/convert/cvs.py not using absolute_import | |
32 | hgext/convert/monotone.py not using absolute_import |
|
|||
33 | hgext/convert/subversion.py not using absolute_import |
|
32 | hgext/convert/subversion.py not using absolute_import | |
34 | hgext/convert/transport.py not using absolute_import |
|
33 | hgext/convert/transport.py not using absolute_import | |
35 | hgext/eol.py not using absolute_import |
|
34 | hgext/eol.py not using absolute_import | |
36 | hgext/extdiff.py not using absolute_import |
|
35 | hgext/extdiff.py not using absolute_import | |
37 | hgext/factotum.py not using absolute_import |
|
36 | hgext/factotum.py not using absolute_import | |
38 | hgext/fetch.py not using absolute_import |
|
37 | hgext/fetch.py not using absolute_import | |
39 | hgext/gpg.py not using absolute_import |
|
38 | hgext/gpg.py not using absolute_import | |
40 | hgext/graphlog.py not using absolute_import |
|
39 | hgext/graphlog.py not using absolute_import | |
41 | hgext/hgcia.py not using absolute_import |
|
40 | hgext/hgcia.py not using absolute_import | |
42 | hgext/hgk.py not using absolute_import |
|
41 | hgext/hgk.py not using absolute_import | |
43 | hgext/highlight/__init__.py not using absolute_import |
|
42 | hgext/highlight/__init__.py not using absolute_import | |
44 | hgext/highlight/highlight.py not using absolute_import |
|
43 | hgext/highlight/highlight.py not using absolute_import | |
45 | hgext/histedit.py not using absolute_import |
|
44 | hgext/histedit.py not using absolute_import | |
46 | hgext/largefiles/__init__.py not using absolute_import |
|
45 | hgext/largefiles/__init__.py not using absolute_import | |
47 | hgext/largefiles/basestore.py not using absolute_import |
|
46 | hgext/largefiles/basestore.py not using absolute_import | |
48 | hgext/largefiles/lfcommands.py not using absolute_import |
|
47 | hgext/largefiles/lfcommands.py not using absolute_import | |
49 | hgext/largefiles/lfutil.py not using absolute_import |
|
48 | hgext/largefiles/lfutil.py not using absolute_import | |
50 | hgext/largefiles/localstore.py not using absolute_import |
|
49 | hgext/largefiles/localstore.py not using absolute_import | |
51 | hgext/largefiles/overrides.py not using absolute_import |
|
50 | hgext/largefiles/overrides.py not using absolute_import | |
52 | hgext/largefiles/proto.py not using absolute_import |
|
51 | hgext/largefiles/proto.py not using absolute_import | |
53 | hgext/largefiles/remotestore.py not using absolute_import |
|
52 | hgext/largefiles/remotestore.py not using absolute_import | |
54 | hgext/largefiles/reposetup.py not using absolute_import |
|
53 | hgext/largefiles/reposetup.py not using absolute_import | |
55 | hgext/largefiles/uisetup.py not using absolute_import |
|
54 | hgext/largefiles/uisetup.py not using absolute_import | |
56 | hgext/largefiles/wirestore.py not using absolute_import |
|
55 | hgext/largefiles/wirestore.py not using absolute_import | |
57 | hgext/mq.py not using absolute_import |
|
56 | hgext/mq.py not using absolute_import | |
58 | hgext/notify.py not using absolute_import |
|
57 | hgext/notify.py not using absolute_import | |
59 | hgext/patchbomb.py not using absolute_import |
|
58 | hgext/patchbomb.py not using absolute_import | |
60 | hgext/purge.py not using absolute_import |
|
59 | hgext/purge.py not using absolute_import | |
61 | hgext/rebase.py not using absolute_import |
|
60 | hgext/rebase.py not using absolute_import | |
62 | hgext/record.py not using absolute_import |
|
61 | hgext/record.py not using absolute_import | |
63 | hgext/relink.py not using absolute_import |
|
62 | hgext/relink.py not using absolute_import | |
64 | hgext/schemes.py not using absolute_import |
|
63 | hgext/schemes.py not using absolute_import | |
65 | hgext/share.py not using absolute_import |
|
64 | hgext/share.py not using absolute_import | |
66 | hgext/shelve.py not using absolute_import |
|
65 | hgext/shelve.py not using absolute_import | |
67 | hgext/strip.py not using absolute_import |
|
66 | hgext/strip.py not using absolute_import | |
68 | hgext/transplant.py not using absolute_import |
|
67 | hgext/transplant.py not using absolute_import | |
69 | hgext/win32mbcs.py not using absolute_import |
|
68 | hgext/win32mbcs.py not using absolute_import | |
70 | hgext/win32text.py not using absolute_import |
|
69 | hgext/win32text.py not using absolute_import | |
71 | i18n/check-translation.py not using absolute_import |
|
70 | i18n/check-translation.py not using absolute_import | |
72 | i18n/polib.py not using absolute_import |
|
71 | i18n/polib.py not using absolute_import | |
73 | setup.py not using absolute_import |
|
72 | setup.py not using absolute_import | |
74 | tests/filterpyflakes.py requires print_function |
|
73 | tests/filterpyflakes.py requires print_function | |
75 | tests/generate-working-copy-states.py requires print_function |
|
74 | tests/generate-working-copy-states.py requires print_function | |
76 | tests/get-with-headers.py requires print_function |
|
75 | tests/get-with-headers.py requires print_function | |
77 | tests/heredoctest.py requires print_function |
|
76 | tests/heredoctest.py requires print_function | |
78 | tests/hypothesishelpers.py not using absolute_import |
|
77 | tests/hypothesishelpers.py not using absolute_import | |
79 | tests/hypothesishelpers.py requires print_function |
|
78 | tests/hypothesishelpers.py requires print_function | |
80 | tests/killdaemons.py not using absolute_import |
|
79 | tests/killdaemons.py not using absolute_import | |
81 | tests/md5sum.py not using absolute_import |
|
80 | tests/md5sum.py not using absolute_import | |
82 | tests/mockblackbox.py not using absolute_import |
|
81 | tests/mockblackbox.py not using absolute_import | |
83 | tests/printenv.py not using absolute_import |
|
82 | tests/printenv.py not using absolute_import | |
84 | tests/readlink.py not using absolute_import |
|
83 | tests/readlink.py not using absolute_import | |
85 | tests/readlink.py requires print_function |
|
84 | tests/readlink.py requires print_function | |
86 | tests/revlog-formatv0.py not using absolute_import |
|
85 | tests/revlog-formatv0.py not using absolute_import | |
87 | tests/run-tests.py not using absolute_import |
|
86 | tests/run-tests.py not using absolute_import | |
88 | tests/seq.py not using absolute_import |
|
87 | tests/seq.py not using absolute_import | |
89 | tests/seq.py requires print_function |
|
88 | tests/seq.py requires print_function | |
90 | tests/silenttestrunner.py not using absolute_import |
|
89 | tests/silenttestrunner.py not using absolute_import | |
91 | tests/silenttestrunner.py requires print_function |
|
90 | tests/silenttestrunner.py requires print_function | |
92 | tests/sitecustomize.py not using absolute_import |
|
91 | tests/sitecustomize.py not using absolute_import | |
93 | tests/svn-safe-append.py not using absolute_import |
|
92 | tests/svn-safe-append.py not using absolute_import | |
94 | tests/svnxml.py not using absolute_import |
|
93 | tests/svnxml.py not using absolute_import | |
95 | tests/test-ancestor.py requires print_function |
|
94 | tests/test-ancestor.py requires print_function | |
96 | tests/test-atomictempfile.py not using absolute_import |
|
95 | tests/test-atomictempfile.py not using absolute_import | |
97 | tests/test-batching.py not using absolute_import |
|
96 | tests/test-batching.py not using absolute_import | |
98 | tests/test-batching.py requires print_function |
|
97 | tests/test-batching.py requires print_function | |
99 | tests/test-bdiff.py not using absolute_import |
|
98 | tests/test-bdiff.py not using absolute_import | |
100 | tests/test-bdiff.py requires print_function |
|
99 | tests/test-bdiff.py requires print_function | |
101 | tests/test-context.py not using absolute_import |
|
100 | tests/test-context.py not using absolute_import | |
102 | tests/test-context.py requires print_function |
|
101 | tests/test-context.py requires print_function | |
103 | tests/test-demandimport.py not using absolute_import |
|
102 | tests/test-demandimport.py not using absolute_import | |
104 | tests/test-demandimport.py requires print_function |
|
103 | tests/test-demandimport.py requires print_function | |
105 | tests/test-dispatch.py not using absolute_import |
|
104 | tests/test-dispatch.py not using absolute_import | |
106 | tests/test-dispatch.py requires print_function |
|
105 | tests/test-dispatch.py requires print_function | |
107 | tests/test-doctest.py not using absolute_import |
|
106 | tests/test-doctest.py not using absolute_import | |
108 | tests/test-duplicateoptions.py not using absolute_import |
|
107 | tests/test-duplicateoptions.py not using absolute_import | |
109 | tests/test-duplicateoptions.py requires print_function |
|
108 | tests/test-duplicateoptions.py requires print_function | |
110 | tests/test-filecache.py not using absolute_import |
|
109 | tests/test-filecache.py not using absolute_import | |
111 | tests/test-filecache.py requires print_function |
|
110 | tests/test-filecache.py requires print_function | |
112 | tests/test-filelog.py not using absolute_import |
|
111 | tests/test-filelog.py not using absolute_import | |
113 | tests/test-filelog.py requires print_function |
|
112 | tests/test-filelog.py requires print_function | |
114 | tests/test-hg-parseurl.py not using absolute_import |
|
113 | tests/test-hg-parseurl.py not using absolute_import | |
115 | tests/test-hg-parseurl.py requires print_function |
|
114 | tests/test-hg-parseurl.py requires print_function | |
116 | tests/test-hgweb-auth.py not using absolute_import |
|
115 | tests/test-hgweb-auth.py not using absolute_import | |
117 | tests/test-hgweb-auth.py requires print_function |
|
116 | tests/test-hgweb-auth.py requires print_function | |
118 | tests/test-hgwebdir-paths.py not using absolute_import |
|
117 | tests/test-hgwebdir-paths.py not using absolute_import | |
119 | tests/test-hybridencode.py not using absolute_import |
|
118 | tests/test-hybridencode.py not using absolute_import | |
120 | tests/test-hybridencode.py requires print_function |
|
119 | tests/test-hybridencode.py requires print_function | |
121 | tests/test-lrucachedict.py not using absolute_import |
|
120 | tests/test-lrucachedict.py not using absolute_import | |
122 | tests/test-lrucachedict.py requires print_function |
|
121 | tests/test-lrucachedict.py requires print_function | |
123 | tests/test-manifest.py not using absolute_import |
|
122 | tests/test-manifest.py not using absolute_import | |
124 | tests/test-minirst.py not using absolute_import |
|
123 | tests/test-minirst.py not using absolute_import | |
125 | tests/test-minirst.py requires print_function |
|
124 | tests/test-minirst.py requires print_function | |
126 | tests/test-parseindex2.py not using absolute_import |
|
125 | tests/test-parseindex2.py not using absolute_import | |
127 | tests/test-parseindex2.py requires print_function |
|
126 | tests/test-parseindex2.py requires print_function | |
128 | tests/test-pathencode.py not using absolute_import |
|
127 | tests/test-pathencode.py not using absolute_import | |
129 | tests/test-pathencode.py requires print_function |
|
128 | tests/test-pathencode.py requires print_function | |
130 | tests/test-propertycache.py not using absolute_import |
|
129 | tests/test-propertycache.py not using absolute_import | |
131 | tests/test-propertycache.py requires print_function |
|
130 | tests/test-propertycache.py requires print_function | |
132 | tests/test-revlog-ancestry.py not using absolute_import |
|
131 | tests/test-revlog-ancestry.py not using absolute_import | |
133 | tests/test-revlog-ancestry.py requires print_function |
|
132 | tests/test-revlog-ancestry.py requires print_function | |
134 | tests/test-run-tests.py not using absolute_import |
|
133 | tests/test-run-tests.py not using absolute_import | |
135 | tests/test-simplemerge.py not using absolute_import |
|
134 | tests/test-simplemerge.py not using absolute_import | |
136 | tests/test-status-inprocess.py not using absolute_import |
|
135 | tests/test-status-inprocess.py not using absolute_import | |
137 | tests/test-status-inprocess.py requires print_function |
|
136 | tests/test-status-inprocess.py requires print_function | |
138 | tests/test-symlink-os-yes-fs-no.py not using absolute_import |
|
137 | tests/test-symlink-os-yes-fs-no.py not using absolute_import | |
139 | tests/test-trusted.py not using absolute_import |
|
138 | tests/test-trusted.py not using absolute_import | |
140 | tests/test-trusted.py requires print_function |
|
139 | tests/test-trusted.py requires print_function | |
141 | tests/test-ui-color.py not using absolute_import |
|
140 | tests/test-ui-color.py not using absolute_import | |
142 | tests/test-ui-color.py requires print_function |
|
141 | tests/test-ui-color.py requires print_function | |
143 | tests/test-ui-config.py not using absolute_import |
|
142 | tests/test-ui-config.py not using absolute_import | |
144 | tests/test-ui-config.py requires print_function |
|
143 | tests/test-ui-config.py requires print_function | |
145 | tests/test-ui-verbosity.py not using absolute_import |
|
144 | tests/test-ui-verbosity.py not using absolute_import | |
146 | tests/test-ui-verbosity.py requires print_function |
|
145 | tests/test-ui-verbosity.py requires print_function | |
147 | tests/test-url.py not using absolute_import |
|
146 | tests/test-url.py not using absolute_import | |
148 | tests/test-url.py requires print_function |
|
147 | tests/test-url.py requires print_function | |
149 | tests/test-walkrepo.py requires print_function |
|
148 | tests/test-walkrepo.py requires print_function | |
150 | tests/test-wireproto.py requires print_function |
|
149 | tests/test-wireproto.py requires print_function | |
151 | tests/tinyproxy.py requires print_function |
|
150 | tests/tinyproxy.py requires print_function |
General Comments 0
You need to be logged in to leave comments.
Login now