changeset 157:91541523ea5c

utility_commands: Test outgoing and fix it to work again.
author Augie Fackler <durin42@gmail.com>
date Wed, 24 Dec 2008 11:12:23 -0600
parents 56dae5beae65
children 91c818377703
files tests/test_utility_commands.py utility_commands.py
diffstat 2 files changed, 64 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/tests/test_utility_commands.py
+++ b/tests/test_utility_commands.py
@@ -6,6 +6,7 @@ from mercurial import ui
 from mercurial import hg
 from mercurial import revlog
 from mercurial import context
+from mercurial import node
 
 import utility_commands
 import fetch_command
@@ -45,6 +46,68 @@ class UtilityTests(test_util.TestBase):
                      })
         self.assertEqual(u.stream.getvalue(), expected)
 
+    def test_parent_output(self):
+        self._load_fixture_and_fetch('two_heads.svndump')
+        u = ui.ui()
+        parents = (self.repo['the_branch'].node(), revlog.nullid, )
+        def filectxfn(repo, memctx, path):
+            return context.memfilectx(path=path,
+                                      data='added',
+                                      islink=False,
+                                      isexec=False,
+                                      copied=False)
+        ctx = context.memctx(self.repo,
+                             parents,
+                             'automated test',
+                             ['added_bogus_file', 'other_added_file', ],
+                             filectxfn,
+                             'testy',
+                             '2008-12-21 16:32:00 -0500',
+                             {'branch': 'localbranch', })
+        new = self.repo.commitctx(ctx)
+        hg.update(self.repo, new)
+        utility_commands.print_parent_revision(u, self.repo, self.wc_path)
+        self.assert_(node.hex(self.repo['the_branch'].node())[:8] in
+                     u.stream.getvalue())
+        self.assert_('the_branch' in u.stream.getvalue())
+        self.assert_('r5' in u.stream.getvalue())
+        hg.update(self.repo, 'default')
+        u = ui.ui()
+        utility_commands.print_parent_revision(u, self.repo, self.wc_path)
+        self.assert_(node.hex(self.repo['default'].node())[:8] in
+                     u.stream.getvalue())
+        self.assert_('trunk' in u.stream.getvalue())
+        self.assert_('r6' in u.stream.getvalue())
+
+    def test_outgoing_output(self):
+        self._load_fixture_and_fetch('two_heads.svndump')
+        u = ui.ui()
+        parents = (self.repo['the_branch'].node(), revlog.nullid, )
+        def filectxfn(repo, memctx, path):
+            return context.memfilectx(path=path,
+                                      data='added',
+                                      islink=False,
+                                      isexec=False,
+                                      copied=False)
+        ctx = context.memctx(self.repo,
+                             parents,
+                             'automated test',
+                             ['added_bogus_file', 'other_added_file', ],
+                             filectxfn,
+                             'testy',
+                             '2008-12-21 16:32:00 -0500',
+                             {'branch': 'localbranch', })
+        new = self.repo.commitctx(ctx)
+        hg.update(self.repo, new)
+        utility_commands.show_outgoing_to_svn(u, self.repo, self.wc_path)
+        self.assert_(node.hex(self.repo['localbranch'].node())[:8] in
+                     u.stream.getvalue())
+        self.assert_('testy' in u.stream.getvalue())
+        hg.update(self.repo, 'default')
+        u = ui.ui()
+        utility_commands.show_outgoing_to_svn(u, self.repo, self.wc_path)
+        self.assertEqual(u.stream.getvalue(), 'No outgoing changes found.\n')
+
     def test_url_output(self):
         self._load_fixture_and_fetch('two_revs.svndump')
         hg.update(self.repo, 'tip')
--- a/utility_commands.py
+++ b/utility_commands.py
@@ -135,7 +135,7 @@ def show_outgoing_to_svn(ui, repo, hg_re
                                            ui_=ui)
     svn_commit_hashes = dict(zip(hge.revmap.itervalues(),
                                  hge.revmap.iterkeys()))
-    o_r = util.outgoing_revisions(ui, repo, hge, svn_commit_hashes, repo.parents()[0])
+    o_r = util.outgoing_revisions(ui, repo, hge, svn_commit_hashes, repo.parents()[0].node())
     if not (o_r and len(o_r)):
         ui.status('No outgoing changes found.\n')
         return 0