# HG changeset patch
# User Stefan Haller <[email protected]>
# Date 1275774340 -7200
# Node ID b0cee21d853aa4865e4da73fcc3d12a08caec059
# Parent d8ebf2aeff32ef17675f8cf4ed5d25f17c7bd40f
annotate: provide Annotate 1st/2nd Parent for merges
Also, don't show the "Annotate Parent" menu item at all when there is no parent.
diff -r d8ebf2aeff32 -r b0cee21d853a tortoisehg/hgtk/datamine.py
--- a/tortoisehg/hgtk/datamine.py Sat Jun 05 23:34:16 2010 +0200
+++ b/tortoisehg/hgtk/datamine.py Sat Jun 05 23:45:40 2010 +0200
@@ -162,8 +162,21 @@
args=[objs])
m.append(_('Di_splay Change'), self.cmenu_display,
'menushowchanged.ico')
- m.append(_('_Annotate Parent'), self.cmenu_annotate_parent,
- 'menublame.ico', args=[objs])
+ (frame, treeview, filepath, graphview) = objs
+ path = graphview.get_path_at_revid(int(self.currev))
+ filepath = graphview.get_wfile_at_path(path)
+ ctx = self.repo[self.currev]
+ fctx = ctx.filectx(filepath)
+ parents = fctx.parents()
+ if len(parents) > 0:
+ if len(parents) == 1:
+ m.append(_('_Annotate Parent'), self.cmenu_annotate_1st_parent,
+ 'menublame.ico', args=[objs])
+ else:
+ m.append(_('_Annotate First Parent'),
self.cmenu_annotate_1st_parent,
+ 'menublame.ico', args=[objs])
+ m.append(_('Annotate Second Parent'),
self.cmenu_annotate_2nd_parent,
+ 'menublame.ico', args=[objs])
m.append(_('_View File at Revision'), self.cmenu_view, gtk.STOCK_EDIT)
m.append(_('_File History'), self.cmenu_file_log, 'menulog.ico')
m.append(_('_Diff to Local'), self.cmenu_local_diff)
@@ -188,20 +201,20 @@
def cmenu_annotate(self, menuitem):
self.add_annotate_page(self.curpath, self.currev)
- def cmenu_annotate_parent(self, menuitem, objs):
- def error_prompt():
- gdialog.Prompt(_('No parent file'),
- _('Unable to annotate'), self).run()
- return False
+ def cmenu_annotate_1st_parent(self, menuitem, objs):
+ self.annotate_parent(objs, 0)
+
+ def cmenu_annotate_2nd_parent(self, menuitem, objs):
+ self.annotate_parent(objs, 1)
+
+ def annotate_parent(self, objs, parent_idx):
(frame, treeview, filepath, graphview) = objs
path = graphview.get_path_at_revid(int(self.currev))
filepath = graphview.get_wfile_at_path(path)
ctx = self.repo[self.currev]
fctx = ctx.filectx(filepath)
parents = fctx.parents()
- if len(parents) == 0:
- return error_prompt()
- parent_fctx = parents[0]
+ parent_fctx = parents[parent_idx]
parent_revid = parent_fctx.changectx().rev()
filepath = parent_fctx.path()
# annotate file of parent rev
------------------------------------------------------------------------------
ThinkGeek and WIRED's GeekDad team up for the Ultimate
GeekDad Father's Day Giveaway. ONE MASSIVE PRIZE to the
lucky parental unit. See the prize list and enter to win:
http://p.sf.net/sfu/thinkgeek-promo
_______________________________________________
Tortoisehg-develop mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/tortoisehg-develop