equal
deleted
inserted
replaced
10 hereby transferred. |
10 hereby transferred. |
11 " |
11 " |
12 "{ Package: 'stx:libscm/mercurial' }" |
12 "{ Package: 'stx:libscm/mercurial' }" |
13 |
13 |
14 Object subclass:#HGRepository |
14 Object subclass:#HGRepository |
15 instanceVariableNames:'uuid path wc changesets branches heads config lock' |
15 instanceVariableNames:'uuid path wc changesets branches heads config lock server' |
16 classVariableNames:'Cache' |
16 classVariableNames:'Cache UseCommandServer' |
17 poolDictionaries:'' |
17 poolDictionaries:'' |
18 category:'SCM-Mercurial-Core' |
18 category:'SCM-Mercurial-Core' |
19 ! |
19 ! |
20 |
20 |
21 HGRepositoryObject subclass:#Changesets |
21 HGRepositoryObject subclass:#Changesets |
54 initialize |
54 initialize |
55 "Invoked at system start or when the class is dynamically loaded." |
55 "Invoked at system start or when the class is dynamically loaded." |
56 |
56 |
57 "/ please change as required (and remove this comment) |
57 "/ please change as required (and remove this comment) |
58 |
58 |
59 Cache := CacheDictionary new: 8 |
59 Cache := CacheDictionary new: 8. |
60 |
60 UseCommandServer := true. |
61 "Modified: / 14-12-2012 / 19:31:44 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
61 |
|
62 "Modified: / 03-03-2013 / 22:57:12 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
62 ! ! |
63 ! ! |
63 |
64 |
64 !HGRepository class methodsFor:'instance creation'! |
65 !HGRepository class methodsFor:'instance creation'! |
65 |
66 |
66 on: aStringOrFilename |
67 on: aStringOrFilename |
162 branches := HGCachedFileData |
163 branches := HGCachedFileData |
163 on: ((Filename named: self pathName) / '.hg' / 'store' / '00changelog.i') |
164 on: ((Filename named: self pathName) / '.hg' / 'store' / '00changelog.i') |
164 reader:[:old | |
165 reader:[:old | |
165 | rbranches current names | |
166 | rbranches current names | |
166 rbranches := old. |
167 rbranches := old. |
167 current := HGCommand branches |
168 current := self execute: |
168 workingDirectory: path pathName; |
169 (HGCommand branches |
169 active: false; |
170 workingDirectory: path pathName; |
170 closed: true; |
171 active: false; |
171 executeOnRepository: self. |
172 closed: true; |
|
173 yourself). |
172 names := rbranches collect:[:b|b name]. |
174 names := rbranches collect:[:b|b name]. |
173 current := current reject:[:b|names includes: b name]. |
175 current := current reject:[:b|names includes: b name]. |
174 current do:[:b|b setRepository: self]. |
176 current do:[:b|b setRepository: self]. |
175 rbranches addAll: current. |
177 rbranches addAll: current. |
176 rbranches isEmpty ifTrue:[ |
178 rbranches isEmpty ifTrue:[ |
181 branches setData: OrderedCollection new. |
183 branches setData: OrderedCollection new. |
182 ]. |
184 ]. |
183 ^branches value |
185 ^branches value |
184 |
186 |
185 "Created: / 27-11-2012 / 19:57:23 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
187 "Created: / 27-11-2012 / 19:57:23 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
186 "Modified: / 03-03-2013 / 20:37:51 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
188 "Modified: / 03-03-2013 / 22:52:48 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
187 ! |
189 ! |
188 |
190 |
189 config |
191 config |
190 ^config |
192 ^config |
191 |
193 |
199 heads := HGCachedFileData |
201 heads := HGCachedFileData |
200 on: ((Filename named: self pathName) / '.hg' / 'store' / '00changelog.i') |
202 on: ((Filename named: self pathName) / '.hg' / 'store' / '00changelog.i') |
201 reader:[ |
203 reader:[ |
202 | ids | |
204 | ids | |
203 |
205 |
204 ids := HGCommand heads |
206 ids := self execute: HGCommand heads. |
205 workingDirectory: path pathName; |
|
206 executeOnRepository: self. |
|
207 ids collect:[:id|self changesetWithId: id]. |
207 ids collect:[:id|self changesetWithId: id]. |
208 ]. |
208 ]. |
209 ]. |
209 ]. |
210 ^heads value. |
210 ^heads value. |
211 |
211 |
212 "Created: / 27-11-2012 / 21:33:02 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
212 "Created: / 27-11-2012 / 21:33:02 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
213 "Modified: / 03-03-2013 / 20:38:00 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
213 "Modified: / 03-03-2013 / 22:53:18 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
214 ! |
214 ! |
215 |
215 |
216 path |
216 path |
217 "Return path to the repository (directory with .hg store)" |
217 "Return path to the repository (directory with .hg store)" |
218 ^ path |
218 ^ path |
332 ^lock |
332 ^lock |
333 |
333 |
334 "Created: / 16-12-2012 / 00:39:12 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
334 "Created: / 16-12-2012 / 00:39:12 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
335 ! ! |
335 ! ! |
336 |
336 |
337 !HGRepository methodsFor:'initialization'! |
337 !HGRepository methodsFor:'initialize & release'! |
|
338 |
|
339 finalize |
|
340 server notNil ifTrue:[ server stop ]. |
|
341 |
|
342 "Created: / 03-03-2013 / 23:15:04 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
343 ! |
338 |
344 |
339 initializeOn: aStringOrFilename |
345 initializeOn: aStringOrFilename |
340 | p | |
346 | p | |
341 |
347 |
342 p := aStringOrFilename asFilename. |
348 p := aStringOrFilename asFilename. |
382 ^self class clone: path to: aStringOrFilename update: update |
388 ^self class clone: path to: aStringOrFilename update: update |
383 |
389 |
384 "Created: / 21-11-2012 / 00:21:28 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
390 "Created: / 21-11-2012 / 00:21:28 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
385 ! |
391 ! |
386 |
392 |
|
393 execute: anHGCommand |
|
394 ^UseCommandServer ifTrue:[ |
|
395 server isNil ifTrue:[ |
|
396 server := HGCommandServer new repository: self. |
|
397 server start. |
|
398 self registerForFinalization. |
|
399 ]. |
|
400 server execute: anHGCommand |
|
401 ] ifFalse:[ |
|
402 anHGCommand execute |
|
403 ] |
|
404 |
|
405 "Created: / 03-03-2013 / 22:52:48 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
406 ! |
|
407 |
387 pull |
408 pull |
388 "Pulls changesets from default upstream repository. |
409 "Pulls changesets from default upstream repository. |
389 See .hg/hgrc, section path" |
410 See .hg/hgrc, section path" |
390 |
411 |
391 ^self pull: nil |
412 ^self pull: nil |
399 an instance HGRemote, an instance of URL or a String (remote alias). |
420 an instance HGRemote, an instance of URL or a String (remote alias). |
400 If 'remote' nil, default upstream repository is used, ' |
421 If 'remote' nil, default upstream repository is used, ' |
401 |
422 |
402 See .hg/hgrc, section for configured aliases" |
423 See .hg/hgrc, section for configured aliases" |
403 |
424 |
404 ^HGCommand pull |
425 ^self execute: |
405 workingDirectory: path pathName; |
426 (HGCommand pull |
406 url: (remote ? 'default') asString; |
427 url: (remote ? 'default') asString; |
407 executeOnRepository: self. |
428 yourself) |
408 |
429 |
409 "Created: / 04-02-2013 / 15:30:22 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
430 "Created: / 04-02-2013 / 15:30:22 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
410 "Modified: / 03-03-2013 / 20:38:06 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
431 "Modified: / 03-03-2013 / 22:53:57 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
411 ! |
432 ! |
412 |
433 |
413 push |
434 push |
414 "Pushes changesets to default upstream repository. |
435 "Pushes changesets to default upstream repository. |
415 See .hg/hgrc, section path" |
436 See .hg/hgrc, section path" |
440 If force is true, push is forced (allowing creation |
461 If force is true, push is forced (allowing creation |
441 of new heads in remote repo), |
462 of new heads in remote repo), |
442 |
463 |
443 See .hg/hgrc, section path" |
464 See .hg/hgrc, section path" |
444 |
465 |
445 ^HGCommand push |
466 ^self execute: |
446 workingDirectory: path pathName; |
467 (HGCommand push |
447 url: (remote ? 'default') asString; |
468 workingDirectory: path pathName; |
448 force: force; |
469 url: (remote ? 'default') asString; |
449 executeOnRepository: self. |
470 force: force; |
|
471 yourself) |
450 |
472 |
451 "Created: / 27-11-2012 / 21:58:06 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
473 "Created: / 27-11-2012 / 21:58:06 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
452 "Modified: / 03-03-2013 / 20:38:11 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
474 "Modified: / 03-03-2013 / 22:54:21 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
453 ! ! |
475 ! ! |
454 |
476 |
455 !HGRepository methodsFor:'synchronized evaluation'! |
477 !HGRepository methodsFor:'synchronized evaluation'! |
456 |
478 |
457 synchronizationSemaphore |
479 synchronizationSemaphore |
556 |
578 |
557 Return changeset with filled data, i.e,, changeset is |
579 Return changeset with filled data, i.e,, changeset is |
558 non-lazy" |
580 non-lazy" |
559 |
581 |
560 | csets cs | |
582 | csets cs | |
561 csets := HGCommand log |
583 csets := self repository execute: |
562 workingDirectory: repository path asString; |
584 (HGCommand log |
563 revsets: (self loadRevsetsForLoad: id); |
585 workingDirectory: repository path asString; |
564 executeOnRepository: self. |
586 revsets: (self loadRevsetsForLoad: id); |
|
587 yourself). |
565 "/just to be defensive... |
588 "/just to be defensive... |
566 csets do:[:each| |
589 csets do:[:each| |
567 | existing | |
590 | existing | |
568 |
591 |
569 each setRepository: repository. |
592 each setRepository: repository. |
581 ]. |
604 ]. |
582 self assert: cs notNil. |
605 self assert: cs notNil. |
583 ^cs |
606 ^cs |
584 |
607 |
585 "Created: / 16-12-2012 / 00:57:53 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
608 "Created: / 16-12-2012 / 00:57:53 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
586 "Modified: / 03-03-2013 / 20:38:35 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
609 "Modified: / 03-03-2013 / 22:58:05 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
587 ! |
610 ! |
588 |
611 |
589 loadRevsetsForLoad: id |
612 loadRevsetsForLoad: id |
590 | revsets ids start stop addId | |
613 | revsets ids start stop addId | |
591 |
614 |