将Mercurial修订分为两个:(1)移动文件,(2)编辑移动文件
我有一个提交,将文件移至其他文件夹中,然后对这些文件进行更改。
我想将此修订版分为两个:
- 只有文件
- 对那些移动的文件进行其余的修改。
如何使用Mercurial/Hg?
我知道我可以将当前文件移动到其他文件夹(例如文件夹 - backup_folder
),然后从头开始启动进行实际移动,然后HG COMMIT
IT,最后重命名Backup_folder->文件夹
并在顶部提交新的修订版。但是,我宁愿有一个hg
命令,该命令可以根据hg log -vpr rev 重命名为”行的“ 重命名为 >显示。
I have a commit where I moved the files into a different folder, and then made changes to those files.
I want to split this revision into two:
- Only the file moves
- the rest of modifications on those moved files.
How can I accomplish this with Mercurial/hg ?
I know I can move the current files to a different folder (e.g. folder -> backup_folder
), then start from scratch and do the actual move and then hg commit
it, and finally rename backup_folder -> folder
and commit a new revision on top. But, I rather have an hg
command that intelligibly splits it all based upon the "rename from/rename to" lines that hg log -vpr REV
shows.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
假设现有的委托尚未被推动。如果是这样,那么这将无法正常工作,因为您无法修改公开的历史记录。
假设您的历史如下:
其中
b
具有移动&修改,*
是当前的工作目录。Say
B
包含从A/B/C/File1
到d/e/e/f/file2
复制的结果。追溯将
b
分为两个部分:方法1:“ pure” mercurial(命令行)
hg up a
HG还原-r B
(此时,工作目录将包含文件移动&文件更改)
&修改文件:
hg cat -utput = a/b/c/file1 -rev = b d/e/f/file2
(现在每个移动的文件都有其原始内容,但在新位置。)
hg commit ...
(创建b'
)hg还原-r b
(恢复文件内容。)
hg commit ...
(创建c
))所以现在您的历史就像:
hg strip b
(或者,如果您还使用
HisteDit
。)离开:
在#5处,您可能可以
rebase
也应该产生相同的结果,还应处理原始提交b
其他方法2:windows上的tortoisehg(主要是GUI)
,我使用tortoisehg,并作为Visual diff工具。鉴于该设置,我认为这样做会更快地做同样的事情:
在thg中,右键单击
a
,选择“ update”右键单击
b
,选择“还原所有文件”打开每个移动& Visual Diff(
^d
)中的修改文件commit ...
右键单击
b
,选择“还原所有文件”commit ...
右键单击
b
,修改历史记录,大概是使用其他DIFF工具的剥离,或者在Windows上不使用类似的工作。
为了解决有关使用日志的问题...如果您像这样查看日志:
它将包含类似的行:
我知道没有简单 /直接的方法来获取HG来读取这些行并使用它们来重新启用命令。尽管这将列举所有复制的文件,但只需使用任何其他方式查看commit
b
也可以做到这一点。因此,不幸的是,我认为使用日志不会让您很远。This assumes the existing commits haven't yet been pushed anywhere else. If so, then this will not work properly because you can't modify history that is public.
Let's say your history looks like this:
where
B
has the move & modifications, and*
is the current working directory.Say
B
contains to results of copying froma/b/c/file1
tod/e/f/file2
.To retroactively split
B
into two parts:Approach 1: "Pure" Mercurial (command line)
hg up A
hg revert -r B
(At this point the working directory will contain both the file moves & file changes)
For each moved & modified file:
hg cat --output=a/b/c/file1 --rev=B d/e/f/file2
(Now each of the moved files will have its original contents, but in the new location.)
hg commit ...
(createsB'
)hg revert -r B
(which restores the file contents.)
hg commit ...
(createsC
)So now your history looks like:
hg strip B
(or you could use
hg prune
if you also usehistedit
.)Leaving:
At #5 you could probably
rebase
as well, which should produce the same outcome and also disposes of the original commitB
which otherApproach 2: TortoiseHG on Windows (mostly GUI)
I use TortoiseHG and also WinMerge as the visual diff tool. Given that setup, I think it would be quicker to do the same thing this way:
In THG, right click on
A
, choose "Update"Right click on
B
, choose "Revert All Files"Open each moved & modified file in visual Diff (
^D
)Commit ...
Right click on
B
, choose "Revert All Files"Commit ...
Right click on
B
, Modify History, StripPresumably THG with other diff tools, or not on Windows, would work similarly.
To address the question about using the log... if you look at the log like so:
it will contain lines like:
I know of no simple / direct way to get hg to read those lines and use them to reapply commands. And though this will enumerate all the copied files, just looking at commit
B
using any other means would do that also. So I don't think using the log gets you very far, unfortunately.