--- a/mercurial/HGRepository.st Sat Nov 17 01:11:41 2012 +0000
+++ b/mercurial/HGRepository.st Sat Nov 17 01:11:55 2012 +0000
@@ -8,7 +8,7 @@
!
HGRepositoryObject subclass:#Changesets
- instanceVariableNames:'changesets'
+ instanceVariableNames:'changesets revno2nodeIdMap'
classVariableNames:''
poolDictionaries:''
privateIn:HGRepository
@@ -90,6 +90,13 @@
"Modified (comment): / 13-11-2012 / 18:18:13 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
+pathName
+ "Return path to the repository (directory with .hg store)"
+ ^ path pathName
+
+ "Created: / 16-11-2012 / 22:36:56 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
uuid
"Returns unique ID identifing this concrete instance
of a repository"
@@ -110,6 +117,12 @@
!HGRepository methodsFor:'accessing-changesets'!
+@ id
+ ^self changesetWithId: id.
+
+ "Created: / 16-11-2012 / 20:29:20 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
changesetWithId: id
^changesets changesetWithId: id
@@ -216,21 +229,36 @@
!HGRepository::Changesets methodsFor:'accessing'!
-changesetWithId: anHGNodeId
- ^changesets at: anHGNodeId ifAbsent:[
- | cs |
- cs := HGCommand log
- workingDirectory: repository path asString;
- start: anHGNodeId printString;
- execute.
- cs do:[:changeset|
- changeset setRepository: repository.
- changesets at: changeset id put: changeset.
- ].
- changesets at: anHGNodeId
- ]
+changesetWithId: idobj
+ | id xid cs |
+
+ id := idobj asHGNodeId.
+ "/Try to translate it...
+ id hasRevnoOnly ifTrue:[
+ xid := revno2nodeIdMap at: id revno ifAbsent:[nil].
+ ] ifFalse:[
+ xid := id.
+ ].
+
+ "/Look in cache using xlated id...
+ cs := changesets at: xid ifAbsent:[ nil ].
+ cs notNil ifTrue: [ ^ cs ].
+
+ cs := HGCommand log
+ workingDirectory: repository path asString;
+ start: (xid ? id) printString;
+ execute.
+ "/just to be defensive...
+ self assert: cs size == 1.
+ cs do:[:changeset|
+ changeset setRepository: repository.
+ changesets at: changeset id put: changeset.
+ revno2nodeIdMap at: changeset id revno put: changeset id.
+ ].
+ ^cs anElement.
"Created: / 13-11-2012 / 17:52:10 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+ "Modified: / 16-11-2012 / 22:04:52 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
!HGRepository::Changesets methodsFor:'initialization'!
@@ -240,10 +268,11 @@
"/ please change as required (and remove this comment)
changesets := Dictionary new.
+ revno2nodeIdMap := Dictionary new.
"/ super initialize. -- commented since inherited method does nothing
- "Modified: / 13-11-2012 / 18:00:04 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+ "Modified: / 16-11-2012 / 21:58:59 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
!HGRepository class methodsFor:'documentation'!