2

我想要一个扩展程序或工具来帮助我浏览给定文件中一系列行的历史记录。假设我想查看特定函数的历史记录,当前位于 [start, end] 行。hg annotate 让我开始:

AAA  772 06-Aug-02: void Graphics2DDXF::lineTo(double x, // the x coordinate
AAA  772 06-Aug-02:                            double y // the y cooordinate
AAA  772 06-Aug-02:                            )
AAA  772 06-Aug-02:     {
BBB 2034 30-Aug-04:     LOG;
BBB 6989 05-Dec-11: 
BBB 4638 31-Oct-07:     transform_->transform(&x,&y);
AAA  772 06-Aug-02: 
BBB 7011 06-Jan-12:     AGcRoot<Line> line = gcnew Line;
BBB 6989 05-Dec-11: 
BBB 6989 05-Dec-11:     Point3d startPoint(lastPenLocation_->x(), lastPenLocation_->y(), 0.0);
BBB 6989 05-Dec-11:     Point3d endPoint(x, y, 0.0);
BBB 6989 05-Dec-11:     line->StartPoint = startPoint;
BBB 6989 05-Dec-11:     line->EndPoint = endPoint;
BBB 6989 05-Dec-11: 
BBB 4638 31-Oct-07:     lastPenLocation_ = APoint2D::New(x,y,AToleranceID::None);
BBB 7011 06-Jan-12: 
BBB 7011 06-Jan-12:     setAndAddEntity(line);
AAA  772 06-Aug-02:     }

此方法的最后一次更改是更改集 7011。我可以使用“hg diff -c7011”来检查它。

困难的部分是在那之前发生的事情。从 7011-1 的注释输出开始:

% hg annotate -r7010 file.cpp
...
AAA  772 06-Aug-02: void Graphics2DDXF::lineTo(double x, // the x coordinate
AAA  772 06-Aug-02:                            double y // the y cooordinate
AAA  772 06-Aug-02:                            )
AAA  772 06-Aug-02:     {
BBB 2034 30-Aug-04:     LOG;
BBB 6989 05-Dec-11: 
BBB 4638 31-Oct-07:     transform_->transform(&x,&y);
AAA  772 06-Aug-02: 
BBB 6989 05-Dec-11:     Line^ line = gcnew Line;
AAA  772 06-Aug-02:     addEntityToModelSpace(line);
AAA  772 06-Aug-02: 
AAA  772 06-Aug-02:     ensureLayerAvailable();
BBB 6989 05-Dec-11:     line->LayerId = s_currentLayerObjectId;
BBB 6989 05-Dec-11: 
BBB 6989 05-Dec-11:     Point3d startPoint(lastPenLocation_->x(), lastPenLocation_->y(), 0.0);
BBB 6989 05-Dec-11:     Point3d endPoint(x, y, 0.0);
BBB 6989 05-Dec-11:     line->StartPoint = startPoint;
BBB 6989 05-Dec-11:     line->EndPoint = endPoint;
BBB 6989 05-Dec-11: 
BBB 6989 05-Dec-11:     line->LinetypeId = currentLinetypeId();
BBB 6989 05-Dec-11:     line->ColorIndex = dwgColor(getColor());
BBB 4638 31-Oct-07:     lastPenLocation_ = APoint2D::New(x,y,AToleranceID::None);
AAA  772 06-Aug-02:     }

所以现在我可以看到影响这一行范围的先前变更集是 6989。等等。

如果有一个可视化工具来做这件事会很棒,但我会对只给我一系列变更集的东西感到满意:7011、6989 等。

过滤行号范围的注释输出并找到最大变更集编号并不难。困难的是调整行的范围以考虑添加和删除的行,尤其是当“差异”声称更改跨越了行范围的最小值或最大值时。至少 CVS diff 输出很难做到这一点,我还没有用 hg diff 的输出尝试过。

如果我梦寐以求的工具/扩展不存在,是否至少有任何工具可以计算修改后的行号?

谢谢,

4

1 回答 1

0

它不是为它而构建的,但您可以通过使用hg grepto search 来近似它,.这意味着正则表达式中的任何内容。这会让你得到这样的输出:

ry4an@four:~/projects/unblog$ hg grep --all --user --date . config.yaml 
config.yaml:79:-:ry4an-hg:Mon Apr 23 22:45:24 2012 -0400:TAGLINE: I think in a monospaced font.
config.yaml:79:+:ry4an-hg:Mon Apr 23 22:45:24 2012 -0400:TAGLINE: A blog about software, projects, and other little things I build.
config.yaml:52:-:ry4an-hg:Sat Apr 30 11:25:08 2011 -0500:AUTHOR: Ry4an Brase
config.yaml:52:-:ry4an-hg:Sat Apr 30 11:25:08 2011 -0500:#DISQUS: rafaelmartins-en
config.yaml:52:-:ry4an-hg:Sat Apr 30 11:25:08 2011 -0500:TIMEZONE: UTC
config.yaml:52:+:ry4an-hg:Sat Apr 30 11:25:08 2011 -0500:#POSTS_PER_PAGE: 10
config.yaml:52:+:ry4an-hg:Sat Apr 30 11:25:08 2011 -0500:AUTHOR: Ry4an Brase
config.yaml:52:+:ry4an-hg:Sat Apr 30 11:25:08 2011 -0500:#DISQUS: your-disqus-id
config.yaml:52:+:ry4an-hg:Sat Apr 30 11:25:08 2011 -0500:TIMEZONE: UTC
config.yaml:0:+:ry4an-hg:Sat Jan 22 22:51:22 2011 -0600:TITLE: Ry4an's Unblog
config.yaml:0:+:ry4an-hg:Sat Jan 22 22:51:22 2011 -0600:TITLE_HTML: Ry4an's Unblog
config.yaml:0:+:ry4an-hg:Sat Jan 22 22:51:22 2011 -0600:TAGLINE: I think in a monospaced font.
config.yaml:0:+:ry4an-hg:Sat Jan 22 22:51:22 2011 -0600:AUTHOR: Ry4an Brase
config.yaml:0:+:ry4an-hg:Sat Jan 22 22:51:22 2011 -0600:#DISQUS: rafaelmartins-en
config.yaml:0:+:ry4an-hg:Sat Jan 22 22:51:22 2011 -0600:TIMEZONE: UTC

where+表示添加了一行,-表示将其删除。该--all选项表示显示所有匹配项,而不仅仅是每行最近的匹配项。

于 2012-06-17T13:06:03.693 回答