{"thread":{"id":"26265","subject":"[PATCH] git-p4: correct indenting and formatting","startedAt":"2011-01-12T05:05:03Z","lastAt":"2011-01-12T09:13:42Z","messageCount":5,"participants":["Andrew Garber","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"159393","messageId":"1294808703-1848-1-git-send-email-andrew@andrewgarber.com","threadId":"26265","inReplyTo":null,"subject":"[PATCH] git-p4: correct indenting and formatting","fromName":"Andrew Garber","fromEmail":"andrew@andrewgarber.com","sentAt":"2011-01-12T05:05:03Z","receivedAt":"2011-01-12T05:05:03Z","isPatch":true,"sender":{"key":"andrew@andrewgarber.com","avatar":"https://avatars.githubusercontent.com/u/265048?v=4"},"body":"- replace tabs with appropriate number of spaces\n- minor tweaks to code formatting\n---\n contrib/fast-import/git-p4 |   71 +++++++++++++++++++++-----------------------\n 1 files changed, 34 insertions(+), 37 deletions(-)\n\ndiff --git a/contrib/fast-import/git-p4 b/contrib/fast-import/git-p4\nindex 04ce7e3..449df2e 100755\n--- a/contrib/fast-import/git-p4\n+++ b/contrib/fast-import/git-p4\n@@ -222,10 +222,10 @@ def p4CmdList(cmd, stdin=None, stdin_mode='w+b', cb=None):\n     try:\n         while True:\n             entry = marshal.load(p4.stdout)\n-\t    if cb is not None:\n-\t\tcb(entry)\n-\t    else:\n-\t\tresult.append(entry)\n+            if cb is not None:\n+                cb(entry)\n+            else:\n+                result.append(entry)\n     except EOFError:\n         pass\n     exitCode = p4.wait()\n@@ -445,8 +445,8 @@ def p4ChangesForPaths(depotPaths, changeRange):\n \n     changes = {}\n     for line in output:\n-\tchangeNum = int(line.split(\" \")[1])\n-\tchanges[changeNum] = True\n+        changeNum = int(line.split(\" \")[1])\n+        changes[changeNum] = True\n \n     changelist = changes.keys()\n     changelist.sort()\n@@ -954,10 +954,9 @@ class P4Sync(Command):\n     # - helper for streamP4Files\n \n     def streamOneP4File(self, file, contents):\n-\tif file[\"type\"] == \"apple\":\n-\t    print \"\\nfile %s is a strange apple file that forks. Ignoring\" % \\\n-\t\tfile['depotFile']\n-\t    return\n+        if file[\"type\"] == \"apple\":\n+            print \"\\nfile %s is a strange apple file that forks. Ignoring\" % file['depotFile']\n+            return\n \n         relPath = self.stripRepoPath(file['depotFile'], self.branchPrefixes)\n         if verbose:\n@@ -1004,23 +1003,22 @@ class P4Sync(Command):\n \n     # handle another chunk of streaming data\n     def streamP4FilesCb(self, marshalled):\n+        if marshalled.has_key('depotFile') and self.stream_have_file_info:\n+            # start of a new file - output the old one first\n+            self.streamOneP4File(self.stream_file, self.stream_contents)\n+            self.stream_file = {}\n+            self.stream_contents = []\n+            self.stream_have_file_info = False\n \n-\tif marshalled.has_key('depotFile') and self.stream_have_file_info:\n-\t    # start of a new file - output the old one first\n-\t    self.streamOneP4File(self.stream_file, self.stream_contents)\n-\t    self.stream_file = {}\n-\t    self.stream_contents = []\n-\t    self.stream_have_file_info = False\n-\n-\t# pick up the new file information... for the\n-\t# 'data' field we need to append to our array\n-\tfor k in marshalled.keys():\n-\t    if k == 'data':\n-\t\tself.stream_contents.append(marshalled['data'])\n-\t    else:\n-\t\tself.stream_file[k] = marshalled[k]\n+        # pick up the new file information... for the\n+        # 'data' field we need to append to our array\n+        for k in marshalled.keys():\n+            if k == 'data':\n+                self.stream_contents.append(marshalled['data'])\n+            else:\n+                self.stream_file[k] = marshalled[k]\n \n-\tself.stream_have_file_info = True\n+        self.stream_have_file_info = True\n \n     # Stream directly from \"p4 files\" into \"git fast-import\"\n     def streamP4Files(self, files):\n@@ -1052,23 +1050,22 @@ class P4Sync(Command):\n             self.stream_contents = []\n             self.stream_have_file_info = False\n \n-\t    # curry self argument\n-\t    def streamP4FilesCbSelf(entry):\n-\t\tself.streamP4FilesCb(entry)\n+        # curry self argument\n+        def streamP4FilesCbSelf(entry):\n+            self.streamP4FilesCb(entry)\n \n-\t    p4CmdList(\"-x - print\",\n-\t\t'\\n'.join(['%s#%s' % (f['path'], f['rev'])\n-                                                  for f in filesToRead]),\n-\t        cb=streamP4FilesCbSelf)\n+        p4CmdList(\"-x - print\",\n+                  '\\n'.join(['%s#%s' % (f['path'], f['rev']) for f in filesToRead]),\n+                  cb=streamP4FilesCbSelf)\n \n-            # do the last chunk\n-            if self.stream_file.has_key('depotFile'):\n-                self.streamOneP4File(self.stream_file, self.stream_contents)\n+        # do the last chunk\n+        if self.stream_file.has_key('depotFile'):\n+            self.streamOneP4File(self.stream_file, self.stream_contents)\n \n     def commit(self, details, files, branch, branchPrefixes, parent = \"\"):\n         epoch = details[\"time\"]\n         author = details[\"user\"]\n-\tself.branchPrefixes = branchPrefixes\n+        self.branchPrefixes = branchPrefixes\n \n         if self.verbose:\n             print \"commit into %s\" % branch\n@@ -1173,7 +1170,7 @@ class P4Sync(Command):\n \n         s = ''\n         for (key, val) in self.users.items():\n-\t    s += \"%s\\t%s\\n\" % (key.expandtabs(1), val.expandtabs(1))\n+            s += \"%s\\t%s\\n\" % (key.expandtabs(1), val.expandtabs(1))\n \n         open(self.getUserCacheFilename(), \"wb\").write(s)\n         self.userMapFromPerforceServer = True\n-- \n1.7.3.2\n"},{"id":"159395","messageId":"7vsjwy33zn.fsf@alter.siamese.dyndns.org","threadId":"26265","inReplyTo":"1294808703-1848-1-git-send-email-andrew@andrewgarber.com","subject":"Re: [PATCH] git-p4: correct indenting and formatting","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2011-01-12T08:45:00Z","receivedAt":"2011-01-12T08:45:00Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Andrew Garber <andrew@andrewgarber.com> writes:\n\n> - replace tabs with appropriate number of spaces\n> - minor tweaks to code formatting\n> ---\n>  contrib/fast-import/git-p4 |   71 +++++++++++++++++++++-----------------------\n>  1 files changed, 34 insertions(+), 37 deletions(-)\n\nSorry, but in git codebase, tabs are 8-place indent by definition, and I\ndon't see much merit in this patch, other than being religious about\nsomebody else's coding style, which would matter only if we are trying to\nget this included in \"batteries included\" set shipped with Python\ndistribution, perhaps.\n\nA downside is that this patch will make life harder for people with\nprivate patches to git-p4 that they haven't shared with us.\n"},{"id":"159396","messageId":"7vlj2q3339.fsf@alter.siamese.dyndns.org","threadId":"26265","inReplyTo":"7vsjwy33zn.fsf@alter.siamese.dyndns.org","subject":"Re: [PATCH] git-p4: correct indenting and formatting","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2011-01-12T09:04:26Z","receivedAt":"2011-01-12T09:04:26Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Junio C Hamano <gitster@pobox.com> writes:\n\n> Andrew Garber <andrew@andrewgarber.com> writes:\n>\n>> - replace tabs with appropriate number of spaces\n>> - minor tweaks to code formatting\n>> ---\n>>  contrib/fast-import/git-p4 |   71 +++++++++++++++++++++-----------------------\n>>  1 files changed, 34 insertions(+), 37 deletions(-)\n>\n> Sorry, but in git codebase, tabs are 8-place indent by definition, and I\n> don't see much merit in this patch, other than being religious about\n> somebody else's coding style, which would matter only if we are trying to\n> get this included in \"batteries included\" set shipped with Python\n> distribution, perhaps.\n>\n> A downside is that this patch will make life harder for people with\n> private patches to git-p4 that they haven't shared with us.\n\nSorry, I obviously was not paying attention to the patch itself.\n\nThe file already mostly follows the Python convention to use only SP and\nyou are fixing some oddballs that have HT instead of typing 8 SPs out to\nmake things consistent.\n\nI don't see any problem with that kind of change.\n\nWill queue on a separate branch for you, expecting that you are doing this\nin preparation for a new feature or a bugfix to the script.\n\nThanks.\n"},{"id":"159397","messageId":"7vhbde331h.fsf@alter.siamese.dyndns.org","threadId":"26265","inReplyTo":"7vlj2q3339.fsf@alter.siamese.dyndns.org","subject":"Re: [PATCH] git-p4: correct indenting and formatting","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2011-01-12T09:05:30Z","receivedAt":"2011-01-12T09:05:30Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Junio C Hamano <gitster@pobox.com> writes:\n\n> Junio C Hamano <gitster@pobox.com> writes:\n>\n>> Andrew Garber <andrew@andrewgarber.com> writes:\n>>\n>>> - replace tabs with appropriate number of spaces\n>>> - minor tweaks to code formatting\n>>> ---\n>>>  contrib/fast-import/git-p4 |   71 +++++++++++++++++++++-----------------------\n>>>  1 files changed, 34 insertions(+), 37 deletions(-)\n>> ...\n> Will queue on a separate branch for you, expecting that you are doing this\n> in preparation for a new feature or a bugfix to the script.\n\nForgot to say obligatory \"Please sign-off your patch\".  Please do so.\n"},{"id":"159400","messageId":"AANLkTimJOsRd4WcDSJZcehP3nn_rckL4hx4ngt48w9gD@mail.gmail.com","threadId":"26265","inReplyTo":"7vhbde331h.fsf@alter.siamese.dyndns.org","subject":"Re: [PATCH] git-p4: correct indenting and formatting","fromName":"Andrew Garber","fromEmail":"andrew@andrewgarber.com","sentAt":"2011-01-12T09:13:42Z","receivedAt":"2011-01-12T09:13:42Z","isPatch":true,"sender":{"key":"andrew@andrewgarber.com","avatar":"https://avatars.githubusercontent.com/u/265048?v=4"},"body":"Great! Thanks Junio. Sorry about forgetting to sign-off my patch.\n\nOn Wed, Jan 12, 2011 at 1:05 AM, Junio C Hamano <gitster@pobox.com> wrote:\n> Junio C Hamano <gitster@pobox.com> writes:\n>\n>> Junio C Hamano <gitster@pobox.com> writes:\n>>\n>>> Andrew Garber <andrew@andrewgarber.com> writes:\n>>>\n>>>> - replace tabs with appropriate number of spaces\n>>>> - minor tweaks to code formatting\n>>>> ---\n>>>>  contrib/fast-import/git-p4 |   71 +++++++++++++++++++++-----------------------\n>>>>  1 files changed, 34 insertions(+), 37 deletions(-)\n>>> ...\n>> Will queue on a separate branch for you, expecting that you are doing this\n>> in preparation for a new feature or a bugfix to the script.\n>\n> Forgot to say obligatory \"Please sign-off your patch\".  Please do so.\n>\n"}]}