--- a/mercurial/extensions.st Tue Aug 25 09:03:57 2015 +0100
+++ b/mercurial/extensions.st Tue Aug 25 17:13:18 2015 +0100
@@ -966,7 +966,33 @@
self binaryRevisionString notNil ifTrue:[
revInfo := HGRevisionInfo readFrom: self binaryRevisionString onError:[nil].
revInfo notNil ifTrue:[
- ^revInfo changesetId
+ "/ Now, validate the changeset in case it does not exist any longer.
+ "/ This may happen when one uses history rewriting (such as histedit,
+ "/ rebase or commit --amend) and forgot to recompile (or commit id change
+ "/ detection fails.
+ "/ If the changeset does not exist eny longer, return nil (meaning
+ "/ binary revision is unavailable)
+ | rev pkgDir repoDir repo |
+
+ rev := revInfo changesetId.
+ pkgDir := Smalltalk getPackageDirectoryForPackage: self package.
+ pkgDir notNil ifTrue:[
+ repoDir := HGRepository discover: pkgDir.
+ repoDir notNil ifTrue:[
+ repo := HGRepository on: repoDir.
+ "/ Check for common case (binary revision is working copy revision
+ "/ This helps to avoid expensive log command
+ repo workingCopy changesetId = rev ifTrue:[
+ ^ rev
+ ] ifFalse:[
+ [
+ repo changesetWithId: rev
+ ] on: HGUnknownRevisionError do:[
+ ^ nil
+ ]
+ ].
+ ].
+ ]
].
].
^nil
@@ -980,6 +1006,7 @@
"
"Created: / 20-11-2012 / 23:58:55 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+ "Modified: / 27-08-2015 / 19:42:23 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
!ProjectDefinition class methodsFor:'accessing - hg - settings'!
@@ -1031,7 +1058,7 @@
3) Look into a package directory and if there is a Mercurial repository,
return working copy's revision"
- | versionMethod versionAnnotation revInfo pkgDir repoDir repo |
+ | versionMethod versionAnnotation binRev pkgDir repoDir repo |
"1 --- "
@@ -1047,11 +1074,13 @@
].
"2 --- "
- self binaryRevisionString notNil ifTrue:[
- revInfo := HGRevisionInfo readFrom: self binaryRevisionString onError:[nil].
- revInfo notNil ifTrue:[
- ^revInfo changesetId
- ].
+ binRev := self hgBinaryRevision.
+ binRev notNil ifTrue:[
+ "/ Here, remember the revision in annotation to
+ "/ avoid (expensive) testing done on #hgBinaryRevision
+ "/ when asked a second time.
+ self hgLogicalRevision: binRev.
+ ^ binRev
].
"3 --- "
@@ -1069,7 +1098,7 @@
].
"4 --- "
- self breakPoint: #jv.
+ "/ self breakPoint: #jv.
^nil
@@ -1081,7 +1110,7 @@
"
"Created: / 20-11-2012 / 23:54:24 / Jan Vrany <jan.vrany@fit.cvut.cz>"
- "Modified: / 14-01-2013 / 13:42:56 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+ "Modified: / 28-08-2015 / 12:17:36 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
!ProjectDefinition class methodsFor:'accessing - hg'!
@@ -1095,18 +1124,20 @@
| versionMethod |
versionMethod := self class compiledMethodAt: HGSourceCodeManager nameOfVersionMethodInClasses.
- versionMethod isNil ifTrue:[
- self class compile:(self class
- versionMethodTemplateForSourceCodeManager:HGSourceCodeManager)
- classified:'documentation'.
- versionMethod := self class compiledMethodAt:HGSourceCodeManager nameOfVersionMethodInClasses.
- versionMethod setPackage:self package.
+ versionMethod isNil ifTrue:[
+ Class withoutUpdatingChangesDo: [
+ self class compile:(self class
+ versionMethodTemplateForSourceCodeManager:HGSourceCodeManager)
+ classified:'documentation'.
+ versionMethod := self class compiledMethodAt:HGSourceCodeManager nameOfVersionMethodInClasses.
+ versionMethod setPackage:self package.
+ ]
].
versionMethod annotateWith:
(HGRevisionAnnotation revision: anHGChangesetId)
"Created: / 20-02-2014 / 00:06:19 / Jan Vrany <jan.vrany@fit.cvut.cz>"
- "Modified: / 27-02-2014 / 22:16:19 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+ "Modified: / 27-08-2015 / 19:44:59 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
!ProjectDefinition class methodsFor:'description - actions - hg'!