mercurial/HGWorkingCopy.st
changeset 282 fb71143ed353
parent 252 b4e6ef5c5be9
child 335 7e19ab19148b
--- a/mercurial/HGWorkingCopy.st	Wed Mar 27 11:58:06 2013 +0000
+++ b/mercurial/HGWorkingCopy.st	Mon Apr 01 14:03:48 2013 +0100
@@ -95,16 +95,55 @@
     "Return an HGChangesetId on which the working copy is based on.
      This is parent1"
 
-    ^repository changesetWithId: self changesetId.
+    ^self parent1
 
     "Created: / 13-11-2012 / 21:47:45 / Jan Vrany <jan.vrany@fit.cvut.cz>"
-    "Modified: / 08-03-2013 / 19:51:22 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "Modified: / 01-04-2013 / 12:44:27 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 !
 
 changesetId
     "Return an HGChangeset on which the working copy is based on.
      This is parent1"
 
+    ^self parent1Id
+
+    "Created: / 08-03-2013 / 19:50:27 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "Modified: / 01-04-2013 / 12:43:36 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+commitTask
+    ^HGCommitTask new temporaryWorkingCopy: self
+
+    "Created: / 01-04-2013 / 12:56:34 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+conflicts
+    "Return entries with conflicts (both resolved and unresolved)"
+
+    ^self mergeState paths collect:[:p|root / p]
+
+    "Created: / 14-01-2013 / 21:48:19 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+heads
+    "Return heads of currently checked-out branch"
+
+    ^self branch heads
+
+    "Created: / 27-11-2012 / 21:51:33 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+parent1
+    "Return an HGChangeset representing parent1 of the receiver"
+
+    ^repository changesetWithId: self parent1Id.
+
+    "Created: / 01-04-2013 / 12:44:13 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+parent1Id
+    "Return an HGChangesetId of parent1 of this working copy."
+
     | id dirstate |
 
     dirstate := root asFilename / '.hg' / 'dirstate'.
@@ -120,23 +159,37 @@
 
     ^id.
 
-    "Created: / 08-03-2013 / 19:50:27 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "Created: / 01-04-2013 / 12:42:52 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+parent2
+    "Return an HGChangeset representing parent2 of the receiver"
+
+    ^repository changesetWithId: self parent2Id.
+
+    "Created: / 01-04-2013 / 12:52:51 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 !
 
-conflicts
-    "Return entries with conflicts (both resolved and unresolved)"
+parent2Id
+    "Return an HGChangesetId of parent1 of this working copy."
 
-    ^self mergeState paths collect:[:p|root / p]
+    | id dirstate |
 
-    "Created: / 14-01-2013 / 21:48:19 / Jan Vrany <jan.vrany@fit.cvut.cz>"
-!
+    dirstate := root asFilename / '.hg' / 'dirstate'.
+    dirstate exists ifFalse:[ 
+        "No changeset yet - fresh repository"
+        ^ HGChangesetId null 
+    ].
 
-heads
-    "Return heads of currently checked-out branch"
+    dirstate readingFileDo:[:s|
+        s binary.
+        s skip: 20.
+        id := HGChangesetId fromBytes: (s next: 20).
+    ].
 
-    ^self branch heads
+    ^id.
 
-    "Created: / 27-11-2012 / 21:51:33 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "Created: / 01-04-2013 / 12:43:09 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 !
 
 path