filedialogs.py:
fileview.py
def displayFile(self, filename=None, status=None, force=False, line=0):
if isinstance(filename, (unicode, QString)):
filename = hglib.fromunicode(filename)
status = hglib.fromunicode(status)
if filename and self._filename == filename:
# Get the last visible line to restore it after reloading the editor
lastCursorPosition = self.sci.getCursorPosition()
lastScrollPosition = self.sci.firstVisibleLine()
else:
lastCursorPosition = (0, 0)
lastScrollPosition = 0
self._filename, self._status = filename, status
self.clearMarkup()
self._diffs = []
if filename is None:
self.restrictModes(False, False, False)
return
if self._ctx2:
ctx2 = self._ctx2
elif self._parent == 0 or len(self._ctx.parents()) == 1:
ctx2 = self._ctx.p1()
else:
ctx2 = self._ctx.p2()
fd = filedata.FileData(self._ctx, ctx2, filename, status, self.changeselection, force=force)
if fd.elabel:
self.extralabel.setText(fd.elabel)
self.extralabel.show()
else:
self.extralabel.hide()
self.filenamelabel.setText(fd.flabel)
uf = hglib.tounicode(filename)
if not fd.isValid():
self.sci.setText(fd.error)
self.sci.setLexer(None)
self.sci.setFont(qtlib.getfont('fontlog').font())
self.sci.setMarginWidth(1, 0)
self.blk.setVisible(False)
self.restrictModes(False, False, False)
self.newChunkList.emit(uf, None)
forcedisplaymsg = filedata.forcedisplaymsg
linkstart = fd.error.find(forcedisplaymsg)
if linkstart >= 0:
# add the link to force to view the data anyway
self._setupForceViewIndicator()
self.sci.fillIndicatorRange(
0, linkstart, 0, linkstart+len(forcedisplaymsg), self._forceviewindicator)
return
candiff = bool(fd.diff)
canfile = bool(fd.contents or fd.ucontents)
canann = bool(fd.contents) and type(self._ctx.rev()) is int
if not candiff or not canfile:
self.restrictModes(candiff, canfile, canann)
else:
self.actionDiffMode.setEnabled(True)
self.actionFileMode.setEnabled(True)
self.actionAnnMode.setEnabled(True)
if self._lostMode:
self._mode = self._lostMode
if self._lostMode == DiffMode:
self.actionDiffMode.trigger()
elif self._lostMode == FileMode:
self.actionFileMode.trigger()
elif self._lostMode == AnnMode:
self.actionAnnMode.trigger()
self._lostMode = None
self.blk.setVisible(self._mode != DiffMode)
self.sci.setAnnotationEnabled(self._mode == AnnMode)
if self._mode == DiffMode:
self.sci.setMarginWidth(1, 0)
lexer = lexers.difflexer(self)
self.sci.setLexer(lexer)
if lexer is None:
self.sci.setFont(qtlib.getfont('fontlog').font())
if fd.changes:
self._showChangeSelectMargin(True)
self.changes = fd.changes
self.sci.setText(hglib.tounicode(fd.diff))
for chunk in self.changes.hunks:
self.chunkatline[chunk.lineno] = chunk
self.sci.markerAdd(chunk.lineno, self.inclmarker)
elif fd.diff:
out = fd.diff.split('\n', 3)
if len(out) == 4:
self.sci.setText(hglib.tounicode(out[3]))
else:
# there was an error or rename without diffs
self.sci.setText(hglib.tounicode(fd.diff))
self.newChunkList.emit(uf, fd.changes)
elif fd.ucontents:
# subrepo summary and perhaps other data
self.sci.setText(fd.ucontents)
self.sci.setLexer(None)
self.sci.setFont(qtlib.getfont('fontlog').font())
self.sci.setMarginWidth(1, 0)
self.blk.setVisible(False)
self.newChunkList.emit(uf, None)
return
elif fd.contents:
lexer = lexers.getlexer(self.repo.ui, filename, fd.contents, self)
self.sci.setLexer(lexer)
if lexer is None:
self.sci.setFont(qtlib.getfont('fontlog').font())
self.sci.setText(hglib.tounicode(fd.contents))
self.blk.setVisible(True)
self.sci._updatemarginwidth()
if self._mode == AnnMode:
self.sci._updateannotation(self._ctx, filename)
self.newChunkList.emit(uf, None)
else:
self.newChunkList.emit(uf, None)
return
# Recover the last cursor/scroll position
self.sci.setCursorPosition(*lastCursorPosition)
# Make sure that lastScrollPosition never exceeds the amount of
# lines on the editor
lastScrollPosition = min(lastScrollPosition, self.sci.lines() - 1)
self.sci.verticalScrollBar().setValue(lastScrollPosition)
self.highlightText(*self._lastSearch)
uc = hglib.tounicode(fd.contents) or ''
self.fileDisplayed.emit(uf, uc)
if self._mode != DiffMode:
self.blk.setVisible(True)
self.blk.syncPageStep()
self.blksearch.syncPageStep()
if fd.contents and fd.olddata:
if self.timer.isActive():
self.timer.stop()
self._fd = fd
self.timer.start()
self.actionNextDiff.setEnabled(bool(self._diffs))
self.actionPrevDiff.setEnabled(bool(self._diffs))
lexer = self.sci.lexer()
if lexer:
font = self.sci.lexer().font(0)
else:
font = self.sci.font()
fm = QFontMetrics(font)
self.maxWidth = fm.maxWidth()
lines = unicode(self.sci.text()).splitlines()
if lines:
# assume that the longest line has the largest width;
# fm.width() is too slow to apply to each line.
try:
longestline = max(lines, key=len)
except TypeError: # Python<2.5 has no key support
longestline = max((len(l), l) for l in lines)[1]
self.maxWidth += fm.width(longestline)
self.updateScrollBar()
if line:
self.showLine(line)
self.sci.setFocus()
self.sci.revisionInfoAtLine(line)
class AnnotateView(qscilib.Scintilla):
'QScintilla widget capable of displaying annotations'
def revisionInfoAtLine(self, line): # retrieves line revision details and put them into the clipboard
if line < 0:
return
(not self._links and self.fillModel())
try:
fctx = self._links[line][0]
s = hglib.get_revision_desc(fctx, self.annfile)
#QMessageBox.about(None, 'Active row annotation', s)
QApplication.clipboard().setText(s)
except IndexError:
pass
workbench.py
def run(ui, *pats, **opts):
root = opts.get('root') or paths.find_root()
line = opts.get('line') and int(opts['line']) or None
annotate = True if line and int(line) > 0 else False
if root and pats:
repo = thgrepo.repository(ui, root)
pats = hglib.canonpaths(pats)
if len(pats) == 1 and os.path.isfile(repo.wjoin(pats[0])):
from tortoisehg.hgqt.filedialogs import FileLogDialog
fname = pats[0]
return FileLogDialog(repo, fname, line=line, annotate=annotate)
run.py
@command('^log|history|explorer|workbench',
[('l', 'limit', '', _('(DEPRECATED)')),
('n', 'line', '', _('open to line'))],
_('thg log [OPTIONS] [FILE]'))
def log(ui, *pats, **opts):
"""workbench application"""
from tortoisehg.hgqt.workbench import run
return qtrun(run, ui, *pats, **opts)
Best Regards,
Artem
--
You received this message because you are subscribed to a topic in the Google Groups "TortoiseHg Developers" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/thg-dev/Zo-6OQ6wa2M/unsubscribe?hl=en.
To unsubscribe from this group and all its topics, send an email to thg-dev+u...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.