microsoft / microsoft/p4vfs

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

Open
#41 3 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C++
Stars
308
Forks
20
Avg merge
14h 56m
Merged PRs (30d)
1

Description

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.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at FDepotClient::Connect(const DepotConfig& config) and compare charset handling in p4vfs.exe with P4VFS.Service.exe. Reproduce the service-mode sync for a Unicode Perforce file using P4CHARSET=utf8; done means the command succeeds without the translation warning, while local mode remains working.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
backend, devtools
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.