Status: New
Owner: ----
Labels: Type-Defect Priority-Medium

New issue 2712 by [rbtools] post-review command line flag --p4-client and --p4-port does not work when P4CONFIG file is used in a multiple workspaces (perforce servers) scenario

* NOTE: Do not post confidential information in this bug report. *
*       If you need immediate support, please contact            *
*                             *

What version are you running?
1.6.11, rbtools

What's the URL of the page containing the problem?
It's the post-review command in rbtools has the problem, so no URL.

What steps will reproduce the problem?
1. suppose the following settings for two workspaces on two Perforce Servers. (PerforceServer1 and PerforceServer2)

PerforceServer1 settings:
  server port: PerforceServer1:1666
  workspace name: alice-workspace
  workspace root: d:\perforce1
  env variable P4CONFIG=config.txt
  configure file: d:\perforce1\config.txt
  content of the config file:

PerforceServer2  settings:
  server port: PerforceServer2:1666
  workspace name: bob-workspace
  workspace root: d:\perforce2
  env variable P4CONFIG=config.txt
  configure file: d:\perforce2\config.txt
  content of the config file:

2. run post-review from a path under d:\perforce1 to post a changelist that actually lives on PerforceServer2. Initiate the post-review command the following way: post-review --p4-port=PerforceServer2:1666 --p4-client=bob-workspace 123456

What is the expected output? What do you see instead?
We expect post-review will post the PerforceServer2 changelist 123456; but it actually try to find the changelist on PerforceServer1

What operating system are you using? What browser?
Win7 + Python 2.6.

Please provide any additional information below.

I did the following research on this issue. Hopefully it will be useful for you to fix it.
According to the p4 manuals, we can specify perforce settings such as server port, user, and workspace names using the following methods, listed in ORDER of precedence:

1. On the command line (p4.exe), using flags
2. In a config file, if P4CONFIG is set
3. User environment variables (on UNIX or Windows)

which means that cmd line flags > P4CONFIG > env variable.

But when running post-review, if the users has specified the --p4-client and --p4-port flags, the corresponding env variables will be set. In the python code, I find the following code:

        if options.p4_client:
           os.environ['P4CLIENT'] = options.p4_client

        if options.p4_port:
           os.environ['P4PORT'] = options.p4_port

but because the env variable P4CONFIG is set and the config file exists, the perforce settings in the config file will override the env variables which was specified from the post-review command line.

For the example in the reproduce steps, because we're running the post-review from a path under d:\perforce1, the workspace root, the setting in the d:\perforce1\config.txt file will take effect and override the env variables, that's why those --p4-client and --p4-port option does not work.

To solve this issue, the post-review tool should, instead of setting env variables, append those flags to the p4 info and p4 describe command directly because command line flags have the highest precedence.

You received this message because you are subscribed to the Google Groups 
"reviewboard-issues" group.
To post to this group, send email to
To unsubscribe from this group, send email to
For more options, visit this group at

Reply via email to