Jump to content


Refresh existing workspaces to respect updated typemap

typemap workspace

  • Please log in to reply
12 replies to this topic

#1 Deltafuge

Deltafuge

    Newbie

  • Members
  • Pip
  • 2 posts

Posted 13 September 2018 - 01:04 PM

Hey,

I have a number of users with existing workspaces, I have recently updated the typemap (p4 typemap) to include new file type mappings, the problem is that existing workspaces from before the change do not seem to respect the new typemap, my question is what options do I have in terms of getting this update applied to the users workspaces?

I feel like the following options are potentially available.

- Some magical function that will apply this to the existing workspace (that'd be great).

- Getting users to create a new workspace every time we have to update the typemap
-- This sucks because it could involve length reconciles or some other command.

What's the best option here? I don't see why the users work space should override this anyway?

Cheers.

#2 Sambwise

Sambwise

    Advanced Member

  • Members
  • PipPipPip
  • 1175 posts

Posted 13 September 2018 - 06:25 PM

The typemap applies to newly mapped files, but doesn't override the types of any existing files (the typemap is meant to be a default, not an absolute, so it only kicks in for default filetype detection done by "p4 add").

If you want to change the filetype of existing files, the best way is to submit a new revision so that the change is versioned:

p4 edit -t NEWTYPE //depot/some/path/....type
p4 revert -a
p4 submit


All workspaces will pick up the change the next time they sync.

You can also use the "p4 retype" command if you want to avoid creating new revisions, but then a bunch of caveats apply (existing workspaces won't pick up the change unless they force-sync, for example).

#3 Deltafuge

Deltafuge

    Newbie

  • Members
  • Pip
  • 2 posts

Posted 13 September 2018 - 08:34 PM

Thanks for your reply!

OK, this is not ideal and I would have hoped that this would just be picked up upon the next checkout of any file with that extension, if I manually change the type mapping for all relevant files will P4 be smart enough to not download the whole file again and only update the workspace mapping to match?

#4 p4rfong

p4rfong

    Advanced Member

  • Staff Moderators
  • 343 posts

Posted 13 September 2018 - 08:48 PM

No, you will have to create a command trigger where a script would run every time "p4 typemap" is executed.
https://www.perforce...commands|_____0

#5 Sambwise

Sambwise

    Advanced Member

  • Members
  • PipPipPip
  • 1175 posts

Posted 13 September 2018 - 09:02 PM

View PostDeltafuge, on 13 September 2018 - 08:34 PM, said:

if I manually change the type mapping for all relevant files will P4 be smart enough to not download the whole file again and only update the workspace mapping to match?

I don't think so (unless the behavior has changed, syncing identical files is only optimized for the case where the client mapping has changed).  But as a general rule you do want to refresh the client file if the type changes.  Like I said "retype" won't cause a resync, so maybe that's what you want -- it depends entirely on what the old and new types were.  For example, if you changed keyword expansion behavior, you absolutely want everything to resync.  If you added the exclusive open flag, not so much.

For the command trigger thing Randall suggested above, the command(s) you'd want to trigger on to get the behavior you describe (change the type on the next open) would be ones that open files (primarily "p4 edit"), so you could rewrite the command arguments to include "-t TYPE".  IMO you're much better off just doing it all in one shot, either via "p4 edit" or "p4 retype", than having a trigger that will need to be maintained forever.

#6 subressor

subressor

    Member

  • Members
  • PipPip
  • 11 posts

Posted 02 April 2020 - 09:50 AM

View PostSambwise, on 13 September 2018 - 06:25 PM, said:

You can also use the "p4 retype" command if you want to avoid creating new revisions, but then a bunch of caveats apply (existing workspaces won't pick up the change unless they force-sync, for example).

Hey, jumping in as I've just made the same issue for myself. I need to update my typemap but already did the initial push to the server. Not confident enough to use the obliterate command...

For a fresh server where no one else is logged in yet, how to I run the retype command on all files once I've changed the typemap?

#7 Sambwise

Sambwise

    Advanced Member

  • Members
  • PipPipPip
  • 1175 posts

Posted 02 April 2020 - 03:33 PM

View Postsubressor, on 02 April 2020 - 09:50 AM, said:

For a fresh server where no one else is logged in yet, how to I run the retype command on all files once I've changed the typemap?

Confidently!  :)

See "p4 help retype" for info on how "p4 retype" works.

Or just do the "p4 edit -t" thing I described earlier.  If nobody else is working on these files, the fact that they all got a new revision isn't going to be in any way disruptive.

#8 subressor

subressor

    Member

  • Members
  • PipPip
  • 11 posts

Posted 03 April 2020 - 10:05 AM

Hey Sambwise


Thanks very much for the reply!

I tried fruitlessly, but unfortunately I couldn't get it to work... I resorted to spending a few hours going into each file and changing the type to what matches in the typefile I was asked to use.

I would still be interested to know what commands I should have used so I can add it to my personal perforce documentation which I'm hoping to share with the UE4 community (a lot of us are having a really hard time trying to get this off the ground)

#9 Sambwise

Sambwise

    Advanced Member

  • Members
  • PipPipPip
  • 1175 posts

Posted 03 April 2020 - 02:09 PM

View Postsubressor, on 03 April 2020 - 10:05 AM, said:

I tried fruitlessly, but unfortunately I couldn't get it to work...

I'm pretty sure either "retype" or "edit" is the correct command to use.  What exactly did you try, and what didn't work?

#10 subressor

subressor

    Member

  • Members
  • PipPip
  • 11 posts

Posted 03 April 2020 - 04:12 PM

View PostSambwise, on 03 April 2020 - 02:09 PM, said:

What exactly did you try, and what didn't work?

p4 retype help worked, but almost every combination I put in thereafter seemed to give me a failure message of some description. I tried it with the whole depot, file area, an individual file. I can't remember exactly what the errors said, should have screenied it but it was late and I was loosing motivation :/

#11 Sambwise

Sambwise

    Advanced Member

  • Members
  • PipPipPip
  • 1175 posts

Posted 03 April 2020 - 04:54 PM

View Postsubressor, on 03 April 2020 - 04:12 PM, said:

p4 retype help worked, but almost every combination I put in thereafter seemed to give me a failure message of some description. I tried it with the whole depot, file area, an individual file. I can't remember exactly what the errors said, should have screenied it but it was late and I was loosing motivation :/

Having the error message and knowing what commands you used would make it possible to debug.  Any time you're trying to get remote help from someone (whether it's professional tech support or some rando on the Internet) it's very important to keep track of what you did and what happened so you can relay it to the other person!  :)

Here's what it looks like when it's working -- in my example I want to change everything in my current directory (all the files currently have the type "text") to the type "text+k":

C:\Perforce\test\main>p4 files ...
//stream/main/main/bar#1 - add change 149 (text)
//stream/main/main/baz#1 - add change 149 (text)
//stream/main/main/foo#1 - add change 149 (text)

C:\Perforce\test\main>p4 retype -t text+k ...
//stream/main/main/bar#1 - text now text+k
//stream/main/main/baz#1 - text now text+k
//stream/main/main/foo#1 - text now text+k

C:\Perforce\test\main>p4 files ...
//stream/main/main/bar#1 - add change 149 (text+k)
//stream/main/main/baz#1 - add change 149 (text+k)
//stream/main/main/foo#1 - add change 149 (text+k)

Note that I'm just running the "p4 files" commands to show what files are there and what their current types are.

If I wanted to change their type via "p4 edit" (let's say this time I want to make the files that start with "b" the "binary" filetype), here's how that looks:


C:\Perforce\test\main>p4 edit -t binary b...
//stream/main/main/bar#1 - opened for edit
//stream/main/main/baz#1 - opened for edit

C:\Perforce\test\main>p4 submit -d "Changing the B files to binary"
Submitting change 150.
Locking 2 files ...
edit //stream/main/main/bar#2
edit //stream/main/main/baz#2
Change 150 submitted.

C:\Perforce\test\main>p4 files ...
//stream/main/main/bar#2 - edit change 150 (binary)
//stream/main/main/baz#2 - edit change 150 (binary)
//stream/main/main/foo#1 - add change 149 (text+k)

For what it's worth, I typically recommend using the "p4 edit" method unless you have a very compelling reason to use "retype" instead, because I think it's generally preferable to have all of your changes be versioned rather than to have them apply retroactively.

#12 subressor

subressor

    Member

  • Members
  • PipPip
  • 11 posts

Posted 05 April 2020 - 08:10 PM

Thanks! I'm pretty sure I tried that and got some weird error like 'client name not recognised' or something.

I will give it another go as I need to edit the typemap with another change! Thanks again for your help

Do you know if there's any way to use retype on specific file formats in specific areas of the depot? Or is retype only to be used generally or on certain files

#13 Sambwise

Sambwise

    Advanced Member

  • Members
  • PipPipPip
  • 1175 posts

Posted 05 April 2020 - 09:35 PM

View Postsubressor, on 05 April 2020 - 08:10 PM, said:

Thanks! I'm pretty sure I tried that and got some weird error like 'client name not recognised' or something.

Sounds like you didn't have a client spec set up.  Any time you're operating on local files (so like when you're opening them for edit, or even when you're referring to files by a local relative path), the client spec defines how your local files correspond to the depot files.  If you got the error I'm thinking of, it actually tells you exactly how to fix it!

C:\Perforce\test>p4 files ...
Client 'subressors-computer' unknown - use 'client' command to create it.

If I already had a client spec set up on this computer, I could switch to it by running "p4 set P4CLIENT=that-client-name", but the error message is telling me that I can create a new client spec with the "client" command.  Thanks for that tip, error message!  Let me try that...

C:\Perforce\test>p4 client

This brings up my text editor with my new client spec:

Client: subressors-computer

Owner: subressor

Description:
Created by subressor

Root: c:\Perforce\test

Options: noallwrite noclobber nocompress unlocked nomodtime normdir

SubmitOptions: submitunchanged

LineEnd: local

View:
//depot/... //subressors-computer/...

The important parts of the client spec are the "Root" (which says where the client spec lives -- it defaults to my current directory) and the "View" (which says how the depot relates to the client root -- by default the entire depot is mapped, or all depots if you have more than one).


If I save this file and exit the editor, it saves the client spec:

C:\Perforce\test>p4 client
Client subressors-computer saved.


Now I can run commands on files in my local directory!  The client spec says that whenever I'm in C:\Perforce\test using this client spec on this computer, it's the same as being in //depot on the server.


C:\Perforce\test>p4 files ...
//depot/foo/bleh#1 - branch change 147 (text)
//depot/main/bleh#1 - branch change 148 (text)


Quote

Do you know if there's any way to use retype on specific file formats in specific areas of the depot? Or is retype only to be used generally or on certain files

I would recommend using the "p4 edit" method; "p4 retype" is not something that's meant for general or routine use.

Any command that operates on files can take a wildcard pattern -- in my previous post you saw how I used the pattern "b..." to say "open all files whose paths relative to this directory start with b for edit with the type of binary".  You could also do "....txt" to say "all files under this directory that end in .txt", or "//depot/foo/....jpg" to say "all files that are in the //depot/foo directory whose names end in .jpg", or any combination you can imagine.





Also tagged with one or more of these keywords: typemap, workspace

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users