Show More
@@ -89,6 +89,9 b' def get_log_child(fp, url, paths, start,' | |||
|
89 | 89 | receiver) |
|
90 | 90 | except SubversionException, (inst, num): |
|
91 | 91 | pickle.dump(num, fp, protocol) |
|
92 | except IOError: | |
|
93 | # Caller may interrupt the iteration | |
|
94 | pickle.dump(None, fp, protocol) | |
|
92 | 95 | else: |
|
93 | 96 | pickle.dump(None, fp, protocol) |
|
94 | 97 | fp.close() |
@@ -102,6 +105,39 b' def debugsvnlog(ui, **opts):' | |||
|
102 | 105 | args = decodeargs(sys.stdin.read()) |
|
103 | 106 | get_log_child(sys.stdout, *args) |
|
104 | 107 | |
|
108 | class logstream: | |
|
109 | """Interruptible revision log iterator.""" | |
|
110 | def __init__(self, stdout): | |
|
111 | self._stdout = stdout | |
|
112 | ||
|
113 | def __iter__(self): | |
|
114 | while True: | |
|
115 | entry = pickle.load(self._stdout) | |
|
116 | try: | |
|
117 | orig_paths, revnum, author, date, message = entry | |
|
118 | except: | |
|
119 | if entry is None: | |
|
120 | break | |
|
121 | raise SubversionException("child raised exception", entry) | |
|
122 | yield entry | |
|
123 | ||
|
124 | def close(self): | |
|
125 | if self._stdout: | |
|
126 | self._stdout.close() | |
|
127 | self._stdout = None | |
|
128 | ||
|
129 | def get_log(url, paths, start, end, limit=0, discover_changed_paths=True, | |
|
130 | strict_node_history=False): | |
|
131 | args = [url, paths, start, end, limit, discover_changed_paths, | |
|
132 | strict_node_history] | |
|
133 | arg = encodeargs(args) | |
|
134 | hgexe = util.hgexecutable() | |
|
135 | cmd = '%s debugsvnlog' % util.shellquote(hgexe) | |
|
136 | stdin, stdout = os.popen2(cmd, 'b') | |
|
137 | stdin.write(arg) | |
|
138 | stdin.close() | |
|
139 | return logstream(stdout) | |
|
140 | ||
|
105 | 141 | # SVN conversion code stolen from bzr-svn and tailor |
|
106 | 142 | class svn_source(converter_source): |
|
107 | 143 | def __init__(self, ui, url, rev=None): |
@@ -263,38 +299,11 b' class svn_source(converter_source):' | |||
|
263 | 299 | del self.commits[rev] |
|
264 | 300 | return commit |
|
265 | 301 | |
|
266 | def get_log(self, paths, start, end, limit=0, discover_changed_paths=True, | |
|
267 | strict_node_history=False): | |
|
268 | ||
|
269 | def parent(fp): | |
|
270 | while True: | |
|
271 | entry = pickle.load(fp) | |
|
272 | try: | |
|
273 | orig_paths, revnum, author, date, message = entry | |
|
274 | except: | |
|
275 | if entry is None: | |
|
276 | break | |
|
277 | raise SubversionException("child raised exception", entry) | |
|
278 | yield entry | |
|
279 | ||
|
280 | args = [self.url, paths, start, end, limit, discover_changed_paths, | |
|
281 | strict_node_history] | |
|
282 | arg = encodeargs(args) | |
|
283 | hgexe = util.hgexecutable() | |
|
284 | cmd = '%s debugsvnlog' % util.shellquote(hgexe) | |
|
285 | stdin, stdout = os.popen2(cmd, 'b') | |
|
286 | ||
|
287 | stdin.write(arg) | |
|
288 | stdin.close() | |
|
289 | ||
|
290 | for p in parent(stdout): | |
|
291 | yield p | |
|
292 | ||
|
293 | 302 | def gettags(self): |
|
294 | 303 | tags = {} |
|
295 | 304 | start = self.revnum(self.head) |
|
296 | 305 | try: |
|
297 |
for entry in self. |
|
|
306 | for entry in get_log(self.url, [self.tags], 0, start): | |
|
298 | 307 | orig_paths, revnum, author, date, message = entry |
|
299 | 308 | for path in orig_paths: |
|
300 | 309 | if not path.startswith(self.tags+'/'): |
@@ -641,23 +650,25 b' class svn_source(converter_source):' | |||
|
641 | 650 | |
|
642 | 651 | try: |
|
643 | 652 | firstcset = None |
|
644 | branched = False | |
|
645 | for entry in self.get_log([self.module], from_revnum, to_revnum): | |
|
646 |
|
|
|
647 | # The iterator must be exhausted for the child process | |
|
648 | # to terminate cleanly. | |
|
649 | continue | |
|
650 | paths, revnum, author, date, message = entry | |
|
651 | if self.is_blacklisted(revnum): | |
|
652 | self.ui.note('skipping blacklisted revision %d\n' % revnum) | |
|
653 | continue | |
|
654 |
|
|
|
655 | self.ui.debug('revision %d has no entries\n' % revnum) | |
|
656 | continue | |
|
657 | cset, branched = parselogentry(paths, revnum, author, | |
|
658 | date, message) | |
|
659 |
if |
|
|
660 |
|
|
|
653 | stream = get_log(self.url, [self.module], from_revnum, to_revnum) | |
|
654 | try: | |
|
655 | for entry in stream: | |
|
656 | paths, revnum, author, date, message = entry | |
|
657 | if self.is_blacklisted(revnum): | |
|
658 | self.ui.note('skipping blacklisted revision %d\n' | |
|
659 | % revnum) | |
|
660 | continue | |
|
661 | if paths is None: | |
|
662 | self.ui.debug('revision %d has no entries\n' % revnum) | |
|
663 | continue | |
|
664 | cset, branched = parselogentry(paths, revnum, author, | |
|
665 | date, message) | |
|
666 | if cset: | |
|
667 | firstcset = cset | |
|
668 | if branched: | |
|
669 | break | |
|
670 | finally: | |
|
671 | stream.close() | |
|
661 | 672 | |
|
662 | 673 | if firstcset and not firstcset.parents: |
|
663 | 674 | # The first revision of the sequence (the last fetched one) |
General Comments 0
You need to be logged in to leave comments.
Login now