threads / patch / 26265

patchgit-p4: correct indenting and formatting

Subject: [PATCH] git-p4: correct indenting and formatting

## tl;dr

5 messages between Jan 12, 2011 and Jan 12, 2011. Diffs are folded; open one to read it.

replies: 4people: 2as markdown or json

Andrew Garber· Jan 12, 2011, 05:05 UTC · lore
- replace tabs with appropriate number of spaces
- minor tweaks to code formatting
---
 contrib/fast-import/git-p4 |   71 +++++++++++++++++++++-----------------------
 1 files changed, 34 insertions(+), 37 deletions(-)
Show changes to contrib/fast-import/git-p4 +34 −37
diff --git a/contrib/fast-import/git-p4 b/contrib/fast-import/git-p4
index 04ce7e3..449df2e 100755
--- a/contrib/fast-import/git-p4
+++ b/contrib/fast-import/git-p4
@@ -222,10 +222,10 @@ def p4CmdList(cmd, stdin=None, stdin_mode='w+b', cb=None):
     try:
         while True:
             entry = marshal.load(p4.stdout)
-	    if cb is not None:
-		cb(entry)
-	    else:
-		result.append(entry)
+            if cb is not None:
+                cb(entry)
+            else:
+                result.append(entry)
     except EOFError:
         pass
     exitCode = p4.wait()
@@ -445,8 +445,8 @@ def p4ChangesForPaths(depotPaths, changeRange):
 
     changes = {}
     for line in output:
-	changeNum = int(line.split(" ")[1])
-	changes[changeNum] = True
+        changeNum = int(line.split(" ")[1])
+        changes[changeNum] = True
 
     changelist = changes.keys()
     changelist.sort()
@@ -954,10 +954,9 @@ class P4Sync(Command):
     # - helper for streamP4Files
 
     def streamOneP4File(self, file, contents):
-	if file["type"] == "apple":
-	    print "\nfile %s is a strange apple file that forks. Ignoring" % \
-		file['depotFile']
-	    return
+        if file["type"] == "apple":
+            print "\nfile %s is a strange apple file that forks. Ignoring" % file['depotFile']
+            return
 
         relPath = self.stripRepoPath(file['depotFile'], self.branchPrefixes)
         if verbose:
@@ -1004,23 +1003,22 @@ class P4Sync(Command):
 
     # handle another chunk of streaming data
     def streamP4FilesCb(self, marshalled):
+        if marshalled.has_key('depotFile') and self.stream_have_file_info:
+            # start of a new file - output the old one first
+            self.streamOneP4File(self.stream_file, self.stream_contents)
+            self.stream_file = {}
+            self.stream_contents = []
+            self.stream_have_file_info = False
 
-	if marshalled.has_key('depotFile') and self.stream_have_file_info:
-	    # start of a new file - output the old one first
-	    self.streamOneP4File(self.stream_file, self.stream_contents)
-	    self.stream_file = {}
-	    self.stream_contents = []
-	    self.stream_have_file_info = False
-
-	# pick up the new file information... for the
-	# 'data' field we need to append to our array
-	for k in marshalled.keys():
-	    if k == 'data':
-		self.stream_contents.append(marshalled['data'])
-	    else:
-		self.stream_file[k] = marshalled[k]
+        # pick up the new file information... for the
+        # 'data' field we need to append to our array
+        for k in marshalled.keys():
+            if k == 'data':
+                self.stream_contents.append(marshalled['data'])
+            else:
+                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"
     def streamP4Files(self, files):
@@ -1052,23 +1050,22 @@ class P4Sync(Command):
             self.stream_contents = []
             self.stream_have_file_info = False
 
-	    # curry self argument
-	    def streamP4FilesCbSelf(entry):
-		self.streamP4FilesCb(entry)
+        # curry self argument
+        def streamP4FilesCbSelf(entry):
+            self.streamP4FilesCb(entry)
 
-	    p4CmdList("-x - print",
-		'\n'.join(['%s#%s' % (f['path'], f['rev'])
-                                                  for f in filesToRead]),
-	        cb=streamP4FilesCbSelf)
+        p4CmdList("-x - print",
+                  '\n'.join(['%s#%s' % (f['path'], f['rev']) for f in filesToRead]),
+                  cb=streamP4FilesCbSelf)
 
-            # do the last chunk
-            if self.stream_file.has_key('depotFile'):
-                self.streamOneP4File(self.stream_file, self.stream_contents)
+        # do the last chunk
+        if self.stream_file.has_key('depotFile'):
+            self.streamOneP4File(self.stream_file, self.stream_contents)
 
     def commit(self, details, files, branch, branchPrefixes, parent = ""):
         epoch = details["time"]
         author = details["user"]
