diff --git a/reviewboard/scmtools/perforce.py b/reviewboard/scmtools/perforce.py
--- a/reviewboard/scmtools/perforce.py
+++ b/reviewboard/scmtools/perforce.py
@@ -30,6 +30,9 @@ class PerforceTool(SCMTool):
         self.p4.password = str(repository.password)
         self.p4.exception_level = 1
 
+        self.user = str(repository.username)
+        self.password = str(repository.password)
+
         # We defer actually connecting until just before we do some operation
         # that requires an active connection to the perforce depot.  This
         # connection is then left open as long as possible.
@@ -43,9 +46,15 @@ class PerforceTool(SCMTool):
             # This is totally safe to ignore.
             pass
 
+    def run_login(self):
+        os.popen('echo %s|p4 -p %s -u %s login -a' % (self.p4.password, self.p4.port, self.p4.user)) 
+
     def _connect(self):
         if not self.p4.connected():
             self.p4.connect()
+            self.p4.user = self.user
+            self.p4.password = self.password
+            self.p4.run_login()
 
     def _disconnect(self):
         try:
@@ -81,11 +90,12 @@ class PerforceTool(SCMTool):
         else:
             file = '%s#%s' % (path, revision)
 
+        self._connect()
         cmdline = ['p4', '-p', self.p4.port]
         if self.p4.user:
             cmdline.extend(['-u', self.p4.user])
-        if self.p4.password:
-            cmdline.extend(['-P', self.p4.password])
+        # if self.p4.password:
+        #    cmdline.extend(['-P', self.p4.password])
         cmdline.extend(['print', '-q', file])
 
         p = subprocess.Popen(cmdline, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
