view tests/test_diff.py @ 890:78db88de9622

Partial metadata rebuilding For highly active subversion repositories, it can be excruciatingly slow to pull updates one at a time from subversion. One way around this is to setup another mercurial repo that pulls new commits from svn periodicly (say every 5 minutes). When you want to update your repository, you can pull commits from this mercurial repository via native mercurial protocols, which will be much faster than pulling directly from svn. Unfortunately, your metadata will be out of date after doing so. Highly active repositories also tend to be very large, which means that it takes a long time to rebuild your metadata from scratch. To address this, this adds support to do a partial rebuild on the metadata by processing only revisions that have been added to the repository after the last revision we processed. With the rev map 1k revisions (~2 days) behind tip updatemeta is dramatically faster than rebuild meta: $ hg --time svn updatemeta Time: real 0.570 secs (user 0.480+0.000 sys 0.060+0.000) $ hg --time svn rebuildmeta Time: real 129.160 secs (user 128.570+0.000 sys 0.320+0.000)
author David Schleimer <dschleimer@fb.com>
date Sat, 12 May 2012 07:28:23 -0700
parents 312b37bc5e20
children d741f536f23a
line wrap: on
line source

import test_util

import unittest

from mercurial import ui

from hgsubversion import wrappers

expected_diff_output = '''Index: alpha
===================================================================
--- alpha\t(revision 3)
+++ alpha\t(working copy)
@@ -1,1 +1,3 @@
-file: alpha
+alpha
+
+added line
Index: foo
===================================================================
new file mode 100644
--- foo\t(revision 0)
+++ foo\t(working copy)
@@ -0,0 +1,1 @@
+This is missing a newline.
\ No newline at end of file
'''

class DiffTests(test_util.TestBase):
    def test_diff_output(self):
        self._load_fixture_and_fetch('two_revs.svndump')
        self.commitchanges([('foo', 'foo', 'This is missing a newline.'),
                            ('alpha', 'alpha', 'alpha\n\nadded line\n'),
                            ])
        u = ui.ui()
        u.pushbuffer()
        wrappers.diff(lambda x, y, z: None, u, self.repo, svn=True)
        self.assertEqual(u.popbuffer(), expected_diff_output)


def suite():
    all_tests = [unittest.TestLoader().loadTestsFromTestCase(DiffTests),
          ]
    return unittest.TestSuite(all_tests)