##// END OF EJS Templates
cleanup: "raise SomeException()" -> "raise SomeException"
Brodie Rao -
r16687:e34106fa default
parent child Browse files
Show More
@@ -24,7 +24,7 b' else:'
24 def read(size):
24 def read(size):
25 data = sys.stdin.read(size)
25 data = sys.stdin.read(size)
26 if not data:
26 if not data:
27 raise EOFError()
27 raise EOFError
28 sys.stdout.write(data)
28 sys.stdout.write(data)
29 sys.stdout.flush()
29 sys.stdout.flush()
30 return data
30 return data
@@ -76,7 +76,7 b' class converter_source(object):'
76
76
77 def getheads(self):
77 def getheads(self):
78 """Return a list of this repository's heads"""
78 """Return a list of this repository's heads"""
79 raise NotImplementedError()
79 raise NotImplementedError
80
80
81 def getfile(self, name, rev):
81 def getfile(self, name, rev):
82 """Return a pair (data, mode) where data is the file content
82 """Return a pair (data, mode) where data is the file content
@@ -84,7 +84,7 b' class converter_source(object):'
84 identifier returned by a previous call to getchanges(). Raise
84 identifier returned by a previous call to getchanges(). Raise
85 IOError to indicate that name was deleted in rev.
85 IOError to indicate that name was deleted in rev.
86 """
86 """
87 raise NotImplementedError()
87 raise NotImplementedError
88
88
89 def getchanges(self, version):
89 def getchanges(self, version):
90 """Returns a tuple of (files, copies).
90 """Returns a tuple of (files, copies).
@@ -95,18 +95,18 b' class converter_source(object):'
95
95
96 copies is a dictionary of dest: source
96 copies is a dictionary of dest: source
97 """
97 """
98 raise NotImplementedError()
98 raise NotImplementedError
99
99
100 def getcommit(self, version):
100 def getcommit(self, version):
101 """Return the commit object for version"""
101 """Return the commit object for version"""
102 raise NotImplementedError()
102 raise NotImplementedError
103
103
104 def gettags(self):
104 def gettags(self):
105 """Return the tags as a dictionary of name: revision
105 """Return the tags as a dictionary of name: revision
106
106
107 Tag names must be UTF-8 strings.
107 Tag names must be UTF-8 strings.
108 """
108 """
109 raise NotImplementedError()
109 raise NotImplementedError
110
110
111 def recode(self, s, encoding=None):
111 def recode(self, s, encoding=None):
112 if not encoding:
112 if not encoding:
@@ -133,7 +133,7 b' class converter_source(object):'
133
133
134 This function is only needed to support --filemap
134 This function is only needed to support --filemap
135 """
135 """
136 raise NotImplementedError()
136 raise NotImplementedError
137
137
138 def converted(self, rev, sinkrev):
138 def converted(self, rev, sinkrev):
139 '''Notify the source that a revision has been converted.'''
139 '''Notify the source that a revision has been converted.'''
@@ -175,13 +175,13 b' class converter_sink(object):'
175
175
176 def getheads(self):
176 def getheads(self):
177 """Return a list of this repository's heads"""
177 """Return a list of this repository's heads"""
178 raise NotImplementedError()
178 raise NotImplementedError
179
179
180 def revmapfile(self):
180 def revmapfile(self):
181 """Path to a file that will contain lines
181 """Path to a file that will contain lines
182 source_rev_id sink_rev_id
182 source_rev_id sink_rev_id
183 mapping equivalent revision identifiers for each system."""
183 mapping equivalent revision identifiers for each system."""
184 raise NotImplementedError()
184 raise NotImplementedError
185
185
186 def authorfile(self):
186 def authorfile(self):
187 """Path to a file that will contain lines
187 """Path to a file that will contain lines
@@ -203,7 +203,7 b' class converter_sink(object):'
203 a particular revision (or even what that revision would be)
203 a particular revision (or even what that revision would be)
204 before it receives the file data.
204 before it receives the file data.
205 """
205 """
206 raise NotImplementedError()
206 raise NotImplementedError
207
207
208 def puttags(self, tags):
208 def puttags(self, tags):
209 """Put tags into sink.
209 """Put tags into sink.
@@ -212,7 +212,7 b' class converter_sink(object):'
212 Return a pair (tag_revision, tag_parent_revision), or (None, None)
212 Return a pair (tag_revision, tag_parent_revision), or (None, None)
213 if nothing was changed.
213 if nothing was changed.
214 """
214 """
215 raise NotImplementedError()
215 raise NotImplementedError
216
216
217 def setbranch(self, branch, pbranches):
217 def setbranch(self, branch, pbranches):
218 """Set the current branch name. Called before the first putcommit
218 """Set the current branch name. Called before the first putcommit
@@ -247,7 +247,7 b' class converter_sink(object):'
247
247
248 def hascommit(self, rev):
248 def hascommit(self, rev):
249 """Return True if the sink contains rev"""
249 """Return True if the sink contains rev"""
250 raise NotImplementedError()
250 raise NotImplementedError
251
251
252 class commandline(object):
252 class commandline(object):
253 def __init__(self, ui, command):
253 def __init__(self, ui, command):
@@ -69,7 +69,7 b' class convert_git(converter_source):'
69
69
70 def catfile(self, rev, type):
70 def catfile(self, rev, type):
71 if rev == hex(nullid):
71 if rev == hex(nullid):
72 raise IOError()
72 raise IOError
73 data, ret = self.gitread("git cat-file %s %s" % (type, rev))
73 data, ret = self.gitread("git cat-file %s %s" % (type, rev))
74 if ret:
74 if ret:
75 raise util.Abort(_('cannot read %r object at %s') % (type, rev))
75 raise util.Abort(_('cannot read %r object at %s') % (type, rev))
@@ -241,7 +241,7 b' class mercurial_source(converter_source)'
241 # try to provoke an exception if this isn't really a hg
241 # try to provoke an exception if this isn't really a hg
242 # repo, but some other bogus compatible-looking url
242 # repo, but some other bogus compatible-looking url
243 if not self.repo.local():
243 if not self.repo.local():
244 raise error.RepoError()
244 raise error.RepoError
245 except error.RepoError:
245 except error.RepoError:
246 ui.traceback()
246 ui.traceback()
247 raise NoRepo(_("%s is not a local Mercurial repository") % path)
247 raise NoRepo(_("%s is not a local Mercurial repository") % path)
@@ -283,11 +283,11 b' class monotone_source(converter_source, '
283
283
284 def getfile(self, name, rev):
284 def getfile(self, name, rev):
285 if not self.mtnisfile(name, rev):
285 if not self.mtnisfile(name, rev):
286 raise IOError() # file was deleted or renamed
286 raise IOError # file was deleted or renamed
287 try:
287 try:
288 data = self.mtnrun("get_file_of", name, r=rev)
288 data = self.mtnrun("get_file_of", name, r=rev)
289 except:
289 except:
290 raise IOError() # file was deleted or renamed
290 raise IOError # file was deleted or renamed
291 self.mtnloadmanifest(rev)
291 self.mtnloadmanifest(rev)
292 node, attr = self.files.get(name, (None, ""))
292 node, attr = self.files.get(name, (None, ""))
293 return data, attr
293 return data, attr
@@ -317,7 +317,7 b' class monotone_source(converter_source, '
317 def getchangedfiles(self, rev, i):
317 def getchangedfiles(self, rev, i):
318 # This function is only needed to support --filemap
318 # This function is only needed to support --filemap
319 # ... and we don't support that
319 # ... and we don't support that
320 raise NotImplementedError()
320 raise NotImplementedError
321
321
322 def before(self):
322 def before(self):
323 # Check if we have a new enough version to use automate stdio
323 # Check if we have a new enough version to use automate stdio
@@ -870,7 +870,7 b' class svn_source(converter_source):'
870 def getfile(self, file, rev):
870 def getfile(self, file, rev):
871 # TODO: ra.get_file transmits the whole file instead of diffs.
871 # TODO: ra.get_file transmits the whole file instead of diffs.
872 if file in self.removed:
872 if file in self.removed:
873 raise IOError()
873 raise IOError
874 mode = ''
874 mode = ''
875 try:
875 try:
876 new_module, revnum = revsplit(rev)[1:]
876 new_module, revnum = revsplit(rev)[1:]
@@ -891,7 +891,7 b' class svn_source(converter_source):'
891 notfound = (svn.core.SVN_ERR_FS_NOT_FOUND,
891 notfound = (svn.core.SVN_ERR_FS_NOT_FOUND,
892 svn.core.SVN_ERR_RA_DAV_PATH_NOT_FOUND)
892 svn.core.SVN_ERR_RA_DAV_PATH_NOT_FOUND)
893 if e.apr_err in notfound: # File not found
893 if e.apr_err in notfound: # File not found
894 raise IOError()
894 raise IOError
895 raise
895 raise
896 if mode == 'l':
896 if mode == 'l':
897 link_prefix = "link "
897 link_prefix = "link "
@@ -129,7 +129,7 b' def _addchangeset(ui, rsrc, rdst, ctx, r'
129 try:
129 try:
130 fctx = ctx.filectx(lfutil.standin(f))
130 fctx = ctx.filectx(lfutil.standin(f))
131 except error.LookupError:
131 except error.LookupError:
132 raise IOError()
132 raise IOError
133 renamed = fctx.renamed()
133 renamed = fctx.renamed()
134 if renamed:
134 if renamed:
135 renamed = lfutil.splitstandin(renamed[0])
135 renamed = lfutil.splitstandin(renamed[0])
@@ -229,7 +229,7 b' def _lfconvert_addchangeset(rsrc, rdst, '
229 try:
229 try:
230 fctx = ctx.filectx(srcfname)
230 fctx = ctx.filectx(srcfname)
231 except error.LookupError:
231 except error.LookupError:
232 raise IOError()
232 raise IOError
233 renamed = fctx.renamed()
233 renamed = fctx.renamed()
234 if renamed:
234 if renamed:
235 # standin is always a largefile because largefile-ness
235 # standin is always a largefile because largefile-ness
@@ -278,7 +278,7 b' def _getnormalcontext(ui, ctx, f, revmap'
278 try:
278 try:
279 fctx = ctx.filectx(f)
279 fctx = ctx.filectx(f)
280 except error.LookupError:
280 except error.LookupError:
281 raise IOError()
281 raise IOError
282 renamed = fctx.renamed()
282 renamed = fctx.renamed()
283 if renamed:
283 if renamed:
284 renamed = renamed[0]
284 renamed = renamed[0]
@@ -322,7 +322,7 b' class queue(object):'
322 try:
322 try:
323 gitmode = ui.configbool('mq', 'git', None)
323 gitmode = ui.configbool('mq', 'git', None)
324 if gitmode is None:
324 if gitmode is None:
325 raise error.ConfigError()
325 raise error.ConfigError
326 self.gitmode = gitmode and 'yes' or 'no'
326 self.gitmode = gitmode and 'yes' or 'no'
327 except error.ConfigError:
327 except error.ConfigError:
328 self.gitmode = ui.config('mq', 'git', 'auto').lower()
328 self.gitmode = ui.config('mq', 'git', 'auto').lower()
@@ -1360,7 +1360,7 b' def amend(ui, repo, commitfunc, old, ext'
1360 copied=copied.get(path))
1360 copied=copied.get(path))
1361 return mctx
1361 return mctx
1362 except KeyError:
1362 except KeyError:
1363 raise IOError()
1363 raise IOError
1364 else:
1364 else:
1365 ui.note(_('copying changeset %s to %s\n') % (old, base))
1365 ui.note(_('copying changeset %s to %s\n') % (old, base))
1366
1366
@@ -1369,7 +1369,7 b' def amend(ui, repo, commitfunc, old, ext'
1369 try:
1369 try:
1370 return old.filectx(path)
1370 return old.filectx(path)
1371 except KeyError:
1371 except KeyError:
1372 raise IOError()
1372 raise IOError
1373
1373
1374 # See if we got a message from -m or -l, if not, open the editor
1374 # See if we got a message from -m or -l, if not, open the editor
1375 # with the message of the changeset to amend
1375 # with the message of the changeset to amend
@@ -166,7 +166,7 b' class server(object):'
166
166
167 # is the other end closed?
167 # is the other end closed?
168 if not data:
168 if not data:
169 raise EOFError()
169 raise EOFError
170
170
171 return data
171 return data
172
172
@@ -26,25 +26,25 b' class basedag(object):'
26
26
27 def nodeset(self):
27 def nodeset(self):
28 '''set of all node idxs'''
28 '''set of all node idxs'''
29 raise NotImplementedError()
29 raise NotImplementedError
30
30
31 def heads(self):
31 def heads(self):
32 '''list of head ixs'''
32 '''list of head ixs'''
33 raise NotImplementedError()
33 raise NotImplementedError
34
34
35 def parents(self, ix):
35 def parents(self, ix):
36 '''list of parents ixs of ix'''
36 '''list of parents ixs of ix'''
37 raise NotImplementedError()
37 raise NotImplementedError
38
38
39 def inverse(self):
39 def inverse(self):
40 '''inverse DAG, where parents becomes children, etc.'''
40 '''inverse DAG, where parents becomes children, etc.'''
41 raise NotImplementedError()
41 raise NotImplementedError
42
42
43 def ancestorset(self, starts, stops=None):
43 def ancestorset(self, starts, stops=None):
44 '''
44 '''
45 set of all ancestors of starts (incl), but stop walk at stops (excl)
45 set of all ancestors of starts (incl), but stop walk at stops (excl)
46 '''
46 '''
47 raise NotImplementedError()
47 raise NotImplementedError
48
48
49 def descendantset(self, starts, stops=None):
49 def descendantset(self, starts, stops=None):
50 '''
50 '''
@@ -59,7 +59,7 b' class basedag(object):'
59 By "connected list" we mean that if an ancestor and a descendant are in
59 By "connected list" we mean that if an ancestor and a descendant are in
60 the list, then so is at least one path connecting them.
60 the list, then so is at least one path connecting them.
61 '''
61 '''
62 raise NotImplementedError()
62 raise NotImplementedError
63
63
64 def externalize(self, ix):
64 def externalize(self, ix):
65 '''return a list of (or set if given a set) of node ids'''
65 '''return a list of (or set if given a set) of node ids'''
@@ -95,7 +95,7 b' class continuereader(object):'
95 def __getattr__(self, attr):
95 def __getattr__(self, attr):
96 if attr in ('close', 'readline', 'readlines', '__iter__'):
96 if attr in ('close', 'readline', 'readlines', '__iter__'):
97 return getattr(self.f, attr)
97 return getattr(self.f, attr)
98 raise AttributeError()
98 raise AttributeError
99
99
100 def _statusmessage(code):
100 def _statusmessage(code):
101 from BaseHTTPServer import BaseHTTPRequestHandler
101 from BaseHTTPServer import BaseHTTPRequestHandler
@@ -534,7 +534,7 b' def safesend(self, str):'
534 if self.auto_open:
534 if self.auto_open:
535 self.connect()
535 self.connect()
536 else:
536 else:
537 raise httplib.NotConnected()
537 raise httplib.NotConnected
538
538
539 # send the data to the server. if we get a broken pipe, then close
539 # send the data to the server. if we get a broken pipe, then close
540 # the socket. we want to reconnect when somebody tries to send again.
540 # the socket. we want to reconnect when somebody tries to send again.
@@ -276,7 +276,7 b' def _buildregexmatch(pats, tail):'
276 try:
276 try:
277 pat = '(?:%s)' % '|'.join([_regex(k, p, tail) for (k, p) in pats])
277 pat = '(?:%s)' % '|'.join([_regex(k, p, tail) for (k, p) in pats])
278 if len(pat) > 20000:
278 if len(pat) > 20000:
279 raise OverflowError()
279 raise OverflowError
280 return pat, re.compile(pat).match
280 return pat, re.compile(pat).match
281 except OverflowError:
281 except OverflowError:
282 # We're using a Python with a tiny regex engine and we
282 # We're using a Python with a tiny regex engine and we
@@ -534,7 +534,7 b' class filestore(object):'
534 if fname in self.data:
534 if fname in self.data:
535 return self.data[fname]
535 return self.data[fname]
536 if not self.opener or fname not in self.files:
536 if not self.opener or fname not in self.files:
537 raise IOError()
537 raise IOError
538 fn, mode, copied = self.files[fname]
538 fn, mode, copied = self.files[fname]
539 return self.opener.read(fn), mode, copied
539 return self.opener.read(fn), mode, copied
540
540
@@ -560,7 +560,7 b' class repobackend(abstractbackend):'
560 try:
560 try:
561 fctx = self.ctx[fname]
561 fctx = self.ctx[fname]
562 except error.LookupError:
562 except error.LookupError:
563 raise IOError()
563 raise IOError
564 flags = fctx.flags()
564 flags = fctx.flags()
565 return fctx.data(), ('l' in flags, 'x' in flags)
565 return fctx.data(), ('l' in flags, 'x' in flags)
566
566
@@ -1628,7 +1628,7 b' def diff(repo, node1=None, node2=None, m'
1628 try:
1628 try:
1629 def losedata(fn):
1629 def losedata(fn):
1630 if not losedatafn or not losedatafn(fn=fn):
1630 if not losedatafn or not losedatafn(fn=fn):
1631 raise GitDiffRequired()
1631 raise GitDiffRequired
1632 # Buffer the whole output until we are sure it can be generated
1632 # Buffer the whole output until we are sure it can be generated
1633 return list(difffn(opts.copy(git=False), losedata))
1633 return list(difffn(opts.copy(git=False), losedata))
1634 except GitDiffRequired:
1634 except GitDiffRequired:
@@ -94,7 +94,7 b' class Merge3Text(object):'
94 elif self.a[0].endswith('\r'):
94 elif self.a[0].endswith('\r'):
95 newline = '\r'
95 newline = '\r'
96 if base_marker and reprocess:
96 if base_marker and reprocess:
97 raise CantReprocessAndShowBase()
97 raise CantReprocessAndShowBase
98 if name_a:
98 if name_a:
99 start_marker = start_marker + ' ' + name_a
99 start_marker = start_marker + ' ' + name_a
100 if name_b:
100 if name_b:
@@ -305,7 +305,7 b' def executablepath():'
305 buf = ctypes.create_string_buffer(size + 1)
305 buf = ctypes.create_string_buffer(size + 1)
306 len = _kernel32.GetModuleFileNameA(None, ctypes.byref(buf), size)
306 len = _kernel32.GetModuleFileNameA(None, ctypes.byref(buf), size)
307 if len == 0:
307 if len == 0:
308 raise ctypes.WinError()
308 raise ctypes.WinError
309 elif len == size:
309 elif len == size:
310 raise ctypes.WinError(_ERROR_INSUFFICIENT_BUFFER)
310 raise ctypes.WinError(_ERROR_INSUFFICIENT_BUFFER)
311 return buf.value
311 return buf.value
@@ -315,7 +315,7 b' def getuser():'
315 size = _DWORD(300)
315 size = _DWORD(300)
316 buf = ctypes.create_string_buffer(size.value + 1)
316 buf = ctypes.create_string_buffer(size.value + 1)
317 if not _advapi32.GetUserNameA(ctypes.byref(buf), ctypes.byref(size)):
317 if not _advapi32.GetUserNameA(ctypes.byref(buf), ctypes.byref(size)):
318 raise ctypes.WinError()
318 raise ctypes.WinError
319 return buf.value
319 return buf.value
320
320
321 _signalhandler = []
321 _signalhandler = []
@@ -333,7 +333,7 b' def setsignalhandler():'
333 h = _SIGNAL_HANDLER(handler)
333 h = _SIGNAL_HANDLER(handler)
334 _signalhandler.append(h) # needed to prevent garbage collection
334 _signalhandler.append(h) # needed to prevent garbage collection
335 if not _kernel32.SetConsoleCtrlHandler(h, True):
335 if not _kernel32.SetConsoleCtrlHandler(h, True):
336 raise ctypes.WinError()
336 raise ctypes.WinError
337
337
338 def hidewindow():
338 def hidewindow():
339
339
@@ -396,7 +396,7 b' def spawndetached(args):'
396 None, args, None, None, False, _DETACHED_PROCESS,
396 None, args, None, None, False, _DETACHED_PROCESS,
397 env, os.getcwd(), ctypes.byref(si), ctypes.byref(pi))
397 env, os.getcwd(), ctypes.byref(si), ctypes.byref(pi))
398 if not res:
398 if not res:
399 raise ctypes.WinError()
399 raise ctypes.WinError
400
400
401 return pi.dwProcessId
401 return pi.dwProcessId
402
402
@@ -304,7 +304,7 b' def termwidth():'
304
304
305 def groupmembers(name):
305 def groupmembers(name):
306 # Don't support groups on Windows for now
306 # Don't support groups on Windows for now
307 raise KeyError()
307 raise KeyError
308
308
309 def isexec(f):
309 def isexec(f):
310 return False
310 return False
@@ -18,7 +18,7 b' def writeblock(server, data):'
18 def readchannel(server):
18 def readchannel(server):
19 data = server.stdout.read(5)
19 data = server.stdout.read(5)
20 if not data:
20 if not data:
21 raise EOFError()
21 raise EOFError
22 channel, length = struct.unpack('>cI', data)
22 channel, length = struct.unpack('>cI', data)
23 if channel in 'IL':
23 if channel in 'IL':
24 return channel, length
24 return channel, length
General Comments 0
You need to be logged in to leave comments. Login now