Kiln » TortoiseHg » TortoiseHg
Clone URL:  
Pushed to one repository · View In Graph Contained in 2.0.3, 2.0.4, and 2.0.5

stable revdetails: Show modified subrepos on revision details panel

This change adds some basic support for showing modified subrepos on the
revision details.
Current limitations are:
- Due to a lack of subrepo specific icon, I am using the "hg" icon to represent
modified subrepos on the file list. This only makes sense for hg subrepos though
- It can only preview mercurial subrepos
- Behaviour for merge revisions is probably not perfect
- The "open..." link does not work. This is surprising since the code that is
used to generate the link (and the link contents) is exactly the same that is
used to generate the link on the status widget. I assume that the status and
revision details panels behave differently on this regard.

Changeset 30e0273a0503

Parent 97af7374008c

by Angel Ezquerra

Changes to 2 files · Browse files at 30e0273a0503 Showing diff from parent 97af7374008c Diff from another changeset...

 
14
15
16
17
 
18
19
20
 
116
117
118
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
119
120
121
 
163
164
165
 
 
166
167
168
 
14
15
16
 
17
18
19
20
 
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
 
178
179
180
181
182
183
184
185
@@ -14,7 +14,7 @@
 # this program; if not, write to the Free Software Foundation, Inc.,  # 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.   -from tortoisehg.util import hglib +from tortoisehg.util import hglib, patchctx    from tortoisehg.hgqt.qtlib import geticon   @@ -116,6 +116,21 @@
  ctxfiles = self._ctx.files()   modified, added, removed = self._ctx.changesToParent(parent)   ismerge = bool(self._ctx.p2()) + + # Add the list of modified subrepos to the top of the list + if not isinstance(self._ctx, patchctx.patchctx): + from mercurial import subrepo + for s, sd in self._ctx.substate.items(): + srev = self._ctx.substate.get(s, subrepo.nullstate)[1] + sp1rev = self._ctx.p1().substate.get(s, subrepo.nullstate)[1] + sp2rev = '' + if ismerge: + sp2rev = self._ctx.p2().substate.get(s, subrepo.nullstate)[1] + if srev != sp1rev or (sp2rev != '' and srev != sp2rev): + wasmerged = ismerge and s in ctxfiles + files.append({'path': s, 'status': 'S', 'parent': parent, + 'wasmerged': wasmerged}) +   if self._fulllist and ismerge:   func = lambda x: True   else: @@ -163,6 +178,8 @@
  return QVariant(geticon('fileadd'))   elif current_file_desc['status'] == 'R':   return QVariant(geticon('filedelete')) + elif current_file_desc['status'] == 'S': + return QVariant(geticon('hg'))   #else:   # return QVariant(geticon('filemodify'))   elif role == Qt.FontRole:
 
605
606
607
608
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
609
610
611
 
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
639
640
 
641
642
643
 
605
606
607
 
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
 
641
642
643
 
 
 
 
 
 
 
 
 
 
 
 
 
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
 
666
667
668
669
@@ -605,7 +605,25 @@
  if status == 'S':   try:   from mercurial import subrepo, commands - assert(ctx.rev() is None) + + def genSubrepoRevChangedDescription(sfrom, sto): + """Generate a subrepository revision change description""" + out = [] + opts = {'date':None, 'user':None, 'rev':[sfrom]} + if not sfrom: + out.append(_('Subrepo initialized to revision:') + u'\n\n') + else: + out.append(_('Revision has changed from:') + u'\n\n') + _ui.pushbuffer() + commands.log(_ui, srepo, **opts) + out.append(hglib.tounicode(_ui.popbuffer())) + out.append(_('To:') + u'\n') + opts['rev'] = [sto] + _ui.pushbuffer() + commands.log(_ui, srepo, **opts) + out.append(hglib.tounicode(_ui.popbuffer())) + return out +   srev = ctx.substate.get(wfile, subrepo.nullstate)[1]   sub = ctx.sub(wfile)   if isinstance(sub, subrepo.hgsubrepo): @@ -623,21 +641,29 @@
  out.append(_('File Status:') + u'\n')   out.append(hglib.tounicode(data))   out.append(u'\n') - if srev == '': - out.append(_('New subrepository') + u'\n\n') - elif srev != sactual: - out.append(_('Revision has changed from:') + u'\n\n') - opts = {'date':None, 'user':None, 'rev':[srev]} - _ui.pushbuffer() - commands.log(_ui, srepo, **opts) - out.append(hglib.tounicode(_ui.popbuffer())) - out.append(_('To:') + u'\n') - opts['rev'] = [sactual] - _ui.pushbuffer() - commands.log(_ui, srepo, **opts) - out.append(hglib.tounicode(_ui.popbuffer())) + sstatedesc = 'changed' + if ctx.rev() is not None: + sparent = ctx.p1().substate.get(wfile, subrepo.nullstate)[1] + out += genSubrepoRevChangedDescription(sparent, srev) + else: + sstatedesc = 'dirty' + if srev == '': + sstatedesc = 'new' + out.append(_('New subrepository') + u'\n\n') + elif srev != sactual: + sstatedesc = 'changed' + out.append(_('Revision has changed from:') + u'\n\n') + opts = {'date':None, 'user':None, 'rev':[srev]} + _ui.pushbuffer() + commands.log(_ui, srepo, **opts) + out.append(hglib.tounicode(_ui.popbuffer())) + out.append(_('To:') + u'\n') + opts['rev'] = [sactual] + _ui.pushbuffer() + commands.log(_ui, srepo, **opts) + out.append(hglib.tounicode(_ui.popbuffer()))   self.contents = u''.join(out) - self.flabel += _(' <i>(is a dirty sub-repository)</i>') + self.flabel += _(' <i>(is a %s sub-repository)</i>' % sstatedesc)   lbl = u' <a href="subrepo:%s">%s...</a>'   self.flabel += lbl % (hglib.tounicode(srepo.root), _('open'))   except (EnvironmentError, error.RepoError, util.Abort), e: