From: "Aneesh Kumar K.V" <aneesh.kumar@gmail.com>
To: git@vger.kernel.org, Junio C Hamano <junkio@cox.net>
Subject: gitview: Code cleanup
Date: Fri, 24 Feb 2006 21:49:54 +0530 [thread overview]
Message-ID: <43FF322A.5020809@gmail.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 0 bytes --]
[-- Attachment #2: 0004-gitview-Code-cleanup.txt --]
[-- Type: text/plain, Size: 3109 bytes --]
Subject: gitview: Code cleanup
Rearrange the code little bit so that it is easier to read
Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@gmail.com>
---
contrib/gitview/gitview | 50 +++++++++++++++++++++--------------------------
1 files changed, 22 insertions(+), 28 deletions(-)
1dd075c97bae172d0c1b6f31897fec962217aab2
diff --git a/contrib/gitview/gitview b/contrib/gitview/gitview
index 02e2445..2cde71e 100755
--- a/contrib/gitview/gitview
+++ b/contrib/gitview/gitview
@@ -870,21 +870,22 @@ class GitView:
# Reset nodepostion
if (last_nodepos > 5):
- last_nodepos = 0
+ last_nodepos = -1
# Add the incomplete lines of the last cell in this
try:
colour = self.colours[commit.commit_sha1]
except KeyError:
- last_colour +=1
- self.colours[commit.commit_sha1] = last_colour
- colour = last_colour
+ self.colours[commit.commit_sha1] = last_colour+1
+ last_colour = self.colours[commit.commit_sha1]
+ colour = self.colours[commit.commit_sha1]
+
try:
node_pos = self.nodepos[commit.commit_sha1]
except KeyError:
- last_nodepos +=1
- self.nodepos[commit.commit_sha1] = last_nodepos
- node_pos = last_nodepos
+ self.nodepos[commit.commit_sha1] = last_nodepos+1
+ last_nodepos = self.nodepos[commit.commit_sha1]
+ node_pos = self.nodepos[commit.commit_sha1]
#The first parent always continue on the same line
try:
@@ -895,32 +896,25 @@ class GitView:
self.nodepos[commit.parent_sha1[0]] = node_pos
for sha1 in self.incomplete_line.keys():
- if ( sha1 != commit.commit_sha1):
+ if (sha1 != commit.commit_sha1):
self.draw_incomplete_line(sha1, node_pos,
out_line, in_line, index)
else:
del self.incomplete_line[sha1]
- in_line.append((node_pos, self.nodepos[commit.parent_sha1[0]],
- self.colours[commit.parent_sha1[0]]))
-
- self.add_incomplete_line(commit.parent_sha1[0], index+1)
-
- if (len(commit.parent_sha1) > 1):
- for parent_id in commit.parent_sha1[1:]:
- try:
- tmp_node_pos = self.nodepos[parent_id]
- except KeyError:
- last_colour += 1;
- self.colours[parent_id] = last_colour
- last_nodepos +=1
- self.nodepos[parent_id] = last_nodepos
-
- in_line.append((node_pos, self.nodepos[parent_id],
- self.colours[parent_id]))
- self.add_incomplete_line(parent_id, index+1)
-
+ for parent_id in commit.parent_sha1:
+ try:
+ tmp_node_pos = self.nodepos[parent_id]
+ except KeyError:
+ self.colours[parent_id] = last_colour+1
+ last_colour = self.colours[parent_id]
+ self.nodepos[parent_id] = last_nodepos+1
+ last_nodepos = self.nodepos[parent_id]
+
+ in_line.append((node_pos, self.nodepos[parent_id],
+ self.colours[parent_id]))
+ self.add_incomplete_line(parent_id)
try:
branch_tag = self.bt_sha1[commit.commit_sha1]
@@ -935,7 +929,7 @@ class GitView:
return (in_line, last_colour, last_nodepos)
- def add_incomplete_line(self, sha1, index):
+ def add_incomplete_line(self, sha1):
try:
self.incomplete_line[sha1].append(self.nodepos[sha1])
except KeyError:
--
1.2.3.g2cf3-dirty
reply other threads:[~2006-02-24 16:20 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=43FF322A.5020809@gmail.com \
--to=aneesh.kumar@gmail.com \
--cc=git@vger.kernel.org \
--cc=junkio@cox.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).