我可以只使用SVN或Mercurial提交部分代码吗? [英] Can I commit only parts of my code using SVN or Mercurial?

查看:166
本文介绍了我可以只使用SVN或Mercurial提交部分代码吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我通常使用Tortoise SVN,但我一直在研究Mercurial,因为它是一个分布式版本控制系统。

在两个系统中,我所寻找的是一种让我只挑选文件的一部分并提交它们的工具。如果我现在要这样做,我必须复制到文件的临时版本,并且只保留我想要在当前版本中提交的更改,然后在提交后再次将临时版本复制到当前版本。这只是一个麻烦,程序应该能够为我做到这一点。



我听说Git支持这个,请告诉我这是否正确。

解决方案

水银可以与 record 扩展名。

它会提示您输入每个文件和每个diff区块。例如:

 %hg record 
diff --git a / prelim.tex b / prelim.tex
2个区块,4行更改
检查对'prelim.tex'的更改? [Ynsfdaq?]
@@ -12,7 +12,7 @@
\setmonofont [比例= 0.88] {索拉}
%从xunicode.sty
\\失踪\\DeclareUTFcomposite [\UTFencname] {x00ED} {\'} {\i}
-\else
+ \else FOO
\usepackage [Pdftex提供] {graphicx宏}
\fi

将此更改记录为prelim.tex? [Ynsfdaq?]
@@ -1281,3 +1281,5 @@
%%局部变量:
%%模式:latex
%%结束:
+
+ foo
\在文件结尾没有换行符
将此更改记录为prelim.tex? [Ynsfdaq?] n
等待Emacs ...

提交后,剩下的diff会被留在后面:

 %hg di 
diff --git a / prelim.tex b / prelim。 tex
--- a / prelim.tex
+++ b / prelim.tex
@@ -1281,3 +1281,5 @@
%%局部变量:
%% mode:latex
%%结束:
+
+ foo
\在文件结尾没有新行

或者,您可能会发现使用MQ(Mercurial Queues)将存储库中的各个更改分隔成多个补丁更容易。还有一个记录(qrecord)的MQ变体。



更新:另请尝试 crecord 扩展,它为hunk / line选项提供了一个curses接口。




I use Tortoise SVN usuallly, but I have been looking into Mercurial since it is a distributed revision control system.

What I am looking for, in both systems, is a tool that let me pick only parts of a file and commit them. If I want to do this now, I have to copy to a temp version of the file and keep only the changes I want to commit in the current version, and then copy the temp version to the current version again after committing. It's just such a hassle and the program should be able to do this for me.

I heard Git supports this, please let me know if this is correct.

解决方案

Mercurial can do this with the record extension.

It'll prompt you for each file and each diff hunk. For example:

% hg record
diff --git a/prelim.tex b/prelim.tex
2 hunks, 4 lines changed
examine changes to 'prelim.tex'? [Ynsfdaq?]  
@@ -12,7 +12,7 @@
 \setmonofont[Scale=0.88]{Consolas}
 % missing from xunicode.sty
 \DeclareUTFcomposite[\UTFencname]{x00ED}{\'}{\i}
-\else
+\else foo
 \usepackage[pdftex]{graphicx}
 \fi

record this change to 'prelim.tex'? [Ynsfdaq?]  
@@ -1281,3 +1281,5 @@
 %% Local variables:
 %% mode: latex
 %% End:
+
+foo
\ No newline at end of file
record this change to 'prelim.tex'? [Ynsfdaq?]  n
Waiting for Emacs...

After the commit, the remaining diff will be left behind:

% hg di
diff --git a/prelim.tex b/prelim.tex
--- a/prelim.tex
+++ b/prelim.tex
@@ -1281,3 +1281,5 @@
 %% Local variables:
 %% mode: latex
 %% End:
+
+foo
\ No newline at end of file

Alternatively, you may find it easier to use MQ (Mercurial Queues) to separate the individual changes in your repository into patches. There is a MQ variant of record (qrecord), too.

Update: Also try the crecord extension, which provides a curses interface to hunk/line selection.

这篇关于我可以只使用SVN或Mercurial提交部分代码吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