##// END OF EJS Templates
Make consistent use of str.startswith() in conditionals....
chad.netzer@gmail.com -
r674:6513ba7d default
parent child Browse files
Show More
@@ -361,12 +361,12 b' class ftpwrapper(urllib.ftpwrapper):'
361 cmd = 'RETR ' + file
361 cmd = 'RETR ' + file
362 conn = self.ftp.ntransfercmd(cmd, rest)
362 conn = self.ftp.ntransfercmd(cmd, rest)
363 except ftplib.error_perm, reason:
363 except ftplib.error_perm, reason:
364 if str(reason)[:3] == '501':
364 if str(reason).startswith('501'):
365 # workaround for REST not supported error
365 # workaround for REST not supported error
366 fp, retrlen = self.retrfile(file, type)
366 fp, retrlen = self.retrfile(file, type)
367 fp = RangeableFileObject(fp, (rest,''))
367 fp = RangeableFileObject(fp, (rest,''))
368 return (fp, retrlen)
368 return (fp, retrlen)
369 elif str(reason)[:3] != '550':
369 elif not str(reason).startswith('550'):
370 raise IOError, ('ftp error', reason), sys.exc_info()[2]
370 raise IOError, ('ftp error', reason), sys.exc_info()[2]
371 if not conn:
371 if not conn:
372 # Set transfer mode to ASCII!
372 # Set transfer mode to ASCII!
@@ -606,10 +606,10 b' def import_(ui, repo, patch1, *patches, '
606 ui.debug(t,'\n')
606 ui.debug(t,'\n')
607 if t == '# HG changeset patch' or hgpatch == True:
607 if t == '# HG changeset patch' or hgpatch == True:
608 hgpatch = True
608 hgpatch = True
609 if t[:7] == "# User ":
609 if t.startswith("# User "):
610 user = t[7:]
610 user = t[7:]
611 ui.debug('User: %s\n' % user)
611 ui.debug('User: %s\n' % user)
612 if t[:2] <> "# " and t.strip() and not snippet: snippet = t
612 if not t.startswith("# ") and t.strip() and not snippet: snippet = t
613 if snippet: text = snippet + '\n' + text
613 if snippet: text = snippet + '\n' + text
614 ui.debug('text:\n%s\n' % text)
614 ui.debug('text:\n%s\n' % text)
615
615
@@ -621,7 +621,7 b' def import_(ui, repo, patch1, *patches, '
621 for l in f.read().splitlines():
621 for l in f.read().splitlines():
622 l.rstrip('\r\n');
622 l.rstrip('\r\n');
623 ui.status("%s\n" % l)
623 ui.status("%s\n" % l)
624 if l[:14] == 'patching file ':
624 if l.startswith('patching file '):
625 pf = l[14:]
625 pf = l[14:]
626 if pf not in files:
626 if pf not in files:
627 files.append(pf)
627 files.append(pf)
@@ -21,14 +21,14 b' class filelog(revlog):'
21
21
22 def read(self, node):
22 def read(self, node):
23 t = self.revision(node)
23 t = self.revision(node)
24 if t[:2] != '\1\n':
24 if not t.startswith('\1\n'):
25 return t
25 return t
26 s = t.find('\1\n', 2)
26 s = t.find('\1\n', 2)
27 return t[s+2:]
27 return t[s+2:]
28
28
29 def readmeta(self, node):
29 def readmeta(self, node):
30 t = self.revision(node)
30 t = self.revision(node)
31 if t[:2] != '\1\n':
31 if not t.startswith('\1\n'):
32 return t
32 return t
33 s = t.find('\1\n', 2)
33 s = t.find('\1\n', 2)
34 mt = t[2:s]
34 mt = t[2:s]
@@ -38,7 +38,7 b' class filelog(revlog):'
38 return m
38 return m
39
39
40 def add(self, text, meta, transaction, link, p1=None, p2=None):
40 def add(self, text, meta, transaction, link, p1=None, p2=None):
41 if meta or text[:2] == '\1\n':
41 if meta or text.startswith('\1\n'):
42 mt = ""
42 mt = ""
43 if meta:
43 if meta:
44 mt = [ "%s: %s\n" % (k, v) for k,v in meta.items() ]
44 mt = [ "%s: %s\n" % (k, v) for k,v in meta.items() ]
@@ -436,7 +436,7 b' class dirstate:'
436 def opener(base):
436 def opener(base):
437 p = base
437 p = base
438 def o(path, mode="r"):
438 def o(path, mode="r"):
439 if p[:7] == "http://":
439 if p.startswith("http://"):
440 f = os.path.join(p, urllib.quote(path))
440 f = os.path.join(p, urllib.quote(path))
441 return httprangereader.httprangereader(f)
441 return httprangereader.httprangereader(f)
442
442
@@ -465,7 +465,7 b' class RepoError(Exception): pass'
465 class localrepository:
465 class localrepository:
466 def __init__(self, ui, path=None, create=0):
466 def __init__(self, ui, path=None, create=0):
467 self.remote = 0
467 self.remote = 0
468 if path and path[:7] == "http://":
468 if path and path.startswith("http://"):
469 self.remote = 1
469 self.remote = 1
470 self.path = path
470 self.path = path
471 else:
471 else:
General Comments 0
You need to be logged in to leave comments. Login now