mirror of
https://github.com/facebook/sapling.git
synced 2024-10-07 07:17:55 +03:00
Make consistent use of str.startswith() in conditionals.
# HG changeset patch # User chad.netzer@gmail.com # Node ID 45db196de89a15fd045cd789f701b0180fd276f1 # Parent 852adf9ffa4dd2cb1a504bd207f0cad178ac4024 Make consistent use of str.startswith() in conditionals.
This commit is contained in:
parent
544875fe3b
commit
899bc83dfc
@ -361,12 +361,12 @@ class ftpwrapper(urllib.ftpwrapper):
|
||||
cmd = 'RETR ' + file
|
||||
conn = self.ftp.ntransfercmd(cmd, rest)
|
||||
except ftplib.error_perm, reason:
|
||||
if str(reason)[:3] == '501':
|
||||
if str(reason).startswith('501'):
|
||||
# workaround for REST not supported error
|
||||
fp, retrlen = self.retrfile(file, type)
|
||||
fp = RangeableFileObject(fp, (rest,''))
|
||||
return (fp, retrlen)
|
||||
elif str(reason)[:3] != '550':
|
||||
elif not str(reason).startswith('550'):
|
||||
raise IOError, ('ftp error', reason), sys.exc_info()[2]
|
||||
if not conn:
|
||||
# Set transfer mode to ASCII!
|
||||
|
@ -606,10 +606,10 @@ def import_(ui, repo, patch1, *patches, **opts):
|
||||
ui.debug(t,'\n')
|
||||
if t == '# HG changeset patch' or hgpatch == True:
|
||||
hgpatch = True
|
||||
if t[:7] == "# User ":
|
||||
if t.startswith("# User "):
|
||||
user = t[7:]
|
||||
ui.debug('User: %s\n' % user)
|
||||
if t[:2] <> "# " and t.strip() and not snippet: snippet = t
|
||||
if not t.startswith("# ") and t.strip() and not snippet: snippet = t
|
||||
if snippet: text = snippet + '\n' + text
|
||||
ui.debug('text:\n%s\n' % text)
|
||||
|
||||
@ -621,7 +621,7 @@ def import_(ui, repo, patch1, *patches, **opts):
|
||||
for l in f.read().splitlines():
|
||||
l.rstrip('\r\n');
|
||||
ui.status("%s\n" % l)
|
||||
if l[:14] == 'patching file ':
|
||||
if l.startswith('patching file '):
|
||||
pf = l[14:]
|
||||
if pf not in files:
|
||||
files.append(pf)
|
||||
|
@ -21,14 +21,14 @@ class filelog(revlog):
|
||||
|
||||
def read(self, node):
|
||||
t = self.revision(node)
|
||||
if t[:2] != '\1\n':
|
||||
if not t.startswith('\1\n'):
|
||||
return t
|
||||
s = t.find('\1\n', 2)
|
||||
return t[s+2:]
|
||||
|
||||
def readmeta(self, node):
|
||||
t = self.revision(node)
|
||||
if t[:2] != '\1\n':
|
||||
if not t.startswith('\1\n'):
|
||||
return t
|
||||
s = t.find('\1\n', 2)
|
||||
mt = t[2:s]
|
||||
@ -38,7 +38,7 @@ class filelog(revlog):
|
||||
return m
|
||||
|
||||
def add(self, text, meta, transaction, link, p1=None, p2=None):
|
||||
if meta or text[:2] == '\1\n':
|
||||
if meta or text.startswith('\1\n'):
|
||||
mt = ""
|
||||
if meta:
|
||||
mt = [ "%s: %s\n" % (k, v) for k,v in meta.items() ]
|
||||
@ -436,7 +436,7 @@ class dirstate:
|
||||
def opener(base):
|
||||
p = base
|
||||
def o(path, mode="r"):
|
||||
if p[:7] == "http://":
|
||||
if p.startswith("http://"):
|
||||
f = os.path.join(p, urllib.quote(path))
|
||||
return httprangereader.httprangereader(f)
|
||||
|
||||
@ -465,7 +465,7 @@ class RepoError(Exception): pass
|
||||
class localrepository:
|
||||
def __init__(self, ui, path=None, create=0):
|
||||
self.remote = 0
|
||||
if path and path[:7] == "http://":
|
||||
if path and path.startswith("http://"):
|
||||
self.remote = 1
|
||||
self.path = path
|
||||
else:
|
||||
|
Loading…
Reference in New Issue
Block a user