Staging
v0.5.1
https://foss.heptapod.net/mercurial/hgview
Revision 30365b5b6264602c7f9da3e801ff2a3fc1acbec5 authored by David Douard on 16 November 2009, 22:36:46 UTC, committed by David Douard on 16 November 2009, 22:36:46 UTC
It does not make use of QTimer based filling process when asking to go directly to a given revision. This makes the QListView behave much more correctly.
1 parent 5f6f19f
Raw File
Tip revision: 30365b5b6264602c7f9da3e801ff2a3fc1acbec5 authored by David Douard on 16 November 2009, 22:36:46 UTC
Refactored the way graph filling is done
Tip revision: 30365b5
util.py
# -*- coding: utf-8 -*-
# util functions
#
# Copyright (C) 2009 Logilab. All rights reserved.
#
# This software may be used and distributed according to the terms
# of the GNU General Public License, incorporated herein by reference.
"""
Several helper functions
"""
import os

def tounicode(string):
    """
    Tries to convert s into a unicode string
    """
    for encoding in ('utf-8', 'iso-8859-15', 'cp1252'):
        try:
            return unicode(string, encoding)
        except UnicodeDecodeError:
            pass
    return unicode(string, 'utf-8', 'replace')
        
def has_closed_branch_support(repo):
    """
    Return True is repository have support for closed branches
    """
    # what a hack... 
    return "closed" in repo.heads.im_func.func_code.co_varnames

def isexec(filectx):
    """
    Return True is the file at filectx revision is executable
    """
    if hasattr(filectx, "isexec"):        
        return filectx.isexec()
    return "x" in filectx.flags()
    
def exec_flag_changed(filectx):
    """
    Return True if the file referenced by filectx has changed its exec
    flag
    """
    flag = isexec(filectx)
    parents = filectx.parents()
    if not parents:
        return ""
    
    pflag = isexec(parents[0])
    if flag != pflag:
        if flag:
            return "set"
        else:
            return "unset"
    return ""

def isbfile(filename):
    return filename and filename.startswith('.hgbfiles' + os.sep)

def bfilepath(filename):
    return filename and filename.replace('.hgbfiles' + os.sep, '')
back to top