mercurial/HGChangeset.st
changeset 808 ae9fdbfa8ba4
parent 686 cfe3514ecfb2
child 812 10b0181c33fb
--- a/mercurial/HGChangeset.st	Thu Feb 08 09:09:51 2018 +0000
+++ b/mercurial/HGChangeset.st	Thu Feb 08 09:54:32 2018 +0000
@@ -22,7 +22,7 @@
 
 HGRepositoryObject subclass:#HGChangeset
 	instanceVariableNames:'lazy id branches bookmarks author timestamp message summary
-		parent1 parent2 root rootPackage changes'
+		parent1 parent2 root rootPackage changes obsolete successors'
 	classVariableNames:'NullChangeset'
 	poolDictionaries:''
 	category:'SCM-Mercurial-Core'
@@ -333,6 +333,46 @@
     "Created: / 06-03-2014 / 09:22:33 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 !
 
+successors
+    "Return the list of successors for this changeset."
+
+    "/ In theory, we coould (and should) use HGCachedFileData, however
+    "/ at least on UNIX systems the timestamp resolution is only 1sec
+    "/ which is too coarse to work reliably on modern fast machines.
+    "/
+    "/ Sp, no caching until we get at least milliscond resolution. 
+    "/ Sigh.
+    "
+    successors isNil ifTrue:[ 
+        successors := HGCachedFileData
+                        on: repository pathToHgStore00changelog_i
+                        reader:[
+                            | ids |    
+
+                            ids := repository execute:
+                                        (HGCommand log
+                                            workingDirectory: repository path asString;
+                                            revset: 'successors(', id printStringWithoutNumber, ')';
+                                            hidden: true; 
+                                            yourself).  
+                            ids collect:[ :id | repository changesetWithId: id ]                            
+                        ].       
+    ].
+    ^ successors value.
+    "
+    | ids |    
+
+    ids := repository execute:
+                (HGCommand log
+                    workingDirectory: repository path asString;
+                    revset: 'successors(', id printStringWithoutNumber, ')';
+                    hidden: true; 
+                    yourself).  
+    ^ids collect:[ :id | repository changesetWithId: id ]                            
+
+    "Created: / 08-02-2018 / 15:27:42 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
 summary
     summary isNil ifTrue:[
         self ensureNotLazy.
@@ -608,6 +648,40 @@
     ^true
 
     "Created: / 22-01-2013 / 13:38:00 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+isObsolete
+    "Return `true`, if the changeset is obsolete, `false` otherwise."
+
+    "/ In theory, we coould (and should) use HGCachedFileData, however
+    "/ at least on UNIX systems the timestamp resolution is only 1sec
+    "/ which is too coarse to work reliably on modern fast machines.
+    "/
+    "/ Sp, no caching until we get at least milliscond resolution. 
+    "/ Sigh.
+    "
+    obsolete isNil ifTrue:[
+        obsolete := HGCachedFileData
+                        on: repository pathToHgStore00changelog_i
+                        reader:[
+                            [ 
+                                repository log: id printStringWithoutNumber limit: 1.
+                                false
+                            ] on: HGObsoleteRevisionError do:[
+                                true
+                            ]
+                        ].                                
+    ].
+    ^obsolete value.
+    "
+    ^ [ 
+        repository log: id printStringWithoutNumber limit: 1.
+        false
+    ] on: HGObsoleteRevisionError do:[
+        true
+    ]
+
+    "Created: / 08-02-2018 / 09:14:40 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 ! !
 
 !HGChangeset methodsFor:'utilities'!