perforce / p4transfer

[Community Supported] Utility for transferring a subset of files (with complete history of all changelists) from one Helix Core repository to another, only requiring read access to the source repository.
BSD 2-Clause "Simplified" License
43 stars 19 forks source link

Paths which include special characters in the name cause an exception #29

Open xrouge opened 4 months ago

xrouge commented 4 months ago

Similar to: #3

Python 3.12 For example, @ in the path:

Traceback (most recent call last):
  File "D:\dev\my\p4transfer\P4Transfer.py", line 2664, in replicate
    num_changes = self.replicate_changes()
                  ^^^^^^^^^^^^^^^^^^^^^^^^
  File "D:\dev\my\p4transfer\P4Transfer.py", line 2478, in replicate_changes
    targetChange = self.target.replicateChange(fileRevs, specialMoveRevs, srcFileLogs, change, self.source.p4.port)
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "D:\dev\my\p4transfer\P4Transfer.py", line 1585, in replicateChange
    self.processChangeRevs(fileRevs, specialMoveRevs, srcFileLogs)
  File "D:\dev\my\p4transfer\P4Transfer.py", line 1514, in processChangeRevs
    self.replicateBranch(f, dirty=False)
  File "D:\dev\my\p4transfer\P4Transfer.py", line 1901, in replicateBranch
    self.p4cmd('sync', '-k', file.fixedLocalFile)
  File "D:\dev\my\p4transfer\P4Transfer.py", line 1044, in p4cmd
    output = self.p4.run(args, **kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "D:\dev\my\p4transfer\.venv\Lib\site-packages\P4.py", line 624, in run
    raise e
  File "D:\dev\my\p4transfer\.venv\Lib\site-packages\P4.py", line 618, in run
    result = P4API.P4Adapter.run(self, *flatArgs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
P4.P4Exception: [P4#run] Errors during command execution( "p4 sync -k D:\dev\p4transfer\nodejs\6.11.0-win-x64\node_modules\npm\node_modules\node-gyp\node_modules\path-array\node_modules\array-index\node_modules\es6-symbol\node_modules\es5-ext\array\#\@@iterator\implement.js" )

        [Error]: "Invalid revision number '\\@@iterator\\implement.js'."

`2024-07-07 09:03:57,755:P4Transfer:DEBUG: processing:0230 add`

escapeWildCards() should handle this, but maybe it's not called from this code path. I understand that the special characters are allowed only when adding files, but ASCII expansion should be used in all other commands https://www.perforce.com/manuals/v22.2/p4guide/Content/P4Guide/syntax.syntax.restrictions.html

therefore fixedLocalFile shouldn't be used here because setLocalFile has the opposite intent:

self.p4cmd('sync', '-k', file.fixedLocalFile)

maybe file.localFile instead of file.fixedLocalFile.