代码之家  ›  专栏  ›  技术社区  ›  Cheeso

如果我有一个文件和一个diff,而不是同一文件的两个版本,我可以使用ediff吗?

  •  2
  • Cheeso  · 技术社区  · 15 年前

    使用tf.exe diff,我可以得到diff。

    我可以将此与EDIFF一起使用来在Emacs中可视化diff吗?

    我的印象是,EDIFF通常需要2或3个文件。我只有一个文件,还有一个差异。

    2 回复  |  直到 15 年前
        1
  •  3
  •   Trey Jackson    15 年前

    你可以选择工作的方法是

    M-x ediff-patch-buffer
    

    它将提示您输入补丁文件(或者如果您已经打开了缓冲区,则输入缓冲区)和要修补的缓冲区。然后它将帮助你克服这些分歧。

    因为diff显示了变化 存储库版本到当前版本,修补程序方向错误。我会编写一个生成正确diff的命令,并使用它——如果您真的想使用diff的话。

    就个人而言,我可能会尝试插入一些代码来获取 'ediff-revision (我必须这样做) C-x v - )让它发挥作用。

    或者只写一些遵循伪代码的lisp(因为我没有tf来做实际测试):

    (defun ediff-tf-file-with-previous-version (file &optional version)
       "DTRT and call ediff with the previous version of this file"
       (interactive)
       (ediff-files (progn
                      (unless version
                         (setq version (<parse-to-get-version> (shell-command (concat  "tf.exe properties " file)))))
                      (shell-command (concat "tf.exe view " file (<munge-itemspec-version> version) " > " file ".older")))
                     file))
    

    感谢R Berg的修复

    看起来好像有人写了一个基本的团队基金会模式,你可以从 wiki page here . 看起来好像没有插上什么东西 ediff 不过。

        2
  •  0
  •   Rodrigo Queiro    15 年前

    这是我写的剧本(我想!):

    #!/bin/bash
    
    # quit on error
    set -e
    
    # create a temporary file for the patched output
    # note that the mkfifo command is optional - it will save disc space
    patched_file=/tmp/diff_$RANDOM
    mkfifo $patched_file
    
    patch -o $patched_file "$1" "$2" &
    
    vimdiff "$1" $patched_file
    
    rm $patched_file