| 
				
			 | 
			
			
				@@ -25,7 +25,6 @@ if sys.hexversion < 0x02050000: 
			 | 
		
	
		
			
			| 
				25
			 | 
			
				25
			 | 
			
			
				     raise SystemExit("*** Requires python >= 2.5.0") 
			 | 
		
	
		
			
			| 
				26
			 | 
			
				26
			 | 
			
			
				 IS_PY3 = sys.hexversion >= 0x03000000 
			 | 
		
	
		
			
			| 
				27
			 | 
			
				27
			 | 
			
			
				  
			 | 
		
	
		
			
			| 
				28
			 | 
			
				
			 | 
			
			
				-import os 
			 | 
		
	
		
			
			| 
				29
			 | 
			
				28
			 | 
			
			
				 import re 
			 | 
		
	
		
			
			| 
				30
			 | 
			
				29
			 | 
			
			
				 import subprocess 
			 | 
		
	
		
			
			| 
				31
			 | 
			
				30
			 | 
			
			
				 import errno 
			 | 
		
	
	
		
			
			| 
				
			 | 
			
			
				@@ -53,9 +52,9 @@ COLORS = { 
			 | 
		
	
		
			
			| 
				53
			 | 
			
				52
			 | 
			
			
				  
			 | 
		
	
		
			
			| 
				54
			 | 
			
				53
			 | 
			
			
				 # Keys for checking and values for diffing. 
			 | 
		
	
		
			
			| 
				55
			 | 
			
				54
			 | 
			
			
				 REVISION_CONTROL = ( 
			 | 
		
	
		
			
			| 
				56
			 | 
			
				
			 | 
			
			
				-    (['git', 'rev-parse'], ['git', 'diff']), 
			 | 
		
	
		
			
			| 
				57
			 | 
			
				
			 | 
			
			
				-    (['svn', 'info'], ['svn', 'diff']), 
			 | 
		
	
		
			
			| 
				58
			 | 
			
				
			 | 
			
			
				-    (['hg', 'summary'], ['hg', 'diff']) 
			 | 
		
	
		
			
			| 
				
			 | 
			
				55
			 | 
			
			
				+    (['git', 'rev-parse'], ['git', 'diff'], ['git', 'log', '--patch']), 
			 | 
		
	
		
			
			| 
				
			 | 
			
				56
			 | 
			
			
				+    (['svn', 'info'],      ['svn', 'diff'], ['svn', 'log', '--diff']), 
			 | 
		
	
		
			
			| 
				
			 | 
			
				57
			 | 
			
			
				+    (['hg',  'summary'],   ['hg',  'diff'], ['hg',  'log', '--patch']) 
			 | 
		
	
		
			
			| 
				59
			 | 
			
				58
			 | 
			
			
				 ) 
			 | 
		
	
		
			
			| 
				60
			 | 
			
				59
			 | 
			
			
				  
			 | 
		
	
		
			
			| 
				61
			 | 
			
				60
			 | 
			
			
				  
			 | 
		
	
	
		
			
			| 
				
			 | 
			
			
				@@ -555,11 +554,18 @@ def check_command_status(arguments): 
			 | 
		
	
		
			
			| 
				555
			 | 
			
				554
			 | 
			
			
				  
			 | 
		
	
		
			
			| 
				556
			 | 
			
				555
			 | 
			
			
				 def revision_control_diff(): 
			 | 
		
	
		
			
			| 
				557
			 | 
			
				556
			 | 
			
			
				     """Return diff from revision control system.""" 
			 | 
		
	
		
			
			| 
				558
			 | 
			
				
			 | 
			
			
				-    for check, diff in REVISION_CONTROL: 
			 | 
		
	
		
			
			| 
				
			 | 
			
				557
			 | 
			
			
				+    for check, diff, _ in REVISION_CONTROL: 
			 | 
		
	
		
			
			| 
				559
			 | 
			
				558
			 | 
			
			
				         if check_command_status(check): 
			 | 
		
	
		
			
			| 
				560
			 | 
			
				559
			 | 
			
			
				             return subprocess.Popen(diff, stdout=subprocess.PIPE).stdout 
			 | 
		
	
		
			
			| 
				561
			 | 
			
				560
			 | 
			
			
				  
			 | 
		
	
		
			
			| 
				562
			 | 
			
				561
			 | 
			
			
				  
			 | 
		
	
		
			
			| 
				
			 | 
			
				562
			 | 
			
			
				+def revision_control_log(): 
			 | 
		
	
		
			
			| 
				
			 | 
			
				563
			 | 
			
			
				+    """Return log from revision control system.""" 
			 | 
		
	
		
			
			| 
				
			 | 
			
				564
			 | 
			
			
				+    for check, _, log in REVISION_CONTROL: 
			 | 
		
	
		
			
			| 
				
			 | 
			
				565
			 | 
			
			
				+        if check_command_status(check): 
			 | 
		
	
		
			
			| 
				
			 | 
			
				566
			 | 
			
			
				+            return subprocess.Popen(log, stdout=subprocess.PIPE).stdout 
			 | 
		
	
		
			
			| 
				
			 | 
			
				567
			 | 
			
			
				+ 
			 | 
		
	
		
			
			| 
				
			 | 
			
				568
			 | 
			
			
				+ 
			 | 
		
	
		
			
			| 
				563
			 | 
			
				569
			 | 
			
			
				 def decode(line): 
			 | 
		
	
		
			
			| 
				564
			 | 
			
				570
			 | 
			
			
				     """Decode UTF-8 if necessary.""" 
			 | 
		
	
		
			
			| 
				565
			 | 
			
				571
			 | 
			
			
				     try: 
			 | 
		
	
	
		
			
			| 
				
			 | 
			
			
				@@ -571,7 +577,7 @@ def decode(line): 
			 | 
		
	
		
			
			| 
				571
			 | 
			
				577
			 | 
			
			
				 def main(): 
			 | 
		
	
		
			
			| 
				572
			 | 
			
				578
			 | 
			
			
				     import optparse 
			 | 
		
	
		
			
			| 
				573
			 | 
			
				579
			 | 
			
			
				  
			 | 
		
	
		
			
			| 
				574
			 | 
			
				
			 | 
			
			
				-    supported_vcs = [check[0] for check, _ in REVISION_CONTROL] 
			 | 
		
	
		
			
			| 
				
			 | 
			
				580
			 | 
			
			
				+    supported_vcs = [check[0][0] for check in REVISION_CONTROL] 
			 | 
		
	
		
			
			| 
				575
			 | 
			
				581
			 | 
			
			
				  
			 | 
		
	
		
			
			| 
				576
			 | 
			
				582
			 | 
			
			
				     usage = """ 
			 | 
		
	
		
			
			| 
				577
			 | 
			
				583
			 | 
			
			
				   %prog [options] 
			 | 
		
	
	
		
			
			| 
				
			 | 
			
			
				@@ -586,9 +592,18 @@ def main(): 
			 | 
		
	
		
			
			| 
				586
			 | 
			
				592
			 | 
			
			
				             help='show in side-by-side mode') 
			 | 
		
	
		
			
			| 
				587
			 | 
			
				593
			 | 
			
			
				     parser.add_option('-w', '--width', type='int', default=80, metavar='N', 
			 | 
		
	
		
			
			| 
				588
			 | 
			
				594
			 | 
			
			
				             help='set text width (side-by-side mode only), default is 80') 
			 | 
		
	
		
			
			| 
				
			 | 
			
				595
			 | 
			
			
				+    parser.add_option('-l', '--log', action='store_true', 
			 | 
		
	
		
			
			| 
				
			 | 
			
				596
			 | 
			
			
				+                      help='show log from revision control (git, svn, hg)') 
			 | 
		
	
		
			
			| 
				589
			 | 
			
				597
			 | 
			
			
				     opts, args = parser.parse_args() 
			 | 
		
	
		
			
			| 
				590
			 | 
			
				598
			 | 
			
			
				  
			 | 
		
	
		
			
			| 
				591
			 | 
			
				
			 | 
			
			
				-    if len(args) > 2: 
			 | 
		
	
		
			
			| 
				
			 | 
			
				599
			 | 
			
			
				+    if opts.log: 
			 | 
		
	
		
			
			| 
				
			 | 
			
				600
			 | 
			
			
				+        diff_hdl = revision_control_log() 
			 | 
		
	
		
			
			| 
				
			 | 
			
				601
			 | 
			
			
				+        if not diff_hdl: 
			 | 
		
	
		
			
			| 
				
			 | 
			
				602
			 | 
			
			
				+            sys.stderr.write(('*** Not in a supported workspace, supported ' 
			 | 
		
	
		
			
			| 
				
			 | 
			
				603
			 | 
			
			
				+                              'are: %s\n\n') % ', '.join(supported_vcs)) 
			 | 
		
	
		
			
			| 
				
			 | 
			
				604
			 | 
			
			
				+            parser.print_help() 
			 | 
		
	
		
			
			| 
				
			 | 
			
				605
			 | 
			
			
				+            return 1 
			 | 
		
	
		
			
			| 
				
			 | 
			
				606
			 | 
			
			
				+    elif len(args) > 2: 
			 | 
		
	
		
			
			| 
				592
			 | 
			
				607
			 | 
			
			
				         parser.print_help() 
			 | 
		
	
		
			
			| 
				593
			 | 
			
				608
			 | 
			
			
				         return 1 
			 | 
		
	
		
			
			| 
				594
			 | 
			
				609
			 | 
			
			
				     elif len(args) == 2: 
			 |