changeset 6737:7239e06e58e9

context: consistently return p1 context for None
author Matt Mackall <mpm@selenic.com>
date Wed, 25 Jun 2008 17:33:51 -0500
parents 369ddc9c0339
children 336fda65759a
files mercurial/context.py tests/test-children.out tests/test-convert-filemap tests/test-convert-filemap.out tests/test-convert-git tests/test-convert-git.out tests/test-manifest tests/test-manifest.out
diffstat 8 files changed, 39 insertions(+), 20 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/context.py	Wed Jun 25 17:33:34 2008 -0500
+++ b/mercurial/context.py	Wed Jun 25 17:33:51 2008 -0500
@@ -19,11 +19,8 @@
         if not changeid and changeid != 0:
             p1, p2 = self._repo.dirstate.parents()
             self._rev = self._repo.changelog.rev(p1)
-            if self._rev == -1:
-                changeid = 'tip'
-            else:
-                self._node = p1
-                return
+            self._node = p1
+            return
 
         self._node = self._repo.lookup(changeid)
         self._rev = self._repo.changelog.rev(self._node)
--- a/tests/test-children.out	Wed Jun 25 17:33:34 2008 -0500
+++ b/tests/test-children.out	Wed Jun 25 17:33:51 2008 -0500
@@ -5,6 +5,18 @@
 % hg children at revision 3 (tip)
 0 files updated, 0 files merged, 1 files removed, 0 files unresolved
 % hg children at nullrev (should be 0 and 3)
+changeset:   0:4df8521a7374
+user:        test
+date:        Thu Jan 01 00:00:00 1970 +0000
+summary:     0
+
+changeset:   3:e2962852269d
+tag:         tip
+parent:      -1:000000000000
+user:        test
+date:        Thu Jan 01 00:00:03 1970 +0000
+summary:     3
+
 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
 % hg children at revision 1 (should be 2)
 changeset:   2:8f5eea5023c2
--- a/tests/test-convert-filemap	Wed Jun 25 17:33:34 2008 -0500
+++ b/tests/test-convert-filemap	Wed Jun 25 17:33:51 2008 -0500
@@ -80,6 +80,7 @@
 	echo "include $i" >> "$fmap"
     done
     hg -q convert $opts --filemap "$fmap" --datesort source "$repo"
+    hg up -q -R "$repo"
     glog -R "$repo"
     hg -R "$repo" manifest --debug
 }
@@ -115,6 +116,7 @@
 rename copied copied2
 EOF
 hg -q convert --filemap renames.fmap --datesort source renames.repo
+hg up -q -R renames.repo
 glog -R renames.repo
 hg -R renames.repo manifest --debug
 hg --cwd renames.repo debugrename copied2
--- a/tests/test-convert-filemap.out	Wed Jun 25 17:33:34 2008 -0500
+++ b/tests/test-convert-filemap.out	Wed Jun 25 17:33:51 2008 -0500
@@ -29,7 +29,7 @@
 copied renamed from foo:2ed2a3912a0b24502043eae84ee4b279c18b90dd
 
 % foo: skip unwanted merges; use 1st parent in 1st merge, 2nd in 2nd
-o  3 "8: change foo" files: foo
+@  3 "8: change foo" files: foo
 |
 o  2 "6: change foo baz" files: foo
 |
@@ -39,7 +39,7 @@
 
 9a7b52012991e4873687192c3e17e61ba3e837a3 644   foo
 % bar: merges are not merges anymore
-o  4 "7: second merge; change bar" files: bar
+@  4 "7: second merge; change bar" files: bar
 |
 o  3 "5: change bar baz quux" files: bar
 |
@@ -51,7 +51,7 @@
 
 9463f52fe115e377cf2878d4fc548117211063f2 644   bar
 % baz: 1st merge is not a merge anymore; 2nd still is
-o    4 "7: second merge; change bar" files: baz
+@    4 "7: second merge; change bar" files: baz
 |\
 | o  3 "6: change foo baz" files: baz
 | |
@@ -63,7 +63,7 @@
 
 94c1be4dfde2ee8d78db8bbfcf81210813307c3d 644   baz
 % foo quux: we add additional merges when they are interesting
-o  8 "8: change foo" files: foo
+@  8 "8: change foo" files: foo
 |
 o    7 "7: second merge; change bar" files:
 |\
@@ -84,14 +84,14 @@
 9a7b52012991e4873687192c3e17e61ba3e837a3 644   foo
 bc3eca3f47023a3e70ca0d8cc95a22a6827db19d 644   quux
 % bar quux: partial conversion
-o  1 "3: change bar quux" files: bar quux
+@  1 "3: change bar quux" files: bar quux
 |
 o  0 "1: add bar quux; copy foo to copied" files: bar quux
 
 b79105bedc55102f394e90a789c9c380117c1b4a 644   bar
 db0421cc6b685a458c8d86c7d5c004f94429ea23 644   quux
 % bar quux: complete the partial conversion