-	self.branchPrefixes = branchPrefixes
+        self.branchPrefixes = branchPrefixes
 
         if self.verbose:
             print "commit into %s" % branch
@@ -1173,7 +1170,7 @@ class P4Sync(Command):
 
         s = ''
         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)
         self.userMapFromPerforceServer = True
-- 
1.7.3.2
Junio C Hamano· Jan 12, 2011, 08:45 UTC · re: Andrew Garber · lore

Re: [PATCH] git-p4: correct indenting and formatting

Andrew Garber <andrew@andrewgarber.com> writes:
Show 5 quoted lines
> - replace tabs with appropriate number of spaces
> - minor tweaks to code formatting
> ---
>  contrib/fast-import/git-p4 |   71 +++++++++++++++++++++-----------------------
>  1 files changed, 34 insertions(+), 37 deletions(-)

Sorry, but in git codebase, tabs are 8-place indent by definition, and I don't see much merit in this patch, other than being religious about somebody else's coding style, which would matter only if we are trying to get this included in "batteries included" set shipped with Python distribution, perhaps.

A downside is that this patch will make life harder for people with private patches to git-p4 that they haven't shared with us.

Junio C Hamano· Jan 12, 2011, 09:04 UTC · re: Junio C Hamano · lore

Re: [PATCH] git-p4: correct indenting and formatting

Junio C Hamano <gitster@pobox.com> writes:
Show 16 quoted lines
> Andrew Garber <andrew@andrewgarber.com> writes:
>
>> - replace tabs with appropriate number of spaces
>> - minor tweaks to code formatting
>> ---
>>  contrib/fast-import/git-p4 |   71 +++++++++++++++++++++-----------------------
>>  1 files changed, 34 insertions(+), 37 deletions(-)
>
> Sorry, but in git codebase, tabs are 8-place indent by definition, and I
> don't see much merit in this patch, other than being religious about
> somebody else's coding style, which would matter only if we are trying to
> get this included in "batteries included" set shipped with Python
> distribution, perhaps.
>
> A downside is that this patch will make life harder for people with
> private patches to git-p4 that they haven't shared with us.
Sorry, I obviously was not paying attention to the patch itself.

The file already mostly follows the Python convention to use only SP and you are fixing some oddballs that have HT instead of typing 8 SPs out to make things consistent.

I don't see any problem with that kind of change.

Will queue on a separate branch for you, expecting that you are doing this in preparation for a new feature or a bugfix to the script.

Thanks.
Junio C Hamano· Jan 12, 2011, 09:05 UTC · re: Junio C Hamano · lore

Re: [PATCH] git-p4: correct indenting and formatting

Junio C Hamano <gitster@pobox.com> writes:
Show 12 quoted lines
> Junio C Hamano <gitster@pobox.com> writes:
>
>> Andrew Garber <andrew@andrewgarber.com> writes:
>>
>>> - replace tabs with appropriate number of spaces
>>> - minor tweaks to code formatting
>>> ---
>>>  contrib/fast-import/git-p4 |   71 +++++++++++++++++++++-----------------------
>>>  1 files changed, 34 insertions(+), 37 deletions(-)
>> ...
> Will queue on a separate branch for you, expecting that you are doing this
> in preparation for a new feature or a bugfix to the script.
Forgot to say obligatory "Please sign-off your patch".  Please do so.
Andrew Garber· Jan 12, 2011, 09:13 UTC · re: Junio C Hamano · lore

Re: [PATCH] git-p4: correct indenting and formatting

Great! Thanks Junio. Sorry about forgetting to sign-off my patch.
On Wed, Jan 12, 2011 at 1:05 AM, Junio C Hamano <gitster@pobox.com> wrote:
Show 17 quoted lines
> Junio C Hamano <gitster@pobox.com> writes:
>
>> Junio C Hamano <gitster@pobox.com> writes:
>>
>>> Andrew Garber <andrew@andrewgarber.com> writes:
>>>
>>>> - replace tabs with appropriate number of spaces
>>>> - minor tweaks to code formatting
>>>> ---
>>>>  contrib/fast-import/git-p4 |   71 +++++++++++++++++++++-----------------------
>>>>  1 files changed, 34 insertions(+), 37 deletions(-)
>>> ...
>> Will queue on a separate branch for you, expecting that you are doing this
>> in preparation for a new feature or a bugfix to the script.
>
> Forgot to say obligatory "Please sign-off your patch".  Please do so.
>

← back to recent threads