1 " |
1 " |
2 stx:libscm - a new source code management library for Smalltalk/X |
2 stx:libscm - a new source code management library for Smalltalk/X |
3 Copyright (C) 2012-2015 Jan Vrany |
3 Copyright (C) 2012-2015 Jan Vrany |
|
4 Copyright (C) 2020 LabWare |
4 |
5 |
5 This library is free software; you can redistribute it and/or |
6 This library is free software; you can redistribute it and/or |
6 modify it under the terms of the GNU Lesser General Public |
7 modify it under the terms of the GNU Lesser General Public |
7 License as published by the Free Software Foundation; either |
8 License as published by the Free Software Foundation; either |
8 version 2.1 of the License. |
9 version 2.1 of the License. |
31 |
32 |
32 copyright |
33 copyright |
33 " |
34 " |
34 stx:libscm - a new source code management library for Smalltalk/X |
35 stx:libscm - a new source code management library for Smalltalk/X |
35 Copyright (C) 2012-2015 Jan Vrany |
36 Copyright (C) 2012-2015 Jan Vrany |
|
37 Copyright (C) 2020 LabWare |
36 |
38 |
37 This library is free software; you can redistribute it and/or |
39 This library is free software; you can redistribute it and/or |
38 modify it under the terms of the GNU Lesser General Public |
40 modify it under the terms of the GNU Lesser General Public |
39 License as published by the Free Software Foundation; either |
41 License as published by the Free Software Foundation; either |
40 version 2.1 of the License. |
42 version 2.1 of the License. |
1535 |
1537 |
1536 savedHgCommand := UserPreferences current hgCommand. |
1538 savedHgCommand := UserPreferences current hgCommand. |
1537 pathOfHgCommand := OperatingSystem pathOfCommand:'hg'. |
1539 pathOfHgCommand := OperatingSystem pathOfCommand:'hg'. |
1538 pathOfPython := OperatingSystem pathOfCommand:'python'. |
1540 pathOfPython := OperatingSystem pathOfCommand:'python'. |
1539 |
1541 |
|
1542 "/ Extract python interpreter from `hg` command - this is to handle |
|
1543 "/ system where Mercurial is using Python 3 but `python` command |
|
1544 "/ refers to Python 2. Sigh. |
|
1545 pathOfHgCommand asFilename exists ifTrue: [ |
|
1546 | shebangLine | |
|
1547 shebangLine := pathOfHgCommand asFilename contents first. |
|
1548 (shebangLine first == $# and: [shebangLine second == $!!]) ifTrue: [ |
|
1549 pathOfPython := (shebangLine copyFrom: 3) trimSeparators. |
|
1550 ]. |
|
1551 ]. |
|
1552 |
1540 self skipIf: OperatingSystem isUNIXlike not description: 'Valid only on UNIX systems'. |
1553 self skipIf: OperatingSystem isUNIXlike not description: 'Valid only on UNIX systems'. |
1541 OperatingSystem isUNIXlike ifFalse:[ ^ self ]. "/ For St/X 6.2.2 - there's no skipIf. |
1554 OperatingSystem isUNIXlike ifFalse:[ ^ self ]. "/ For St/X 6.2.2 - there's no skipIf. |
1542 |
1555 |
1543 self skipIf: pathOfHgCommand isNil description: 'No hg command found along the PATH'. |
1556 self skipIf: pathOfHgCommand isNil description: 'No hg command found along the PATH'. |
1544 pathOfHgCommand isNil ifTrue:[ ^ self ]. "/ For St/X 6.2.2 - there's no skipIf. |
1557 pathOfHgCommand isNil ifTrue:[ ^ self ]. "/ For St/X 6.2.2 - there's no skipIf. |
1546 self skipIf: pathOfPython isNil description: 'No hg command found along the PATH'. |
1559 self skipIf: pathOfPython isNil description: 'No hg command found along the PATH'. |
1547 pathOfPython isNil ifTrue:[ ^ self ]. "/ For St/X 6.2.2 - there's no skipIf. |
1560 pathOfPython isNil ifTrue:[ ^ self ]. "/ For St/X 6.2.2 - there's no skipIf. |
1548 |
1561 |
1549 [ |
1562 [ |
1550 HGCommand hgCommand: nil. |
1563 HGCommand hgCommand: nil. |
1551 UserPreferences current hgCommand: ('python "%1"' bindWith: pathOfHgCommand). |
1564 UserPreferences current hgCommand: ('%1 "%2"' bindWith: pathOfPython with: pathOfHgCommand). |
1552 cmd := HGCommand commit message:'123'. |
1565 cmd := HGCommand commit message:'123'. |
1553 self assert: (cmd executable = pathOfPython). |
1566 self assert: (cmd executable = pathOfPython). |
1554 self assert: (cmd arguments size == 8). |
1567 self assert: (cmd arguments size == 8). |
1555 self assert: (cmd arguments at:1) = pathOfPython. |
1568 self assert: (cmd arguments at:1) = pathOfPython. |
1556 self assert: (cmd arguments at:2) = pathOfHgCommand. |
1569 self assert: (cmd arguments at:2) = pathOfHgCommand. |
1557 self assert: (cmd arguments at:3) = '--noninteractive'. |
1570 self assert: (cmd arguments at:3) = '--noninteractive'. |
1558 self assert: (cmd arguments at:4) = '--config'. |
1571 self assert: (cmd arguments at:4) = '--config'. |
1559 self assert: (cmd arguments at:5) = 'extensions.share='. |
1572 self assert: (cmd arguments at:5) = 'extensions.share='. |
1560 self assert: (cmd arguments at:6) = 'commit'. |
1573 self assert: (cmd arguments at:6) = 'commit'. |
1561 self assert: (cmd arguments at:7) = '-m'. |
1574 self assert: (cmd arguments at:7) = '-m'. |
1562 |
1575 |