-o  4 "7: second merge; change bar" files: bar
+@  4 "7: second merge; change bar" files: bar
 |
 o  3 "5: change bar baz quux" files: bar quux
 |
@@ -104,11 +104,11 @@
 9463f52fe115e377cf2878d4fc548117211063f2 644   bar
 bc3eca3f47023a3e70ca0d8cc95a22a6827db19d 644   quux
 % foo: partial conversion
-o  0 "0: add foo baz dir/" files: foo
+@  0 "0: add foo baz dir/" files: foo
 
 2ed2a3912a0b24502043eae84ee4b279c18b90dd 644   foo
 % foo: complete the partial conversion
-o  3 "8: change foo" files: foo
+@  3 "8: change foo" files: foo
 |
 o  2 "6: change foo baz" files: foo
 |
@@ -118,12 +118,12 @@
 
 9a7b52012991e4873687192c3e17e61ba3e837a3 644   foo
 % copied: copied file; source not included in new repo
-o  0 "1: add bar quux; copy foo to copied" files: copied
+@  0 "1: add bar quux; copy foo to copied" files: copied
 
 2ed2a3912a0b24502043eae84ee4b279c18b90dd 644   copied
 copied not renamed
 % foo copied: copied file; source included in new repo
-o  4 "8: change foo" files: foo
+@  4 "8: change foo" files: foo
 |
 o  3 "6: change foo baz" files: foo
 |
@@ -136,7 +136,7 @@
 6ca237634e1f6bee1b6db94292fb44f092a25842 644   copied
 9a7b52012991e4873687192c3e17e61ba3e837a3 644   foo
 copied renamed from foo:2ed2a3912a0b24502043eae84ee4b279c18b90dd
-o  4 "8: change foo" files: foo2
+@  4 "8: change foo" files: foo2
 |
 o  3 "6: change foo baz" files: foo2
 |
--- a/tests/test-convert-git	Wed Jun 25 17:33:34 2008 -0500
+++ b/tests/test-convert-git	Wed Jun 25 17:33:51 2008 -0500
@@ -53,7 +53,7 @@
 cd ..
 
 hg convert --datesort git-repo
-
+hg up -q -R git-repo-hg
 hg -R git-repo-hg tip -v
 
 count=10
@@ -117,12 +117,14 @@
 	echo "include $i" >> "$fmap"
     done
     hg -q convert $opts --filemap "$fmap" --datesort git-repo2 "$repo"
+    hg up -q -R "$repo"
     glog -R "$repo"
     hg -R "$repo" manifest --debug
 }
 
 echo '% full conversion'
 hg -q convert --datesort git-repo2 fullrepo
+hg up -q -R fullrepo
 glog -R fullrepo
 hg -R fullrepo manifest --debug
 
--- a/tests/test-convert-git.out	Wed Jun 25 17:33:34 2008 -0500
+++ b/tests/test-convert-git.out	Wed Jun 25 17:33:51 2008 -0500
@@ -24,7 +24,7 @@
 
 
 % full conversion
-o    9 "Discard change to foo" files: foo
+@    9 "Discard change to foo" files: foo
 |\
 | o  8 "change foo" files: foo
 | |
@@ -49,7 +49,7 @@
 9277c9cc8dd4576fc01a17939b4351e5ada93466 644   foo
 88dfeab657e8cf2cef3dec67b914f49791ae76b1 644   quux
 % foo bar baz: octopus merge
-o    8 "Discard change to foo" files: foo
+@    8 "Discard change to foo" files: foo
 |\
 | o  7 "change foo" files: foo
 | |
@@ -71,7 +71,7 @@
 354ae8da6e890359ef49ade27b68bbc361f3ca88 644   baz
 9277c9cc8dd4576fc01a17939b4351e5ada93466 644   foo
 % foo baz quux: only some parents of an octopus merge; "discard" a head
-o  6 "Discard change to foo" files: foo
+@  6 "Discard change to foo" files: foo
 |
 o  5 "change foo" files: foo
 |
--- a/tests/test-manifest	Wed Jun 25 17:33:34 2008 -0500
+++ b/tests/test-manifest	Wed Jun 25 17:33:51 2008 -0500
@@ -14,6 +14,10 @@
 hg init
 hg -q pull "$TESTDIR/test-manifest.hg"
 
+echo % should be empty
+hg manifest
+
+hg co
 hg manifest
 hg manifest -v
 hg manifest --debug
--- a/tests/test-manifest.out	Wed Jun 25 17:33:34 2008 -0500
+++ b/tests/test-manifest.out	Wed Jun 25 17:33:51 2008 -0500
@@ -1,3 +1,5 @@
+% should be empty
+3 files updated, 0 files merged, 0 files removed, 0 files unresolved
 a
 b/a
 l