在perforce下载一个仓库

时间:2013-06-04 19:01:08

标签: perforce p4v

我是perforce的新用户(来自svn)并且正在使用gui接口p4v。我想在某人的仓库中有一个文件夹的本地副本,但我不确定该怎么做。我希望最终得到一份本地副本,供我探索和环顾四周。我不希望它受到修订控制。只需要它就好像我从互联网上下载了一个文件夹,随意做任何事情。我怎样才能在p4v中实现这一目标?

2 个答案:

答案 0 :(得分:2)

一旦您同步了文件,您就可以随心所欲地执行任何操作。 Perforce将文件标记为只读,除非您打开它们进行编辑,因此我要做的是同步软件仓库,将其复制到硬盘上的新位置,然后将所有文件标记为可写。

此外,如果您只想查看文件,则可以同步软件仓库并打开文件。您甚至可以检查它们(假设您有权限),如果您想要修补,则不要提交这些更改。

答案 1 :(得分:0)

这2个功能将帮助您开始工作。

public Repository GetRepository(string i_Workspace, string i_Username, string i_Password, string i_Server)
{
    Repository rep;
    Server server;
    ServerAddress address;

    // Create the repository
    address = new ServerAddress(i_Server + ":1666");
    server = new Server(address);
    rep = new Repository(server);

    rep.Connection.UserName = i_Username;
    Perforce.P4.Options options = new Perforce.P4.Options();
    options["Password"] = i_Password;

    Environment.SetEnvironmentVariable("P4PASSWD", i_Password);

    rep.Connection.Client = new Client();

    if (i_Workspace != null && i_Workspace != string.Empty)
    {
        rep.Connection.Client.Name = i_Workspace;
    }

    rep.Connection.Connect(options);
    rep.Connection.CommandTimeout = System.TimeSpan.Zero;
    rep.Connection.Login(i_Password);


    return rep;
}

private Client createWorkspace(string i_DepotPath, string i_RootDirectory)
{
    string workspaceName = "workspace" + new Random().Next().ToString();

    Repository rep = GetRepository(string.Empty);

    Client client = new Client();
    client.Name = workspaceName;
    client.Root = i_RootDirectory;
    client.OwnerName = k_DefaultUser;
    client.ViewMap = new ViewMap();
    client.Options = ClientOption.AllWrite;
    client.LineEnd = LineEnd.Local;
    client.SubmitOptions = new ClientSubmitOptions(false, SubmitType.SubmitUnchanged);

    string depotPath = i_DepotPath + "/...";

    String clientPath;
    //clientPath = String.Format("//{0}/{1}/...", client.Name, i_DepotPath.Replace("//depot/", string.Empty));
    clientPath = "//" + client.Name + "/...";

    MapEntry entry = new MapEntry(MapType.Include, new DepotPath(depotPath), new ClientPath(clientPath));

    client.ViewMap.Add(entry);


    rep.CreateClient(client);


    return client;
}