Changeset 2991

Show
Ignore:
Timestamp:
01/06/08 15:54:10 (1 year ago)
Author:
ttressieres
Message:
  • update classes from p4trac.repos
  • use Option class for parameters
  • code cleaning
Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • perforceplugin/trunk/p4trac/api.py

    r2974 r2991  
    4242    """ 
    4343 
    44     from p4trac.repos import NodePath 
    45     path = NodePath.normalisePath(path) 
     44    from p4trac.repos import P4NodePath 
     45    path = P4NodePath.normalisePath(path) 
    4646    if path is None: 
    4747        return u'/' 
     
    5555    returns '@<change>' as an integer value. 
    5656    """ 
    57     from p4trac.repos import NodePath 
    58     rev = NodePath.normaliseRevision(rev) 
     57    from p4trac.repos import P4NodePath 
     58    rev = P4NodePath.normaliseRevision(rev) 
    5959    if rev is None: 
    6060        return rev 
     
    7272    implements(IRepositoryConnector) 
    7373 
     74    port = Option('perforce', 'port', 'localhost:1666', doc= 
     75        """Perforce server IP address and port. 
     76        """) 
     77    user = Option('perforce', 'user', '', doc= 
     78        """Perforce user name used to identify requests. 
     79        """) 
     80    password = Option('perforce', 'password', '', doc= 
     81        """Perforce password used to identify requests. 
     82        """) 
     83    language = Option('perforce', 'password', '', doc= 
     84        """Perforce password used to identify requests. 
     85        """) 
     86    workspace = Option('perforce', 'workspace', NO_CLIENT, doc= 
     87        """Perforce workspace used to request server. 
     88        """) 
     89    charset = Option('perforce', 'charset', 'none', doc= 
     90        """Perforce charset used to request server. 
     91        valid options are 'none', 'utf-8'. 
     92        """) 
     93 
    7494    branches = ListOption('perforce', 'branches', 'main,branches/*', doc= 
    7595        """List of paths categorized as ''branches''. 
     
    7797        below that path will be included. 
    7898        """) 
    79  
    8099    labels = ListOption('perforce', 'labels', 'labels/*', doc= 
    81100        """List of paths categorized as ''labels''. 
     
    110129        self.log.debug("get_repository options : %s" % (options)) 
    111130 
    112         if 'port' not in options: 
    113             raise TracError( 
    114                 message="Missing 'port' value in [perforce] config section.", 
    115                 title="TracPerforce configuration error", 
    116                 ) 
    117  
    118131        # Try to connect to the Perforce server 
    119132        from perforce import Connection, ConnectionFailed 
    120         p4 = Connection(port=options['port'], api='58') # Limit to 2005.2 behaviour 
     133        p4 = Connection(port=self.port, api='58') # Limit to 2005.2 behaviour 
    121134        try: 
    122135            from trac import __version__ as tracVersion 
     
    127140                title="Perforce connection error") 
    128141 
    129         if 'user' not in options
     142        if 'user' == ''
    130143            raise TracError( 
    131144                message="Missing 'user' value in [perforce] config section.", 
    132145                title="Perforce configuration error") 
    133         p4.user = options['user'] 
    134  
    135         p4.password = options.get('password', '') 
    136         p4.charset = 'none' 
    137         if 'unicode' in options: 
    138             if options['unicode'] == '1': 
    139                 p4.charset = 'utf8' 
    140             elif options['unicode'] == '0': 
    141                 p4.charset = 'none' 
    142             else: 
    143                 raise TracError( 
    144                     message="Invalid 'unicode' value in [perforce] config " \ 
    145                     "section.", 
    146                     title="Perforce configuration error") 
    147  
    148         p4.language = options.get('language', '') 
     146        p4.user = self.user 
     147        p4.password = self.password 
     148        p4.charset = self.charset 
     149        p4.language = self.language 
    149150        jobPrefixLength = len(options.get('job_prefix', 'job')) 
    150         p4.client = options.get('workspace', NO_CLIENT) 
    151  
    152         self.log.debug("get_repository [%s,%s,%s]" % (p4.user, p4.password, p4.client)) 
     151        p4.client = self.workspace 
     152 
    153153        p4_repos = PerforceRepository(p4, None, self.log, jobPrefixLength, 
    154154                                      {'labels': self.labels, 
     
    190190        self.options = options 
    191191        self._connection = connection 
    192         name = 'p4://%s:%s@%s' % (self._connection.user, self._connection.password, self._connection.port) 
     192        name = 'p4://%s:%s@%s' % (connection.user,  
     193                                  connection.password, connection.port) 
    193194        Repository.__init__(self, name, authz, log) 
    194195        from p4trac.repos import P4Repository 
     
    241242 
    242243    def get_changeset(self, rev): 
    243         self.log.debug('get_changeset(%r)' % rev) 
     244        self.log.debug('PerforceRepository.get_changeset(%r)' % rev) 
    244245        if isinstance(rev, int): 
    245246            change = rev 
     
    249250            if rev.startswith(u'@'): 
    250251                rev = rev[1:] 
    251  
    252252            try: 
    253253                change = int(rev) 
    254254            except ValueError: 
    255255                raise TracError(u"Invalid changeset number '%s'" % rev) 
    256  
    257256        return PerforceChangeset(change, self._repos, self.log, self._job_prefix_length) 
    258257 
    259258    def get_changesets(self, start, stop): 
    260  
    261259        self.log.debug('PerforceRepository.get_changesets(%r,%r)' % (start, 
    262260                                                                      stop)) 
     
    264262        start = datetime.datetime.fromtimestamp(start) 
    265263        stop = datetime.datetime.fromtimestamp(stop) 
    266  
    267264        startDate = start.strftime('%Y/%m/%d:%H:%M:%S') 
    268265        stopDate = stop.strftime('%Y/%m/%d:%H:%M:%S') 
    269266 
    270         from p4trac.repos import _P4ChangesOutputConsumer 
    271         output = _P4ChangesOutputConsumer(self._repos) 
     267        from p4trac.repos import P4ChangesOutputConsumer 
     268        output = P4ChangesOutputConsumer(self._repos) 
    272269        depot_path = '%s@>=%s,@<=%s' % (rootPath(self._connection), startDate, stopDate) 
    273270        self._connection.run('changes', '-l', '-s', 'submitted', 
     
    281278 
    282279    def has_node(self, path, rev=None): 
    283         from p4trac.repos import NodePath 
    284         path = NodePath.normalisePath(path) 
    285         return self._repos.getNode(NodePath(path, rev)).exists 
     280        from p4trac.repos import P4NodePath 
     281        path = P4NodePath.normalisePath(path) 
     282        return self._repos.getNode(P4NodePath(path, rev)).exists 
    286283 
    287284    def get_node(self, path, rev=None): 
    288285        self.log.debug('get_node(%s, %s) called' % (path, rev)) 
    289         from p4trac.repos import NodePath 
    290         nodePath = NodePath(NodePath.normalisePath(path), rev) 
     286        from p4trac.repos import P4NodePath 
     287        nodePath = P4NodePath(P4NodePath.normalisePath(path), rev) 
    291288        return PerforceNode(nodePath, self._repos, self.log) 
    292289 
     
    304301                raise NoSuchChangeset(rev) 
    305302 
    306         from p4trac.repos import _P4ChangesOutputConsumer 
    307         output = _P4ChangesOutputConsumer(self._repos) 
     303        from p4trac.repos import P4ChangesOutputConsumer 
     304        output = P4ChangesOutputConsumer(self._repos) 
    308305        self._connection.run('changes', '-l', '-s', 'submitted', 
    309306                             '-m', '1', '@<%i' % rev, output=output) 
    310307        if output.errors: 
    311             from p4trac.repos import PerforcError 
    312             raise PerforcError(output.errors) 
     308            from p4trac.repos import PerforceError 
     309            raise PerforceError(output.errors) 
    313310        if output.changes: 
    314311            return max(output.changes) 
     
    326323        self.log.debug('next_rev(%r,%r)' % (rev, path)) 
    327324 
    328         from p4trac.repos import NodePath 
     325        from p4trac.repos import P4NodePath 
    329326        if not path: 
    330327            path = u'//' 
    331328        else: 
    332             path = NodePath.normalisePath(path) 
    333         node = self._repos.getNode(NodePath(path, rev)) 
     329            path = P4NodePath.normalisePath(path) 
     330        node = self._repos.getNode(P4NodePath(path, rev)) 
    334331 
    335332        if node.isDirectory: 
     
    364361                                                           batchUpperBound)) 
    365362 
    366             from p4trac.repos import _P4ChangesOutputConsumer 
    367             output = _P4ChangesOutputConsumer(self._repos) 
     363            from p4trac.repos import P4ChangesOutputConsumer 
     364            output = P4ChangesOutputConsumer(self._repos) 
    368365            depot_path = '%s%s@>=%i,@<=%i' % (rootPath(self._connection), 
    369366                                              queryPath, lowerBound, batchUpperBound) 
     
    373370 
    374371            if output.errors: 
    375                 from p4trac.repos import PerforcError 
    376                 raise PerforcError(output.errors) 
     372                from p4trac.repos import PerforceError 
     373                raise PerforceError(output.errors) 
    377374 
    378375            if output.changes: 
     
    445442        # Can't compare these revisions directly, 
    446443        # Compare based on the latest change number that affects this revision. 
    447         from p4trac.repos import NodePath 
     444        from p4trac.repos import P4NodePath 
    448445        if not isinstance(rev1, int): 
    449             rootAtRev1 = NodePath(u'//', rev1) 
     446            rootAtRev1 = P4NodePath(u'//', rev1) 
    450447            rev1 = self._repos.getNode(rootAtRev1).change 
    451448        if not isinstance(rev2, int): 
    452             rootAtRev2 = NodePath(u'//', rev2) 
     449            rootAtRev2 = P4NodePath(u'//', rev2) 
    453450            rev2 = self._repos.getNode(rootAtRev2).change 
    454451        self.log.debug('Comparing by change rev1=%i, rev2=%i' % (rev1, rev2)) 
     
    458455        # TODO: This doesn't handle the case where the head node has been 
    459456        # deleted or a file has changed to a directory or vica versa. 
    460         from p4trac.repos import NodePath 
    461         nodePath = NodePath(NodePath.normalisePath(path), rev) 
     457        from p4trac.repos import P4NodePath 
     458        nodePath = P4NodePath(P4NodePath.normalisePath(path), rev) 
    462459        node = PerforceNode(nodePath, self._repos, self.log) 
    463460        return node.get_history(limit) 
     
    483480                       old_path, old_rev, new_path, new_rev)) 
    484481 
    485         from p4trac.repos import NodePath 
    486         oldNodePath = NodePath(NodePath.normalisePath(old_path), old_rev) 
     482        from p4trac.repos import P4NodePath 
     483        oldNodePath = P4NodePath(P4NodePath.normalisePath(old_path), old_rev) 
    487484        oldNode = self._repos.getNode(oldNodePath) 
    488485 
    489         newNodePath = NodePath(NodePath.normalisePath(new_path), new_rev) 
     486        newNodePath = P4NodePath(P4NodePath.normalisePath(new_path), new_rev) 
    490487        newNode = self._repos.getNode(newNodePath) 
    491488 
     
    513510            raise TracError("Cannot diff two non-existant nodes") 
    514511 
    515         from p4trac.repos import _P4Diff2OutputConsumer 
    516         output = _P4Diff2OutputConsumer(self._repos) 
     512        from p4trac.repos import P4Diff2OutputConsumer 
     513        output = P4Diff2OutputConsumer(self._repos) 
    517514 
    518515        self._connection.run('diff2', '-ds', 
     
    589586        self._log.debug('PerforceNode.get_history(%r)' % limit) 
    590587        if self._node.isFile: 
    591  
    592588            # Force population of the filelog history for efficiency 
    593             from p4trac.repos import _P4FileLogOutputConsumer 
    594             output = _P4FileLogOutputConsumer(self._repos) 
    595  
    596             if limit is None: 
    597                 self._repos._connection.run( 
    598                     'filelog', 
    599                     '-i', '-l', 
    600                     self._repos.fromUnicode(self._nodePath.fullPath), 
    601                     output=output) 
    602             else: 
    603                 self._repos._connection.run( 
    604                     'filelog', 
    605                     '-i', '-l', 
    606                     '-m', str(limit), 
    607                     self._repos.fromUnicode(self._nodePath.fullPath), 
    608                     output=output) 
    609  
    610             from p4trac.repos import NodePath 
     589            self._repos._runFileLog(self._nodePath, limit) 
     590 
     591            from p4trac.repos import P4NodePath 
    611592 
    612593            currentNode = self._node 
     
    621602                               currentNode.change, 
    622603                               Changeset.COPY) 
    623                          
    624604                        currentNode = self._repos.getNode(nodePath) 
    625605                    else: 
     
    627607                              currentNode.change, 
    628608                              Changeset.ADD) 
    629  
    630609                        if currentNode.fileRevision > 1: 
    631610                            # Get the previous revision 
    632                             nodePath = NodePath(currentNode.nodePath.path, 
    633                                                 '#%i' % (currentNode.fileRevision - 1)) 
     611                            nodePath = P4NodePath(currentNode.nodePath.path, 
     612                                                  '#%i' % (currentNode.fileRevision - 1)) 
    634613                            currentNode = self._repos.getNode(nodePath) 
    635614                        else: 
    636615                            currentNode = None 
    637                              
    638616                elif currentNode.action in [u'edit', u'integrate']: 
    639  
    640617                    nextNode = None 
    641618                    if currentNode.integrations: 
    642619                        nodePath, how = currentNode.integrations[0] 
    643  
    644620                        if how == 'copy': 
    645621                            yield (normalisePath(currentNode.nodePath.path), 
     
    655631                               currentNode.change, 
    656632                               Changeset.EDIT) 
    657  
    658633                    if nextNode is None: 
    659634                        if currentNode.fileRevision > 1: 
    660635                            currentNode = self._repos.getNode( 
    661                                 NodePath(currentNode.nodePath.path, 
    662                                          '#%i' % (currentNode.fileRevision - 1))) 
     636                                P4NodePath(currentNode.nodePath.path, 
     637                                           '#%i' % (currentNode.fileRevision - 1))) 
    663638                        else: 
    664639                            currentNode = None 
    665640                    else: 
    666641                        currentNode = nextNode 
    667  
    668642                elif currentNode.action in [u'delete']: 
    669643                    yield (normalisePath(currentNode.nodePath.path), 
    670644                           currentNode.change, 
    671645                           Changeset.DELETE) 
    672  
    673646                    if currentNode.fileRevision > 1: 
    674647                        currentNode = self._repos.getNode( 
    675                             NodePath(currentNode.nodePath.path, 
    676                                      '#%i' % (currentNode.fileRevision - 1))) 
     648                            P4NodePath(currentNode.nodePath.path, 
     649                                       '#%i' % (currentNode.fileRevision - 1))) 
    677650                    else: 
    678651                        currentNode = None 
    679  
    680652                i += 1 
    681  
    682653        elif self._node.isDirectory: 
    683  
    684654            # List all changelists that have affected this directory 
    685             from p4trac.repos import _P4ChangesOutputConsumer 
    686             output = _P4ChangesOutputConsumer(self._repos) 
     655            from p4trac.repos import P4ChangesOutputConsumer 
     656            output = P4ChangesOutputConsumer(self._repos) 
    687657 
    688658            if self._nodePath.isRoot: 
     
    702672            if output.errors: 
    703673                raise PerforceError(output.errors) 
    704  
    705674            changes = output.changes 
    706675 
    707             # And describe the contents of those changelists 
    708             from p4trac.repos import _P4DescribeOutputConsumer 
    709             output = _P4DescribeOutputConsumer(self._repos) 
    710             self._repos._connection.run('describe', '-s', 
    711                                         output=output, 
    712                                         *[str(c) for c in changes]) 
    713  
    714             from p4trac.repos import NodePath 
    715  
     676            self._repos._runDescribe(changes) 
     677 
     678            from p4trac.repos import P4NodePath 
    716679            for i in xrange(len(changes)): 
    717680                change = changes[i] 
    718                 nodePath = NodePath(self._nodePath.path, change) 
    719  
     681                nodePath = P4NodePath(self._nodePath.path, change) 
    720682                if i < len(changes)-1: 
    721683                    prevChange = changes[i+1] 
     
    723685                    prevChange = change-1 
    724686 
    725                 prevNodePath = NodePath(self._nodePath.path, prevChange) 
     687                prevNodePath = P4NodePath(self._nodePath.path, prevChange) 
    726688                node = self._repos.getNode(nodePath) 
    727689                prevNode = self._repos.getNode(prevNodePath) 
    728  
    729690                if node.isDirectory: 
    730691                    if prevNode.isDirectory: 
     
    740701                           change, 
    741702                           Changeset.DELETE) 
    742                      
    743703        else: 
    744704            raise NoSuchNode(self._nodePath.path, self._nodePath.rev) 
    745705 
    746706    def get_annotations(self): 
     707        self._log.debug('PerforceNode.get_annotations') 
    747708        annotations = [] 
    748709        if self.isfile: 
     
    799760        self._changelist = self._repos.getChangelist(self._change) 
    800761        Changeset.__init__(self, self._change, self._changelist.description, 
    801                            self._changelist.user, datetime.fromtimestamp(self._changelist.time, utc)) 
     762                           self._changelist.user, 
     763                           datetime.fromtimestamp(self._changelist.time, utc)) 
    802764 
    803765    def get_properties(self): 
     
    814776                self._log.debug("get_properties  %d " % tktid) 
    815777                fixes += ' %d' % tktid 
    816  
    817778            if fixes != '': 
    818779                props['Tickets'] = to_unicode(fixes) 
     
    853814                    otherNodePath, how = node.integrations[0] 
    854815                    otherNode = self._repos.getNode(otherNodePath) 
    855                      
     816 
    856817                    # A 'copy from' operation 
    857818                    yield (normalisePath(nodePath.path), 
     
    862823                else: 
    863824                    if node.fileRevision > 1: 
    864                         from p4trac.repos import NodePath 
    865                         otherNode = self._repos.getNode(NodePath(nodePath.path, 
    866                                                                  '#%i' % (node.fileRevision - 1))) 
    867                              
     825                        from p4trac.repos import P4NodePath 
     826                        otherNode = self._repos.getNode(P4NodePath(nodePath.path, 
     827                                                                   '#%i' % (node.fileRevision - 1))) 
     828 
    868829                        # A basic edit operation 
    869830                        yield (normalisePath(nodePath.path), 
     
    880841            elif node.action in [u'delete']: 
    881842                # The file was deleted 
    882                 from p4trac.repos import NodePath 
    883                 otherNodePath = NodePath(nodePath.path, 
    884                                          '#%i' % (node.fileRevision - 1)) 
     843                from p4trac.repos import P4NodePath 
     844                otherNodePath = P4NodePath(nodePath.path, 
     845                                           '#%i' % (node.fileRevision - 1)) 
    885846                otherNode = self._repos.getNode(otherNodePath) 
    886  
    887847                yield (normalisePath(nodePath.path), 
    888848                       Node.FILE, 
    889849                       Changeset.DELETE, 
    890850                       normalisePath(nodePath.path), 
    891                        otherNode.change, 
    892                        ) 
     851                       otherNode.change) 
  • perforceplugin/trunk/p4trac/repos.py

    r2971 r2991  
    2020NO_CLIENT = '_P4TRAC_DUMMY_CLIENT' 
    2121 
    22 class _ChangeInfo(object): 
     22 
     23class _P4ChangeInfo(object): 
    2324    """A data structure for recording info about a changelist. 
    2425 
     
    4445        self.files = None 
    4546 
    46 class _FileInfo(object): 
     47 
     48class _P4FileInfo(object): 
    4749    """A data structure for recording info about a file. 
    4850 
     
    7375        self.attributes = None 
    7476 
    75 class _DirectoryInfo(object): 
     77 
     78class _P4DirectoryInfo(object): 
    7679    """A data structure for recording info about a directory. 
    7780 
     
    9396        self.change = None 
    9497 
     98 
    9599class PerforceError(Exception): 
    96  
    97100    def __init__(self, errors): 
    98101        self.errors = errors 
     
    101104        return '\n'.join([e.format() for e in self.errors]) 
    102105 
     106 
    103107class NoSuchChangelist(Exception): 
    104  
    105108    def __init__(self, change): 
    106109        self.change = change 
    107110 
     111 
    108112class NoSuchNode(Exception): 
    109      
    110113    def __init__(self, path, rev): 
    111114        self.path = path 
    112115        self.rev = rev 
    113116 
     117 
    114118class NoSuchFile(NoSuchNode): 
    115119    pass 
    116120 
     121 
    117122class NoSuchDirectory(NoSuchNode): 
    118123    pass 
    119124 
    120 # Some regular expressions used by NodePath 
     125# Some regular expressions used by P4NodePath 
    121126_slashDotSlashRE = re.compile(ur'/(\./)+') 
    122127_dirSlashDotDotRE = re.compile(ur'[^/]+/..(/|$)') 
    123128_trailingSlashesRE = re.compile(ur'(?<=[^/])/*$') 
    124129 
    125 class NodePath(object): 
     130class P4NodePath(object): 
    126131    """A path to a node in the Perforce repository. 
    127132 
     
    220225 
    221226    def __init__(self, path, rev=None): 
    222         """Construct a NodePath object. 
     227        """Construct a P4NodePath object. 
    223228 
    224229        @param path: The depot path to the node. 
    225         This must be a normalised path. Call L{NodePath.normalisePath} if 
     230        This must be a normalised path. Call L{P4NodePath.normalisePath} if 
    226231        normalisation is required. 
    227232        @type path: C{unicode} 
     
    234239        assert isinstance(path, unicode) 
    235240        self._path = path 
    236         self._rev = NodePath.normaliseRevision(rev) 
     241        self._rev = P4NodePath.normaliseRevision(rev) 
    237242 
    238243    def _get_path(self): 
     
    354359 
    355360    def __eq__(self, other): 
    356         if isinstance(other, NodePath): 
     361        if isinstance(other, P4NodePath): 
    357362            return self.path == other.path and self.rev == other.rev 
    358363        else: 
     
    363368 
    364369 
    365 class Changelist(object): 
     370class _P4Changelist(object): 
    366371    """A proxy object that gives access to details about a particular 
    367372    changelist in a Perforce repository. 
     
    376381 
    377382    def __init__(self, change, repository): 
    378         """Construct a new Changelist object. 
     383        """Construct a new _P4Changelist object. 
    379384 
    380385        @param change: The change number of the changelist to query. 
     
    479484        Has the value None if the changelist is not submitted. 
    480485 
    481         @type: C{list} of L{Node} objects or C{None} 
     486        @type: C{list} of L{_P4Node} objects or C{None} 
    482487 
    483488        @raise NoSuchChangelist: If the changelist doesn't exist in the 
     
    498503        nodes = [] 
    499504        for path in info.files: 
    500             nodePath = NodePath(path, self._change) 
    501             node = Node(nodePath, self._repo) 
     505            nodePath = P4NodePath(path, self._change) 
     506            node = _P4Node(nodePath, self._repo) 
    502507            nodes.append(node) 
    503  
    504508        return nodes 
    505509 
    506 class Node(object): 
     510 
     511class _P4Node(object): 
    507512    """A Perforce node is a particular revision of a path in the repository. 
    508513    """ 
     
    519524        """The node path of this node. 
    520525 
    521         @type: L{NodePath} 
     526        @type: L{P4NodePath} 
    522527        """ 
    523528        return self._nodePath 
    524529 
    525530    def _get_isDirectory(self): 
    526         """Boolean flag indicating whether the L{Node} is a directory. 
     531        """Boolean flag indicating whether the L{_P4Node} is a directory. 
    527532 
    528533        @type: C{boolean} 
     
    536541        if self._nodePath.rev is None: 
    537542            latestChange = self._repo.getLatestChange() 
    538             self._nodePath = NodePath(self._nodePath.path, latestChange) 
     543            self._nodePath = P4NodePath(self._nodePath.path, latestChange) 
    539544 
    540545        # Do we already know it's a directory? 
     
    559564 
    560565    def _get_isFile(self): 
    561         """Boolean flag indicating whether the L{Node} is a file. 
     566        """Boolean flag indicating whether the L{_P4Node} is a file. 
    562567 
    563568        @type: C{boolean} 
     
    571576        if self._nodePath.rev is None: 
    572577            latestChange = self._repo.getLatestChange() 
    573             self._nodePath = NodePath(self._nodePath.path, latestChange) 
     578            self._nodePath = P4NodePath(self._nodePath.path, latestChange) 
    574579 
    575580        # Do we already know it's a file? 
     
    602607 
    603608    def _get_exists(self): 
    604         """Boolean flag indicating whether the L{Node} exists or not. 
     609        """Boolean flag indicating whether the L{_P4Node} exists or not. 
    605610 
    606611        @type: C{boolean} 
     
    615620        @type: C{int} 
    616621 
    617         @raise NoSuchFile: If the L{Node} isn't a file. 
     622        @raise NoSuchFile: If the L{_P4Node} isn't a file. 
    618623        """ 
    619624 
     
    635640        @type: C{int} 
    636641 
    637         @raise NoSuchFile: If the L{Node} isn't a file node. 
     642        @raise NoSuchFile: If the L{_P4Node} isn't a file node. 
    638643        """ 
    639644 
     
    657662        @type: C{file}-like object 
    658663 
    659         @raise NoSuchFile: If the L{Node} isn't a file. 
     664        @raise NoSuchFile: If the L{_P4Node} isn't a file. 
    660665        """ 
    661666 
     
    682687        @type: C{int} 
    683688 
    684         @raise NoSuchNode: If the L{Node} doesn't exist. 
     689        @raise NoSuchNode: If the L{_P4Node} doesn't exist. 
    685690        """ 
    686691 
     
    688693        if self._nodePath.rev is None: 
    689694            latestChange = self._repo.getLatestChange() 
    690             self._nodePath = NodePath(self._nodePath.path, latestChange) 
     695            self._nodePath = P4NodePath(self._nodePath.path, latestChange) 
    691696 
    692697        if not self.exists: 
     
    818823            if self._nodePath.isRoot: 
    819824                if self._repo._connection.client != NO_CLIENT: 
    820                     nodePath = NodePath(u'//%s/%s' % (self._repo._connection.client, subdir), 
    821                                         self._nodePath.rev) 
     825                    nodePath = P4NodePath(u'//%s/%s' % (self._repo._connection.client, subdir), 
     826                                          self._nodePath.rev) 
    822827                else: 
    823                     nodePath = NodePath(u'//%s' % subdir, 
    824                                         self._nodePath.rev) 
     828                    nodePath = P4NodePath(u'//%s' % subdir, 
     829                                          self._nodePath.rev) 
    825830            else: 
    826                 nodePath = NodePath(u'%s/%s' % (self._nodePath.path, subdir), 
    827                                     self._nodePath.rev) 
    828  
    829             self._repo._log.debug("_get_subDirectories '%s ' " % (nodePath._path)) 
    830             node = Node(nodePath, self._repo) 
     831                nodePath = P4NodePath(u'%s/%s' % (self._nodePath.path, subdir), 
     832                                      self._nodePath.rev) 
     833 
     834            self._repo._log.debug("_P4Node._get_subDirectories '%s'" % (nodePath._path)) 
     835            node = _P4Node(nodePath, self._repo) 
    831836            subdirNodes.append(node) 
    832  
    833837        return subdirNodes 
    834838 
     
    840844 
    841845        if not self.isDirectory: 
    842             raise NoSuchDirectory(self._nodePath.path, 
    843                                   self._nodePath.rev) 
     846            raise NoSuchDirectory(self._nodePath.path, self._nodePath.rev) 
    844847 
    845848        # The root path never has any files under it 
     
    854857                if dirInfo.files is None: 
    855858                    raise 
    856              
    857859        assert dirInfo.files is not None 
    858860 
    859861        fileNodes = [] 
    860862        for file in dirInfo.files: 
    861             nodePath = NodePath(u'%s/%s' % (self._nodePath.path, file), 
    862                                 self._nodePath.rev) 
    863             node = Node(nodePath, self._repo) 
     863            nodePath = P4NodePath(u'%s/%s' % (self._nodePath.path, file), 
     864                                  self._nodePath.rev) 
     865            node = _P4Node(nodePath, self._repo) 
    864866            fileNodes.append(node) 
    865  
    866867        return fileNodes 
     868 
    867869 
    868870class P4Repository(object): 
     
    899901        self._latestChange = None 
    900902 
    901         # Mapping from change number (int) to _ChangeInfo object 
     903        # Mapping from change number (int) to _P4ChangeInfo object 
    902904        self._changes = {} 
    903905 
    904         # Mapping from node-path (unicode) to _DirectoryInfo object 
     906        # Mapping from node-path (unicode) to _P4DirectoryInfo object 
    905907        self._dirs = {} 
    906908 
    907         # Mapping from node-path (unicode) to _FileInfo object 
     909        # Mapping from node-path (unicode) to _P4FileInfo object 
    908910        self._files = {} 
    909911 
     
    933935 
    934936    def getChangelist(self, change): 
    935         """Get the Changelist object corresponding to the change number.""" 
    936         return Changelist(change, self) 
     937        """Get the _P4Changelist object corresponding to the change number.""" 
     938        return _P4Changelist(change, self) 
    937939 
    938940    def isChangelistCached(self, change): 
     
    946948                    info.description is not None and 
    947949                    info.time is not None) 
    948      
     950 
    949951    def getLatestChange(self): 
    950952        """Return the number of the most recently submitted change. 
     
    953955        """ 
    954956        if self._latestChange is None: 
    955             output = _P4ChangesOutputConsumer(self) 
     957            output = P4ChangesOutputConsumer(self) 
    956958            self._connection.run('changes', 
    957959                                 '-m', '1', 
     
    10091011            batchUpperBound = lowerBound + batchSize 
    10101012 
    1011             output = _P4ChangesOutputConsumer(self) 
     1013            output = P4ChangesOutputConsumer(self) 
    10121014            self._connection.run('changes', '-l', '-s', 'submitted', 
    10131015                                 '-m', str(batchSize), 
     
    10351037             
    10361038    def getNode(self, nodePath): 
    1037         """Get the Node object corresponding to the node path. 
    1038  
    1039         nodePath is a NodePath object 
    1040         """ 
    1041         return Node(nodePath, self) 
     1039        """Get the _P4Node object corresponding to the node path. 
     1040 
     1041        nodePath is a P4NodePath object 
     1042        """ 
     1043        return _P4Node(nodePath, self) 
    10421044 
    10431045    def precacheFileInformationForChanges(self, changes): 
     
    10681070        def filesWithoutCachedHistory(): 
    10691071            for change in changes: 
    1070                  
    10711072                changeInfo = self._getChangeInfo(change) 
    1072                  
    10731073                assert changeInfo is not None 
    10741074                assert changeInfo.files is not None 
    10751075                 
    10761076                for file in changeInfo.files: 
    1077                      
    1078                     nodePath = NodePath(file, '@%i' % change) 
     1077                    nodePath = P4NodePath(file, '@%i' % change) 
    10791078                    fileInfo = self._getFileInfo(nodePath) 
    1080                      
    10811079                    assert fileInfo is not None 
    1082                      
     1080 
    10831081                    if fileInfo.sources is None: 
    10841082                        yield nodePath 
     
    10951093 
    10961094        for batch in batchesOfFilesWithoutCachedHistory(1000): 
    1097              
    10981095            output = _P4FileLogOutputConsumer(self) 
    10991096            self._connection.run('filelog', '-m', '1', 
     
    11011098                                 *[self.fromUnicode(np.fullPath) 
    11021099                                   for np in batch]) 
    1103  
    11041100            if output.errors: 
    11051101                raise PerforceError(output.errors) 
     
    11301126        @return: The changelist info structure or C{None} if the change 
    11311127        doesn't yet exist in the cache. 
    1132         @rtype: L{_ChangeInfo} or C{None} 
     1128        @rtype: L{_P4ChangeInfo} or C{None} 
    11331129        """ 
    11341130 
     
    11361132            return self._changes[change] 
    11371133        elif create: 
    1138             info = _ChangeInfo(int(change)) 
     1134            info = _P4ChangeInfo(int(change)) 
    11391135            self._changes[change] = info 
    11401136            return info 
     
    11451141        """Get the directory info structure for the set of nodePaths. 
    11461142 
    1147         @param nodePaths: Either a NodePath or a list of NodePath objects. 
     1143        @param nodePaths: Either a P4NodePath or a list of P4NodePath objects. 
    11481144        If a list is provided, then you must already know that all of the 
    1149         NodePaths refer to the same Node (this implies that the path component 
     1145        NodePaths refer to the same _P4Node (this implies that the path component 
    11501146        of the NodePaths are all equal). 
    11511147 
    11521148        @param create: If true and the nodePaths aren't already in existence 
    1153         then a new empty _DirectoryInfo object is inserted into the database 
     1149        then a new empty _P4DirectoryInfo object is inserted into the database 
    11541150        and is returned, otherwise None is returned. Should only be set to 
    11551151        True if you already know that the nodePaths are a directory. 
    11561152 
    1157         @return: The L{_DirectoryInfo} object for the nodePaths or C{None}, 
    1158         @rtype: L{_DirectoryInfo} or C{None} 
     1153        @return: The L{_P4DirectoryInfo} object for the nodePaths or C{None}, 
     1154        @rtype: L{_P4DirectoryInfo} or C{None} 
    11591155        """ 
    11601156 
     
    11711167                     for p in fullPaths 
    11721168                     if p in self._dirs] 
    1173              
     1169 
    11741170            if infos: 
    11751171                # There are existing info objects, pick the first one 
     
    11791175                    if other is not info: 
    11801176                        assert other.path == info.path 
    1181                          
     1177 
    11821178                        if other.subdirs is not None: 
    11831179                            if info.subdirs is None: