[p4python] Client mappings
john.wiseman at rovicorp.com
Wed Sep 30 16:44:51 PDT 2009
On 9/29/09 2:46 PM, "John Wiseman" <john.wiseman at rovicorp.com> wrote:
> Does anyone have code for building a P4.Map object corresponding to a
> particular client? I just want to make sure I¹m doing it right so that I
> get exactly the same translations that Perforce would give me.
Here's the solution I came up with for mapping between depot paths and
# Build a map that lets us translate between depot paths and physical
# pathnames, like //depot/users/wiseman ->
# /home/wiseman/work/spdc/wiseman and vice versa.
g_cached_depot_to_phys_map = None
# I got the inspiration for this from the "P4::Map class" section of
# Just note that he's trying to map from //depot/... to the physical
# pathname of the file *on the depot server*, whereas I'm mapping
# between depot paths and physical pathnames on the client machine.
if not g_cached_depot_to_phys_map:
if not p4:
p4 = P4.P4()
client_info = p4.run_client('-o')
client_name = client_info['Client']
client_root = client_info['Root']
client_views = client_info['View']
depot_to_ws_map = P4.Map()
ws_to_physical_map = P4.Map()
ws_to_physical_map.insert('//%s/...' % (client_name,),
g_cached_depot_to_phys_map = P4.Map.join(depot_to_ws_map,
trans_map = ensure_translation_map.reverse()
trans_map = ensure_translation_map()
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the p4python