I use p4 under WSL on Windows 10. I can normally use other operations from open files for editing to shelving, etc.
Now I have my own shelved changelist i.e. 12345, and current state of my workspace is clean. I want to unshelve all shelved files inside such changelist into the local workspace. I execute with the following command
p4 unshelve -s 12345
The result is similar to the following for each file
//depot/mydir/myfile#22 - unshelved, opened for edit
... //depot/mydir/myfile#22 - also opened by someone@someone_at_work
rename: /mnt/d/mydir/myfile: Permission denied
I tried with strace p4 unshelve -s 12345 and it seems like it tried to create a temporary file, chmod it, then finally try to rename temporary file into the actual file name as seen in workspace. The last step has "-1 EACCES (Permission Denied)" similar to the following
chmod("/mnt/d/mydir/tmp.1648.139747365556800.93", 0666) = 0
stat("/mnt/d/mydir/tmp.1648.139747365556800.93", {st_mode=S_IFREG|0777, st_size=16367, ...}) = 0
openat(AT_FDCWD, "/etc/localtime", O_RDONLY|O_CLOEXEC) = 4
fstat(4, {st_mode=S_IFREG|0644, st_size=2326, ...}) = 0
fstat(4, {st_mode=S_IFREG|0644, st_size=2326, ...}) = 0
read(4, "TZif2\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\t\0\0\0\t\0\0\0\0"..., 512) = 512
lseek(4, 347, SEEK_CUR) = 859
read(4, "TZif2\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\t\0\0\0\t\0\0\0\0"..., 512) = 512
read(4, ".\204\313\220\0\0\0\0/t\274\220\0\0\0\0000d\255\220\0\0\0\0001]\331\20\0\0\0\0"..., 512) = 512
read(4, "j\335T\220\0\0\0\0k\250[\220\0\0\0\0l\306q\20\0\0\0\0m\210=\220\0\0\0\0"..., 512) = 443
close(4) = 0
stat("/etc/localtime", {st_mode=S_IFREG|0644, st_size=2326, ...}) = 0
rename("/mnt/d/mydir/tmp.1648.139747365556800.93", "/mnt/d/mydir/myfile") = -1 EACCES (Permission denied)
write(2, "rename: /mnt/d/mydir/m"..., 90rename: /mnt/d/mydir/myfile: Permission denied
) = 90
brk(0x1b40000) = 0x1b40000
unlink("/mnt/d/mydir/tmp.1648.139747365556800.93") = 0
unlink("/mnt/d/mydir/tmp.1648.139747365556800.93") = -1 ENOENT (No such file or directory)
brk(0x1b30000) = 0x1b30000
gettimeofday({tv_sec=1596130958, tv_usec=871360}, NULL) = 0
Despite possibly knowing what the root cause might be but I have no clue what I can do to make p4 works. Note that my WSL username is different from P4 username.
Update:
This WSL issue is very close to my problem and probably it is for the compatibility between WSL and p4 at this point. Thanks to Samwise in the comment for pointing out into proper direction as well.
Update 2:
The workaround I found is to
- Open all files for edit as listed in shelved changelist
- Unshelve the files from shelved changelist
With this, we need to do some cleanup to get actual clean file name. 3 steps needed as follows.
p4 files @=12345 | sed 's/#.*//g' | cut -d'/' -f5- | xargs -n 1 -I{} p4 edit -c 12345 {}(get list of files from changelist, remove unrelevant part, remove first two components in file path, then one by one edit such file into changelist of our shelved file12345). Note: We can also removecut -d'/' -f5-out as I tested it, it still works fine. Your streams/views path might be complicated thus-f5-won't be able to cover for all cases.p4 unshelve -s 12345p4 resolve -af(oratto get theirs changes, orayto only get yours)
PS: it's important to use edit -c <changelist> as if you edit into default changelist, you won't be able to shelve all files updating it again as perfoce cannot detect any shelved files associated with that changelist.
Update 3:
If use WSL(1 or 2), then we can avoid applying workarounds by directly using p4.exe and work logically with Windows filesystem. To make this works, your Root: property as seen in p4.exe client needs to be modified to based on Windows filesystem. Then continue using p4.exe for all other commands.