Skip to content

Commit 05efb63

Browse files
authored
Skip unecessary flush for brand new client workspaces (#183)
1 parent 7e1b00f commit 05efb63

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

python/perforce.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -97,17 +97,17 @@ def _setup_client(self):
9797

9898
self.perforce.save_client(client)
9999

100-
if not os.path.isfile(self.p4config):
101-
self.perforce.logger.warning("p4config missing, flushing workspace to revision zero")
102-
self.perforce.run_flush(['//...@0'])
103-
else:
100+
if os.path.isfile(self.p4config):
104101
with open(self.p4config) as infile:
105102
prev_clientname = next(line.split('=', 1)[-1]
106103
for line in infile.read().splitlines() # removes \n
107104
if line.startswith('P4CLIENT='))
108-
if prev_clientname != clientname:
109-
self.perforce.logger.warning("p4config last client was %s, flushing workspace to match" % prev_clientname)
110-
self.perforce.run_flush(['//...@%s' % prev_clientname])
105+
if prev_clientname != clientname:
106+
self.perforce.logger.warning("p4config last client was %s, flushing workspace to match" % prev_clientname)
107+
self.perforce.run_flush(['//...@%s' % prev_clientname])
108+
elif 'Update' in client: # client was accessed previously
109+
self.perforce.logger.warning("p4config missing for previously accessed client workspace. flushing to revision zero")
110+
self.perforce.run_flush(['//...@0'])
111111

112112
self._write_p4config()
113113
self.created_client = True

0 commit comments

Comments
 (0)