Skip to contentSkip to conversation

gitview 0.3

PATCH New Aneesh Kumar 4 participants 7 messages Jun 15, 2016

lore
Share & tools
lore
#0 lore raw

Attaching below the latest code

Changes from 0.1
* use diff-tree -m to generate the diff with --with-diff option.
* Some code cleanup
* Added --with-diff option
* Fixed typo (Dave Jones)

-aneesh

#1 lore raw

PATCH 1/1 Fix date display

Hello,

Here is a patch that uses the tz info for setting commit dates.

gitview +20 -16
@@ -31,6 +31,7 @@
     have_gtksourceview = False
     print "Running without gtksourceview module"
 
+re_ident = re.compile('(author|committer) (?P<ident>.*) (?P<epoch>\d+) (?P<tz>[+-]\d{4})')
 
 def list_to_string(args, skip):
 	count = len(args)
@@ -43,6 +44,16 @@
 
 	return str_arg
 
+def show_date(epoch, tz):
+	secs = float(epoch)
+	tzsecs = float(tz[1:3]) * 3600
+	tzsecs += float(tz[3:5]) * 60
+	if (tz[0] == "+"):
+		secs += tzsecs
+	else:
+		secs -= tzsecs
+	return time.strftime("%Y-%m-%d %H:%M:%S", time.gmtime(secs))
+
 
 class CellRendererGraph(gtk.GenericCellRenderer):
 	"""Cell renderer for directed graph.
@@ -277,22 +288,15 @@
 			if (m != None):
 				continue
 
-
-			m = re.match("author", line)
-			if (m  != None ):
-				patch_author = re.split(" ", line)	
-				self.author = list_to_string(patch_author[1:-2], 0)
-				self.date = time.strftime("%Y-%m-%d %H:%M:%S",
-						time.gmtime(float(patch_author[-2])))
-				continue
-
-			m = re.match("committer", line)
-			if (m  != None ):
-				patch_committer = re.split(" ", line)	
-				self.committer = list_to_string(patch_committer[1:-2], 0)
-				self.commit_date = time.strftime("%Y-%m-%d %H:%M:%S",
-						time.gmtime(float(patch_committer[-2])))
-				continue
+			m = re_ident.match(line)
+			if (m != None):
+				date = show_date(m.group('epoch'), m.group('tz'))
+				if m.group(1)[0] == 'a':
+					self.author = m.group('ident')
+					self.date = date
+				else:
+					self.committer = m.group('ident')
+					self.commit_date = date
 
 	def get_message(self, with_diff=0):
 		if (with_diff == 1):
Signature · 1 line
Jonas Fonseca
#2 lore raw
In reply to Aneesh Kumar

Nice work for 0.low-number version.

On my notebook, I felt really miserable to see that the middle band taking so much space to show rev committer timestamp and parents. The bottom window starts with the same information repeated (worse, with unreadable timestamp format) and I had to scroll all the way down to view the rest of the commit message.

If you absolutely want the middle band, maybe instead of showing object names in "Parents" "Children" part, you can show the one-line commit logs from them there, and pop-up the object names along with the rest of commit log message as mouse hovers over.

I missed "this commit is branch head of X" and "this commit is tagged with T" markers gitk has.

Needs a bit more compact layout to be useful for me. In short, gitk's display does everything I want it to show in a compact enough way and I think there is no reason not to imitate it.

Do colors of nodes have any significance? I couldn't tell from the UI (and I tried to figure it out without reading code -- otherwise I cannot tell if the choice of colors is intuitive).

It might match more people's expectation if --with-diff were the default.

This patch might make merges easier to read.

-- >8 --
[PATCH] Use "diff-tree -c" to display merges a bit more readably.

gitview +1 -1
@@ -305,7 +305,7 @@
 		return message
 
 	def diff_tree(self):
-		fp = os.popen("git diff-tree --pretty -m -v -p " + " " + self.commit_sha1)
+		fp = os.popen("git diff-tree --pretty -c -v -p " + " " + self.commit_sha1)
 		diff = fp.read()
 		fp.close()
 
#3 lore raw
Quoted 5 lines · Junio C Hamano

Nhe choice of colors is intuitive).

It might match more people's expectation if --with-diff were the default.

Done. I made it to take option --without-diff for guys like me

Quoted 11 lines

This patch might make merges easier to read.

-- >8 --
[PATCH] Use "diff-tree -c" to display merges a bit more readably.

gitview 2006-02-01 21:46:24.000000000 -0800 line 311

Quoted 8 lines
gitview 2006-02-01 21:46:24.000000000 -0800 renamed from gitview 2006-02-01 21:16:43.000000000 -0800 +1 -1
@@ -305,7 +305,7 @@
                return message
 
        def diff_tree(self):
-               fp = os.popen("git diff-tree --pretty -m -v -p " + " " + self.commit_sha1)
+               fp = os.popen("git diff-tree --pretty -c -v -p " + " " + self.commit_sha1)
                diff = fp.read()
                fp.close()
 

I applied this patch . But the problem now is merge commits doesn't show the commit messages. Adding -m also didn't help. Any suggestion

-aneesh

#4 lore raw
In reply to Junio C Hamano
Quoted 7 lines · Junio C Hamano

Nice work for 0.low-number version.

On my notebook, I felt really miserable to see that the middle band taking so much space to show rev committer timestamp and parents. The bottom window starts with the same information repeated (worse, with unreadable timestamp format) and I had to scroll all the way down to view the rest of the commit message.

I have rearranged the default with respect these frames. Attaching the code below. Let me know if it is ok.

Quoted 10 lines

If you absolutely want the middle band, maybe instead of showing object names in "Parents" "Children" part, you can show the one-line commit logs from them there, and pop-up the object names along with the rest of commit log message as mouse hovers over.

I missed "this commit is branch head of X" and "this commit is tagged with T" markers gitk has.

I am planning to add this. I am yet to learn fully how to use the cairo API. gitview was partly my attempt to learn pygtk.

Quoted 4 lines

Needs a bit more compact layout to be useful for me. In short, gitk's display does everything I want it to show in a compact enough way and I think there is no reason not to imitate it.

One thing i didn't like with gitk was the looks. And the diff window was so shaded i had to put real effort to read the contents. May be i didn't had necessary fonts. I don't know

Quoted 4 lines

Do colors of nodes have any significance? I couldn't tell from the UI (and I tried to figure it out without reading code -- otherwise I cannot tell if the choice of colors is intuitive).

One parent of the child follows the same colour. It in a way let one figure out at what point branch happened and at what point they merged back.

Quoted 3 lines

It might match more people's expectation if --with-diff were the default.

This is done. I am attaching the full code below. Can you get the gitview added git repository so that next time onwards i need to send only the diff.

Quoted 11 lines

This patch might make merges easier to read.

-- >8 --
[PATCH] Use "diff-tree -c" to display merges a bit more readably.

gitview 2006-02-01 21:46:24.000000000 -0800 line 311

Quoted 8 lines
gitview 2006-02-01 21:46:24.000000000 -0800 renamed from gitview 2006-02-01 21:16:43.000000000 -0800 +1 -1
@@ -305,7 +305,7 @@
                return message
 
        def diff_tree(self):
-               fp = os.popen("git diff-tree --pretty -m -v -p " + " " + self.commit_sha1)
+               fp = os.popen("git diff-tree --pretty -c -v -p " + " " + self.commit_sha1)
                diff = fp.read()
                fp.close()
 

I am using the --cc flag and if i don't have any message i get the commit message only using git cat-file. I guess that is ok

-aneesh

#5 lore raw
Quoted 2 lines · Aneesh Kumar

... Can you get the gitview added git repository so that next time onwards i need to send only the diff.

We _could_ make a contrib/gitview directory to keep it there, and as somebody else comes up with a new interesting git application, add a new directory in contrib/ to expand that area.

But personally I am not enthused about keeping other peoples' projects in git.git tree [*1*]. I'd rather see you start your own public repository, propagate your changes from there, and run it as your own project.

Even though it is currently a single file 'project', you will want to add more stuff, maybe splitting the code to use your own *.py module to import into the main program, and add *.c files to interface with the lower level and Makefile to describe the build rules once we start libifying git. I suspect we are all better off if we keep separate projects separate in the long run.

Somebody (I think it was Sean Estabrooks but I may be mistaken) once offered to host git projects at a site he controls. I wonder if you can get him interested...

[Footnote]

*1* I was not too happy to see gitk merged in with "the coolest merge ever" myself, but that was done before my time. "Not too happy" does not necessarily mean I object to it. All things considered I think it was a good thing: (1) as a showcase of how cool a merge can be, it was a good demonstration; (2) coming with a repository browser usable out-of-box with minimum dependencies was a good thing (tcl/tk is pretty much available universally for easy install); (3) it is a good example program of how a repository browser can be done.

#6 lore raw
Quoted 5 lines · Junio C Hamano

Somebody (I think it was Sean Estabrooks but I may be mistaken) once offered to host git projects at a site he controls. I wonder if you can get him interested...

I've got space for this. If anyone's interested, send me an email off-list.

Signature · 3 lines
Andreas Ericsson                   [email protected]
OP5 AB                             www.op5.se
Tel: +46 8-230225                  Fax: +46 8-230231