# HG changeset patch
# User Alain Leufroy <alain.leufroy@logilab.fr>
# Date 1338536131 -7200
# Fri Jun 01 09:35:31 2012 +0200
# Node ID df0bd07d63bccc087f563cf6e29a4918caa554b5
# Parent fb5ee4cf21dd7180aef991858bf2919e19781d9b
[tui] enable "reselect currently visited rev and file on reload" (closes #93653)
RepoViewer is now reponsible for the graph refreshing as manifest must be
refreshed after the graph.
# User Alain Leufroy <alain.leufroy@logilab.fr>
# Date 1338536131 -7200
# Fri Jun 01 09:35:31 2012 +0200
# Node ID df0bd07d63bccc087f563cf6e29a4918caa554b5
# Parent fb5ee4cf21dd7180aef991858bf2919e19781d9b
[tui] enable "reselect currently visited rev and file on reload" (closes #93653)
RepoViewer is now reponsible for the graph refreshing as manifest must be
refreshed after the graph.
@@ -71,23 +71,15 @@
1 self.asciistate = [0, 0] # graphlog.asciistate() 2 3 def connect_commands(self): 4 """Connect usefull commands to callbacks""" 5 connect_command('goto', self.set_rev) 6 - connect_command('refresh', self.refresh) 7 8 def _modified(self): 9 """obsolete widget content""" 10 super(RevisionsWalker, self)._modified() 11 12 - def refresh(self): 13 - """refresh widget content""" 14 - self._invalidate() 15 - self.walker.setRepo() 16 - emit_signal(self, 'focus changed', self.get_ctx()) 17 - self._modified() 18 - 19 def _invalidate(self): 20 """obsolete rendering cache""" 21 self._data_cache.clear() 22 super(RevisionsWalker, self)._modified() 23
@@ -286,10 +286,11 @@
24 25 def __init__(self, repo, *args, **kwargs): 26 self.repo = repo 27 self.cfg = HgConfig(repo.ui) 28 self._show_context = 0 # O:hide, 1:half, 2:maximized 29 + self.refreshing = False # flag to now if the repo is refreshing 30 31 walker = HgRepoListWalker(repo) 32 self.graphlog = GraphlogViewer(walker=walker) 33 self.context = ContextViewer(walker=walker) 34
@@ -300,11 +301,11 @@
35 if self.cfg.getContentAtStartUp(): 36 self.show_context() 37 38 def update_context(self, ctx): 39 """Change the current displayed context""" 40 - self.context.manifest_walker.ctx = ctx 41 + self.context.manifest_walker.set_ctx(ctx, reset_focus=(not self.refreshing)) 42 43 def register_commands(self): 44 """Register commands and commands of bodies""" 45 register_command('hide-context', 'Hide context pane.') 46 register_command('show-context', 'Show context pane.',
@@ -313,15 +314,30 @@
47 register_command('maximize-context', 'Maximize context pane.') 48 self.graphlog.register_commands() 49 connect_command('hide-context', self.hide_context) 50 connect_command('show-context', self.show_context) 51 connect_command('maximize-context', self.maximize_context) 52 + connect_command('refresh', self.refresh) 53 54 def unregister_commands(self): 55 """Unregister commands and commands of bodies""" 56 self.graphlog.unregister_commands() 57 58 + def refresh(self): 59 + graphlog_walker = self.graphlog.graphlog_walker 60 + manifest_walker = self.context.manifest_walker 61 + self.refreshing = True 62 + rev = graphlog_walker.rev 63 + filename = manifest_walker.filename 64 + self._walker.setRepo() 65 + try: 66 + graphlog_walker.set_rev(rev) # => focus changed => update_context 67 + except AttributeError: # rev stripped 68 + graphlog_walker.rev = None 69 + manifest_walker.filename = filename 70 + self.refreshing = False 71 + 72 def hide_context(self): 73 ''' hide the context widget''' 74 if self._show_context == 0: # already hidden 75 return 76 self._deactivate_context()
@@ -59,27 +59,31 @@
77 if self._focus < 0: 78 return 79 return self._files[self._focus] 80 def set_filename(self, filename): 81 """change focus element by giving the corresponding file name""" 82 - focus = self._files.index(filename) 83 + try: 84 + focus = self._files.index(filename) 85 + except ValueError: # focus on description 86 + focus = -1 87 self.set_focus(focus) 88 filename = property(get_filename, set_filename, None, 89 'File name under focus.') 90 91 def __len__(self): 92 return len(self._files) 93 94 def get_ctx(self): 95 """Return the current context""" 96 return self._ctx 97 - def set_ctx(self, ctx): 98 + def set_ctx(self, ctx, reset_focus=True): 99 """set the curreont context (obsolete the content)""" 100 self._cached_flags.clear() 101 self._ctx = ctx 102 self._files = tuple(self._ctx.files()) 103 - del self.focus 104 + if reset_focus: 105 + del self.focus 106 self._modified() 107 ctx = property(get_ctx, set_ctx, None, 'Current changeset context') 108 109 def get_focus(self): 110 """return (focused widget, position)"""