3221: get_repository_info in perforce.py fails if norm_cwd and norm_client_root have different cases.

pedro******@gmai***** (Google Code) (Is this you? Claim this profile.)
Feb. 16, 2014
3285
What version are you running?
rbtools 0.5.7
python 2.7.3


What's the URL of the page containing the problem?
it's in the rbtools python scripts, in perforce.py, no URL.


What steps will reproduce the problem?
1. Set your client root to C:\your_root_here in P4
2. Check that you root path with P4 client to c:\your_root_here (notice the lowercase c:\)
3. Run rbt post --debug and see it fail

What is the expected output? What do you see instead?
rbt fails to detect a repository in the root directory

What operating system are you using? What browser?
Windows 7


Please provide any additional information below.
I debugged this and found the issue:

When the path case doesn't match between norm_cwd and norm_client_root the function returns None.
The solution is to call os.path.normcase for both norm_cwd and norm_client_root as below:


 def get_repository_info(self):
        if not self.p4.is_supported():
            return None
 
        p4_info = self.p4.info()
 
        # For the repository path, we first prefer p4 brokers, then the
        # upstream p4 server. If neither of those are found, just return None.
        repository_path = (p4_info.get('Broker address') or
                           p4_info.get('Server address'))
 
        if repository_path is None:
            return None
 
        client_root = p4_info.get('Client root')
 
        if client_root is None:
            return None
 
        norm_cwd = os.path.normcase(os.path.realpath(os.getcwd()) + os.path.sep)
        norm_client_root = os.path.normcase(os.path.realpath(client_root) + os.path.sep)
 
        # Don't accept the repository if the current directory is outside the
        # root of the Perforce client.
        if not norm_cwd.startswith(norm_client_root):
            return None
david
#1 david
  • +EasyFix
    +Component-RBTools
david
#2 david
Fixed in release-0.5.x (446a656). Thanks!
  • +Fixed