Opened 9 years ago

# Strange behaviour when using p4 workspace

Reported by: Owned by: Nounours ttressieres normal PerforcePlugin major 0.5dev Kim Rasmussen 0.11

### Description

On a Trac v0.11 running the 0.5dev version of the Perforce Plugin :

We have one repository for all our projects, then we restrict the views with workspaces.

Setting the workspace value in the [perforce] section from trac.ini doesn't seem to restrict the contents of the cached repository (I assume it's normal because p4 changesets aren't workspace-bound).

But when i'm trying to browse the repository from Trac web UI, the plugin raises a NoSuchNode exception (maybe because the generated nodePath workspace_name/etc.... isn't stored inside the cached repository). I can browse the repository by entering a real repository path in the URL, as http://trac.site.url/browse/repos/real/path/. Alas that's not the behaviour I was expecting for.

Is there an easy way to enable repository browsing from workspace_name/ ? Do I need to store the workspace mapped pathes in the cached repository instead of the real pathes ?

### comment:1 Changed 9 years ago by ttressieres

Owner: changed from Lewis Baker to ttressieres new → assigned

### comment:2 Changed 9 years ago by Kim Rasmussen

Cc: Kim Rasmussen added; anonymous removed

### comment:3 Changed 9 years ago by Kim Rasmussen

I have the same problem. To reproduce, I create a new client specification TEST containing a view sections as follows

View:
//misc/... //whatever/misc/...


Then I set the workspace argument in the [perforce] section to TEST, and issue a resync.

If I then go to the Browse Source section I get a:

Error: No such node

No node //whatever/misc at revision @962


### comment:4 Changed 6 years ago by Ingo Müller

Severity: normal → major

I am experiencing the same problem, and I am trying to track it down. I think the reason of the problem is, that only part of the code works with workspace relative paths, while other parts don't. When they interact, there occur problems.

One of them (might be the only one, but that's the one where I am stuck) is the _getDirInfo function (which is called by by _get_isDirectory, which is called by _get_kind in order to determine whether a certain node is a file or a directory. As _getDirInfo fails, there is no type, so the NoSuchNode exception is raised).

In repos.py:1216, the following check is performed:

if fullPath in self._dirs:


fullPath is in working dir format (eg whatever/misc@692), while the paths in self._dirs are in depot format (eg misc@692). Of course, the tests fails although it shouldn't.

I am trying to hack a solution, but as a complete python newbie, I am stuck with a segmentation fault caused by the following code supposed to replace above line:

           # HACK: make workspaces work --ingo
output = _P4DirsOutputConsumer(self,nodePath.rev)
print fullPath,output
self._connection.run('dirs',fullPath,output=output)
if len(output.dirs) is 1:
fullPath = output.dirs[0].fullPath
if fullPath in self._dirs:


This should run the P4 "dirs" command with the workspace path, which returns the depot paths, and hence convert one format to the other. Unfortunately, it doesn't work. Can anyone help?

I am changing severity to major, as neither restricting to a subdirectory (#694) nor workspaces work. Feel free to change back.

### comment:5 Changed 6 years ago by Ingo Müller

I couldn't get it to work, even after several days of intensive debugging. Fortunetly, I found an alternative, which I just posted on the wiki as well:

Alternatively, trac can access to Perforce through a git wrapper. Here's roughly what you need to do: