author | Jan Vrany <jan.vrany@fit.cvut.cz> |
Fri, 21 Mar 2014 11:23:30 +0000 | |
changeset 403 | 237ed0ed6c49 |
parent 335 | 7e19ab19148b |
child 404 | d920ee124ca8 |
permissions | -rw-r--r-- |
210 | 1 |
" |
335
7e19ab19148b
Changed license to LGPL2.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
210
diff
changeset
|
2 |
stx:libscm - a new source code management library for Smalltalk/X |
7e19ab19148b
Changed license to LGPL2.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
210
diff
changeset
|
3 |
Copyright (C) 2012-2013 Jan Vrany |
7e19ab19148b
Changed license to LGPL2.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
210
diff
changeset
|
4 |
|
7e19ab19148b
Changed license to LGPL2.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
210
diff
changeset
|
5 |
This library is free software; you can redistribute it and/or |
7e19ab19148b
Changed license to LGPL2.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
210
diff
changeset
|
6 |
modify it under the terms of the GNU Lesser General Public |
7e19ab19148b
Changed license to LGPL2.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
210
diff
changeset
|
7 |
License as published by the Free Software Foundation; either |
7e19ab19148b
Changed license to LGPL2.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
210
diff
changeset
|
8 |
version 2.1 of the License. |
210 | 9 |
|
335
7e19ab19148b
Changed license to LGPL2.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
210
diff
changeset
|
10 |
This library is distributed in the hope that it will be useful, |
7e19ab19148b
Changed license to LGPL2.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
210
diff
changeset
|
11 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
7e19ab19148b
Changed license to LGPL2.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
210
diff
changeset
|
12 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
7e19ab19148b
Changed license to LGPL2.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
210
diff
changeset
|
13 |
Lesser General Public License for more details. |
7e19ab19148b
Changed license to LGPL2.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
210
diff
changeset
|
14 |
|
7e19ab19148b
Changed license to LGPL2.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
210
diff
changeset
|
15 |
You should have received a copy of the GNU Lesser General Public |
7e19ab19148b
Changed license to LGPL2.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
210
diff
changeset
|
16 |
License along with this library; if not, write to the Free Software |
7e19ab19148b
Changed license to LGPL2.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
210
diff
changeset
|
17 |
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
210 | 18 |
" |
177 | 19 |
"{ Package: 'stx:libscm/mercurial' }" |
20 |
||
21 |
Object subclass:#HGCachedFileData |
|
403
237ed0ed6c49
Initial support for Mercurial bookmarks.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
335
diff
changeset
|
22 |
instanceVariableNames:'file exists timestamp size data reader' |
177 | 23 |
classVariableNames:'' |
24 |
poolDictionaries:'' |
|
25 |
category:'SCM-Mercurial-Internal' |
|
26 |
! |
|
27 |
||
210 | 28 |
!HGCachedFileData class methodsFor:'documentation'! |
29 |
||
30 |
copyright |
|
31 |
" |
|
335
7e19ab19148b
Changed license to LGPL2.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
210
diff
changeset
|
32 |
stx:libscm - a new source code management library for Smalltalk/X |
7e19ab19148b
Changed license to LGPL2.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
210
diff
changeset
|
33 |
Copyright (C) 2012-2013 Jan Vrany |
7e19ab19148b
Changed license to LGPL2.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
210
diff
changeset
|
34 |
|
7e19ab19148b
Changed license to LGPL2.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
210
diff
changeset
|
35 |
This library is free software; you can redistribute it and/or |
7e19ab19148b
Changed license to LGPL2.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
210
diff
changeset
|
36 |
modify it under the terms of the GNU Lesser General Public |
7e19ab19148b
Changed license to LGPL2.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
210
diff
changeset
|
37 |
License as published by the Free Software Foundation; either |
7e19ab19148b
Changed license to LGPL2.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
210
diff
changeset
|
38 |
version 2.1 of the License. |
210 | 39 |
|
335
7e19ab19148b
Changed license to LGPL2.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
210
diff
changeset
|
40 |
This library is distributed in the hope that it will be useful, |
7e19ab19148b
Changed license to LGPL2.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
210
diff
changeset
|
41 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
7e19ab19148b
Changed license to LGPL2.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
210
diff
changeset
|
42 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
7e19ab19148b
Changed license to LGPL2.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
210
diff
changeset
|
43 |
Lesser General Public License for more details. |
7e19ab19148b
Changed license to LGPL2.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
210
diff
changeset
|
44 |
|
7e19ab19148b
Changed license to LGPL2.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
210
diff
changeset
|
45 |
You should have received a copy of the GNU Lesser General Public |
7e19ab19148b
Changed license to LGPL2.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
210
diff
changeset
|
46 |
License along with this library; if not, write to the Free Software |
7e19ab19148b
Changed license to LGPL2.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
210
diff
changeset
|
47 |
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
210 | 48 |
" |
49 |
! ! |
|
177 | 50 |
|
51 |
!HGCachedFileData class methodsFor:'instance creation'! |
|
52 |
||
53 |
on: file reader: reader |
|
54 |
^self new setFile: file reader: reader |
|
55 |
||
56 |
"Created: / 14-01-2013 / 16:27:11 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
57 |
! ! |
|
58 |
||
59 |
!HGCachedFileData methodsFor:'accessing'! |
|
60 |
||
61 |
value |
|
403
237ed0ed6c49
Initial support for Mercurial bookmarks.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
335
diff
changeset
|
62 |
| fexists finfo fmodtime | |
177 | 63 |
|
403
237ed0ed6c49
Initial support for Mercurial bookmarks.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
335
diff
changeset
|
64 |
fexists := file exists. |
237ed0ed6c49
Initial support for Mercurial bookmarks.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
335
diff
changeset
|
65 |
fexists == exists ifTrue:[ |
237ed0ed6c49
Initial support for Mercurial bookmarks.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
335
diff
changeset
|
66 |
fexists ifTrue:[ |
237ed0ed6c49
Initial support for Mercurial bookmarks.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
335
diff
changeset
|
67 |
finfo := file info. |
237ed0ed6c49
Initial support for Mercurial bookmarks.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
335
diff
changeset
|
68 |
fmodtime := finfo statusChangeTime ? finfo modificationTime. |
237ed0ed6c49
Initial support for Mercurial bookmarks.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
335
diff
changeset
|
69 |
(data notNil |
237ed0ed6c49
Initial support for Mercurial bookmarks.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
335
diff
changeset
|
70 |
and:[timestamp notNil |
237ed0ed6c49
Initial support for Mercurial bookmarks.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
335
diff
changeset
|
71 |
and:[fmodtime <= timestamp |
237ed0ed6c49
Initial support for Mercurial bookmarks.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
335
diff
changeset
|
72 |
and:[finfo size = size]]]) |
237ed0ed6c49
Initial support for Mercurial bookmarks.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
335
diff
changeset
|
73 |
ifTrue:[ |
237ed0ed6c49
Initial support for Mercurial bookmarks.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
335
diff
changeset
|
74 |
^ data |
237ed0ed6c49
Initial support for Mercurial bookmarks.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
335
diff
changeset
|
75 |
]. |
237ed0ed6c49
Initial support for Mercurial bookmarks.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
335
diff
changeset
|
76 |
] ifFalse:[ |
237ed0ed6c49
Initial support for Mercurial bookmarks.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
335
diff
changeset
|
77 |
^ data |
237ed0ed6c49
Initial support for Mercurial bookmarks.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
335
diff
changeset
|
78 |
]. |
177 | 79 |
]. |
403
237ed0ed6c49
Initial support for Mercurial bookmarks.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
335
diff
changeset
|
80 |
exists := fexists. |
237ed0ed6c49
Initial support for Mercurial bookmarks.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
335
diff
changeset
|
81 |
fexists ifTrue:[ |
237ed0ed6c49
Initial support for Mercurial bookmarks.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
335
diff
changeset
|
82 |
finfo isNil ifTrue:[ |
237ed0ed6c49
Initial support for Mercurial bookmarks.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
335
diff
changeset
|
83 |
finfo := file info. |
237ed0ed6c49
Initial support for Mercurial bookmarks.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
335
diff
changeset
|
84 |
fmodtime := finfo statusChangeTime ? finfo modificationTime. |
237ed0ed6c49
Initial support for Mercurial bookmarks.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
335
diff
changeset
|
85 |
]. |
237ed0ed6c49
Initial support for Mercurial bookmarks.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
335
diff
changeset
|
86 |
timestamp := fmodtime. |
237ed0ed6c49
Initial support for Mercurial bookmarks.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
335
diff
changeset
|
87 |
size := finfo size. |
237ed0ed6c49
Initial support for Mercurial bookmarks.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
335
diff
changeset
|
88 |
]. |
237ed0ed6c49
Initial support for Mercurial bookmarks.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
335
diff
changeset
|
89 |
data := reader valueWithOptionalArgument: data and: file. |
177 | 90 |
^data |
91 |
||
92 |
"Created: / 14-01-2013 / 16:25:28 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
403
237ed0ed6c49
Initial support for Mercurial bookmarks.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
335
diff
changeset
|
93 |
"Modified: / 21-03-2014 / 00:45:52 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
177 | 94 |
! ! |
95 |
||
96 |
!HGCachedFileData methodsFor:'initialization'! |
|
97 |
||
98 |
flush |
|
99 |
data := timestamp := size := nil. |
|
100 |
||
101 |
"Created: / 14-01-2013 / 16:26:28 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
102 |
! |
|
103 |
||
203
85d2f90dc053
Performance improvement: cache heads and branches.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
180
diff
changeset
|
104 |
setData: anObject |
85d2f90dc053
Performance improvement: cache heads and branches.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
180
diff
changeset
|
105 |
data := anObject |
85d2f90dc053
Performance improvement: cache heads and branches.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
180
diff
changeset
|
106 |
|
85d2f90dc053
Performance improvement: cache heads and branches.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
180
diff
changeset
|
107 |
"Created: / 25-01-2013 / 18:52:25 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
85d2f90dc053
Performance improvement: cache heads and branches.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
180
diff
changeset
|
108 |
! |
85d2f90dc053
Performance improvement: cache heads and branches.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
180
diff
changeset
|
109 |
|
177 | 110 |
setFile:fileArg reader:readerArg |
111 |
file := fileArg. |
|
112 |
reader := readerArg. |
|
113 |
||
114 |
"Created: / 14-01-2013 / 16:20:26 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
115 |
! ! |
|
116 |
||
117 |
!HGCachedFileData class methodsFor:'documentation'! |
|
118 |
||
119 |
version_HG |
|
120 |
||
121 |
^ '$Changeset: <not expanded> $' |
|
122 |
! ! |
|
203
85d2f90dc053
Performance improvement: cache heads and branches.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
180
diff
changeset
|
123 |