Browse Source

git-p4: replace each tab with 8 spaces for consistency

Note that the majority of git-p4 uses spaces, not tabs, for indentation.
Consistent indentation is a good hygiene for Python scripts, and mixing
tabs and spaces in Python can lead to hard-to-find bugs.

Signed-off-by: Andrew Garber <andrew@andrewgarber.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
maint
Andrew Garber 14 years ago committed by Junio C Hamano
parent
commit
c3f6163b0b
  1. 64
      contrib/fast-import/git-p4

64
contrib/fast-import/git-p4

@ -222,10 +222,10 @@ def p4CmdList(cmd, stdin=None, stdin_mode='w+b', cb=None):
try: try:
while True: while True:
entry = marshal.load(p4.stdout) entry = marshal.load(p4.stdout)
if cb is not None: if cb is not None:
cb(entry) cb(entry)
else: else:
result.append(entry) result.append(entry)
except EOFError: except EOFError:
pass pass
exitCode = p4.wait() exitCode = p4.wait()
@ -449,8 +449,8 @@ def p4ChangesForPaths(depotPaths, changeRange):


changes = {} changes = {}
for line in output: for line in output:
changeNum = int(line.split(" ")[1]) changeNum = int(line.split(" ")[1])
changes[changeNum] = True changes[changeNum] = True


changelist = changes.keys() changelist = changes.keys()
changelist.sort() changelist.sort()
@ -1033,10 +1033,10 @@ class P4Sync(Command):
# - helper for streamP4Files # - helper for streamP4Files


def streamOneP4File(self, file, contents): def streamOneP4File(self, file, contents):
if file["type"] == "apple": if file["type"] == "apple":
print "\nfile %s is a strange apple file that forks. Ignoring" % \ print "\nfile %s is a strange apple file that forks. Ignoring" % \
file['depotFile'] file['depotFile']
return return


relPath = self.stripRepoPath(file['depotFile'], self.branchPrefixes) relPath = self.stripRepoPath(file['depotFile'], self.branchPrefixes)
relPath = self.wildcard_decode(relPath) relPath = self.wildcard_decode(relPath)
@ -1085,22 +1085,22 @@ class P4Sync(Command):
# handle another chunk of streaming data # handle another chunk of streaming data
def streamP4FilesCb(self, marshalled): def streamP4FilesCb(self, marshalled):


if marshalled.has_key('depotFile') and self.stream_have_file_info: if marshalled.has_key('depotFile') and self.stream_have_file_info:
# start of a new file - output the old one first # start of a new file - output the old one first
self.streamOneP4File(self.stream_file, self.stream_contents) self.streamOneP4File(self.stream_file, self.stream_contents)
self.stream_file = {} self.stream_file = {}
self.stream_contents = [] self.stream_contents = []
self.stream_have_file_info = False self.stream_have_file_info = False


# pick up the new file information... for the # pick up the new file information... for the
# 'data' field we need to append to our array # 'data' field we need to append to our array
for k in marshalled.keys(): for k in marshalled.keys():
if k == 'data': if k == 'data':
self.stream_contents.append(marshalled['data']) self.stream_contents.append(marshalled['data'])
else: else:
self.stream_file[k] = marshalled[k] self.stream_file[k] = marshalled[k]


self.stream_have_file_info = True self.stream_have_file_info = True


# Stream directly from "p4 files" into "git fast-import" # Stream directly from "p4 files" into "git fast-import"
def streamP4Files(self, files): def streamP4Files(self, files):
@ -1132,14 +1132,14 @@ class P4Sync(Command):
self.stream_contents = [] self.stream_contents = []
self.stream_have_file_info = False self.stream_have_file_info = False


# curry self argument # curry self argument
def streamP4FilesCbSelf(entry): def streamP4FilesCbSelf(entry):
self.streamP4FilesCb(entry) self.streamP4FilesCb(entry)


p4CmdList("-x - print", p4CmdList("-x - print",
'\n'.join(['%s#%s' % (f['path'], f['rev']) '\n'.join(['%s#%s' % (f['path'], f['rev'])
for f in filesToRead]), for f in filesToRead]),
cb=streamP4FilesCbSelf) cb=streamP4FilesCbSelf)


# do the last chunk # do the last chunk
if self.stream_file.has_key('depotFile'): if self.stream_file.has_key('depotFile'):
@ -1148,7 +1148,7 @@ class P4Sync(Command):
def commit(self, details, files, branch, branchPrefixes, parent = ""): def commit(self, details, files, branch, branchPrefixes, parent = ""):
epoch = details["time"] epoch = details["time"]
author = details["user"] author = details["user"]
self.branchPrefixes = branchPrefixes self.branchPrefixes = branchPrefixes


if self.verbose: if self.verbose:
print "commit into %s" % branch print "commit into %s" % branch
@ -1253,7 +1253,7 @@ class P4Sync(Command):


s = '' s = ''
for (key, val) in self.users.items(): for (key, val) in self.users.items():
s += "%s\t%s\n" % (key.expandtabs(1), val.expandtabs(1)) s += "%s\t%s\n" % (key.expandtabs(1), val.expandtabs(1))


open(self.getUserCacheFilename(), "wb").write(s) open(self.getUserCacheFilename(), "wb").write(s)
self.userMapFromPerforceServer = True self.userMapFromPerforceServer = True

Loading…
Cancel
Save