还有哪些其他存储库系统具有 cvs 的 -D(日期)选项?

发布于 2024-09-13 02:10:42 字数 219 浏览 3 评论 0原文

我最近在 CVS 中偶然发现了一个很酷的功能,您可以按日期命名修订,例如:

# List changes made between the latest revision 24 hours ago and now
cvs diff -D "1 day ago"

其他存储库系统(例如 Git、SVN、Bazaar、Mercurial 等)是否有这样的选项?

I recently stumbled upon a cool feature in CVS where you can name revisions by date, e.g.:

# List changes made between the latest revision 24 hours ago and now
cvs diff -D "1 day ago"

Do any other repository systems (e.g. Git, SVN, Bazaar, Mercurial, etc.) have an option like this?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

爱殇璃 2024-09-20 02:10:43

(回答我自己的问题)

git log 支持在给定时间之前或之后过滤日期。示例:

git log --after='july 17 2010' --before='july 31 2010'

这是一个 shell 脚本,可以更轻松地列出提交范围,但它也使用比 git log 的默认格式更简洁的格式:

#!/bin/sh
# git-changes

FORMAT='%cd%x09%h%n%x09%s%n'
CMD="git log --format=format:$FORMAT"

case $# in
    0 )
        $CMD ;;
    1 )
        $CMD "--after=`date -d "$1"`" ;;
    2 )
        $CMD "--after=`date -d "$1"`" --before="`date -d "$2"`";;
esac

注意:我用 date 命令包装了日期参数,因为 git 处理 'July由于某种原因,“2010 年 7 月 17 日”比“2010 年 7 月 17 日”晚了几个小时。

用法:

git-changes                  # Same as git log, but more terse
git-changes 'yesterday'      # List all commits from 24 hours ago to now
git-changes 'jul 17' 'aug 1' # List all commits after July 17 at midnight
                             #              and before August 1 at midnight.

git-changes 'jul 17' 'aug 1' 的示例输出:

Sat Jul 31 23:43:47 2010 -0400  86a6727
        * Moved libcurl into project directory as static lib.

Sat Jul 31 20:04:24 2010 -0400  3a4eb10
        * Added configuration file support.

Sat Jul 31 17:44:53 2010 -0400  aa2046b
        * Fixed truncation bug in bit parser.

Sat Jul 17 00:10:57 2010 -0400  99e8124
        * Added support for more bits.

现在,要查看提交 99e8124 引入的所有更改,请输入 git show 99e8124。要查看自修订版 99e8124 以来的所有更改(不包括该提交本身),请输入 git diff 99e8124。

(answering my own question)

git log supports dates for filtering before or after given times. Example:

git log --after='july 17 2010' --before='july 31 2010'

Here's a shell script that makes it a little easier to list ranges of commits, but it also uses a terser format than git log's default:

#!/bin/sh
# git-changes

FORMAT='%cd%x09%h%n%x09%s%n'
CMD="git log --format=format:$FORMAT"

case $# in
    0 )
        $CMD ;;
    1 )
        $CMD "--after=`date -d "$1"`" ;;
    2 )
        $CMD "--after=`date -d "$1"`" --before="`date -d "$2"`";;
esac

Note: I wrapped the date arguments with the date command, since git treats 'July 17' as a few hours off from 'July 17 2010' for some reason.

Usage:

git-changes                  # Same as git log, but more terse
git-changes 'yesterday'      # List all commits from 24 hours ago to now
git-changes 'jul 17' 'aug 1' # List all commits after July 17 at midnight
                             #              and before August 1 at midnight.

Sample output of git-changes 'jul 17' 'aug 1':

Sat Jul 31 23:43:47 2010 -0400  86a6727
        * Moved libcurl into project directory as static lib.

Sat Jul 31 20:04:24 2010 -0400  3a4eb10
        * Added configuration file support.

Sat Jul 31 17:44:53 2010 -0400  aa2046b
        * Fixed truncation bug in bit parser.

Sat Jul 17 00:10:57 2010 -0400  99e8124
        * Added support for more bits.

Now, to see all changes introduced by commit 99e8124, type git show 99e8124. To see all changes since revision 99e8124 (not including that commit itself), type git diff 99e8124.

姐不稀罕 2024-09-20 02:10:42

Subversion 也有类似的功能。例如:

svn diff -r {2010-07-31}

语法在 http://svnbook.red-bean.com/en/1.5/svn.tour.revs.specifiers.html#svn.tour.revs.dates

Subversion has a similar feature. For example:

svn diff -r {2010-07-31}

The syntax is explained in http://svnbook.red-bean.com/en/1.5/svn.tour.revs.specifiers.html#svn.tour.revs.dates

呆萌少年 2024-09-20 02:10:42

Mercurial 具有多种日期格式: http://www.selenic .com/mercurial/hg.1.html#date-formats,尽管可能不是“1 天前”。

此 Subversion 错误报告表明 Subversion 无法做到这一点本身,但确实提供了使用 date 来执行此操作的提示:

(2) 虽然 Subversion 不理解 -r "{3 days ago}",但 date 可以
也可以帮忙:-r“{date -Is -d '3天前'}”。

Mercurial has a wide range of date formats: http://www.selenic.com/mercurial/hg.1.html#date-formats, though maybe not "1 day ago".

This subversion bug report indicates that Subversion can't do it natively, but does offer a tip on using date to do it:

(2) Whilst Subversion doesn't understand -r "{3 days ago}", date can
help out there too: -r "{date -Is -d '3 days ago'}".

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文