Show More
@@ -89,6 +89,9 b' def get_log_child(fp, url, paths, start,' | |||||
89 | receiver) |
|
89 | receiver) | |
90 | except SubversionException, (inst, num): |
|
90 | except SubversionException, (inst, num): | |
91 | pickle.dump(num, fp, protocol) |
|
91 | pickle.dump(num, fp, protocol) | |
|
92 | except IOError: | |||
|
93 | # Caller may interrupt the iteration | |||
|
94 | pickle.dump(None, fp, protocol) | |||
92 | else: |
|
95 | else: | |
93 | pickle.dump(None, fp, protocol) |
|
96 | pickle.dump(None, fp, protocol) | |
94 | fp.close() |
|
97 | fp.close() | |
@@ -102,6 +105,39 b' def debugsvnlog(ui, **opts):' | |||||
102 | args = decodeargs(sys.stdin.read()) |
|
105 | args = decodeargs(sys.stdin.read()) | |
103 | get_log_child(sys.stdout, *args) |
|
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 | # SVN conversion code stolen from bzr-svn and tailor |
|
141 | # SVN conversion code stolen from bzr-svn and tailor | |
106 | class svn_source(converter_source): |
|
142 | class svn_source(converter_source): | |
107 | def __init__(self, ui, url, rev=None): |
|
143 | def __init__(self, ui, url, rev=None): | |
@@ -263,38 +299,11 b' class svn_source(converter_source):' | |||||
263 | del self.commits[rev] |
|
299 | del self.commits[rev] | |
264 | return commit |
|
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 | def gettags(self): |
|
302 | def gettags(self): | |
294 | tags = {} |
|
303 | tags = {} | |
295 | start = self.revnum(self.head) |
|
304 | start = self.revnum(self.head) | |
296 | try: |
|
305 | try: | |
297 |
for entry in self. |
|
306 | for entry in get_log(self.url, [self.tags], 0, start): | |
298 | orig_paths, revnum, author, date, message = entry |
|
307 | orig_paths, revnum, author, date, message = entry | |
299 | for path in orig_paths: |
|
308 | for path in orig_paths: | |
300 | if not path.startswith(self.tags+'/'): |
|
309 | if not path.startswith(self.tags+'/'): | |
@@ -641,15 +650,13 b' class svn_source(converter_source):' | |||||
641 |
|
650 | |||
642 | try: |
|
651 | try: | |
643 | firstcset = None |
|
652 | firstcset = None | |
644 | branched = False |
|
653 | stream = get_log(self.url, [self.module], from_revnum, to_revnum) | |
645 | for entry in self.get_log([self.module], from_revnum, to_revnum): |
|
654 | try: | |
646 |
|
|
655 | for entry in stream: | |
647 | # The iterator must be exhausted for the child process |
|
|||
648 | # to terminate cleanly. |
|
|||
649 | continue |
|
|||
650 | paths, revnum, author, date, message = entry |
|
656 | paths, revnum, author, date, message = entry | |
651 | if self.is_blacklisted(revnum): |
|
657 | if self.is_blacklisted(revnum): | |
652 |
self.ui.note('skipping blacklisted revision %d\n' |
|
658 | self.ui.note('skipping blacklisted revision %d\n' | |
|
659 | % revnum) | |||
653 | continue |
|
660 | continue | |
654 | if paths is None: |
|
661 | if paths is None: | |
655 | self.ui.debug('revision %d has no entries\n' % revnum) |
|
662 | self.ui.debug('revision %d has no entries\n' % revnum) | |
@@ -658,6 +665,10 b' class svn_source(converter_source):' | |||||
658 | date, message) |
|
665 | date, message) | |
659 | if cset: |
|
666 | if cset: | |
660 | firstcset = cset |
|
667 | firstcset = cset | |
|
668 | if branched: | |||
|
669 | break | |||
|
670 | finally: | |||
|
671 | stream.close() | |||
661 |
|
672 | |||
662 | if firstcset and not firstcset.parents: |
|
673 | if firstcset and not firstcset.parents: | |
663 | # The first revision of the sequence (the last fetched one) |
|
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