def normaliseRev(rev): """Normalise a Perforce revision and return it as a Trac-compatible rev. Basically converts revisions to '@<label/client/date>' or '#<rev>' but returns '@<change>' as an integer value. """ from p4trac.repos import NodePath rev = NodePath.normaliseRevision(rev) if rev is None: return rev elif rev.startswith(u'@') and rev[1:].isdigit(): return int(rev[1:]) else: return rev