Commits

mdelagra committed 68e638f

fixed problem generating parent diffs against an empty repo

Comments (0)

Files changed (2)

mercurial_reviewboard/__init__.py

 
     c = repo.changectx(rev)
 
-    rparent = find_rparent(ui, repo, c, opts)        
+    rparent = find_rparent(ui, repo, c, opts)
+    ui.debug('remote parent: %s\n' % rparent)
     parent  = find_parent(ui, repo, c, rparent, opts)
+    ui.debug('parent: %s\n' % parent)
 
     if parent is None:
         msg = "Unable to determine parent revision for diff. "
     ui.debug('\n=== Diff from parent to rev ===\n')
     ui.debug(diff + '\n')
 
-    if rparent and parent != rparent:
+    if rparent != None and parent != rparent:
         parentdiff = getdiff(ui, repo, parent, rparent)
         ui.debug('\n=== Diff from rparent to parent ===\n')
         ui.debug(parentdiff + '\n')

mercurial_reviewboard/tests/test_post_to_empty_repo.py

+from mock import patch
+from nose.tools import eq_
+
+from mercurial_reviewboard import postreview
+from mercurial_reviewboard.tests import get_initial_opts, get_repo, mock_ui
+
+
+@patch('mercurial_reviewboard.send_review')
+def test_diff(mock_send):
+    ui = mock_ui()
+
+    repo = get_repo(ui, 'two_revs')
+    opts = get_initial_opts()
+    opts['outgoingrepo'] = 'mercurial_reviewboard/tests/repos/no_revs'
+    
+    postreview(ui, repo, **opts)
+    
+    expected = open('mercurial_reviewboard/tests/diffs/two_revs_1', 
+        'r').read()
+    eq_(expected, mock_send.call_args[0][4])
+
+
+@patch('mercurial_reviewboard.send_review')
+def test_parentdiff(mock_send):
+    ui = mock_ui()
+
+    repo = get_repo(ui, 'two_revs')
+    opts = get_initial_opts()
+    opts['outgoingrepo'] = 'mercurial_reviewboard/tests/repos/no_revs'
+    
+    postreview(ui, repo, **opts)
+    
+    expected = open('mercurial_reviewboard/tests/diffs/two_revs_0', 
+        'r').read()
+    eq_(expected, mock_send.call_args[0][5])