--- a/mercurial/HGWorkingCopyFile.st Tue Jan 22 12:35:43 2013 +0000
+++ b/mercurial/HGWorkingCopyFile.st Tue Jan 22 14:05:05 2013 +0000
@@ -7,6 +7,13 @@
category:'SCM-Mercurial-Core'
!
+Object subclass:#LazyRevision
+ instanceVariableNames:'collection index changeset wc path'
+ classVariableNames:''
+ poolDictionaries:''
+ privateIn:HGWorkingCopyFile
+!
+
!HGWorkingCopyFile class methodsFor:'documentation'!
documentation
@@ -81,35 +88,39 @@
revisions isNil ifTrue:[
- | old p |
- old := HGCommand log
+ | old oldIds |
+ oldIds := HGCommand log
workingDirectory: wc pathName;
path: path;
execute.
- p := pathS.
- old := old collect: [:id|
- | cs f |
-
- f := (cs := wc repository changesetWithId: id) / p.
-
- cs changes do:[:chg|
- "/Catch renames...
- (chg isCopied and:[chg path = p]) ifTrue:[
- p := chg source.
- ]
- ].
- f.
+ pathS.
+ old := OrderedCollection new.
+ oldIds withIndexDo: [:id :index|
+ old add: (
+ LazyRevision new
+ setCollection: old index: index changesetId: id workingCopy: wc path: pathS)
+"/ | cs f |
+"/
+"/ f := (cs := wc repository changesetWithId: id) / p.
+"/
+"/ cs changes do:[:chg|
+"/ "/Catch renames...
+"/ (chg isCopied and:[chg path = p]) ifTrue:[
+"/ p := chg source.
+"/ ]
+"/ ].
+"/ f.
].
revisions := old.
].
- "/older revisions are cached, newer not since this may change...
+ "/older revisions are cached, newer not since they may change...
^((wc changeset / pathS) newer:true) , revisions
"Created: / 05-12-2012 / 19:09:48 / Jan Vrany <jan.vrany@fit.cvut.cz>"
"Modified: / 06-12-2012 / 03:50:58 / jv"
- "Modified: / 16-12-2012 / 01:23:08 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+ "Modified: / 22-01-2013 / 13:52:47 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
status
@@ -500,6 +511,82 @@
"Created: / 14-11-2012 / 23:56:29 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
+!HGWorkingCopyFile::LazyRevision methodsFor:'accessing'!
+
+changeset
+ ^changeset isHGChangeset
+ ifTrue:[changeset]
+ ifFalse:[changeset := wc repository changesetWithId: changeset]
+
+ "Created: / 22-01-2013 / 13:38:53 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+changesetId
+ ^changeset isHGChangesetId
+ ifTrue:[changeset]
+ ifFalse:[changeset id]
+
+ "Created: / 22-01-2013 / 13:38:47 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+! !
+
+!HGWorkingCopyFile::LazyRevision methodsFor:'error handling'!
+
+doesNotUnderstand: aMessage
+ (HGChangesetFile canUnderstand: aMessage selector) ifFalse:[
+ ^ super doesNotUnderstand: aMessage
+ ].
+ self ensureNotLazy.
+ ^aMessage sendTo: (collection at: index).
+
+ "Created: / 22-01-2013 / 13:41:20 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+! !
+
+!HGWorkingCopyFile::LazyRevision methodsFor:'initialization'!
+
+setCollection: coll index: idx changesetId: csId workingCopy: workCopy path: p
+ collection := coll.
+ index := idx.
+ changeset := csId.
+ wc := workCopy.
+ path := p.
+
+ "Created: / 22-01-2013 / 13:32:15 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+setPath: p
+ path := p.
+
+ "Created: / 22-01-2013 / 13:48:45 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+! !
+
+!HGWorkingCopyFile::LazyRevision methodsFor:'private'!
+
+ensureNotLazy
+ | cs file renamed |
+
+ index ~~ 1 ifTrue:[
+ (collection at: index - 1) ensureNotLazy.
+ ].
+
+ cs := self changeset.
+ file := cs / path.
+ collection at: index put: file.
+ index ~~ collection size ifTrue:[
+ cs changes do:[:chg|
+ "/Catch renames...
+ (chg isCopied and:[chg path = path]) ifTrue:[
+ renamed := chg source.
+ index + 1 to: collection size do:[:i|
+ (collection at: i) setPath: renamed.
+ ].
+ ^self
+ ]
+ ].
+ ].
+
+ "Created: / 22-01-2013 / 13:48:36 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+! !
+
!HGWorkingCopyFile class methodsFor:'documentation'!
version_HG
@@ -510,3 +597,4 @@
version_SVN
^ '§Id:: §'
! !
+