From f338555a41511f08a9a1fa0f8420683c56451e93 Mon Sep 17 00:00:00 2001 From: Carl Johnson Date: Thu, 31 Oct 2019 16:31:37 +0000 Subject: [PATCH] Switch to p4 print -o for consistent encoding (#131) --- python/perforce.py | 21 +++------------------ 1 file changed, 3 insertions(+), 18 deletions(-) diff --git a/python/perforce.py b/python/perforce.py index 0c8e892..aeeb6ce 100644 --- a/python/perforce.py +++ b/python/perforce.py @@ -212,29 +212,14 @@ def p4print_unshelve(self, changelist): whereinfo = self.perforce.run_where(depotfiles) depot_to_local = {item['depotFile']: item['path'] for item in whereinfo} - shelved_depotfiles = [file + '@=' + changelist for file in depotfiles] - printinfo = self.perforce.run_print(shelved_depotfiles) - - # coerce [info, content, info, content] - # into {localpath: content, localpath: content} - local_to_content = {depot_to_local[fileinfo['depotFile']]: (fileinfo, content) - for fileinfo, content in - zip(printinfo[0::2], printinfo[1::2]) - if fileinfo['depotFile'] in depot_to_local} - # Flag these files as modified - self._write_patched(list(local_to_content.keys())) + self._write_patched(list(depot_to_local.values())) - for localfile, (fileinfo, content) in local_to_content.items(): + for depotfile, localfile in depot_to_local.items(): if os.path.isfile(localfile): os.chmod(localfile, stat.S_IWRITE) os.unlink(localfile) - if content: - if not os.path.exists(os.path.dirname(localfile)): - os.makedirs(os.path.dirname(localfile)) - mode = 'wb' if 'binary' in fileinfo['type'] else 'w' - with open(localfile, mode=mode) as outfile: - outfile.write(content) + self.perforce.run_print('-o', localfile, '%s@=%s' % (depotfile, changelist)) def backup(self, changelist): """Make a copy of a shelved change"""