mercurial/HGRepository.st
changeset 372 5acd6d915c77
parent 335 7e19ab19148b
child 395 fc0607653d8a
--- a/mercurial/HGRepository.st	Fri Feb 07 11:02:59 2014 +0100
+++ b/mercurial/HGRepository.st	Sun Feb 09 19:36:58 2014 +0000
@@ -325,6 +325,19 @@
     ^changesets changesetWithId: id
 
     "Created: / 13-11-2012 / 17:58:52 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+changesetsMatching: revset limit: limit
+    "Returns a list of changesets that matches given revset, but not more than
+     `limit` changesets.
+
+    revset could be either HGRevset or plain string.
+    limit is an integer or nil for not limit at all (use vit caution
+    on large repositories this may take a while)
+    "
+    ^changesets changesetsMatching: revset limit: limit
+
+    "Created: / 07-02-2014 / 13:08:28 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 ! !
 
 !HGRepository methodsFor:'accessing-private'!
@@ -448,6 +461,19 @@
     "Modified (format): / 06-03-2013 / 11:14:41 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 !
 
+log: revset limit: limit
+    "Returns a list of changesets that matches given revset, but not more than
+     `limit` changesets.
+
+    revset could be either HGRevset or plain string.
+    limit is an integer or nil for not limit at all (use vit caution
+    on large repositories this may take a while)
+    "
+    ^ self changesetsMatching: revset limit: limit
+
+    "Created: / 07-02-2014 / 13:08:52 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
 pull
     "Pulls changesets from default upstream repository.
      See .hg/hgrc, section path"
@@ -597,6 +623,35 @@
 
     "Created: / 13-11-2012 / 17:52:10 / Jan Vrany <jan.vrany@fit.cvut.cz>"
     "Modified (format): / 08-03-2013 / 19:54:34 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+changesetsMatching: revset limit: limit
+    | csets |
+
+    csets := self repository execute:
+                    (HGCommand log
+                        workingDirectory: repository path asString;
+                        revset: revset;
+                        limit: limit; 
+                        yourself).
+    csets collect:[ :cset |
+        | existing |
+
+        existing := changesets at: cset id ifAbsent:[ nil ].
+        existing isNil ifTrue:[ 
+            cset setRepository: repository .
+            changesets at: cset id put: cset. 
+            revno2nodeIdMap at: cset id revno put: cset id.
+            cset
+        ] ifFalse:[ 
+            existing.
+        ].
+
+    ].
+    ^ csets
+
+    "Created: / 07-02-2014 / 13:11:59 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "Modified: / 08-02-2014 / 22:34:31 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 ! !
 
 !HGRepository::Changesets methodsFor:'initialization'!