Skip to content

Command sync -r fails for file with filetype <unicode> on perforce #41

@xun-eric-zhang

Description

@xun-eric-zhang

Hi, thanks for the awesome work on p4vfs!
I would like to report an issue I had when testing out p4vfs. I found out an solution, but wanted to check if there is a better fix, or if I missed something for my setup.

  • Background
    Perforce server is in Unicode mode, Client P4CHARSET is set to utf8.

  • Issue
    If a file unicode_test.txt is of unicode filetype on perforce, then following command would fail.
    p4vfs.exe sync -r -f //depot//unicode_test.txt
    And gives the error: - Translation of file content failed near line ...
    The same command in p4 would succeed:
    p4 sync -f //depot//unicode_test.txt
    The same p4vfs command in local mode would also succeed:
    p4vfs.exe sync -r -f -t //depot//unicode_test.txt
    Just in case I attached the file for my test there: UnicodeTest.txt

  • Investigation
    By outputing m_P4->m_ClientApi->GetCharset().Text() in FDepotClient::Connect(const DepotConfig& config), I found the issue.
    In p4vfs.exe, the FDepotClient is properly picking up P4CHARSET settings and is set to utf8. However in P4VFS.Service.exe, it does not pick up P4CHARSET, and charset is set to auto. I'm not sure why, but this is the reason we have translation problem using sync command in service mode, but not in local mode.

  • Fix
    Added the following in FDepotClient::Connect(const DepotConfig& config)

DepotString charset = GetEnvImpersonated(DepotConstants::P4CHARSET); 
if (charset.empty() == false) 
{ 
    m_P4->m_ClientApi->SetCharset(charset.c_str()); 
} 

Much appreciated if you can share any insight on this problem. Thank you.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions