git_handler.filter_min_date: support tag times for annotated tags

Previously we'd crash on annotated tags because they don't have a 'tag_time'
property.
This commit is contained in:
Siddharth Agarwal 2014-11-04 13:56:00 -08:00
parent d1d7def3b9
commit abfba0b8e3
2 changed files with 52 additions and 3 deletions

View File

@ -1093,8 +1093,13 @@ class GitHandler(object):
# filter refs older than min_timestamp # filter refs older than min_timestamp
min_timestamp, min_offset = hgutil.parsedate(min_date) min_timestamp, min_offset = hgutil.parsedate(min_date)
def check_min_time(obj):
if isinstance(obj, Tag):
return obj.tag_time >= min_timestamp
else:
return obj.commit_time >= min_timestamp
return util.OrderedDict((ref, sha) for ref, sha in refs.iteritems() return util.OrderedDict((ref, sha) for ref, sha in refs.iteritems()
if self.git[sha].commit_time >= min_timestamp) if check_min_time(self.git[sha]))
def update_references(self): def update_references(self):
exportable = self.get_exportable() exportable = self.get_exportable()

View File

@ -270,6 +270,15 @@ and not the author date
$ GIT_AUTHOR_DATE="2014-03-01 00:00:00 +0000" \ $ GIT_AUTHOR_DATE="2014-03-01 00:00:00 +0000" \
> GIT_COMMITTER_DATE="2009-01-01 00:00:00 +0000" \ > GIT_COMMITTER_DATE="2009-01-01 00:00:00 +0000" \
> git commit -m oldcommit > /dev/null || echo "git commit error" > git commit -m oldcommit > /dev/null || echo "git commit error"
also add an annotated tag
$ git checkout -q master^
$ echo oldtag > oldtag
$ git add oldtag
$ GIT_AUTHOR_DATE="2014-03-01 00:00:00 +0000" \
> GIT_COMMITTER_DATE="2009-01-01 00:00:00 +0000" \
> git commit -m oldtag > /dev/null || echo "git commit error"
$ GIT_COMMITTER_DATE="2009-02-01 00:00:00 +0000" \
> git tag -a -m 'tagging oldtag' oldtag
$ cd .. $ cd ..
$ hg -R hgrepo pull $ hg -R hgrepo pull
pulling from $TESTTMP/gitrepo pulling from $TESTTMP/gitrepo
@ -285,18 +294,22 @@ and not the author date
$ cd gitrepo $ cd gitrepo
$ git checkout -q master
$ echo newcommit > newcommit $ echo newcommit > newcommit
$ git add newcommit $ git add newcommit
$ GIT_AUTHOR_DATE="2014-01-01 00:00:00 +0000" \ $ GIT_AUTHOR_DATE="2014-01-01 00:00:00 +0000" \
> GIT_COMMITTER_DATE="2014-01-02 00:00:00 +0000" \ > GIT_COMMITTER_DATE="2014-01-02 00:00:00 +0000" \
> git commit -m newcommit > /dev/null || echo "git commit error" > git commit -m newcommit > /dev/null || echo "git commit error"
$ git checkout -q refs/tags/oldtag
$ GIT_COMMITTER_DATE="2014-01-02 00:00:00 +0000" \
> git tag -a -m 'tagging newtag' newtag
$ cd .. $ cd ..
$ hg -R hgrepo pull $ hg -R hgrepo pull
pulling from $TESTTMP/gitrepo pulling from $TESTTMP/gitrepo
importing git objects into hg importing git objects into hg
(run 'hg heads .' to see heads, 'hg merge' to merge) (run 'hg heads .' to see heads, 'hg merge' to merge)
$ hg -R hgrepo log -r master $ hg -R hgrepo heads
changeset: 8:c7d0cf1a7601 changeset: 9:c7d0cf1a7601
bookmark: master bookmark: master
tag: default/master tag: default/master
tag: tip tag: tip
@ -304,3 +317,34 @@ and not the author date
date: Wed Jan 01 00:00:00 2014 +0000 date: Wed Jan 01 00:00:00 2014 +0000
summary: newcommit summary: newcommit
changeset: 7:d416c428c92d
tag: newtag
tag: oldtag
parent: 4:892d20308ddf
user: test <test@example.org>
date: Sat Mar 01 00:00:00 2014 +0000
summary: oldtag
changeset: 6:bdc34645137e
bookmark: releases/v2
tag: default/releases/v2
parent: 4:892d20308ddf
user: test <test@example.org>
date: Mon Jan 01 00:00:15 2007 +0000
summary: add eta
changeset: 5:3e35a45c61f9
bookmark: releases/v1
tag: default/releases/v1
user: test <test@example.org>
date: Mon Jan 01 00:00:14 2007 +0000
summary: add zeta
changeset: 2:4d41070bf840
bookmark: delta
tag: default/delta
parent: 0:3442585be8a6
user: test <test@example.org>
date: Mon Jan 01 00:00:12 2007 +0000
summary: add delta