本文介绍了什么是p4命令相当于像git / hg / bzr / svn status? (提示:不是'p4状态')的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Q:其他版本控制工具的状态命令的perforce相当于什么?



git status 或 hg status 或 bzr status 或 svn status ? (令人困惑的是, cvs update -nq 是该版本控制系统最接近的一个。)

提示:它不是 p4状态

首先, p4 status 不会告诉您有关正在挂起更改列表的文件。你需要调用 p4打开,但输出格式有很大不同。

第二, p4 status 并不总是只读状态命令。我认为我默认发布时使用的perforce版本实际上改变了工作区的状态 - 它实际上是将本地更改添加到挂起的更改列表中。但我可能会误解。那家公司使用了一个非常老的perforce版本。截至我更新时,使用日期为2014/04/08的perforce客户端版本,默认的 p4 status 行为是只读的,但请注意不要使用 -A 选项,如果您不想更改工作区。



它看起来像某种组合需要 p4 status 和 p4 opened 来获得其他VCS在单个命令中完成的最小值。

详细信息:

大多数版本控制系统都有一个命令,你是一个工作区的状态。诸如以下信息:


  • 检出哪些文件进行编辑(如果VCS使用检出)


    • 哪些签出文件已被本地更改或删除


  • 哪些文件已被更改未签出


    • 例如哪些文件可能有您想要合并的更改


  • 可能哪些文件在仓库中比在工作区中更新更新


    • 例如您可能想要合并到工作区中的更改


  • 工作区中有哪些文件但尚未在版本控制下运行


    • 例如您可能希望添加到版本控制系统的文件

    • 或可能添加到.hgignore / .gitignore / ...忽略文件模式



      • 例如,哪些文件可能要从版本控制系统中删除

      • 或您可能意外删除了哪些文件




    具体提供哪些状态信息取决于VCS。例如。 Perforce是基于结账的,但是大多数现代版本控制工具都不是。



    但是...几乎所有的版本控制工具都有一个简单的命令,可以告诉你这样的状态。



    显然,perforce。



    ...我可以继续提供git / hg / bzr / svn status在单个命令中执行,但是哪个perforce似乎至少需要两个命令才能提供。

    解决方案

    svn / git / hg / bzr status 。



    git / hg / bzr / svn status = p4打开 + p4 status



    在perforce中,似乎需要至少两个单独的命令大致了解其他VCS工具使用单个命令所做的工作,以便快速总结工作区的状态:

    p4打开 - 获取您在工作区中打开的文件列表

    p4 status - 以查看未登录Perforce的文件列表。



    ** --- + OLD: p4 reconcile -n 而不是 p4状态 **



    perforce的旧版本都有 p4 status 默认情况下会像 p4 reconcile 一样对工作空间进行更改,如添加到工作空间。



    新: git / hg / bzr / svn status = p4打开 + p4状态 **



    新: git / hg / bzr / svn status = p4已打开 + p4 reconcile -n **



    p4 reconcile -n - 列出未打开的文件您可以在本地进行更改。



    ( p4 reconcile -n 要说make no )



    -n告诉reconcile不做任何更改。不再需要 - 现在 p4 status 是

    旧:
    p4 $ P4OPTS已打开
    p4 $ P4OPTS reconcile -n | sed -e's / - / - RECONCILE TO MAKE:/'



    --- +适用于别名或快速输入



    我将这些结合如下:

      p4 $ P4OPTS打开
    p4 $ P4OPTS状态| sed - e's / - / - RECONCILE TO MAKE:/'

    sed部分可以更好地区分perforce已打开的文件的状态,以及未在perforce下打开的文件的状态。但我注意到这是不安全的,当一个文件的名字中可能有字符串 - 。

    / p>

    因为我经常需要本地路径,所以我现在使用下面的shell脚本 my-p4-status 来给我更像我习惯于从其他VCS的状态命令=。



    下面的脚本使用旧的 reconcile -n ,并且尚未更新为使用 status 。

      #!/ bin / bash 
    #Perforce缺少一个命令来告诉你工作区的状态,
    #相当于hg / bzr / git状态。

    #警告:p4 status实际上并不是一个只读查询!
    #p4 status更像是p4 reconcile - 它实际上会打开要编辑,添加或删除的文件(-e -a -d)

    #p4仅打开报告当前由Perforce打开的文件的状态

    #需要组合p4 opened和p4 reconcile -n以获得网络概览。

    #TBD:转换为本地文件路径,而不是软件仓库路径。
    #(不是简单的sed-xargs-p4_fstat管道)

    P4OPTS =''
    if [$ 1==-ztag] || [$ 1==-verbose]
    然后
    转换
    P4OPTS = - ztag
    fi

    case $ P4OPTS in
    -ztag)
    p4 $ P4OPTS开立
    p4 $ P4OPTS协调-n
    ;;
    *)
    echo'#### p4打开 - 已打开Perforce文件###'
    p4 $ P4OPTS打开
    echo'#### p4 reconcile -n - - 本地编辑,不在Perforce中打开。运行p4协调以实际打开。 ###'
    p4 $ P4OPTS reconcile -n | sed -e's / - / - RECONCILE TO MAKE:/'
    esac

    --- +更好?请分享!



    如果您还有其他事情,请分享。


    Q: what is the perforce equivalent for the status command of other version control tools?

    E.g. git status or hg status or bzr status or svn status? (Confusingly, cvs update -nq is the closest thing for that version control system.)

    Hint: it is NOT p4 status.

    First, p4 status does not tell you about files that are on pending changelists. You need to call p4 opened for that, but the output format is quite different.

    Second, p4 status is not always a read-only status command. I think that the perforce version I was using at the time I originally posted this by default actually changes the state of the workspace - it actually adds local changes to a pending changelist. But I may misremember. That company used a very old version of perforce. As of the time I am updating this, using a perforce client version dated 2014/04/08, the default p4 status behavior is read-only, but take care not to use the -A option if you don't want to make changes to the workspace.

    It looks like some combination of p4 status and p4 opened is needed to get the bare minimum of what the other VCSes do in a single command.

    DETAIL:

    Most version control systems have a command that can quickly tell you the status of a workspace. Information such as:

    • what files are checked out for editing (if the VCS uses checkouts)
      • which of those checked out files have been locally changed or deleted
    • which files have been changed even though NOT checked out
      • e.g. which files may have changes that you want to merge
    • possibly which files are more recently updated in the repository than in your workspace
      • e.g. changes that you may want to merge into your workspace
    • what files are in the workspace but are not (yet) under version control
      • e.g. which files you may want to add to the version control system
      • or possibly add to your .hgignore/.gitignore/... ignore file patterns
    • what files are under version control but are not in the workspace
      • e.g. which files you may want to delete from your version control system
      • or which files you may have accidentally deleted

    Exactly what status information is provided depends on the VCS. E.g. Perforce is checkout based, but most modern version control tools are not.

    But... nearly all version control tools have a single, simple, command that will tell you such status.

    Except, apparently, perforce.

    ... I may go on to provide examples of what git/hg/bzr/svn status do in a single command, but which perforce seems to require at least two commands to provide.

    解决方案

    I keep saying that I dislike answering my own question, but I am going to do this here. I welcome anyone who wants to share better solutions and scripts. I would especially welcome somebody showing me that this is unnecessary, that Perforce actually does have the equivalent of svn/git/hg/bzr status.

    ---+ A: git/hg/bzr/svn status = p4 opened + p4 status

    In perforce at least two separate commands seem to be required to approximate what other VCS tools do with a single command, to provide a quick summary of the status of the workspace wrt the depot:

    p4 opened - for a list of files that you have opened in the workspace

    p4 status - for a list of files not checked in to Perforce.

    **---+ OLD: p4 reconcile -n instead of p4 status **

    Either old versions of perforce had p4 status act like p4 reconcile by default making changes to workspace like adding to workspace. Or I was broken at the time I wrote this page.

    New: git/hg/bzr/svn status = p4 opened + p4 status**

    New: git/hg/bzr/svn status = p4 opened + p4 reconcile -n**

    p4 reconcile -n - for a list of files that are not opened wrt perforce, but to which you have made local changes.

    (p4 reconcile -n to say "make no changes.)

    -n to tell reconcile to make no changes. No longer necessary - now that p4 status is read-only by default.

    OLD: p4 $P4OPTS opened p4 $P4OPTS reconcile -n | sed -e 's/ - / - RECONCILE TO MAKE: /'

    ---+ Suitable for an alias or quick typing

    I combine these as follows:

    p4 $P4OPTS opened
    p4 $P4OPTS status | sed -e 's/ - / - RECONCILE TO MAKE: /'
    

    The sed part to better differentiate the status for files that perforce already has opened from the status of files not opened under perforce. But I note that this is unsafe, when a file may have the string " - " in its name.

    ---+ Fancified

    Because I often want the local paths, I currently use the following shell script my-p4-status to give me something more like what I am used to from other VCSes' status command=.

    The script below uses old reconcile -n, and has not yet been updated to use status.

    #!/bin/bash
    # Perforce lacks a single command to tell you the status of a workspace,
    # the equivalent of hg/bzr/git status.
    
    # Warning: "p4 status" is not actually a read-only query!!!
    # "p4 status" is more like "p4 reconcile" - it actually opens files to edit, add, or delete (-e -a -d)
    
    # p4 opened only reports on the status of files currently opened by Perforce
    
    # It is necessary to combine "p4 opened" and "p4 reconcile -n" to get a net overview.
    
    # TBD: convert to local file path, rather than depot path.
    # (Not a simple sed-xargs-p4_fstat pipeline)
    
    P4OPTS=''
    if [ "$1" == "-ztag" ] || [ "$1" == "-verbose" ]
    then
       shift
       P4OPTS="-ztag"
    fi
    
    case $P4OPTS in
    -ztag)
        p4 $P4OPTS opened
        p4 $P4OPTS reconcile -n
        ;;
    *)
        echo '#### p4 opened - Perforce files already opened ###'
        p4 $P4OPTS opened
        echo '#### p4 reconcile -n --- local edits, not opened in Perforce.  Run p4 reconcile to actually open. ###'
        p4 $P4OPTS reconcile -n | sed -e 's/ - / - RECONCILE TO MAKE: /'
    esac
    

    ---+ Better? Please Share!

    If you have anything better, please share.

    这篇关于什么是p4命令相当于像git / hg / bzr / svn status? (提示:不是'p4状态')的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-04 17:50
查看更多