File tree 2 files changed +14
-2
lines changed
2 files changed +14
-2
lines changed Original file line number Diff line number Diff line change @@ -190,7 +190,12 @@ def rev_parse(repo, rev):
190
190
raise NotImplementedError ("Support for additional @{...} modes not implemented" )
191
191
#END handle revlog index
192
192
193
- entry = ref .log ()[revlog_index ]
193
+ try :
194
+ entry = ref .log ()[revlog_index ]
195
+ except IndexError :
196
+ raise BadObject ("Invalid revlog index: %i" % revlog_index )
197
+ #END handle index out of bound
198
+
194
199
obj = Object .new_from_sha (repo , hex_to_bin (entry .newhexsha ))
195
200
196
201
# make it pass the following checks
Original file line number Diff line number Diff line change @@ -557,12 +557,19 @@ def test_rev_parse(self):
557
557
# uses HEAD.ref by default
558
558
assert rev_parse ('@{0}' ) == head .commit
559
559
if not head .is_detached :
560
- assert rev_parse ('%s@{0}' % head .ref .name ) == head .ref .commit
560
+ refspec = '%s@{0}' % head .ref .name
561
+ assert rev_parse (refspec ) == head .ref .commit
562
+ # all additional specs work as well
563
+ assert rev_parse (refspec + "^{tree}" ) == head .commit .tree
564
+ assert rev_parse (refspec + ":CHANGES" ).type == 'blob'
561
565
#END operate on non-detached head
562
566
563
567
# the last position
564
568
assert rev_parse ('@{1}' ) != head .commit
565
569
570
+ # position doesn't exist
571
+ self .failUnlessRaises (BadObject , rev_parse , '@{10000}' )
572
+
566
573
# currently, nothing more is supported
567
574
self .failUnlessRaises (NotImplementedError , rev_parse , "@{1 week ago}" )
568
575
You can’t perform that action at this time.
0 commit comments