开发者

What other repository systems have cvs's -D (date) option?

开发者 https://www.devze.com 2023-01-09 23:22 出处:网络
I recently stumbl开发者_JS百科ed upon a cool feature in CVS where you can name revisions by date, e.g.:

I recently stumbl开发者_JS百科ed 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?


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


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'}".


(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.

0

精彩评论

暂无评论...
验证码 换一张
取 消