1. Dan Villiom Podlaski Christiansen
  2. hgsubversion-queue

Commits

Dan Villiom Podlaski Christiansen  committed 066b1f4

Better.

  • Participants
  • Parent commits a5d6812
  • Branches default

Comments (0)

Files changed (8)

File fix-prefix.diff

-# HG changeset patch
-# User Dan Villiom Podlaski Christiansen <dan@cabo.dk>
-# Date 1323817677 -3600
-# Node ID 5b3fb9e8c4c5691ce48d75a48060c1a1b1e862aa
-# Parent 30f376d7d3903bef218f2443c72be7b18577dce8
-svnmeta: only remove directory components in normalize()
-
-Previously, a file beginning with the repository subdirectory would be
-stripped, resulting in a leftover file name with a wrong name. A
-subsequent pull of a revision modifying the file would add it under
-its correct name, but leave the leftover file.
-
-diff --git a/hgsubversion/svnmeta.py b/hgsubversion/svnmeta.py
---- a/hgsubversion/svnmeta.py
-+++ b/hgsubversion/svnmeta.py
-@@ -292,7 +292,9 @@ class SVNMeta(object):
-             return ''
-         if path and path[0] == '/':
-             path = path[1:]
--        if path and path.startswith(self.subdir):
-+        if path == self.subdir:
-+            return ''
-+        if path and path.startswith(self.subdir + '/'):
-             path = path[len(self.subdir):]
-         if path and path[0] == '/':
-             path = path[1:]
-diff --git a/tests/comprehensive/test_verify_and_startrev.py b/tests/comprehensive/test_verify_and_startrev.py
---- a/tests/comprehensive/test_verify_and_startrev.py
-+++ b/tests/comprehensive/test_verify_and_startrev.py
-@@ -23,6 +23,14 @@ from hgsubversion import svncommands
-     'emptyrepo.svndump',
- ])
- 
-+_skipall = set([
-+    'project_root_not_repo_root.svndump',
-+])
-+
-+_skipstandard = set([
-+    'subdir_is_file_prefix.svndump',
-+])
-+
- def _do_case(self, name, stupid, layout):
-     subdir = test_util.subdir.get(name, '')
-     repo = self._load_fixture_and_fetch(name, subdir=subdir, stupid=stupid, layout=layout)
-@@ -64,13 +72,13 @@ def buildmethod(case, name, stupid, layo
- attrs = {'_do_case': _do_case}
- fixtures = [f for f in os.listdir(test_util.FIXTURES) if f.endswith('.svndump')]
- for case in fixtures:
--    # this fixture results in an empty repository, don't use it
--    if case == 'project_root_not_repo_root.svndump':
-+    if case in _skipall:
-         continue
-     bname = 'test_' + case[:-len('.svndump')]
--    attrs[bname] = buildmethod(case, bname, False, 'standard')
--    name = bname + '_stupid'
--    attrs[name] = buildmethod(case, name, True, 'standard')
-+    if case not in _skipstandard:
-+        attrs[bname] = buildmethod(case, bname, False, 'standard')
-+        name = bname + '_stupid'
-+        attrs[name] = buildmethod(case, name, True, 'standard')
-     name = bname + '_single'
-     attrs[name] = buildmethod(case, name, False, 'single')
-     # Disabled because the "stupid and real are the same" tests
-diff --git a/tests/fixtures/subdir_is_file_prefix.svndump b/tests/fixtures/subdir_is_file_prefix.svndump
-new file mode 100644
---- /dev/null
-+++ b/tests/fixtures/subdir_is_file_prefix.svndump
-@@ -0,0 +1,72 @@
-+SVN-fs-dump-format-version: 2
-+
-+UUID: 924a052a-5e5a-4a8e-a677-da5565bec340
-+
-+Revision-number: 0
-+Prop-content-length: 56
-+Content-length: 56
-+
-+K 8
-+svn:date
-+V 27
-+2011-03-04T12:33:29.342045Z
-+PROPS-END
-+
-+Revision-number: 1
-+Prop-content-length: 123
-+Content-length: 123
-+
-+K 7
-+svn:log
-+V 22
-+Create directory flaf.
-+K 10
-+svn:author
-+V 6
-+danchr
-+K 8
-+svn:date
-+V 27
-+2011-03-04T12:34:00.349950Z
-+PROPS-END
-+
-+Node-path: flaf
-+Node-kind: dir
-+Node-action: add
-+Prop-content-length: 10
-+Content-length: 10
-+
-+PROPS-END
-+
-+
-+Revision-number: 2
-+Prop-content-length: 138
-+Content-length: 138
-+
-+K 7
-+svn:log
-+V 37
-+Create the file flaf.txt within flaf.
-+K 10
-+svn:author
-+V 6
-+danchr
-+K 8
-+svn:date
-+V 27
-+2011-03-04T12:45:01.701033Z
-+PROPS-END
-+
-+Node-path: flaf/flaf.txt
-+Node-kind: file
-+Node-action: add
-+Prop-content-length: 10
-+Text-content-length: 15
-+Text-content-md5: 8c0059c8f7998e8003836b8e8fcb74d7
-+Text-content-sha1: b7d680bc5411f46395c4ef267001e1a307d7b0d5
-+Content-length: 25
-+
-+PROPS-END
-+Goodbye world.
-+
-+
-diff --git a/tests/test_single_dir_clone.py b/tests/test_single_dir_clone.py
---- a/tests/test_single_dir_clone.py
-+++ b/tests/test_single_dir_clone.py
-@@ -44,6 +44,15 @@ class TestSingleDir(test_util.TestBase):
-         self.assertEqual(repo.branchtags().keys(), ['default', ])
-         self.assertEqual(repo['default'].manifest().keys(), oldmanifest)
- 
-+    def test_clone_subdir_is_file_prefix(self, stupid=False):
-+        FIXTURE = 'subdir_is_file_prefix.svndump'
-+        repo = self._load_fixture_and_fetch(FIXTURE,
-+                                            stupid=stupid,
-+                                            layout='single',
-+                                            subdir=test_util.subdir[FIXTURE])
-+        self.assertEqual(repo.branchtags().keys(), ['default'])
-+        self.assertEqual(repo['tip'].manifest().keys(), ['flaf.txt'])
-+
-     def test_externals_single(self):
-         repo = self._load_fixture_and_fetch('externals.svndump',
-                                             stupid=False,
-diff --git a/tests/test_util.py b/tests/test_util.py
---- a/tests/test_util.py
-+++ b/tests/test_util.py
-@@ -96,6 +96,7 @@ subdir = {'truncatedhistory.svndump': '/
-           'project_name_with_space.svndump': '/project name',
-           'non_ascii_path_1.svndump': '/b\xC3\xB8b',
-           'non_ascii_path_2.svndump': '/b%C3%B8b',
-+          'subdir_is_file_prefix.svndump': '/flaf',
-           }
- 
- FIXTURES = os.path.join(os.path.abspath(os.path.dirname(__file__)),

File fold-test_startrev.diff

-# HG changeset patch
-# Parent 99a15c6a283c951e7a99008b74a9098736a94379
-# User Dan Villiom Podlaski Christiansen  <danchr@gmail.com>
-fold test_startrev and test_verify into a new test; test_verify_and_startrev
-
-diff --git a/tests/comprehensive/test_verify.py b/tests/comprehensive/test_verify_and_startrev.py
-rename from tests/comprehensive/test_verify.py
-rename to tests/comprehensive/test_verify_and_startrev.py
---- a/tests/comprehensive/test_verify.py
-+++ b/tests/comprehensive/test_verify_and_startrev.py
-@@ -16,14 +16,45 @@ from mercurial import ui
- 
- from hgsubversion import svncommands
- 
-+# these fixtures contain no files at HEAD and would result in empty clones
-+_skipshallow = set([
-+    'binaryfiles.svndump',
-+    'binaryfiles-broken.svndump',
-+    'emptyrepo.svndump',
-+])
-+
- def _do_case(self, name, stupid, layout):
-     subdir = test_util.subdir.get(name, '')
--    repo = self._load_fixture_and_fetch(name, subdir=subdir, stupid=stupid, layout=layout)
-+    repo, svnpath = self.load_and_fetch(name, subdir=subdir, stupid=stupid,
-+                                        layout=layout)
-     assert len(self.repo) > 0
-     for i in repo:
-         ctx = repo[i]
-         self.assertEqual(svncommands.verify(repo.ui, repo, rev=ctx.node()), 0)
- 
-+    # check a startrev clone
-+    if layout == 'single' and name not in _skipshallow:
-+        self.wc_path += '_shallow'
-+        shallowrepo = self.fetch(svnpath, subdir=subdir, stupid=stupid,
-+                                 layout='single', startrev='HEAD')
-+
-+        self.assertEqual(len(shallowrepo), 1,
-+                         "shallow clone should have just one revision, not %d"
-+                         % len(shallowrepo))
-+
-+        fulltip = repo['tip']
-+        shallowtip = shallowrepo['tip']
-+
-+        self.assertEqual(0, svncommands.verify(repo.ui, shallowrepo,
-+                                               rev=shallowtip.node()))
-+
-+        # viewing diff's of lists of files is easier on the eyes
-+        self.assertMultiLineEqual('\n'.join(fulltip), '\n'.join(shallowtip))
-+
-+        for f in fulltip:
-+            self.assertMultiLineEqual(fulltip[f].data(), shallowtip[f].data())
-+
-+
- def buildmethod(case, name, stupid, layout):
-     m = lambda self: self._do_case(case, stupid, layout)
-     m.__name__ = name
-diff --git a/tests/run.py b/tests/run.py
---- a/tests/run.py
-+++ b/tests/run.py
-@@ -25,7 +25,6 @@ def tests():
-     import test_push_eol
-     import test_rebuildmeta
-     import test_single_dir_clone
--    import test_startrev
-     import test_svnwrap
-     import test_tags
-     import test_template_keywords
-@@ -37,7 +36,7 @@ def tests():
-     sys.path.append(os.path.join(os.path.dirname(__file__), 'comprehensive'))
- 
-     import test_stupid_pull
--    import test_verify
-+    import test_verify_and_startrev
- 
-     return locals()
- 
-diff --git a/tests/test_startrev.py b/tests/test_startrev.py
-deleted file mode 100644
---- a/tests/test_startrev.py
-+++ /dev/null
-@@ -1,71 +0,0 @@
--import test_util
--
--import os
--import unittest
--
--def _do_case(self, name, subdir, stupid):
--    wc_base = self.wc_path
--    self.wc_path = wc_base + '_full'
--    headclone = self._load_fixture_and_fetch(name, subdir=subdir, stupid=stupid,
--                                             layout='single', startrev='HEAD')
--    self.wc_path = wc_base + '_head'
--    fullclone = self._load_fixture_and_fetch(name, subdir=subdir, stupid=stupid,
--                                             layout='single')
--
--    fulltip = fullclone['tip']
--    headtip = headclone['tip']
--    # viewing diff's of lists of files is easier on the eyes
--    self.assertMultiLineEqual('\n'.join(fulltip), '\n'.join(headtip))
--
--    for f in fulltip:
--        self.assertMultiLineEqual(fulltip[f].data(), headtip[f].data())
--
--    self.assertNotEqual(len(fullclone), 0, "full clone shouldn't be empty")
--    self.assertEqual(len(headclone), 1,
--                     "shallow clone should have just one revision, not %d"
--                     % len(headclone))
--
--def buildmethod(case, name, subdir, stupid):
--    m = lambda self: self._do_case(case, subdir.strip('/'), stupid)
--    m.__name__ = name
--    m.__doc__ = ('Test clone with startrev on %s%s with %s replay.' %
--                 (case, subdir, (stupid and 'stupid') or 'real'))
--    return m
--
--
--# these fixtures contain no files at HEAD and would result in empty clones
--nofiles = set([
--    'binaryfiles.svndump',
--    'binaryfiles-broken.svndump',
--    'emptyrepo.svndump',
--])
--
--# these fixtures contain no files in trunk at HEAD and would result in an empty
--# shallow clone if cloning trunk, so we use another subdirectory
--subdirmap = {
--    'commit-to-tag.svndump': '/branches/magic',
--    'pushexternals.svndump': '',
--    'tag_name_same_as_branch.svndump': '/branches/magic',
--}
--
--attrs = {'_do_case': _do_case,
--         }
--
--for case in [f for f in os.listdir(test_util.FIXTURES) if f.endswith('.svndump')]:
--    if case in nofiles:
--        continue
--
--    subdir = test_util.subdir.get(case, '') + subdirmap.get(case, '/trunk')
--
--    bname = 'test_' + case[:-len('.svndump')]
--    attrs[bname] = buildmethod(case, bname, subdir, False)
--    name = bname + '_stupid'
--    attrs[name] = buildmethod(case, name, subdir, True)
--
--StartRevTests = type('StartRevTests', (test_util.TestBase,), attrs)
--
--
--def suite():
--    all_tests = [unittest.TestLoader().loadTestsFromTestCase(StartRevTests),
--          ]
--    return unittest.TestSuite(all_tests)
-diff --git a/tests/test_util.py b/tests/test_util.py
---- a/tests/test_util.py
-+++ b/tests/test_util.py
-@@ -297,15 +297,13 @@ class TestBase(unittest.TestCase):
-         proc.communicate()
-         return path
- 
--    def load_and_fetch(self, fixture_name, subdir=None, stupid=False,
--                       layout='auto', startrev=0, externals=None,
--                       noupdate=True):
-+    def fetch(self, repo_path, subdir=None, stupid=False, layout='auto', startrev=0,
-+              externals=None, noupdate=True, dest=None):
-         if layout == 'single':
-             if subdir is None:
-                 subdir = 'trunk'
-         elif subdir is None:
-             subdir = ''
--        repo_path = self.load_svndump(fixture_name)
-         projectpath = repo_path
-         if subdir:
-             projectpath += '/' + subdir
-@@ -326,7 +324,12 @@ class TestBase(unittest.TestCase):
- 
-         dispatch(cmd)
- 
--        return hg.repository(testui(), self.wc_path), repo_path
-+        return hg.repository(testui(), self.wc_path)
-+
-+    def load_and_fetch(self, fixture_name, *args, **opts):
-+        repo_path = self.load_svndump(fixture_name)
-+
-+        return self.fetch(repo_path, *args, **opts), repo_path
- 
-     def _load_fixture_and_fetch(self, *args, **kwargs):
-         repo, repo_path = self.load_and_fetch(*args, **kwargs)

File helpful.diff

View file
+# HG changeset patch
+# Parent 158010a469a141f350822d811dbcabd7047ad1ff
+# User Dan Villiom Podlaski Christiansen  <danchr@gmail.com>
+make assertion failures slightly more helpful by including the failing verification
+
+diff --git a/tests/comprehensive/test_verify_and_startrev.py b/tests/comprehensive/test_verify_and_startrev.py
+--- a/tests/comprehensive/test_verify_and_startrev.py
++++ b/tests/comprehensive/test_verify_and_startrev.py
+@@ -57,11 +57,13 @@ def _do_case(self, name, stupid, layout)
+         fulltip = repo['tip']
+         shallowtip = shallowrepo['tip']
+ 
++        repo.ui.pushbuffer()
+         self.assertEqual(0, svncommands.verify(repo.ui, shallowrepo,
+                                                rev=shallowtip.node()))
+ 
+         # viewing diff's of lists of files is easier on the eyes
+-        self.assertMultiLineEqual('\n'.join(fulltip), '\n'.join(shallowtip))
++        self.assertMultiLineEqual('\n'.join(fulltip), '\n'.join(shallowtip),
++                                  repo.ui.popbuffer())
+ 
+         for f in fulltip:
+             self.assertMultiLineEqual(fulltip[f].data(), shallowtip[f].data())

File kill-prints.diff

View file
+# HG changeset patch
+# Parent 3c134c3e9485e398df84d46f681892ac5c430256
+# User Dan Villiom Podlaski Christiansen  <danchr@gmail.com>
+kill all 'print' statements in the extension proper
+
+
+diff --git a/hgsubversion/editor.py b/hgsubversion/editor.py
+--- a/hgsubversion/editor.py
++++ b/hgsubversion/editor.py
+@@ -364,7 +364,6 @@ class HgEditor(svnwrap.Editor):
+                 else: # pragma: no cover
+                     raise hgutil.Abort(*e.args)
+             except: # pragma: no cover
+-                print len(base), self.current.file
+                 self._exception_info = sys.exc_info()
+                 raise
+         return txdelt_window
+diff --git a/hgsubversion/maps.py b/hgsubversion/maps.py
+--- a/hgsubversion/maps.py
++++ b/hgsubversion/maps.py
+@@ -135,8 +135,7 @@ class Tags(dict):
+             svncommands.rebuildmeta(repo.ui, repo, ())
+             return
+         elif ver != self.VERSION:
+-            print 'tagmap too new -- please upgrade'
+-            raise NotImplementedError
++            raise hgutil.Abort('tagmap too new -- please upgrade')
+         for l in f:
+             ha, revision, tag = l.split(' ', 2)
+             revision = int(revision)
+@@ -228,8 +227,7 @@ class RevMap(dict):
+             return iter([])
+         ver = int(f.readline())
+         if ver != cls.VERSION:
+-            print 'revmap too new -- please upgrade'
+-            raise NotImplementedError
++            raise hgutil.Abort('revmap too new -- please upgrade')
+         return f
+ 
+     def _load(self):
+@@ -361,8 +359,7 @@ class FileMap(object):
+         f = open(self.path)
+         ver = int(f.readline())
+         if ver != self.VERSION:
+-            print 'filemap too new -- please upgrade'
+-            raise NotImplementedError
++            raise hgutil.Abort('filemap too new -- please upgrade')
+         self.load_fd(f, self.path)
+         f.close()
+ 

File pretty.diff

-# HG changeset patch
-# Parent 998504c51de7a731d3d87641fc22e3f47aa14815
-# User Dan Villiom Podlaski Christiansen  <danchr@gmail.com>
-diff --git a/tests/test_utility_commands.py b/tests/test_utility_commands.py
---- a/tests/test_utility_commands.py
-+++ b/tests/test_utility_commands.py
-@@ -258,7 +258,7 @@ class UtilityTests(test_util.TestBase):
-         output = u.popbuffer()
-         self.assertEqual(1, ret)
-         output = re.sub(r'file://\S+', 'file://', output)
--        self.assertEqual("""\
-+        self.assertMultiLineEqual("""\
- verifying d51f46a715a1 against file://
- difference in: binary2
- unexpected file: binary1

File series

View file
-fold-test_startrev.diff
-fix-prefix.diff
+kill-prints.diff
 verify-test.diff
-pretty.diff
+traceback.diff
+helpful.diff
 verify-editor.diff
 configpath.diff
 allow-multi-rebuildmeta.diff

File traceback.diff

View file
+# HG changeset patch
+# Parent ece6f4129e79a826e2b6d38b580f65408e203d58
+# User Dan Villiom Podlaski Christiansen  <danchr@gmail.com>
+don't suppress KeyboardInterrupt exception tracebacks
+
+diff --git a/hgsubversion/wrappers.py b/hgsubversion/wrappers.py
+--- a/hgsubversion/wrappers.py
++++ b/hgsubversion/wrappers.py
+@@ -380,7 +380,7 @@ def pull(repo, source, heads=[], force=F
+                             ui.traceback()
+                             raise hgutil.Abort(*e.args)
+         except KeyboardInterrupt:
+-            pass
++            ui.traceback()
+     finally:
+         util.progress(ui, 'pull', None, total=total)
+         util.swap_out_encoding(old_encoding)

File verify-test.diff

View file
 # User Dan Villiom Podlaski Christiansen <danchr@gmail.com>
 # Date 1323817678 -3600
 # Node ID 7780f14edecbc1606dc552e08993ca9a31ce0e03
-# Parent 0684f7e0e32610954f0a111bc7c1237f204f03a2
+# Parent c6388ed0ec0a59e70189f95869c8f2087fcbb8a6
 svn verify: add a test for corrupt repositories.
 
 This case contains a couple of unlikely (but not impossible) failure
  ])
  
  _skipall = set([
-@@ -29,6 +31,7 @@ from hgsubversion import svncommands
+@@ -29,6 +31,8 @@ from hgsubversion import svncommands
  
  _skipstandard = set([
      'subdir_is_file_prefix.svndump',
++    'correct.svndump',
 +    'corrupt.svndump',
  ])
  
 new file mode 100644
 --- /dev/null
 +++ b/tests/fixtures/corrupt.svndump
-@@ -0,0 +1,88 @@
+@@ -0,0 +1,97 @@
 +SVN-fs-dump-format-version: 2
 +
 +UUID: 00000000-0000-0000-0000-000000000000
 +Prop-content-length: 100
 +Content-length: 100
 +
-+K 7
-+svn:log
-+V 0
-+
 +K 10
 +svn:author
 +V 6
 +svn:date
 +V 27
 +2010-11-30T15:16:01.077550Z
++K 7
++svn:log
++V 0
++
 +PROPS-END
 +
++Node-path: another-regular-file
++Node-kind: file
++Node-action: add
++Prop-content-length: 10
++Text-content-length: 0
++Text-content-md5: d41d8cd98f00b204e9800998ecf8427e
++Text-content-sha1: da39a3ee5e6b4b0d3255bfef95601890afd80709
++Content-length: 10
++
++PROPS-END
++
++
++Node-path: executable-file
++Node-kind: file
++Node-action: add
++Prop-content-length: 10
++Text-content-length: 11
++Text-content-md5: 01839ba8c81c3b2c7486607e0c683e62
++Text-content-sha1: 5e70f8a25fe8ad4ad971bfd3388c258b019268d4
++Content-length: 21
++
++PROPS-END
++Executable
++
++
 +Node-path: missing-file
 +Node-kind: file
 +Node-action: add
 +PROPS-END
 +
 +
-+Node-path: executable-file
-+Node-kind: file
-+Node-action: add
-+Text-content-length: 11
-+Content-length: 11
-+
-+Executable
-+
-+
 +Node-path: regular-file
 +Node-kind: file
 +Node-action: add
-+Prop-content-length: 59
++Prop-content-length: 33
 +Text-content-length: 13
-+Content-length: 72
++Text-content-md5: 2263e9e0f5eda11545c8c918a05ea2b6
++Text-content-sha1: 0e1e3a724ca9b54e89d072929377126defaa0ef9
++Content-length: 46
 +
 +K 11
 +svn:special
 +V 1
 +*
-+K 14
-+svn:executable
-+V 1
-+*
 +PROPS-END
 +Bad contents.
 +
-+
 +Node-path: symlink
 +Node-kind: file
 +Node-action: add
++Prop-content-length: 10
 +Text-content-length: 1
-+Content-length: 1
++Text-content-md5: 7fc56270e7a70fa81a5935b72eacbe29
++Text-content-sha1: 6dcd4ce23d88e2ee9568ba546c007c63d9131c1b
++Content-length: 11
 +
++PROPS-END
 +A
 +
-+
-+Node-path: another-regular-file
-+Node-kind: file
-+Node-action: add
-+Text-content-length: 0
-+Content-length: 0
-+
-+
 diff --git a/tests/test_rebuildmeta.py b/tests/test_rebuildmeta.py
 --- a/tests/test_rebuildmeta.py
 +++ b/tests/test_rebuildmeta.py
 +++ b/tests/test_utility_commands.py
 @@ -260,13 +260,46 @@ class UtilityTests(test_util.TestBase):
          output = re.sub(r'file://\S+', 'file://', output)
-         self.assertEqual("""\
+         self.assertMultiLineEqual("""\
  verifying d51f46a715a1 against file://
 -difference in file binary2
 -unexpected files: