Mercurial > hgsubversion
annotate tests/test_util.py @ 1555:cff81f35b31e
cleanup: reference Abort from mercurial.error instead of mercurial.util
It's been there since hg 1.7 or so, which lets us avoid any need for
compat shims.
author | Augie Fackler <raf@durin42.com> |
---|---|
date | Sat, 24 Mar 2018 16:39:30 -0400 |
parents | 258fb67fb956 |
children | 4afe8d7e4602 |
rev | line source |
---|---|
492 | 1 import StringIO |
548
2148eb4b4da4
test_util: add assertStringEqual to output diff output for string checks
Augie Fackler <durin42@gmail.com>
parents:
546
diff
changeset
|
2 import difflib |
78
072010a271c6
Fix basic issues with tests on Windows
Patrick Mezard <pmezard@gmail.com>
parents:
23
diff
changeset
|
3 import errno |
492 | 4 import gettext |
14
d78dbf88c13d
Started a meaningful test suite.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
5 import os |
78
072010a271c6
Fix basic issues with tests on Windows
Patrick Mezard <pmezard@gmail.com>
parents:
23
diff
changeset
|
6 import shutil |
072010a271c6
Fix basic issues with tests on Windows
Patrick Mezard <pmezard@gmail.com>
parents:
23
diff
changeset
|
7 import stat |
492 | 8 import subprocess |
9 import sys | |
910
312f36a425f0
Ignore invalid utf8 in commit messages
David Schleimer <dschleimer@fb.com>
parents:
908
diff
changeset
|
10 import tarfile |
82
71de43e9f614
Extract PushTest common code into test_util.TestBase
Patrick Mezard <pmezard@gmail.com>
parents:
78
diff
changeset
|
11 import tempfile |
71de43e9f614
Extract PushTest common code into test_util.TestBase
Patrick Mezard <pmezard@gmail.com>
parents:
78
diff
changeset
|
12 import unittest |
78
072010a271c6
Fix basic issues with tests on Windows
Patrick Mezard <pmezard@gmail.com>
parents:
23
diff
changeset
|
13 import urllib |
14
d78dbf88c13d
Started a meaningful test suite.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
14 |
644
95abc4cfc78f
tests: improve import logic
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
626
diff
changeset
|
15 _rootdir = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) |
95abc4cfc78f
tests: improve import logic
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
626
diff
changeset
|
16 sys.path.insert(0, _rootdir) |
347
537de0300510
Remove the 'outgoing' wrapper, and use the Mercurial infrastructure instead.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
342
diff
changeset
|
17 |
711
cfc7df19e4dc
test_util: add requiresoption decorator function.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
706
diff
changeset
|
18 from mercurial import cmdutil |
331
75f082b5897e
Switch to using url scheme wrappers instead of duplicating each command we wrap.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
326
diff
changeset
|
19 from mercurial import commands |
492 | 20 from mercurial import context |
813
f07bfd66db13
test_util: handle dispatch.dispatch() taking a request
Patrick Mezard <pmezard@gmail.com>
parents:
793
diff
changeset
|
21 from mercurial import dispatch as dispatchmod |
22
95d0109e495e
Refactor tests so I can reuse code more.
Augie Fackler <durin42@gmail.com>
parents:
16
diff
changeset
|
22 from mercurial import hg |
492 | 23 from mercurial import i18n |
84
01e747937d35
test_util: add commitchanges() to TestBase
Patrick Mezard <pmezard@gmail.com>
parents:
83
diff
changeset
|
24 from mercurial import node |
1003
6945d3359456
testutil: clear rcpath when we update HGRCPATH env var
David Schleimer <dschleimer@fb.com>
parents:
1001
diff
changeset
|
25 from mercurial import scmutil |
84
01e747937d35
test_util: add commitchanges() to TestBase
Patrick Mezard <pmezard@gmail.com>
parents:
83
diff
changeset
|
26 from mercurial import ui |
1245
260212f056b7
test_util: fix up i18n monkeypatch for Mercurial 3.2
Siddharth Agarwal <sid0@fb.com>
parents:
1238
diff
changeset
|
27 from mercurial import util as hgutil |
527
2be9f14bd23f
test_util: add helper to draw repo with graphlog extension
Patrick Mezard <pmezard@gmail.com>
parents:
522
diff
changeset
|
28 from mercurial import extensions |
22
95d0109e495e
Refactor tests so I can reuse code more.
Augie Fackler <durin42@gmail.com>
parents:
16
diff
changeset
|
29 |
1203
518a9552f7f9
test_util: call makememfilectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
1174
diff
changeset
|
30 from hgsubversion import compathacks |
1464
1a4d0f1563d0
test_util: add utility function for logging the Subversion repository
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
1463
diff
changeset
|
31 from hgsubversion import svnrepo |
1365
89997a5fc181
stupid: self-disable if svn bindings are too new to work with stupid mode
Augie Fackler <raf@durin42.com>
parents:
1363
diff
changeset
|
32 from hgsubversion import svnwrap |
1203
518a9552f7f9
test_util: call makememfilectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
1174
diff
changeset
|
33 |
1049
608e7c8740af
tests: add a metaclass for testing obsolete mode
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
1048
diff
changeset
|
34 try: |
608e7c8740af
tests: add a metaclass for testing obsolete mode
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
1048
diff
changeset
|
35 from mercurial import obsolete |
1174
a22d4972e01f
push: fix obsolete feature detection
Dan Villiom Podlaski Christiansen <dan@cabo.dk>
parents:
1101
diff
changeset
|
36 obsolete._enabled |
1049
608e7c8740af
tests: add a metaclass for testing obsolete mode
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
1048
diff
changeset
|
37 except ImportError: |
608e7c8740af
tests: add a metaclass for testing obsolete mode
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
1048
diff
changeset
|
38 obsolete = None |
608e7c8740af
tests: add a metaclass for testing obsolete mode
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
1048
diff
changeset
|
39 |
716
38ebf7714cdf
requiresoption: raise SkipTest if available
Augie Fackler <durin42@gmail.com>
parents:
715
diff
changeset
|
40 try: |
734
e24fb3e27ec9
test_util: use SkipTest if provided by the unittest module.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
727
diff
changeset
|
41 SkipTest = unittest.SkipTest |
e24fb3e27ec9
test_util: use SkipTest if provided by the unittest module.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
727
diff
changeset
|
42 except AttributeError: |
1458 | 43 if 'nose' in sys.modules: |
44 SkipTest = sys.modules['nose'].SkipTest | |
45 else: | |
46 SkipTest = None | |
716
38ebf7714cdf
requiresoption: raise SkipTest if available
Augie Fackler <durin42@gmail.com>
parents:
715
diff
changeset
|
47 |
1457
019c3e194fba
tests: optimise creating repositories and loading dumps
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
1365
diff
changeset
|
48 from hgsubversion import svnwrap |
337
46e69be8e2c8
Reorganize to have a more conventional module structure.
Augie Fackler <durin42@gmail.com>
parents:
334
diff
changeset
|
49 from hgsubversion import util |
911
772280aed751
Honor SVN auto-props (solves issue #186)
Ronny Voelker <ronny.voelker@googlemail.com>
parents:
910
diff
changeset
|
50 from hgsubversion import svnwrap |
333
a59ab58969d9
test_util: normalize path in svnls()
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
331
diff
changeset
|
51 |
479
83fcb1cf6d8f
Avoid 'ValueError: close_fds is not supported on Windows platforms' exception
Risto Kankkunen <risto.kankkunen@iki.fi>
parents:
355
diff
changeset
|
52 # Documentation for Subprocess.Popen() says: |
83fcb1cf6d8f
Avoid 'ValueError: close_fds is not supported on Windows platforms' exception
Risto Kankkunen <risto.kankkunen@iki.fi>
parents:
355
diff
changeset
|
53 # "Note that on Windows, you cannot set close_fds to true and |
83fcb1cf6d8f
Avoid 'ValueError: close_fds is not supported on Windows platforms' exception
Risto Kankkunen <risto.kankkunen@iki.fi>
parents:
355
diff
changeset
|
54 # also redirect the standard handles by setting stdin, stdout or |
83fcb1cf6d8f
Avoid 'ValueError: close_fds is not supported on Windows platforms' exception
Risto Kankkunen <risto.kankkunen@iki.fi>
parents:
355
diff
changeset
|
55 # stderr." |
832
e9af7eba88db
globally: clean up whitespace around operators and commas to conform with PEP8
Yonggang Luo <luoyonggang@gmail.com>
parents:
816
diff
changeset
|
56 canCloseFds = 'win32' not in sys.platform |
479
83fcb1cf6d8f
Avoid 'ValueError: close_fds is not supported on Windows platforms' exception
Risto Kankkunen <risto.kankkunen@iki.fi>
parents:
355
diff
changeset
|
57 |
483
37718f514acb
No os.kill() in Windows, use ctypes to call Win32 TerminateProcess()
Risto Kankkunen <risto.kankkunen@iki.fi>
parents:
479
diff
changeset
|
58 if not 'win32' in sys.platform: |
37718f514acb
No os.kill() in Windows, use ctypes to call Win32 TerminateProcess()
Risto Kankkunen <risto.kankkunen@iki.fi>
parents:
479
diff
changeset
|
59 def kill_process(popen_obj): |
37718f514acb
No os.kill() in Windows, use ctypes to call Win32 TerminateProcess()
Risto Kankkunen <risto.kankkunen@iki.fi>
parents:
479
diff
changeset
|
60 os.kill(popen_obj.pid, 9) |
37718f514acb
No os.kill() in Windows, use ctypes to call Win32 TerminateProcess()
Risto Kankkunen <risto.kankkunen@iki.fi>
parents:
479
diff
changeset
|
61 else: |
37718f514acb
No os.kill() in Windows, use ctypes to call Win32 TerminateProcess()
Risto Kankkunen <risto.kankkunen@iki.fi>
parents:
479
diff
changeset
|
62 import ctypes |
487
6b481331c355
test_util: fix up line endings
Augie Fackler <durin42@gmail.com>
parents:
486
diff
changeset
|
63 from ctypes.wintypes import BOOL, DWORD, HANDLE, UINT |
6b481331c355
test_util: fix up line endings
Augie Fackler <durin42@gmail.com>
parents:
486
diff
changeset
|
64 |
6b481331c355
test_util: fix up line endings
Augie Fackler <durin42@gmail.com>
parents:
486
diff
changeset
|
65 def win_status_check(result, func, args): |
6b481331c355
test_util: fix up line endings
Augie Fackler <durin42@gmail.com>
parents:
486
diff
changeset
|
66 if result == 0: |
6b481331c355
test_util: fix up line endings
Augie Fackler <durin42@gmail.com>
parents:
486
diff
changeset
|
67 raise ctypes.WinError() |
6b481331c355
test_util: fix up line endings
Augie Fackler <durin42@gmail.com>
parents:
486
diff
changeset
|
68 return args |
6b481331c355
test_util: fix up line endings
Augie Fackler <durin42@gmail.com>
parents:
486
diff
changeset
|
69 |
6b481331c355
test_util: fix up line endings
Augie Fackler <durin42@gmail.com>
parents:
486
diff
changeset
|
70 def WINAPI(returns, func, *params): |
6b481331c355
test_util: fix up line endings
Augie Fackler <durin42@gmail.com>
parents:
486
diff
changeset
|
71 assert len(params) % 2 == 0 |
6b481331c355
test_util: fix up line endings
Augie Fackler <durin42@gmail.com>
parents:
486
diff
changeset
|
72 |
6b481331c355
test_util: fix up line endings
Augie Fackler <durin42@gmail.com>
parents:
486
diff
changeset
|
73 func.argtypes = tuple(params[0::2]) |
6b481331c355
test_util: fix up line endings
Augie Fackler <durin42@gmail.com>
parents:
486
diff
changeset
|
74 func.resvalue = returns |
6b481331c355
test_util: fix up line endings
Augie Fackler <durin42@gmail.com>
parents:
486
diff
changeset
|
75 func.errcheck = win_status_check |
6b481331c355
test_util: fix up line endings
Augie Fackler <durin42@gmail.com>
parents:
486
diff
changeset
|
76 |
6b481331c355
test_util: fix up line endings
Augie Fackler <durin42@gmail.com>
parents:
486
diff
changeset
|
77 return func |
483
37718f514acb
No os.kill() in Windows, use ctypes to call Win32 TerminateProcess()
Risto Kankkunen <risto.kankkunen@iki.fi>
parents:
479
diff
changeset
|
78 |
37718f514acb
No os.kill() in Windows, use ctypes to call Win32 TerminateProcess()
Risto Kankkunen <risto.kankkunen@iki.fi>
parents:
479
diff
changeset
|
79 # dwDesiredAccess |
37718f514acb
No os.kill() in Windows, use ctypes to call Win32 TerminateProcess()
Risto Kankkunen <risto.kankkunen@iki.fi>
parents:
479
diff
changeset
|
80 PROCESS_TERMINATE = 0x0001 |
37718f514acb
No os.kill() in Windows, use ctypes to call Win32 TerminateProcess()
Risto Kankkunen <risto.kankkunen@iki.fi>
parents:
479
diff
changeset
|
81 |
487
6b481331c355
test_util: fix up line endings
Augie Fackler <durin42@gmail.com>
parents:
486
diff
changeset
|
82 OpenProcess = WINAPI(HANDLE, ctypes.windll.kernel32.OpenProcess, |
6b481331c355
test_util: fix up line endings
Augie Fackler <durin42@gmail.com>
parents:
486
diff
changeset
|
83 DWORD, 'dwDesiredAccess', |
6b481331c355
test_util: fix up line endings
Augie Fackler <durin42@gmail.com>
parents:
486
diff
changeset
|
84 BOOL, 'bInheritHandle', |
6b481331c355
test_util: fix up line endings
Augie Fackler <durin42@gmail.com>
parents:
486
diff
changeset
|
85 DWORD, 'dwProcessId', |
6b481331c355
test_util: fix up line endings
Augie Fackler <durin42@gmail.com>
parents:
486
diff
changeset
|
86 ) |
483
37718f514acb
No os.kill() in Windows, use ctypes to call Win32 TerminateProcess()
Risto Kankkunen <risto.kankkunen@iki.fi>
parents:
479
diff
changeset
|
87 |
832
e9af7eba88db
globally: clean up whitespace around operators and commas to conform with PEP8
Yonggang Luo <luoyonggang@gmail.com>
parents:
816
diff
changeset
|
88 CloseHandle = WINAPI(BOOL, ctypes.windll.kernel32.CloseHandle, |
487
6b481331c355
test_util: fix up line endings
Augie Fackler <durin42@gmail.com>
parents:
486
diff
changeset
|
89 HANDLE, 'hObject' |
6b481331c355
test_util: fix up line endings
Augie Fackler <durin42@gmail.com>
parents:
486
diff
changeset
|
90 ) |
483
37718f514acb
No os.kill() in Windows, use ctypes to call Win32 TerminateProcess()
Risto Kankkunen <risto.kankkunen@iki.fi>
parents:
479
diff
changeset
|
91 |
487
6b481331c355
test_util: fix up line endings
Augie Fackler <durin42@gmail.com>
parents:
486
diff
changeset
|
92 TerminateProcess = WINAPI(BOOL, ctypes.windll.kernel32.TerminateProcess, |
6b481331c355
test_util: fix up line endings
Augie Fackler <durin42@gmail.com>
parents:
486
diff
changeset
|
93 HANDLE, 'hProcess', |
6b481331c355
test_util: fix up line endings
Augie Fackler <durin42@gmail.com>
parents:
486
diff
changeset
|
94 UINT, 'uExitCode' |
6b481331c355
test_util: fix up line endings
Augie Fackler <durin42@gmail.com>
parents:
486
diff
changeset
|
95 ) |
483
37718f514acb
No os.kill() in Windows, use ctypes to call Win32 TerminateProcess()
Risto Kankkunen <risto.kankkunen@iki.fi>
parents:
479
diff
changeset
|
96 |
37718f514acb
No os.kill() in Windows, use ctypes to call Win32 TerminateProcess()
Risto Kankkunen <risto.kankkunen@iki.fi>
parents:
479
diff
changeset
|
97 def kill_process(popen_obj): |
37718f514acb
No os.kill() in Windows, use ctypes to call Win32 TerminateProcess()
Risto Kankkunen <risto.kankkunen@iki.fi>
parents:
479
diff
changeset
|
98 phnd = OpenProcess(PROCESS_TERMINATE, False, popen_obj.pid) |
37718f514acb
No os.kill() in Windows, use ctypes to call Win32 TerminateProcess()
Risto Kankkunen <risto.kankkunen@iki.fi>
parents:
479
diff
changeset
|
99 TerminateProcess(phnd, 1) |
37718f514acb
No os.kill() in Windows, use ctypes to call Win32 TerminateProcess()
Risto Kankkunen <risto.kankkunen@iki.fi>
parents:
479
diff
changeset
|
100 CloseHandle(phnd) |
37718f514acb
No os.kill() in Windows, use ctypes to call Win32 TerminateProcess()
Risto Kankkunen <risto.kankkunen@iki.fi>
parents:
479
diff
changeset
|
101 |
194
13ae1bded5e7
Add some comprehensive tests that can be run with nose in order to make it easier to verify stupid and real replay do the same thing.
Augie Fackler <durin42@gmail.com>
parents:
170
diff
changeset
|
102 # Fixtures that need to be pulled at a subdirectory of the repo path |
13ae1bded5e7
Add some comprehensive tests that can be run with nose in order to make it easier to verify stupid and real replay do the same thing.
Augie Fackler <durin42@gmail.com>
parents:
170
diff
changeset
|
103 subdir = {'truncatedhistory.svndump': '/project2', |
13ae1bded5e7
Add some comprehensive tests that can be run with nose in order to make it easier to verify stupid and real replay do the same thing.
Augie Fackler <durin42@gmail.com>
parents:
170
diff
changeset
|
104 'fetch_missing_files_subdir.svndump': '/foo', |
270
2848d17eae71
Fix rebuildmeta tests for empty_dir_in_trunk_not_repo_root
Augie Fackler <durin42@gmail.com>
parents:
257
diff
changeset
|
105 'empty_dir_in_trunk_not_repo_root.svndump': '/project', |
351
3d5c4352a6c8
test_util: Add another missing project root.
Augie Fackler <durin42@gmail.com>
parents:
347
diff
changeset
|
106 'project_root_not_repo_root.svndump': '/dummyproj', |
512
c421e6bf0d95
tests: test paths with spaces
Augie Fackler <durin42@gmail.com>
parents:
511
diff
changeset
|
107 'project_name_with_space.svndump': '/project name', |
717
ae5968ffe6fe
svnwrap: fix handling of quotable URLs (fixes #197, refs #132)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
716
diff
changeset
|
108 'non_ascii_path_1.svndump': '/b\xC3\xB8b', |
ae5968ffe6fe
svnwrap: fix handling of quotable URLs (fixes #197, refs #132)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
716
diff
changeset
|
109 'non_ascii_path_2.svndump': '/b%C3%B8b', |
888
c6388ed0ec0a
svnmeta: only remove directory components in normalize()
Dan Villiom Podlaski Christiansen <dan@cabo.dk>
parents:
886
diff
changeset
|
110 'subdir_is_file_prefix.svndump': '/flaf', |
1234
d3c79072bc6a
editor: correctly import symlink copy+modify with non-empty prefix
David Schleimer <dschleimer@fb.com>
parents:
1232
diff
changeset
|
111 'renames_with_prefix.svndump': '/prefix', |
194
13ae1bded5e7
Add some comprehensive tests that can be run with nose in order to make it easier to verify stupid and real replay do the same thing.
Augie Fackler <durin42@gmail.com>
parents:
170
diff
changeset
|
112 } |
1092
cd0d14e25757
layouts: add custom layout for those of us that need weird mappings
David Schleimer <dschleimer@fb.com>
parents:
1084
diff
changeset
|
113 # map defining the layouts of the fixtures we can use with custom layout |
cd0d14e25757
layouts: add custom layout for those of us that need weird mappings
David Schleimer <dschleimer@fb.com>
parents:
1084
diff
changeset
|
114 # these are really popular layouts, so I gave them names |
cd0d14e25757
layouts: add custom layout for those of us that need weird mappings
David Schleimer <dschleimer@fb.com>
parents:
1084
diff
changeset
|
115 trunk_only = { |
cd0d14e25757
layouts: add custom layout for those of us that need weird mappings
David Schleimer <dschleimer@fb.com>
parents:
1084
diff
changeset
|
116 'default': 'trunk', |
cd0d14e25757
layouts: add custom layout for those of us that need weird mappings
David Schleimer <dschleimer@fb.com>
parents:
1084
diff
changeset
|
117 } |
cd0d14e25757
layouts: add custom layout for those of us that need weird mappings
David Schleimer <dschleimer@fb.com>
parents:
1084
diff
changeset
|
118 trunk_dev_branch = { |
cd0d14e25757
layouts: add custom layout for those of us that need weird mappings
David Schleimer <dschleimer@fb.com>
parents:
1084
diff
changeset
|
119 'default': 'trunk', |
cd0d14e25757
layouts: add custom layout for those of us that need weird mappings
David Schleimer <dschleimer@fb.com>
parents:
1084
diff
changeset
|
120 'dev_branch': 'branches/dev_branch', |
cd0d14e25757
layouts: add custom layout for those of us that need weird mappings
David Schleimer <dschleimer@fb.com>
parents:
1084
diff
changeset
|
121 } |
cd0d14e25757
layouts: add custom layout for those of us that need weird mappings
David Schleimer <dschleimer@fb.com>
parents:
1084
diff
changeset
|
122 custom = { |
cd0d14e25757
layouts: add custom layout for those of us that need weird mappings
David Schleimer <dschleimer@fb.com>
parents:
1084
diff
changeset
|
123 'addspecial.svndump': { |
cd0d14e25757
layouts: add custom layout for those of us that need weird mappings
David Schleimer <dschleimer@fb.com>
parents:
1084
diff
changeset
|
124 'default': 'trunk', |
cd0d14e25757
layouts: add custom layout for those of us that need weird mappings
David Schleimer <dschleimer@fb.com>
parents:
1084
diff
changeset
|
125 'foo': 'branches/foo', |
cd0d14e25757
layouts: add custom layout for those of us that need weird mappings
David Schleimer <dschleimer@fb.com>
parents:
1084
diff
changeset
|
126 }, |
cd0d14e25757
layouts: add custom layout for those of us that need weird mappings
David Schleimer <dschleimer@fb.com>
parents:
1084
diff
changeset
|
127 'binaryfiles.svndump': trunk_only, |
cd0d14e25757
layouts: add custom layout for those of us that need weird mappings
David Schleimer <dschleimer@fb.com>
parents:
1084
diff
changeset
|
128 'branch_create_with_dir_delete.svndump': trunk_dev_branch, |
cd0d14e25757
layouts: add custom layout for those of us that need weird mappings
David Schleimer <dschleimer@fb.com>
parents:
1084
diff
changeset
|
129 'branch_delete_parent_dir.svndump': trunk_dev_branch, |
cd0d14e25757
layouts: add custom layout for those of us that need weird mappings
David Schleimer <dschleimer@fb.com>
parents:
1084
diff
changeset
|
130 'branchmap.svndump': { |
cd0d14e25757
layouts: add custom layout for those of us that need weird mappings
David Schleimer <dschleimer@fb.com>
parents:
1084
diff
changeset
|
131 'default': 'trunk', |
cd0d14e25757
layouts: add custom layout for those of us that need weird mappings
David Schleimer <dschleimer@fb.com>
parents:
1084
diff
changeset
|
132 'badname': 'branches/badname', |
cd0d14e25757
layouts: add custom layout for those of us that need weird mappings
David Schleimer <dschleimer@fb.com>
parents:
1084
diff
changeset
|
133 'feature': 'branches/feature', |
cd0d14e25757
layouts: add custom layout for those of us that need weird mappings
David Schleimer <dschleimer@fb.com>
parents:
1084
diff
changeset
|
134 }, |
cd0d14e25757
layouts: add custom layout for those of us that need weird mappings
David Schleimer <dschleimer@fb.com>
parents:
1084
diff
changeset
|
135 'branch_prop_edit.svndump': trunk_dev_branch, |
cd0d14e25757
layouts: add custom layout for those of us that need weird mappings
David Schleimer <dschleimer@fb.com>
parents:
1084
diff
changeset
|
136 'branch_rename_to_trunk.svndump': { |
cd0d14e25757
layouts: add custom layout for those of us that need weird mappings
David Schleimer <dschleimer@fb.com>
parents:
1084
diff
changeset
|
137 'default': 'trunk', |
cd0d14e25757
layouts: add custom layout for those of us that need weird mappings
David Schleimer <dschleimer@fb.com>
parents:
1084
diff
changeset
|
138 'dev_branch': 'branches/dev_branch', |
cd0d14e25757
layouts: add custom layout for those of us that need weird mappings
David Schleimer <dschleimer@fb.com>
parents:
1084
diff
changeset
|
139 'old_trunk': 'branches/old_trunk', |
cd0d14e25757
layouts: add custom layout for those of us that need weird mappings
David Schleimer <dschleimer@fb.com>
parents:
1084
diff
changeset
|
140 }, |
cd0d14e25757
layouts: add custom layout for those of us that need weird mappings
David Schleimer <dschleimer@fb.com>
parents:
1084
diff
changeset
|
141 'copies.svndump': trunk_only, |
1232
ba8485b9fee0
editor: correctly import copies of directories from non-tracked or closed branches
David Schleimer <dschleimer@fb.com>
parents:
1203
diff
changeset
|
142 'copyafterclose.svndump': { |
ba8485b9fee0
editor: correctly import copies of directories from non-tracked or closed branches
David Schleimer <dschleimer@fb.com>
parents:
1203
diff
changeset
|
143 'default': 'trunk', |
ba8485b9fee0
editor: correctly import copies of directories from non-tracked or closed branches
David Schleimer <dschleimer@fb.com>
parents:
1203
diff
changeset
|
144 'test': 'branches/test' |
ba8485b9fee0
editor: correctly import copies of directories from non-tracked or closed branches
David Schleimer <dschleimer@fb.com>
parents:
1203
diff
changeset
|
145 }, |
1092
cd0d14e25757
layouts: add custom layout for those of us that need weird mappings
David Schleimer <dschleimer@fb.com>
parents:
1084
diff
changeset
|
146 'copybeforeclose.svndump': { |
cd0d14e25757
layouts: add custom layout for those of us that need weird mappings
David Schleimer <dschleimer@fb.com>
parents:
1084
diff
changeset
|
147 'default': 'trunk', |
cd0d14e25757
layouts: add custom layout for those of us that need weird mappings
David Schleimer <dschleimer@fb.com>
parents:
1084
diff
changeset
|
148 'test': 'branches/test' |
cd0d14e25757
layouts: add custom layout for those of us that need weird mappings
David Schleimer <dschleimer@fb.com>
parents:
1084
diff
changeset
|
149 }, |
cd0d14e25757
layouts: add custom layout for those of us that need weird mappings
David Schleimer <dschleimer@fb.com>
parents:
1084
diff
changeset
|
150 'delentries.svndump': trunk_only, |
cd0d14e25757
layouts: add custom layout for those of us that need weird mappings
David Schleimer <dschleimer@fb.com>
parents:
1084
diff
changeset
|
151 'delete_restore_trunk.svndump': trunk_only, |
cd0d14e25757
layouts: add custom layout for those of us that need weird mappings
David Schleimer <dschleimer@fb.com>
parents:
1084
diff
changeset
|
152 'empty_dir_in_trunk_not_repo_root.svndump': trunk_only, |
cd0d14e25757
layouts: add custom layout for those of us that need weird mappings
David Schleimer <dschleimer@fb.com>
parents:
1084
diff
changeset
|
153 'executebit.svndump': trunk_only, |
cd0d14e25757
layouts: add custom layout for those of us that need weird mappings
David Schleimer <dschleimer@fb.com>
parents:
1084
diff
changeset
|
154 'filecase.svndump': trunk_only, |
cd0d14e25757
layouts: add custom layout for those of us that need weird mappings
David Schleimer <dschleimer@fb.com>
parents:
1084
diff
changeset
|
155 'file_not_in_trunk_root.svndump': trunk_only, |
cd0d14e25757
layouts: add custom layout for those of us that need weird mappings
David Schleimer <dschleimer@fb.com>
parents:
1084
diff
changeset
|
156 'project_name_with_space.svndump': trunk_dev_branch, |
cd0d14e25757
layouts: add custom layout for those of us that need weird mappings
David Schleimer <dschleimer@fb.com>
parents:
1084
diff
changeset
|
157 'pushrenames.svndump': trunk_only, |
cd0d14e25757
layouts: add custom layout for those of us that need weird mappings
David Schleimer <dschleimer@fb.com>
parents:
1084
diff
changeset
|
158 'rename_branch_parent_dir.svndump': trunk_dev_branch, |
cd0d14e25757
layouts: add custom layout for those of us that need weird mappings
David Schleimer <dschleimer@fb.com>
parents:
1084
diff
changeset
|
159 'renamedproject.svndump': { |
cd0d14e25757
layouts: add custom layout for those of us that need weird mappings
David Schleimer <dschleimer@fb.com>
parents:
1084
diff
changeset
|
160 'default': 'trunk', |
cd0d14e25757
layouts: add custom layout for those of us that need weird mappings
David Schleimer <dschleimer@fb.com>
parents:
1084
diff
changeset
|
161 'branch': 'branches/branch', |
cd0d14e25757
layouts: add custom layout for those of us that need weird mappings
David Schleimer <dschleimer@fb.com>
parents:
1084
diff
changeset
|
162 }, |
cd0d14e25757
layouts: add custom layout for those of us that need weird mappings
David Schleimer <dschleimer@fb.com>
parents:
1084
diff
changeset
|
163 'renames.svndump': { |
cd0d14e25757
layouts: add custom layout for those of us that need weird mappings
David Schleimer <dschleimer@fb.com>
parents:
1084
diff
changeset
|
164 'default': 'trunk', |
cd0d14e25757
layouts: add custom layout for those of us that need weird mappings
David Schleimer <dschleimer@fb.com>
parents:
1084
diff
changeset
|
165 'branch1': 'branches/branch1', |
cd0d14e25757
layouts: add custom layout for those of us that need weird mappings
David Schleimer <dschleimer@fb.com>
parents:
1084
diff
changeset
|
166 }, |
1234
d3c79072bc6a
editor: correctly import symlink copy+modify with non-empty prefix
David Schleimer <dschleimer@fb.com>
parents:
1232
diff
changeset
|
167 'renames_with_prefix.svndump': { |
d3c79072bc6a
editor: correctly import symlink copy+modify with non-empty prefix
David Schleimer <dschleimer@fb.com>
parents:
1232
diff
changeset
|
168 'default': 'trunk', |
d3c79072bc6a
editor: correctly import symlink copy+modify with non-empty prefix
David Schleimer <dschleimer@fb.com>
parents:
1232
diff
changeset
|
169 'branch1': 'branches/branch1', |
d3c79072bc6a
editor: correctly import symlink copy+modify with non-empty prefix
David Schleimer <dschleimer@fb.com>
parents:
1232
diff
changeset
|
170 }, |
1092
cd0d14e25757
layouts: add custom layout for those of us that need weird mappings
David Schleimer <dschleimer@fb.com>
parents:
1084
diff
changeset
|
171 'replace_branch_with_branch.svndump': { |
cd0d14e25757
layouts: add custom layout for those of us that need weird mappings
David Schleimer <dschleimer@fb.com>
parents:
1084
diff
changeset
|
172 'default': 'trunk', |
cd0d14e25757
layouts: add custom layout for those of us that need weird mappings
David Schleimer <dschleimer@fb.com>
parents:
1084
diff
changeset
|
173 'branch1': 'branches/branch1', |
cd0d14e25757
layouts: add custom layout for those of us that need weird mappings
David Schleimer <dschleimer@fb.com>
parents:
1084
diff
changeset
|
174 'branch2': 'branches/branch2', |
cd0d14e25757
layouts: add custom layout for those of us that need weird mappings
David Schleimer <dschleimer@fb.com>
parents:
1084
diff
changeset
|
175 }, |
cd0d14e25757
layouts: add custom layout for those of us that need weird mappings
David Schleimer <dschleimer@fb.com>
parents:
1084
diff
changeset
|
176 'replace_trunk_with_branch.svndump': { |
cd0d14e25757
layouts: add custom layout for those of us that need weird mappings
David Schleimer <dschleimer@fb.com>
parents:
1084
diff
changeset
|
177 'default': 'trunk', |
cd0d14e25757
layouts: add custom layout for those of us that need weird mappings
David Schleimer <dschleimer@fb.com>
parents:
1084
diff
changeset
|
178 'test': 'branches/test', |
cd0d14e25757
layouts: add custom layout for those of us that need weird mappings
David Schleimer <dschleimer@fb.com>
parents:
1084
diff
changeset
|
179 }, |
cd0d14e25757
layouts: add custom layout for those of us that need weird mappings
David Schleimer <dschleimer@fb.com>
parents:
1084
diff
changeset
|
180 'revert.svndump': trunk_only, |
cd0d14e25757
layouts: add custom layout for those of us that need weird mappings
David Schleimer <dschleimer@fb.com>
parents:
1084
diff
changeset
|
181 'siblingbranchfix.svndump': { |
cd0d14e25757
layouts: add custom layout for those of us that need weird mappings
David Schleimer <dschleimer@fb.com>
parents:
1084
diff
changeset
|
182 'default': 'trunk', |
cd0d14e25757
layouts: add custom layout for those of us that need weird mappings
David Schleimer <dschleimer@fb.com>
parents:
1084
diff
changeset
|
183 'wrongbranch': 'branches/wrongbranch', |
cd0d14e25757
layouts: add custom layout for those of us that need weird mappings
David Schleimer <dschleimer@fb.com>
parents:
1084
diff
changeset
|
184 }, |
cd0d14e25757
layouts: add custom layout for those of us that need weird mappings
David Schleimer <dschleimer@fb.com>
parents:
1084
diff
changeset
|
185 'simple_branch.svndump': { |
cd0d14e25757
layouts: add custom layout for those of us that need weird mappings
David Schleimer <dschleimer@fb.com>
parents:
1084
diff
changeset
|
186 'default': 'trunk', |
cd0d14e25757
layouts: add custom layout for those of us that need weird mappings
David Schleimer <dschleimer@fb.com>
parents:
1084
diff
changeset
|
187 'the_branch': 'branches/the_branch', |
cd0d14e25757
layouts: add custom layout for those of us that need weird mappings
David Schleimer <dschleimer@fb.com>
parents:
1084
diff
changeset
|
188 }, |
cd0d14e25757
layouts: add custom layout for those of us that need weird mappings
David Schleimer <dschleimer@fb.com>
parents:
1084
diff
changeset
|
189 'spaces-in-path.svndump': trunk_dev_branch, |
cd0d14e25757
layouts: add custom layout for those of us that need weird mappings
David Schleimer <dschleimer@fb.com>
parents:
1084
diff
changeset
|
190 'symlinks.svndump': trunk_only, |
cd0d14e25757
layouts: add custom layout for those of us that need weird mappings
David Schleimer <dschleimer@fb.com>
parents:
1084
diff
changeset
|
191 'truncatedhistory.svndump': trunk_only, |
cd0d14e25757
layouts: add custom layout for those of us that need weird mappings
David Schleimer <dschleimer@fb.com>
parents:
1084
diff
changeset
|
192 'unorderedbranch.svndump': { |
cd0d14e25757
layouts: add custom layout for those of us that need weird mappings
David Schleimer <dschleimer@fb.com>
parents:
1084
diff
changeset
|
193 'default': 'trunk', |
cd0d14e25757
layouts: add custom layout for those of us that need weird mappings
David Schleimer <dschleimer@fb.com>
parents:
1084
diff
changeset
|
194 'branch': 'branches/branch', |
cd0d14e25757
layouts: add custom layout for those of us that need weird mappings
David Schleimer <dschleimer@fb.com>
parents:
1084
diff
changeset
|
195 }, |
cd0d14e25757
layouts: add custom layout for those of us that need weird mappings
David Schleimer <dschleimer@fb.com>
parents:
1084
diff
changeset
|
196 'unrelatedbranch.svndump': { |
cd0d14e25757
layouts: add custom layout for those of us that need weird mappings
David Schleimer <dschleimer@fb.com>
parents:
1084
diff
changeset
|
197 'default': 'trunk', |
cd0d14e25757
layouts: add custom layout for those of us that need weird mappings
David Schleimer <dschleimer@fb.com>
parents:
1084
diff
changeset
|
198 'branch1': 'branches/branch1', |
cd0d14e25757
layouts: add custom layout for those of us that need weird mappings
David Schleimer <dschleimer@fb.com>
parents:
1084
diff
changeset
|
199 'branch2': 'branches/branch2', |
cd0d14e25757
layouts: add custom layout for those of us that need weird mappings
David Schleimer <dschleimer@fb.com>
parents:
1084
diff
changeset
|
200 }, |
cd0d14e25757
layouts: add custom layout for those of us that need weird mappings
David Schleimer <dschleimer@fb.com>
parents:
1084
diff
changeset
|
201 } |
194
13ae1bded5e7
Add some comprehensive tests that can be run with nose in order to make it easier to verify stupid and real replay do the same thing.
Augie Fackler <durin42@gmail.com>
parents:
170
diff
changeset
|
202 |
14
d78dbf88c13d
Started a meaningful test suite.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
203 FIXTURES = os.path.join(os.path.abspath(os.path.dirname(__file__)), |
d78dbf88c13d
Started a meaningful test suite.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
204 'fixtures') |
d78dbf88c13d
Started a meaningful test suite.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
205 |
930
5bacb9c63e3e
Fix more peer breakage with old hg versions
Patrick Mezard <patrick@mezard.eu>
parents:
923
diff
changeset
|
206 def getlocalpeer(repo): |
5bacb9c63e3e
Fix more peer breakage with old hg versions
Patrick Mezard <patrick@mezard.eu>
parents:
923
diff
changeset
|
207 localrepo = getattr(repo, 'local', lambda: repo)() |
5bacb9c63e3e
Fix more peer breakage with old hg versions
Patrick Mezard <patrick@mezard.eu>
parents:
923
diff
changeset
|
208 if isinstance(localrepo, bool): |
5bacb9c63e3e
Fix more peer breakage with old hg versions
Patrick Mezard <patrick@mezard.eu>
parents:
923
diff
changeset
|
209 localrepo = repo |
5bacb9c63e3e
Fix more peer breakage with old hg versions
Patrick Mezard <patrick@mezard.eu>
parents:
923
diff
changeset
|
210 return localrepo |
719
ae52a3b30cfb
test_util: refactor requiresoption to ease creation of other skip decorators
Augie Fackler <durin42@gmail.com>
parents:
717
diff
changeset
|
211 |
1463
86ae03f889a4
test_util: allow counting converted revisions
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
1462
diff
changeset
|
212 def repolen(repo, svnonly=False): |
1048
903c9c9dfe6a
tests: count revisions explicitly
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
1041
diff
changeset
|
213 """Naively calculate the amount of available revisions in a repository. |
903c9c9dfe6a
tests: count revisions explicitly
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
1041
diff
changeset
|
214 |
903c9c9dfe6a
tests: count revisions explicitly
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
1041
diff
changeset
|
215 this is usually equal to len(repo) -- except in the face of |
903c9c9dfe6a
tests: count revisions explicitly
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
1041
diff
changeset
|
216 obsolete revisions. |
1463
86ae03f889a4
test_util: allow counting converted revisions
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
1462
diff
changeset
|
217 |
86ae03f889a4
test_util: allow counting converted revisions
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
1462
diff
changeset
|
218 if svnonly is true, only count revisions converted from Subversion. |
1048
903c9c9dfe6a
tests: count revisions explicitly
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
1041
diff
changeset
|
219 """ |
903c9c9dfe6a
tests: count revisions explicitly
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
1041
diff
changeset
|
220 # kind of nasty way of calculating the length, but fortunately, |
903c9c9dfe6a
tests: count revisions explicitly
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
1041
diff
changeset
|
221 # our test repositories tend to be rather small |
1463
86ae03f889a4
test_util: allow counting converted revisions
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
1462
diff
changeset
|
222 revs = set(repo) |
86ae03f889a4
test_util: allow counting converted revisions
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
1462
diff
changeset
|
223 |
86ae03f889a4
test_util: allow counting converted revisions
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
1462
diff
changeset
|
224 if obsolete: |
86ae03f889a4
test_util: allow counting converted revisions
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
1462
diff
changeset
|
225 revs -= obsolete.getrevs(repo, 'obsolete') |
86ae03f889a4
test_util: allow counting converted revisions
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
1462
diff
changeset
|
226 |
86ae03f889a4
test_util: allow counting converted revisions
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
1462
diff
changeset
|
227 if svnonly: |
86ae03f889a4
test_util: allow counting converted revisions
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
1462
diff
changeset
|
228 revs = set(r for r in revs if util.getsvnrev(repo[r])) |
86ae03f889a4
test_util: allow counting converted revisions
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
1462
diff
changeset
|
229 |
86ae03f889a4
test_util: allow counting converted revisions
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
1462
diff
changeset
|
230 return len(revs) |
1048
903c9c9dfe6a
tests: count revisions explicitly
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
1041
diff
changeset
|
231 |
719
ae52a3b30cfb
test_util: refactor requiresoption to ease creation of other skip decorators
Augie Fackler <durin42@gmail.com>
parents:
717
diff
changeset
|
232 def _makeskip(name, message): |
727
e830b592917b
tests: fix test skipping in pure unittest
Augie Fackler <durin42@gmail.com>
parents:
720
diff
changeset
|
233 if SkipTest: |
e830b592917b
tests: fix test skipping in pure unittest
Augie Fackler <durin42@gmail.com>
parents:
720
diff
changeset
|
234 def skip(*args, **kwargs): |
e830b592917b
tests: fix test skipping in pure unittest
Augie Fackler <durin42@gmail.com>
parents:
720
diff
changeset
|
235 raise SkipTest(message) |
e830b592917b
tests: fix test skipping in pure unittest
Augie Fackler <durin42@gmail.com>
parents:
720
diff
changeset
|
236 skip.__name__ = name |
e830b592917b
tests: fix test skipping in pure unittest
Augie Fackler <durin42@gmail.com>
parents:
720
diff
changeset
|
237 return skip |
719
ae52a3b30cfb
test_util: refactor requiresoption to ease creation of other skip decorators
Augie Fackler <durin42@gmail.com>
parents:
717
diff
changeset
|
238 |
720
a19a208c085b
test_util: new requiresmodule decorator for tests that require a feature
Augie Fackler <durin42@gmail.com>
parents:
719
diff
changeset
|
239 def requiresmodule(mod): |
a19a208c085b
test_util: new requiresmodule decorator for tests that require a feature
Augie Fackler <durin42@gmail.com>
parents:
719
diff
changeset
|
240 """Skip a test if the specified module is not None.""" |
a19a208c085b
test_util: new requiresmodule decorator for tests that require a feature
Augie Fackler <durin42@gmail.com>
parents:
719
diff
changeset
|
241 def decorator(fn): |
727
e830b592917b
tests: fix test skipping in pure unittest
Augie Fackler <durin42@gmail.com>
parents:
720
diff
changeset
|
242 if fn is None: |
e830b592917b
tests: fix test skipping in pure unittest
Augie Fackler <durin42@gmail.com>
parents:
720
diff
changeset
|
243 return |
720
a19a208c085b
test_util: new requiresmodule decorator for tests that require a feature
Augie Fackler <durin42@gmail.com>
parents:
719
diff
changeset
|
244 if mod is not None: |
a19a208c085b
test_util: new requiresmodule decorator for tests that require a feature
Augie Fackler <durin42@gmail.com>
parents:
719
diff
changeset
|
245 return fn |
a19a208c085b
test_util: new requiresmodule decorator for tests that require a feature
Augie Fackler <durin42@gmail.com>
parents:
719
diff
changeset
|
246 return _makeskip(fn.__name__, 'missing required feature') |
a19a208c085b
test_util: new requiresmodule decorator for tests that require a feature
Augie Fackler <durin42@gmail.com>
parents:
719
diff
changeset
|
247 return decorator |
a19a208c085b
test_util: new requiresmodule decorator for tests that require a feature
Augie Fackler <durin42@gmail.com>
parents:
719
diff
changeset
|
248 |
a19a208c085b
test_util: new requiresmodule decorator for tests that require a feature
Augie Fackler <durin42@gmail.com>
parents:
719
diff
changeset
|
249 |
711
cfc7df19e4dc
test_util: add requiresoption decorator function.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
706
diff
changeset
|
250 def requiresoption(option): |
715
c33293a34752
requiresoption: clean up docstring
Augie Fackler <durin42@gmail.com>
parents:
711
diff
changeset
|
251 '''Skip a test if commands.clone does not take the specified option.''' |
711
cfc7df19e4dc
test_util: add requiresoption decorator function.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
706
diff
changeset
|
252 def decorator(fn): |
cfc7df19e4dc
test_util: add requiresoption decorator function.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
706
diff
changeset
|
253 for entry in cmdutil.findcmd('clone', commands.table)[1][1]: |
cfc7df19e4dc
test_util: add requiresoption decorator function.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
706
diff
changeset
|
254 if entry[1] == option: |
cfc7df19e4dc
test_util: add requiresoption decorator function.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
706
diff
changeset
|
255 return fn |
716
38ebf7714cdf
requiresoption: raise SkipTest if available
Augie Fackler <durin42@gmail.com>
parents:
715
diff
changeset
|
256 # no match found, so skip |
38ebf7714cdf
requiresoption: raise SkipTest if available
Augie Fackler <durin42@gmail.com>
parents:
715
diff
changeset
|
257 if SkipTest: |
719
ae52a3b30cfb
test_util: refactor requiresoption to ease creation of other skip decorators
Augie Fackler <durin42@gmail.com>
parents:
717
diff
changeset
|
258 return _makeskip(fn.__name__, |
ae52a3b30cfb
test_util: refactor requiresoption to ease creation of other skip decorators
Augie Fackler <durin42@gmail.com>
parents:
717
diff
changeset
|
259 'test requires clone to accept %s' % option) |
716
38ebf7714cdf
requiresoption: raise SkipTest if available
Augie Fackler <durin42@gmail.com>
parents:
715
diff
changeset
|
260 # no skipping support, so erase decorated method |
38ebf7714cdf
requiresoption: raise SkipTest if available
Augie Fackler <durin42@gmail.com>
parents:
715
diff
changeset
|
261 return |
711
cfc7df19e4dc
test_util: add requiresoption decorator function.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
706
diff
changeset
|
262 if not isinstance(option, str): |
cfc7df19e4dc
test_util: add requiresoption decorator function.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
706
diff
changeset
|
263 raise TypeError('requiresoption takes a string argument') |
cfc7df19e4dc
test_util: add requiresoption decorator function.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
706
diff
changeset
|
264 return decorator |
cfc7df19e4dc
test_util: add requiresoption decorator function.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
706
diff
changeset
|
265 |
1056
0932bb4d8870
tests: add a metaclass for triggering stupid on a class level
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
1049
diff
changeset
|
266 def requiresreplay(method): |
0932bb4d8870
tests: add a metaclass for triggering stupid on a class level
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
1049
diff
changeset
|
267 '''Skip a test in stupid mode.''' |
0932bb4d8870
tests: add a metaclass for triggering stupid on a class level
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
1049
diff
changeset
|
268 def test(self, *args, **kwargs): |
0932bb4d8870
tests: add a metaclass for triggering stupid on a class level
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
1049
diff
changeset
|
269 if self.stupid: |
0932bb4d8870
tests: add a metaclass for triggering stupid on a class level
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
1049
diff
changeset
|
270 if SkipTest: |
1080
661f4065bfbf
test_util: fix missing message in SkipTest raise
Augie Fackler <raf@durin42.com>
parents:
1078
diff
changeset
|
271 raise SkipTest("test requires replay mode") |
1056
0932bb4d8870
tests: add a metaclass for triggering stupid on a class level
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
1049
diff
changeset
|
272 else: |
0932bb4d8870
tests: add a metaclass for triggering stupid on a class level
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
1049
diff
changeset
|
273 return method(self, *args, **kwargs) |
0932bb4d8870
tests: add a metaclass for triggering stupid on a class level
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
1049
diff
changeset
|
274 |
0932bb4d8870
tests: add a metaclass for triggering stupid on a class level
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
1049
diff
changeset
|
275 test.__name__ = method.__name__ |
0932bb4d8870
tests: add a metaclass for triggering stupid on a class level
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
1049
diff
changeset
|
276 return test |
0932bb4d8870
tests: add a metaclass for triggering stupid on a class level
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
1049
diff
changeset
|
277 |
499
1fd3cfa47c5e
Support for single-directory clones.
Augie Fackler <durin42@gmail.com>
parents:
492
diff
changeset
|
278 def filtermanifest(manifest): |
772
f3af4fe98d37
test_util: make manifest filter use shared list of files to ignore
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
764
diff
changeset
|
279 return [f for f in manifest if f not in util.ignoredfiles] |
499
1fd3cfa47c5e
Support for single-directory clones.
Augie Fackler <durin42@gmail.com>
parents:
492
diff
changeset
|
280 |
91
7d10165cf3d9
tests: Mock the mercurial.ui.ui class like we really should to capture output.
Augie Fackler <durin42@gmail.com>
parents:
84
diff
changeset
|
281 def fileurl(path): |
522
60bf433647e7
test_util: fix Windows test URLs
Patrick Mezard <pmezard@gmail.com>
parents:
516
diff
changeset
|
282 path = os.path.abspath(path).replace(os.sep, '/') |
78
072010a271c6
Fix basic issues with tests on Windows
Patrick Mezard <pmezard@gmail.com>
parents:
23
diff
changeset
|
283 drive, path = os.path.splitdrive(path) |
072010a271c6
Fix basic issues with tests on Windows
Patrick Mezard <pmezard@gmail.com>
parents:
23
diff
changeset
|
284 if drive: |
923
847953806c77
test_util: make repourl() return upper-cased drive letters
Patrick Mezard <patrick@mezard.eu>
parents:
917
diff
changeset
|
285 # In svn 1.7, the swig svn wrapper returns local svn URLs |
847953806c77
test_util: make repourl() return upper-cased drive letters
Patrick Mezard <patrick@mezard.eu>
parents:
917
diff
changeset
|
286 # with an uppercase drive letter, try to match that to |
847953806c77
test_util: make repourl() return upper-cased drive letters
Patrick Mezard <patrick@mezard.eu>
parents:
917
diff
changeset
|
287 # simplify svn info tests. |
847953806c77
test_util: make repourl() return upper-cased drive letters
Patrick Mezard <patrick@mezard.eu>
parents:
917
diff
changeset
|
288 drive = '/' + drive.upper() |
342
76c833526fbc
Use fallbacks in the wrappers for Subversion support, instead of prefixes.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
337
diff
changeset
|
289 url = 'file://%s%s' % (drive, path) |
78
072010a271c6
Fix basic issues with tests on Windows
Patrick Mezard <pmezard@gmail.com>
parents:
23
diff
changeset
|
290 return url |
072010a271c6
Fix basic issues with tests on Windows
Patrick Mezard <pmezard@gmail.com>
parents:
23
diff
changeset
|
291 |
1541
adba152a5177
test_util: make developer warnings cause our tests to fail
Augie Fackler <raf@durin42.com>
parents:
1517
diff
changeset
|
292 class _testui(ui.ui): |
adba152a5177
test_util: make developer warnings cause our tests to fail
Augie Fackler <raf@durin42.com>
parents:
1517
diff
changeset
|
293 def develwarn(self, msg, stacklevel=1, *args, **kwargs): |
adba152a5177
test_util: make developer warnings cause our tests to fail
Augie Fackler <raf@durin42.com>
parents:
1517
diff
changeset
|
294 from hgsubversion import util |
adba152a5177
test_util: make developer warnings cause our tests to fail
Augie Fackler <raf@durin42.com>
parents:
1517
diff
changeset
|
295 if util.smartset is not None: |
adba152a5177
test_util: make developer warnings cause our tests to fail
Augie Fackler <raf@durin42.com>
parents:
1517
diff
changeset
|
296 config = args[0] if args else kwargs['config'] |
adba152a5177
test_util: make developer warnings cause our tests to fail
Augie Fackler <raf@durin42.com>
parents:
1517
diff
changeset
|
297 raise Exception('flunked develwarn: %r (%r)' % (msg, config)) |
adba152a5177
test_util: make developer warnings cause our tests to fail
Augie Fackler <raf@durin42.com>
parents:
1517
diff
changeset
|
298 return ui.ui.develwarn(self, msg, stacklevel=stacklevel, |
adba152a5177
test_util: make developer warnings cause our tests to fail
Augie Fackler <raf@durin42.com>
parents:
1517
diff
changeset
|
299 *args, **kwargs) |
adba152a5177
test_util: make developer warnings cause our tests to fail
Augie Fackler <raf@durin42.com>
parents:
1517
diff
changeset
|
300 |
1554
258fb67fb956
externals: correctly enable hgsubversion externals support during tests
Augie Fackler <raf@durin42.com>
parents:
1552
diff
changeset
|
301 def testui(stupid=False, layout='auto', startrev=0, subrepo=False): |
1541
adba152a5177
test_util: make developer warnings cause our tests to fail
Augie Fackler <raf@durin42.com>
parents:
1517
diff
changeset
|
302 u = _testui() |
576
d96aa92d9ad9
tests: silence test suite by using quiet UIs everywhere
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
548
diff
changeset
|
303 bools = {True: 'true', False: 'false'} |
d96aa92d9ad9
tests: silence test suite by using quiet UIs everywhere
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
548
diff
changeset
|
304 u.setconfig('ui', 'quiet', bools[True]) |
1493
bac709b5ff6c
testui: set a username so recording obsolete markers doesn't break
Augie Fackler <raf@durin42.com>
parents:
1365
diff
changeset
|
305 u.setconfig('ui', 'username', 'automated tests') |
696
c11bf0dd38d3
tests: enable hgsubversion in the generated UI.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
689
diff
changeset
|
306 u.setconfig('extensions', 'hgsubversion', '') |
576
d96aa92d9ad9
tests: silence test suite by using quiet UIs everywhere
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
548
diff
changeset
|
307 u.setconfig('hgsubversion', 'stupid', bools[stupid]) |
d96aa92d9ad9
tests: silence test suite by using quiet UIs everywhere
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
548
diff
changeset
|
308 u.setconfig('hgsubversion', 'layout', layout) |
652
c3900ad3bf69
test_util: support specifying a start revision
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
645
diff
changeset
|
309 u.setconfig('hgsubversion', 'startrev', startrev) |
1554
258fb67fb956
externals: correctly enable hgsubversion externals support during tests
Augie Fackler <raf@durin42.com>
parents:
1552
diff
changeset
|
310 u.setconfig('subrepos', 'hgsubversion:allowed', subrepo) |
1517 | 311 u.setconfig('devel', 'all-warnings', True) |
576
d96aa92d9ad9
tests: silence test suite by using quiet UIs everywhere
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
548
diff
changeset
|
312 return u |
d96aa92d9ad9
tests: silence test suite by using quiet UIs everywhere
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
548
diff
changeset
|
313 |
813
f07bfd66db13
test_util: handle dispatch.dispatch() taking a request
Patrick Mezard <pmezard@gmail.com>
parents:
793
diff
changeset
|
314 def dispatch(cmd): |
1344
38be7a6b6def
tests: have our dispatch wrappers assert --quiet is always passed
Augie Fackler <raf@durin42.com>
parents:
1343
diff
changeset
|
315 assert '--quiet' in cmd |
916
7e9d805a0e1f
tests: fix regressions introduced by peer classes in hg 2.3
Bryan O'Sullivan <bryano@fb.com>
parents:
910
diff
changeset
|
316 cmd = getattr(dispatchmod, 'request', lambda x: x)(cmd) |
1041
70090e2ee262
tests: assert that fetches actually succeed
Dan Villiom Podlaski Christiansen <dan@cabo.dk>
parents:
1038
diff
changeset
|
317 return dispatchmod.dispatch(cmd) |
813
f07bfd66db13
test_util: handle dispatch.dispatch() taking a request
Patrick Mezard <pmezard@gmail.com>
parents:
793
diff
changeset
|
318 |
78
072010a271c6
Fix basic issues with tests on Windows
Patrick Mezard <pmezard@gmail.com>
parents:
23
diff
changeset
|
319 def rmtree(path): |
072010a271c6
Fix basic issues with tests on Windows
Patrick Mezard <pmezard@gmail.com>
parents:
23
diff
changeset
|
320 # Read-only files cannot be removed under Windows |
072010a271c6
Fix basic issues with tests on Windows
Patrick Mezard <pmezard@gmail.com>
parents:
23
diff
changeset
|
321 for root, dirs, files in os.walk(path): |
072010a271c6
Fix basic issues with tests on Windows
Patrick Mezard <pmezard@gmail.com>
parents:
23
diff
changeset
|
322 for f in files: |
072010a271c6
Fix basic issues with tests on Windows
Patrick Mezard <pmezard@gmail.com>
parents:
23
diff
changeset
|
323 f = os.path.join(root, f) |
072010a271c6
Fix basic issues with tests on Windows
Patrick Mezard <pmezard@gmail.com>
parents:
23
diff
changeset
|
324 try: |
072010a271c6
Fix basic issues with tests on Windows
Patrick Mezard <pmezard@gmail.com>
parents:
23
diff
changeset
|
325 s = os.stat(f) |
072010a271c6
Fix basic issues with tests on Windows
Patrick Mezard <pmezard@gmail.com>
parents:
23
diff
changeset
|
326 except OSError, e: |
072010a271c6
Fix basic issues with tests on Windows
Patrick Mezard <pmezard@gmail.com>
parents:
23
diff
changeset
|
327 if e.errno == errno.ENOENT: |
072010a271c6
Fix basic issues with tests on Windows
Patrick Mezard <pmezard@gmail.com>
parents:
23
diff
changeset
|
328 continue |
072010a271c6
Fix basic issues with tests on Windows
Patrick Mezard <pmezard@gmail.com>
parents:
23
diff
changeset
|
329 raise |
072010a271c6
Fix basic issues with tests on Windows
Patrick Mezard <pmezard@gmail.com>
parents:
23
diff
changeset
|
330 if (s.st_mode & stat.S_IWRITE) == 0: |
072010a271c6
Fix basic issues with tests on Windows
Patrick Mezard <pmezard@gmail.com>
parents:
23
diff
changeset
|
331 os.chmod(f, s.st_mode | stat.S_IWRITE) |
072010a271c6
Fix basic issues with tests on Windows
Patrick Mezard <pmezard@gmail.com>
parents:
23
diff
changeset
|
332 shutil.rmtree(path) |
82
71de43e9f614
Extract PushTest common code into test_util.TestBase
Patrick Mezard <pmezard@gmail.com>
parents:
78
diff
changeset
|
333 |
645
3cb5042531fb
tests: verify locations of any imported hgsubversion modules
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
644
diff
changeset
|
334 def _verify_our_modules(): |
3cb5042531fb
tests: verify locations of any imported hgsubversion modules
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
644
diff
changeset
|
335 ''' |
3cb5042531fb
tests: verify locations of any imported hgsubversion modules
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
644
diff
changeset
|
336 Verify that hgsubversion was imported from the correct location. |
3cb5042531fb
tests: verify locations of any imported hgsubversion modules
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
644
diff
changeset
|
337 |
3cb5042531fb
tests: verify locations of any imported hgsubversion modules
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
644
diff
changeset
|
338 The correct location is any location within the parent directory of the |
3cb5042531fb
tests: verify locations of any imported hgsubversion modules
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
644
diff
changeset
|
339 directory containing this file. |
3cb5042531fb
tests: verify locations of any imported hgsubversion modules
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
644
diff
changeset
|
340 ''' |
3cb5042531fb
tests: verify locations of any imported hgsubversion modules
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
644
diff
changeset
|
341 |
3cb5042531fb
tests: verify locations of any imported hgsubversion modules
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
644
diff
changeset
|
342 for modname, module in sys.modules.iteritems(): |
3cb5042531fb
tests: verify locations of any imported hgsubversion modules
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
644
diff
changeset
|
343 if not module or not modname.startswith('hgsubversion.'): |
3cb5042531fb
tests: verify locations of any imported hgsubversion modules
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
644
diff
changeset
|
344 continue |
3cb5042531fb
tests: verify locations of any imported hgsubversion modules
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
644
diff
changeset
|
345 |
3cb5042531fb
tests: verify locations of any imported hgsubversion modules
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
644
diff
changeset
|
346 modloc = module.__file__ |
3cb5042531fb
tests: verify locations of any imported hgsubversion modules
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
644
diff
changeset
|
347 cp = os.path.commonprefix((os.path.abspath(__file__), modloc)) |
3cb5042531fb
tests: verify locations of any imported hgsubversion modules
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
644
diff
changeset
|
348 assert cp.rstrip(os.sep) == _rootdir, ( |
3cb5042531fb
tests: verify locations of any imported hgsubversion modules
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
644
diff
changeset
|
349 'Module location verification failed: hgsubversion was imported ' |
3cb5042531fb
tests: verify locations of any imported hgsubversion modules
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
644
diff
changeset
|
350 'from the wrong path!' |
3cb5042531fb
tests: verify locations of any imported hgsubversion modules
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
644
diff
changeset
|
351 ) |
486
5607e81ba616
test_util: specify LANG=LC_ALL=C so l10n stops breaking tests
Augie Fackler <durin42@gmail.com>
parents:
483
diff
changeset
|
352 |
890
78db88de9622
Partial metadata rebuilding
David Schleimer <dschleimer@fb.com>
parents:
888
diff
changeset
|
353 def hgclone(ui, source, dest, update=True, rev=None): |
816
86d124a8768e
Fix hg.clone() calls changed by d976542986d2
Patrick Mezard <pmezard@gmail.com>
parents:
813
diff
changeset
|
354 if getattr(hg, 'peer', None): |
86d124a8768e
Fix hg.clone() calls changed by d976542986d2
Patrick Mezard <pmezard@gmail.com>
parents:
813
diff
changeset
|
355 # Since 1.9 (d976542986d2) |
890
78db88de9622
Partial metadata rebuilding
David Schleimer <dschleimer@fb.com>
parents:
888
diff
changeset
|
356 src, dest = hg.clone(ui, {}, source, dest, update=update, rev=rev) |
816
86d124a8768e
Fix hg.clone() calls changed by d976542986d2
Patrick Mezard <pmezard@gmail.com>
parents:
813
diff
changeset
|
357 else: |
890
78db88de9622
Partial metadata rebuilding
David Schleimer <dschleimer@fb.com>
parents:
888
diff
changeset
|
358 src, dest = hg.clone(ui, source, dest, update=update, rev=rev) |
816
86d124a8768e
Fix hg.clone() calls changed by d976542986d2
Patrick Mezard <pmezard@gmail.com>
parents:
813
diff
changeset
|
359 return src, dest |
86d124a8768e
Fix hg.clone() calls changed by d976542986d2
Patrick Mezard <pmezard@gmail.com>
parents:
813
diff
changeset
|
360 |
869
db3a651494f9
test_util: pass repo_path to svnls(), turn it into a function
Patrick Mezard <patrick@mezard.eu>
parents:
868
diff
changeset
|
361 def svnls(repo_path, path, rev='HEAD'): |
db3a651494f9
test_util: pass repo_path to svnls(), turn it into a function
Patrick Mezard <patrick@mezard.eu>
parents:
868
diff
changeset
|
362 path = repo_path + '/' + path |
db3a651494f9
test_util: pass repo_path to svnls(), turn it into a function
Patrick Mezard <patrick@mezard.eu>
parents:
868
diff
changeset
|
363 path = util.normalize_url(fileurl(path)) |
db3a651494f9
test_util: pass repo_path to svnls(), turn it into a function
Patrick Mezard <patrick@mezard.eu>
parents:
868
diff
changeset
|
364 args = ['svn', 'ls', '-r', rev, '-R', path] |
db3a651494f9
test_util: pass repo_path to svnls(), turn it into a function
Patrick Mezard <patrick@mezard.eu>
parents:
868
diff
changeset
|
365 p = subprocess.Popen(args, |
db3a651494f9
test_util: pass repo_path to svnls(), turn it into a function
Patrick Mezard <patrick@mezard.eu>
parents:
868
diff
changeset
|
366 stdout=subprocess.PIPE, |
db3a651494f9
test_util: pass repo_path to svnls(), turn it into a function
Patrick Mezard <patrick@mezard.eu>
parents:
868
diff
changeset
|
367 stderr=subprocess.STDOUT) |
db3a651494f9
test_util: pass repo_path to svnls(), turn it into a function
Patrick Mezard <patrick@mezard.eu>
parents:
868
diff
changeset
|
368 stdout, stderr = p.communicate() |
db3a651494f9
test_util: pass repo_path to svnls(), turn it into a function
Patrick Mezard <patrick@mezard.eu>
parents:
868
diff
changeset
|
369 if p.returncode: |
db3a651494f9
test_util: pass repo_path to svnls(), turn it into a function
Patrick Mezard <patrick@mezard.eu>
parents:
868
diff
changeset
|
370 raise Exception('svn ls failed on %s: %r' % (path, stderr)) |
db3a651494f9
test_util: pass repo_path to svnls(), turn it into a function
Patrick Mezard <patrick@mezard.eu>
parents:
868
diff
changeset
|
371 entries = [e.strip('/') for e in stdout.splitlines()] |
db3a651494f9
test_util: pass repo_path to svnls(), turn it into a function
Patrick Mezard <patrick@mezard.eu>
parents:
868
diff
changeset
|
372 entries.sort() |
db3a651494f9
test_util: pass repo_path to svnls(), turn it into a function
Patrick Mezard <patrick@mezard.eu>
parents:
868
diff
changeset
|
373 return entries |
db3a651494f9
test_util: pass repo_path to svnls(), turn it into a function
Patrick Mezard <patrick@mezard.eu>
parents:
868
diff
changeset
|
374 |
871
51fd75ae62b9
test_util: pass repo_path to svnpropget(), turn into a function
Patrick Mezard <patrick@mezard.eu>
parents:
870
diff
changeset
|
375 def svnpropget(repo_path, path, prop, rev='HEAD'): |
51fd75ae62b9
test_util: pass repo_path to svnpropget(), turn into a function
Patrick Mezard <patrick@mezard.eu>
parents:
870
diff
changeset
|
376 path = repo_path + '/' + path |
51fd75ae62b9
test_util: pass repo_path to svnpropget(), turn into a function
Patrick Mezard <patrick@mezard.eu>
parents:
870
diff
changeset
|
377 path = util.normalize_url(fileurl(path)) |
51fd75ae62b9
test_util: pass repo_path to svnpropget(), turn into a function
Patrick Mezard <patrick@mezard.eu>
parents:
870
diff
changeset
|
378 args = ['svn', 'propget', '-r', str(rev), prop, path] |
51fd75ae62b9
test_util: pass repo_path to svnpropget(), turn into a function
Patrick Mezard <patrick@mezard.eu>
parents:
870
diff
changeset
|
379 p = subprocess.Popen(args, |
51fd75ae62b9
test_util: pass repo_path to svnpropget(), turn into a function
Patrick Mezard <patrick@mezard.eu>
parents:
870
diff
changeset
|
380 stdout=subprocess.PIPE, |
51fd75ae62b9
test_util: pass repo_path to svnpropget(), turn into a function
Patrick Mezard <patrick@mezard.eu>
parents:
870
diff
changeset
|
381 stderr=subprocess.STDOUT) |
51fd75ae62b9
test_util: pass repo_path to svnpropget(), turn into a function
Patrick Mezard <patrick@mezard.eu>
parents:
870
diff
changeset
|
382 stdout, stderr = p.communicate() |
1363
3c213ca49f7e
tests: update for behavior change in subversion 1.9
Sean Farley <sean@farley.io>
parents:
1344
diff
changeset
|
383 if p.returncode and stderr: |
871
51fd75ae62b9
test_util: pass repo_path to svnpropget(), turn into a function
Patrick Mezard <patrick@mezard.eu>
parents:
870
diff
changeset
|
384 raise Exception('svn ls failed on %s: %r' % (path, stderr)) |
1363
3c213ca49f7e
tests: update for behavior change in subversion 1.9
Sean Farley <sean@farley.io>
parents:
1344
diff
changeset
|
385 if 'W200017' in stdout: |
3c213ca49f7e
tests: update for behavior change in subversion 1.9
Sean Farley <sean@farley.io>
parents:
1344
diff
changeset
|
386 # subversion >= 1.9 changed 'no properties' to be an error, so let's |
3c213ca49f7e
tests: update for behavior change in subversion 1.9
Sean Farley <sean@farley.io>
parents:
1344
diff
changeset
|
387 # avoid that |
3c213ca49f7e
tests: update for behavior change in subversion 1.9
Sean Farley <sean@farley.io>
parents:
1344
diff
changeset
|
388 return '' |
871
51fd75ae62b9
test_util: pass repo_path to svnpropget(), turn into a function
Patrick Mezard <patrick@mezard.eu>
parents:
870
diff
changeset
|
389 return stdout.strip() |
51fd75ae62b9
test_util: pass repo_path to svnpropget(), turn into a function
Patrick Mezard <patrick@mezard.eu>
parents:
870
diff
changeset
|
390 |
1049
608e7c8740af
tests: add a metaclass for testing obsolete mode
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
1048
diff
changeset
|
391 |
608e7c8740af
tests: add a metaclass for testing obsolete mode
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
1048
diff
changeset
|
392 def _obsolete_wrap(cls, name): |
608e7c8740af
tests: add a metaclass for testing obsolete mode
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
1048
diff
changeset
|
393 origfunc = getattr(cls, name) |
608e7c8740af
tests: add a metaclass for testing obsolete mode
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
1048
diff
changeset
|
394 |
608e7c8740af
tests: add a metaclass for testing obsolete mode
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
1048
diff
changeset
|
395 if not name.startswith('test_') or not origfunc: |
608e7c8740af
tests: add a metaclass for testing obsolete mode
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
1048
diff
changeset
|
396 return |
608e7c8740af
tests: add a metaclass for testing obsolete mode
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
1048
diff
changeset
|
397 |
608e7c8740af
tests: add a metaclass for testing obsolete mode
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
1048
diff
changeset
|
398 if not obsolete: |
608e7c8740af
tests: add a metaclass for testing obsolete mode
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
1048
diff
changeset
|
399 wrapper = _makeskip(name, 'obsolete not available') |
608e7c8740af
tests: add a metaclass for testing obsolete mode
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
1048
diff
changeset
|
400 else: |
608e7c8740af
tests: add a metaclass for testing obsolete mode
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
1048
diff
changeset
|
401 def wrapper(self, *args, **opts): |
608e7c8740af
tests: add a metaclass for testing obsolete mode
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
1048
diff
changeset
|
402 self.assertFalse(obsolete._enabled, 'obsolete was already active') |
608e7c8740af
tests: add a metaclass for testing obsolete mode
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
1048
diff
changeset
|
403 |
608e7c8740af
tests: add a metaclass for testing obsolete mode
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
1048
diff
changeset
|
404 obsolete._enabled = True |
608e7c8740af
tests: add a metaclass for testing obsolete mode
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
1048
diff
changeset
|
405 |
608e7c8740af
tests: add a metaclass for testing obsolete mode
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
1048
diff
changeset
|
406 try: |
608e7c8740af
tests: add a metaclass for testing obsolete mode
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
1048
diff
changeset
|
407 origfunc(self, *args, **opts) |
608e7c8740af
tests: add a metaclass for testing obsolete mode
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
1048
diff
changeset
|
408 self.assertTrue(obsolete._enabled, 'obsolete remains active') |
608e7c8740af
tests: add a metaclass for testing obsolete mode
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
1048
diff
changeset
|
409 finally: |
608e7c8740af
tests: add a metaclass for testing obsolete mode
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
1048
diff
changeset
|
410 obsolete._enabled = False |
608e7c8740af
tests: add a metaclass for testing obsolete mode
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
1048
diff
changeset
|
411 |
608e7c8740af
tests: add a metaclass for testing obsolete mode
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
1048
diff
changeset
|
412 if not wrapper: |
608e7c8740af
tests: add a metaclass for testing obsolete mode
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
1048
diff
changeset
|
413 return |
608e7c8740af
tests: add a metaclass for testing obsolete mode
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
1048
diff
changeset
|
414 |
608e7c8740af
tests: add a metaclass for testing obsolete mode
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
1048
diff
changeset
|
415 wrapper.__name__ = name + ' obsolete' |
608e7c8740af
tests: add a metaclass for testing obsolete mode
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
1048
diff
changeset
|
416 wrapper.__module__ = origfunc.__module__ |
608e7c8740af
tests: add a metaclass for testing obsolete mode
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
1048
diff
changeset
|
417 |
608e7c8740af
tests: add a metaclass for testing obsolete mode
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
1048
diff
changeset
|
418 if origfunc.__doc__: |
608e7c8740af
tests: add a metaclass for testing obsolete mode
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
1048
diff
changeset
|
419 firstline = origfunc.__doc__.strip().splitlines()[0] |
608e7c8740af
tests: add a metaclass for testing obsolete mode
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
1048
diff
changeset
|
420 wrapper.__doc__ = firstline + ' (obsolete)' |
608e7c8740af
tests: add a metaclass for testing obsolete mode
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
1048
diff
changeset
|
421 |
608e7c8740af
tests: add a metaclass for testing obsolete mode
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
1048
diff
changeset
|
422 assert getattr(cls, wrapper.__name__, None) is None |
608e7c8740af
tests: add a metaclass for testing obsolete mode
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
1048
diff
changeset
|
423 |
608e7c8740af
tests: add a metaclass for testing obsolete mode
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
1048
diff
changeset
|
424 setattr(cls, wrapper.__name__, wrapper) |
608e7c8740af
tests: add a metaclass for testing obsolete mode
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
1048
diff
changeset
|
425 |
1056
0932bb4d8870
tests: add a metaclass for triggering stupid on a class level
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
1049
diff
changeset
|
426 |
0932bb4d8870
tests: add a metaclass for triggering stupid on a class level
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
1049
diff
changeset
|
427 def _stupid_wrap(cls, name): |
0932bb4d8870
tests: add a metaclass for triggering stupid on a class level
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
1049
diff
changeset
|
428 origfunc = getattr(cls, name) |
0932bb4d8870
tests: add a metaclass for triggering stupid on a class level
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
1049
diff
changeset
|
429 |
0932bb4d8870
tests: add a metaclass for triggering stupid on a class level
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
1049
diff
changeset
|
430 if not name.startswith('test_') or not origfunc: |
0932bb4d8870
tests: add a metaclass for triggering stupid on a class level
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
1049
diff
changeset
|
431 return |
0932bb4d8870
tests: add a metaclass for triggering stupid on a class level
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
1049
diff
changeset
|
432 |
0932bb4d8870
tests: add a metaclass for triggering stupid on a class level
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
1049
diff
changeset
|
433 def wrapper(self, *args, **opts): |
0932bb4d8870
tests: add a metaclass for triggering stupid on a class level
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
1049
diff
changeset
|
434 self.assertFalse(self.stupid, 'stupid mode was already active') |
0932bb4d8870
tests: add a metaclass for triggering stupid on a class level
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
1049
diff
changeset
|
435 |
0932bb4d8870
tests: add a metaclass for triggering stupid on a class level
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
1049
diff
changeset
|
436 self.stupid = True |
0932bb4d8870
tests: add a metaclass for triggering stupid on a class level
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
1049
diff
changeset
|
437 |
0932bb4d8870
tests: add a metaclass for triggering stupid on a class level
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
1049
diff
changeset
|
438 try: |
0932bb4d8870
tests: add a metaclass for triggering stupid on a class level
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
1049
diff
changeset
|
439 origfunc(self, *args, **opts) |
0932bb4d8870
tests: add a metaclass for triggering stupid on a class level
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
1049
diff
changeset
|
440 finally: |
0932bb4d8870
tests: add a metaclass for triggering stupid on a class level
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
1049
diff
changeset
|
441 self.stupid = False |
0932bb4d8870
tests: add a metaclass for triggering stupid on a class level
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
1049
diff
changeset
|
442 |
0932bb4d8870
tests: add a metaclass for triggering stupid on a class level
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
1049
diff
changeset
|
443 wrapper.__name__ = name + ' stupid' |
0932bb4d8870
tests: add a metaclass for triggering stupid on a class level
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
1049
diff
changeset
|
444 wrapper.__module__ = origfunc.__module__ |
0932bb4d8870
tests: add a metaclass for triggering stupid on a class level
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
1049
diff
changeset
|
445 |
0932bb4d8870
tests: add a metaclass for triggering stupid on a class level
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
1049
diff
changeset
|
446 if origfunc.__doc__: |
0932bb4d8870
tests: add a metaclass for triggering stupid on a class level
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
1049
diff
changeset
|
447 firstline = origfunc.__doc__.strip().splitlines()[0] |
0932bb4d8870
tests: add a metaclass for triggering stupid on a class level
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
1049
diff
changeset
|
448 wrapper.__doc__ = firstline + ' (stupid)' |
0932bb4d8870
tests: add a metaclass for triggering stupid on a class level
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
1049
diff
changeset
|
449 |
0932bb4d8870
tests: add a metaclass for triggering stupid on a class level
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
1049
diff
changeset
|
450 assert getattr(cls, wrapper.__name__, None) is None |
0932bb4d8870
tests: add a metaclass for triggering stupid on a class level
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
1049
diff
changeset
|
451 |
0932bb4d8870
tests: add a metaclass for triggering stupid on a class level
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
1049
diff
changeset
|
452 setattr(cls, wrapper.__name__, wrapper) |
0932bb4d8870
tests: add a metaclass for triggering stupid on a class level
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
1049
diff
changeset
|
453 |
1049
608e7c8740af
tests: add a metaclass for testing obsolete mode
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
1048
diff
changeset
|
454 class TestMeta(type): |
608e7c8740af
tests: add a metaclass for testing obsolete mode
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
1048
diff
changeset
|
455 def __init__(cls, *args, **opts): |
608e7c8740af
tests: add a metaclass for testing obsolete mode
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
1048
diff
changeset
|
456 if cls.obsolete_mode_tests: |
608e7c8740af
tests: add a metaclass for testing obsolete mode
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
1048
diff
changeset
|
457 for origname in dir(cls): |
608e7c8740af
tests: add a metaclass for testing obsolete mode
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
1048
diff
changeset
|
458 _obsolete_wrap(cls, origname) |
608e7c8740af
tests: add a metaclass for testing obsolete mode
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
1048
diff
changeset
|
459 |
1365
89997a5fc181
stupid: self-disable if svn bindings are too new to work with stupid mode
Augie Fackler <raf@durin42.com>
parents:
1363
diff
changeset
|
460 if cls.stupid_mode_tests and svnwrap.subversion_version < (1, 9, 0): |
1056
0932bb4d8870
tests: add a metaclass for triggering stupid on a class level
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
1049
diff
changeset
|
461 for origname in dir(cls): |
0932bb4d8870
tests: add a metaclass for triggering stupid on a class level
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
1049
diff
changeset
|
462 _stupid_wrap(cls, origname) |
0932bb4d8870
tests: add a metaclass for triggering stupid on a class level
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
1049
diff
changeset
|
463 |
1049
608e7c8740af
tests: add a metaclass for testing obsolete mode
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
1048
diff
changeset
|
464 return super(TestMeta, cls).__init__(*args, **opts) |
608e7c8740af
tests: add a metaclass for testing obsolete mode
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
1048
diff
changeset
|
465 |
82
71de43e9f614
Extract PushTest common code into test_util.TestBase
Patrick Mezard <pmezard@gmail.com>
parents:
78
diff
changeset
|
466 class TestBase(unittest.TestCase): |
1049
608e7c8740af
tests: add a metaclass for testing obsolete mode
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
1048
diff
changeset
|
467 __metaclass__ = TestMeta |
608e7c8740af
tests: add a metaclass for testing obsolete mode
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
1048
diff
changeset
|
468 |
608e7c8740af
tests: add a metaclass for testing obsolete mode
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
1048
diff
changeset
|
469 obsolete_mode_tests = False |
1056
0932bb4d8870
tests: add a metaclass for triggering stupid on a class level
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
1049
diff
changeset
|
470 stupid_mode_tests = False |
0932bb4d8870
tests: add a metaclass for triggering stupid on a class level
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
1049
diff
changeset
|
471 |
0932bb4d8870
tests: add a metaclass for triggering stupid on a class level
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
1049
diff
changeset
|
472 stupid = False |
1049
608e7c8740af
tests: add a metaclass for testing obsolete mode
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
1048
diff
changeset
|
473 |
82
71de43e9f614
Extract PushTest common code into test_util.TestBase
Patrick Mezard <pmezard@gmail.com>
parents:
78
diff
changeset
|
474 def setUp(self): |
645
3cb5042531fb
tests: verify locations of any imported hgsubversion modules
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
644
diff
changeset
|
475 _verify_our_modules() |
1101
4a92eb1484ba
layouts: fix crash when importing hgsubversion itself (issue #402)
Greg Ward <greg@gerg.ca>
parents:
1092
diff
changeset
|
476 if 'hgsubversion' in sys.modules: |
4a92eb1484ba
layouts: fix crash when importing hgsubversion itself (issue #402)
Greg Ward <greg@gerg.ca>
parents:
1092
diff
changeset
|
477 sys.modules['hgext_hgsubversion'] = sys.modules['hgsubversion'] |
645
3cb5042531fb
tests: verify locations of any imported hgsubversion modules
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
644
diff
changeset
|
478 |
896
04dfc23688b9
allow Python 2.7 to show medium-size multiline diffs when tests fail
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
890
diff
changeset
|
479 # the Python 2.7 default of 640 is obnoxiously low |
04dfc23688b9
allow Python 2.7 to show medium-size multiline diffs when tests fail
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
890
diff
changeset
|
480 self.maxDiff = 4096 |
04dfc23688b9
allow Python 2.7 to show medium-size multiline diffs when tests fail
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
890
diff
changeset
|
481 |
832
e9af7eba88db
globally: clean up whitespace around operators and commas to conform with PEP8
Yonggang Luo <luoyonggang@gmail.com>
parents:
816
diff
changeset
|
482 self.oldenv = dict([(k, os.environ.get(k, None),) for k in |
e9af7eba88db
globally: clean up whitespace around operators and commas to conform with PEP8
Yonggang Luo <luoyonggang@gmail.com>
parents:
816
diff
changeset
|
483 ('LANG', 'LC_ALL', 'HGRCPATH',)]) |
1245
260212f056b7
test_util: fix up i18n monkeypatch for Mercurial 3.2
Siddharth Agarwal <sid0@fb.com>
parents:
1238
diff
changeset
|
484 try: |
260212f056b7
test_util: fix up i18n monkeypatch for Mercurial 3.2
Siddharth Agarwal <sid0@fb.com>
parents:
1238
diff
changeset
|
485 self.oldugettext = i18n._ugettext # Mercurial >= 3.2 |
260212f056b7
test_util: fix up i18n monkeypatch for Mercurial 3.2
Siddharth Agarwal <sid0@fb.com>
parents:
1238
diff
changeset
|
486 except AttributeError: |
260212f056b7
test_util: fix up i18n monkeypatch for Mercurial 3.2
Siddharth Agarwal <sid0@fb.com>
parents:
1238
diff
changeset
|
487 self.oldt = i18n.t |
260212f056b7
test_util: fix up i18n monkeypatch for Mercurial 3.2
Siddharth Agarwal <sid0@fb.com>
parents:
1238
diff
changeset
|
488 os.environ['LANG'] = os.environ['LC_ALL'] = 'C' |
260212f056b7
test_util: fix up i18n monkeypatch for Mercurial 3.2
Siddharth Agarwal <sid0@fb.com>
parents:
1238
diff
changeset
|
489 i18n.t = gettext.translation('hg', i18n.localedir, fallback=True) |
260212f056b7
test_util: fix up i18n monkeypatch for Mercurial 3.2
Siddharth Agarwal <sid0@fb.com>
parents:
1238
diff
changeset
|
490 else: |
260212f056b7
test_util: fix up i18n monkeypatch for Mercurial 3.2
Siddharth Agarwal <sid0@fb.com>
parents:
1238
diff
changeset
|
491 os.environ['LANG'] = os.environ['LC_ALL'] = 'C' |
260212f056b7
test_util: fix up i18n monkeypatch for Mercurial 3.2
Siddharth Agarwal <sid0@fb.com>
parents:
1238
diff
changeset
|
492 i18n.setdatapath(hgutil.datapath) |
486
5607e81ba616
test_util: specify LANG=LC_ALL=C so l10n stops breaking tests
Augie Fackler <durin42@gmail.com>
parents:
483
diff
changeset
|
493 |
82
71de43e9f614
Extract PushTest common code into test_util.TestBase
Patrick Mezard <pmezard@gmail.com>
parents:
78
diff
changeset
|
494 self.oldwd = os.getcwd() |
148
0c5f6420a8b5
tests: Add an environment variable (HGSUBVERSION_TEST_TEMP) which allows
Augie Fackler <durin42@gmail.com>
parents:
139
diff
changeset
|
495 self.tmpdir = tempfile.mkdtemp( |
0c5f6420a8b5
tests: Add an environment variable (HGSUBVERSION_TEST_TEMP) which allows
Augie Fackler <durin42@gmail.com>
parents:
139
diff
changeset
|
496 'svnwrap_test', dir=os.environ.get('HGSUBVERSION_TEST_TEMP', None)) |
1081
c8d0f5983571
tests: cd to tempdir during setUp
David Schleimer <dschleimer@fb.com>
parents:
1080
diff
changeset
|
497 os.chdir(self.tmpdir) |
231
b1543f243910
tests: Start providing our own custom hgrc for testing purposes.
Augie Fackler <durin42@gmail.com>
parents:
194
diff
changeset
|
498 self.hgrc = os.path.join(self.tmpdir, '.hgrc') |
b1543f243910
tests: Start providing our own custom hgrc for testing purposes.
Augie Fackler <durin42@gmail.com>
parents:
194
diff
changeset
|
499 os.environ['HGRCPATH'] = self.hgrc |
1003
6945d3359456
testutil: clear rcpath when we update HGRCPATH env var
David Schleimer <dschleimer@fb.com>
parents:
1001
diff
changeset
|
500 scmutil._rcpath = None |
1552
ed2df771f578
test_util: modernize writing of hgrc
Augie Fackler <raf@durin42.com>
parents:
1549
diff
changeset
|
501 with open(self.hgrc, 'w') as rc: |
ed2df771f578
test_util: modernize writing of hgrc
Augie Fackler <raf@durin42.com>
parents:
1549
diff
changeset
|
502 rc.write('[ui]\nusername=test-user\n') |
ed2df771f578
test_util: modernize writing of hgrc
Augie Fackler <raf@durin42.com>
parents:
1549
diff
changeset
|
503 rc.write('[extensions]\nhgsubversion=\n') |
148
0c5f6420a8b5
tests: Add an environment variable (HGSUBVERSION_TEST_TEMP) which allows
Augie Fackler <durin42@gmail.com>
parents:
139
diff
changeset
|
504 |
872
a279b5838aaf
test_util: remove self.repo_path, generate new paths each time
Patrick Mezard <patrick@mezard.eu>
parents:
871
diff
changeset
|
505 self.repocount = 0 |
82
71de43e9f614
Extract PushTest common code into test_util.TestBase
Patrick Mezard <pmezard@gmail.com>
parents:
78
diff
changeset
|
506 self.wc_path = '%s/testrepo_wc' % self.tmpdir |
689
35a1e93b6f78
tests: move _add_svn_rev to test_util for reuse
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
652
diff
changeset
|
507 self.svn_wc = None |
331
75f082b5897e
Switch to using url scheme wrappers instead of duplicating each command we wrap.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
326
diff
changeset
|
508 |
911
772280aed751
Honor SVN auto-props (solves issue #186)
Ronny Voelker <ronny.voelker@googlemail.com>
parents:
910
diff
changeset
|
509 self.config_dir = self.tmpdir |
772280aed751
Honor SVN auto-props (solves issue #186)
Ronny Voelker <ronny.voelker@googlemail.com>
parents:
910
diff
changeset
|
510 svnwrap.common._svn_config_dir = self.config_dir |
772280aed751
Honor SVN auto-props (solves issue #186)
Ronny Voelker <ronny.voelker@googlemail.com>
parents:
910
diff
changeset
|
511 self.setup_svn_config('') |
772280aed751
Honor SVN auto-props (solves issue #186)
Ronny Voelker <ronny.voelker@googlemail.com>
parents:
910
diff
changeset
|
512 |
331
75f082b5897e
Switch to using url scheme wrappers instead of duplicating each command we wrap.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
326
diff
changeset
|
513 # Previously, we had a MockUI class that wrapped ui, and giving access |
75f082b5897e
Switch to using url scheme wrappers instead of duplicating each command we wrap.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
326
diff
changeset
|
514 # to the stream. The ui.pushbuffer() and ui.popbuffer() can be used |
75f082b5897e
Switch to using url scheme wrappers instead of duplicating each command we wrap.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
326
diff
changeset
|
515 # instead. Using the regular UI class, with all stderr redirected to |
75f082b5897e
Switch to using url scheme wrappers instead of duplicating each command we wrap.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
326
diff
changeset
|
516 # stdout ensures that the test setup is much more similar to usage |
75f082b5897e
Switch to using url scheme wrappers instead of duplicating each command we wrap.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
326
diff
changeset
|
517 # setups. |
334
3c3c3264c362
test_util: Make the patching of ui.ui.write_err() slightly more reusable.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
333
diff
changeset
|
518 self.patch = (ui.ui.write_err, ui.ui.write) |
3c3c3264c362
test_util: Make the patching of ui.ui.write_err() slightly more reusable.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
333
diff
changeset
|
519 setattr(ui.ui, self.patch[0].func_name, self.patch[1]) |
82
71de43e9f614
Extract PushTest common code into test_util.TestBase
Patrick Mezard <pmezard@gmail.com>
parents:
78
diff
changeset
|
520 |
911
772280aed751
Honor SVN auto-props (solves issue #186)
Ronny Voelker <ronny.voelker@googlemail.com>
parents:
910
diff
changeset
|
521 def setup_svn_config(self, config): |
1038
aa043f64d8b7
tests: fix syntax incompatible with Python 2.4
Dan Villiom Podlaski Christiansen <dan@cabo.dk>
parents:
1003
diff
changeset
|
522 c = open(self.config_dir + '/config', 'w') |
aa043f64d8b7
tests: fix syntax incompatible with Python 2.4
Dan Villiom Podlaski Christiansen <dan@cabo.dk>
parents:
1003
diff
changeset
|
523 try: |
911
772280aed751
Honor SVN auto-props (solves issue #186)
Ronny Voelker <ronny.voelker@googlemail.com>
parents:
910
diff
changeset
|
524 c.write(config) |
1038
aa043f64d8b7
tests: fix syntax incompatible with Python 2.4
Dan Villiom Podlaski Christiansen <dan@cabo.dk>
parents:
1003
diff
changeset
|
525 finally: |
aa043f64d8b7
tests: fix syntax incompatible with Python 2.4
Dan Villiom Podlaski Christiansen <dan@cabo.dk>
parents:
1003
diff
changeset
|
526 c.close() |
911
772280aed751
Honor SVN auto-props (solves issue #186)
Ronny Voelker <ronny.voelker@googlemail.com>
parents:
910
diff
changeset
|
527 |
872
a279b5838aaf
test_util: remove self.repo_path, generate new paths each time
Patrick Mezard <patrick@mezard.eu>
parents:
871
diff
changeset
|
528 def _makerepopath(self): |
a279b5838aaf
test_util: remove self.repo_path, generate new paths each time
Patrick Mezard <patrick@mezard.eu>
parents:
871
diff
changeset
|
529 self.repocount += 1 |
a279b5838aaf
test_util: remove self.repo_path, generate new paths each time
Patrick Mezard <patrick@mezard.eu>
parents:
871
diff
changeset
|
530 return '%s/testrepo-%d' % (self.tmpdir, self.repocount) |
a279b5838aaf
test_util: remove self.repo_path, generate new paths each time
Patrick Mezard <patrick@mezard.eu>
parents:
871
diff
changeset
|
531 |
82
71de43e9f614
Extract PushTest common code into test_util.TestBase
Patrick Mezard <pmezard@gmail.com>
parents:
78
diff
changeset
|
532 def tearDown(self): |
486
5607e81ba616
test_util: specify LANG=LC_ALL=C so l10n stops breaking tests
Augie Fackler <durin42@gmail.com>
parents:
483
diff
changeset
|
533 for var, val in self.oldenv.iteritems(): |
5607e81ba616
test_util: specify LANG=LC_ALL=C so l10n stops breaking tests
Augie Fackler <durin42@gmail.com>
parents:
483
diff
changeset
|
534 if val is None: |
5607e81ba616
test_util: specify LANG=LC_ALL=C so l10n stops breaking tests
Augie Fackler <durin42@gmail.com>
parents:
483
diff
changeset
|
535 del os.environ[var] |
5607e81ba616
test_util: specify LANG=LC_ALL=C so l10n stops breaking tests
Augie Fackler <durin42@gmail.com>
parents:
483
diff
changeset
|
536 else: |
5607e81ba616
test_util: specify LANG=LC_ALL=C so l10n stops breaking tests
Augie Fackler <durin42@gmail.com>
parents:
483
diff
changeset
|
537 os.environ[var] = val |
1245
260212f056b7
test_util: fix up i18n monkeypatch for Mercurial 3.2
Siddharth Agarwal <sid0@fb.com>
parents:
1238
diff
changeset
|
538 try: |
260212f056b7
test_util: fix up i18n monkeypatch for Mercurial 3.2
Siddharth Agarwal <sid0@fb.com>
parents:
1238
diff
changeset
|
539 i18n._ugettext = self.oldugettext # Mercurial >= 3.2 |
260212f056b7
test_util: fix up i18n monkeypatch for Mercurial 3.2
Siddharth Agarwal <sid0@fb.com>
parents:
1238
diff
changeset
|
540 except AttributeError: |
260212f056b7
test_util: fix up i18n monkeypatch for Mercurial 3.2
Siddharth Agarwal <sid0@fb.com>
parents:
1238
diff
changeset
|
541 i18n.t = self.oldt |
82
71de43e9f614
Extract PushTest common code into test_util.TestBase
Patrick Mezard <pmezard@gmail.com>
parents:
78
diff
changeset
|
542 os.chdir(self.oldwd) |
1337
0f1f88e71138
tests: leave from the directory before removing
Shun-ichi Goto <shunichi.goto@gmail.com>
parents:
1245
diff
changeset
|
543 rmtree(self.tmpdir) |
334
3c3c3264c362
test_util: Make the patching of ui.ui.write_err() slightly more reusable.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
333
diff
changeset
|
544 setattr(ui.ui, self.patch[0].func_name, self.patch[0]) |
91
7d10165cf3d9
tests: Mock the mercurial.ui.ui class like we really should to capture output.
Augie Fackler <durin42@gmail.com>
parents:
84
diff
changeset
|
545 |
645
3cb5042531fb
tests: verify locations of any imported hgsubversion modules
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
644
diff
changeset
|
546 _verify_our_modules() |
3cb5042531fb
tests: verify locations of any imported hgsubversion modules
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
644
diff
changeset
|
547 |
1554
258fb67fb956
externals: correctly enable hgsubversion externals support during tests
Augie Fackler <raf@durin42.com>
parents:
1552
diff
changeset
|
548 def ui(self, layout='auto', subrepo=False): |
258fb67fb956
externals: correctly enable hgsubversion externals support during tests
Augie Fackler <raf@durin42.com>
parents:
1552
diff
changeset
|
549 return testui(self.stupid, layout, subrepo=subrepo) |
576
d96aa92d9ad9
tests: silence test suite by using quiet UIs everywhere
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
548
diff
changeset
|
550 |
866
20e73b5ab6f7
test_util: merge load_svndump_fixture() into TestBase
Patrick Mezard <patrick@mezard.eu>
parents:
865
diff
changeset
|
551 def load_svndump(self, fixture_name): |
20e73b5ab6f7
test_util: merge load_svndump_fixture() into TestBase
Patrick Mezard <patrick@mezard.eu>
parents:
865
diff
changeset
|
552 '''Loads an svnadmin dump into a fresh repo. Return the svn repo |
20e73b5ab6f7
test_util: merge load_svndump_fixture() into TestBase
Patrick Mezard <patrick@mezard.eu>
parents:
865
diff
changeset
|
553 path. |
20e73b5ab6f7
test_util: merge load_svndump_fixture() into TestBase
Patrick Mezard <patrick@mezard.eu>
parents:
865
diff
changeset
|
554 ''' |
872
a279b5838aaf
test_util: remove self.repo_path, generate new paths each time
Patrick Mezard <patrick@mezard.eu>
parents:
871
diff
changeset
|
555 path = self._makerepopath() |
a279b5838aaf
test_util: remove self.repo_path, generate new paths each time
Patrick Mezard <patrick@mezard.eu>
parents:
871
diff
changeset
|
556 assert not os.path.exists(path) |
1457
019c3e194fba
tests: optimise creating repositories and loading dumps
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
1365
diff
changeset
|
557 with open(os.path.join(FIXTURES, fixture_name)) as inp: |
019c3e194fba
tests: optimise creating repositories and loading dumps
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
1365
diff
changeset
|
558 svnwrap.create_and_load(path, inp) |
866
20e73b5ab6f7
test_util: merge load_svndump_fixture() into TestBase
Patrick Mezard <patrick@mezard.eu>
parents:
865
diff
changeset
|
559 return path |
20e73b5ab6f7
test_util: merge load_svndump_fixture() into TestBase
Patrick Mezard <patrick@mezard.eu>
parents:
865
diff
changeset
|
560 |
910
312f36a425f0
Ignore invalid utf8 in commit messages
David Schleimer <dschleimer@fb.com>
parents:
908
diff
changeset
|
561 def load_repo_tarball(self, fixture_name): |
312f36a425f0
Ignore invalid utf8 in commit messages
David Schleimer <dschleimer@fb.com>
parents:
908
diff
changeset
|
562 '''Extracts a tarball of an svn repo and returns the svn repo path.''' |
312f36a425f0
Ignore invalid utf8 in commit messages
David Schleimer <dschleimer@fb.com>
parents:
908
diff
changeset
|
563 path = self._makerepopath() |
312f36a425f0
Ignore invalid utf8 in commit messages
David Schleimer <dschleimer@fb.com>
parents:
908
diff
changeset
|
564 assert not os.path.exists(path) |
312f36a425f0
Ignore invalid utf8 in commit messages
David Schleimer <dschleimer@fb.com>
parents:
908
diff
changeset
|
565 os.mkdir(path) |
312f36a425f0
Ignore invalid utf8 in commit messages
David Schleimer <dschleimer@fb.com>
parents:
908
diff
changeset
|
566 tarball = tarfile.open(os.path.join(FIXTURES, fixture_name)) |
312f36a425f0
Ignore invalid utf8 in commit messages
David Schleimer <dschleimer@fb.com>
parents:
908
diff
changeset
|
567 # This is probably somewhat fragile, but I'm not sure how to |
312f36a425f0
Ignore invalid utf8 in commit messages
David Schleimer <dschleimer@fb.com>
parents:
908
diff
changeset
|
568 # do better in particular, I think it assumes that the tar |
312f36a425f0
Ignore invalid utf8 in commit messages
David Schleimer <dschleimer@fb.com>
parents:
908
diff
changeset
|
569 # entries are in the right order and that directories appear |
312f36a425f0
Ignore invalid utf8 in commit messages
David Schleimer <dschleimer@fb.com>
parents:
908
diff
changeset
|
570 # before their contents. This is a valid assummption for sane |
312f36a425f0
Ignore invalid utf8 in commit messages
David Schleimer <dschleimer@fb.com>
parents:
908
diff
changeset
|
571 # tarballs, from what I can tell. In particular, for a simple |
312f36a425f0
Ignore invalid utf8 in commit messages
David Schleimer <dschleimer@fb.com>
parents:
908
diff
changeset
|
572 # tarball of a svn repo with paths relative to the repo root, |
312f36a425f0
Ignore invalid utf8 in commit messages
David Schleimer <dschleimer@fb.com>
parents:
908
diff
changeset
|
573 # it seems to work |
312f36a425f0
Ignore invalid utf8 in commit messages
David Schleimer <dschleimer@fb.com>
parents:
908
diff
changeset
|
574 for entry in tarball: |
312f36a425f0
Ignore invalid utf8 in commit messages
David Schleimer <dschleimer@fb.com>
parents:
908
diff
changeset
|
575 tarball.extract(entry, path) |
312f36a425f0
Ignore invalid utf8 in commit messages
David Schleimer <dschleimer@fb.com>
parents:
908
diff
changeset
|
576 return path |
312f36a425f0
Ignore invalid utf8 in commit messages
David Schleimer <dschleimer@fb.com>
parents:
908
diff
changeset
|
577 |
1078
1afd308b8f46
tests: remove ability to toggle stupidity on less than class level
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
1056
diff
changeset
|
578 def fetch(self, repo_path, subdir=None, layout='auto', |
944
d6db289f1548
pull: add hgsubversion.filestoresize to control memory consumption
Patrick Mezard <patrick@mezard.eu>
parents:
930
diff
changeset
|
579 startrev=0, externals=None, noupdate=True, dest=None, rev=None, |
d6db289f1548
pull: add hgsubversion.filestoresize to control memory consumption
Patrick Mezard <patrick@mezard.eu>
parents:
930
diff
changeset
|
580 config=None): |
499
1fd3cfa47c5e
Support for single-directory clones.
Augie Fackler <durin42@gmail.com>
parents:
492
diff
changeset
|
581 if layout == 'single': |
1fd3cfa47c5e
Support for single-directory clones.
Augie Fackler <durin42@gmail.com>
parents:
492
diff
changeset
|
582 if subdir is None: |
1fd3cfa47c5e
Support for single-directory clones.
Augie Fackler <durin42@gmail.com>
parents:
492
diff
changeset
|
583 subdir = 'trunk' |
1fd3cfa47c5e
Support for single-directory clones.
Augie Fackler <durin42@gmail.com>
parents:
492
diff
changeset
|
584 elif subdir is None: |
1fd3cfa47c5e
Support for single-directory clones.
Augie Fackler <durin42@gmail.com>
parents:
492
diff
changeset
|
585 subdir = '' |
866
20e73b5ab6f7
test_util: merge load_svndump_fixture() into TestBase
Patrick Mezard <patrick@mezard.eu>
parents:
865
diff
changeset
|
586 projectpath = repo_path |
865
04729f3a3d17
test_util: merge load_fixture_and_fetch() into TestBase method
Patrick Mezard <patrick@mezard.eu>
parents:
832
diff
changeset
|
587 if subdir: |
04729f3a3d17
test_util: merge load_fixture_and_fetch() into TestBase method
Patrick Mezard <patrick@mezard.eu>
parents:
832
diff
changeset
|
588 projectpath += '/' + subdir |
04729f3a3d17
test_util: merge load_fixture_and_fetch() into TestBase method
Patrick Mezard <patrick@mezard.eu>
parents:
832
diff
changeset
|
589 |
04729f3a3d17
test_util: merge load_fixture_and_fetch() into TestBase method
Patrick Mezard <patrick@mezard.eu>
parents:
832
diff
changeset
|
590 cmd = [ |
04729f3a3d17
test_util: merge load_fixture_and_fetch() into TestBase method
Patrick Mezard <patrick@mezard.eu>
parents:
832
diff
changeset
|
591 'clone', |
1343
e597714cb420
tests: pass --quiet anyplace we call dispatch to run a command
Augie Fackler <raf@durin42.com>
parents:
1342
diff
changeset
|
592 '--quiet', |
865
04729f3a3d17
test_util: merge load_fixture_and_fetch() into TestBase method
Patrick Mezard <patrick@mezard.eu>
parents:
832
diff
changeset
|
593 '--layout=%s' % layout, |
04729f3a3d17
test_util: merge load_fixture_and_fetch() into TestBase method
Patrick Mezard <patrick@mezard.eu>
parents:
832
diff
changeset
|
594 '--startrev=%s' % startrev, |
04729f3a3d17
test_util: merge load_fixture_and_fetch() into TestBase method
Patrick Mezard <patrick@mezard.eu>
parents:
832
diff
changeset
|
595 fileurl(projectpath), |
04729f3a3d17
test_util: merge load_fixture_and_fetch() into TestBase method
Patrick Mezard <patrick@mezard.eu>
parents:
832
diff
changeset
|
596 self.wc_path, |
04729f3a3d17
test_util: merge load_fixture_and_fetch() into TestBase method
Patrick Mezard <patrick@mezard.eu>
parents:
832
diff
changeset
|
597 ] |
1078
1afd308b8f46
tests: remove ability to toggle stupidity on less than class level
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
1056
diff
changeset
|
598 if self.stupid: |
865
04729f3a3d17
test_util: merge load_fixture_and_fetch() into TestBase method
Patrick Mezard <patrick@mezard.eu>
parents:
832
diff
changeset
|
599 cmd.append('--stupid') |
04729f3a3d17
test_util: merge load_fixture_and_fetch() into TestBase method
Patrick Mezard <patrick@mezard.eu>
parents:
832
diff
changeset
|
600 if noupdate: |
04729f3a3d17
test_util: merge load_fixture_and_fetch() into TestBase method
Patrick Mezard <patrick@mezard.eu>
parents:
832
diff
changeset
|
601 cmd.append('--noupdate') |
908
c4ee11a5d04c
pull: add a hgsubversion.unsafeskip option to omit unwanted revs
Bryan O'Sullivan <bryano@fb.com>
parents:
896
diff
changeset
|
602 if rev is not None: |
c4ee11a5d04c
pull: add a hgsubversion.unsafeskip option to omit unwanted revs
Bryan O'Sullivan <bryano@fb.com>
parents:
896
diff
changeset
|
603 cmd.append('--rev=%s' % rev) |
944
d6db289f1548
pull: add hgsubversion.filestoresize to control memory consumption
Patrick Mezard <patrick@mezard.eu>
parents:
930
diff
changeset
|
604 config = dict(config or {}) |
865
04729f3a3d17
test_util: merge load_fixture_and_fetch() into TestBase method
Patrick Mezard <patrick@mezard.eu>
parents:
832
diff
changeset
|
605 if externals: |
944
d6db289f1548
pull: add hgsubversion.filestoresize to control memory consumption
Patrick Mezard <patrick@mezard.eu>
parents:
930
diff
changeset
|
606 config['hgsubversion.externals'] = str(externals) |
1554
258fb67fb956
externals: correctly enable hgsubversion externals support during tests
Augie Fackler <raf@durin42.com>
parents:
1552
diff
changeset
|
607 config['subrepos.hgsubversion:allowed'] = 'true' |
944
d6db289f1548
pull: add hgsubversion.filestoresize to control memory consumption
Patrick Mezard <patrick@mezard.eu>
parents:
930
diff
changeset
|
608 for k,v in reversed(sorted(config.iteritems())): |
d6db289f1548
pull: add hgsubversion.filestoresize to control memory consumption
Patrick Mezard <patrick@mezard.eu>
parents:
930
diff
changeset
|
609 cmd[:0] = ['--config', '%s=%s' % (k, v)] |
865
04729f3a3d17
test_util: merge load_fixture_and_fetch() into TestBase method
Patrick Mezard <patrick@mezard.eu>
parents:
832
diff
changeset
|
610 |
1041
70090e2ee262
tests: assert that fetches actually succeed
Dan Villiom Podlaski Christiansen <dan@cabo.dk>
parents:
1038
diff
changeset
|
611 r = dispatch(cmd) |
70090e2ee262
tests: assert that fetches actually succeed
Dan Villiom Podlaski Christiansen <dan@cabo.dk>
parents:
1038
diff
changeset
|
612 assert not r, 'fetch of %s failed' % projectpath |
865
04729f3a3d17
test_util: merge load_fixture_and_fetch() into TestBase method
Patrick Mezard <patrick@mezard.eu>
parents:
832
diff
changeset
|
613 |
1554
258fb67fb956
externals: correctly enable hgsubversion externals support during tests
Augie Fackler <raf@durin42.com>
parents:
1552
diff
changeset
|
614 return hg.repository(self.ui(subrepo=bool(externals)), self.wc_path) |
886
d3ff5807f1bd
fold test_startrev and test_verify into a new test; test_verify_and_startrev
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
874
diff
changeset
|
615 |
1457
019c3e194fba
tests: optimise creating repositories and loading dumps
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
1365
diff
changeset
|
616 def load(self, fixture_name): |
910
312f36a425f0
Ignore invalid utf8 in commit messages
David Schleimer <dschleimer@fb.com>
parents:
908
diff
changeset
|
617 if fixture_name.endswith('.svndump'): |
312f36a425f0
Ignore invalid utf8 in commit messages
David Schleimer <dschleimer@fb.com>
parents:
908
diff
changeset
|
618 repo_path = self.load_svndump(fixture_name) |
312f36a425f0
Ignore invalid utf8 in commit messages
David Schleimer <dschleimer@fb.com>
parents:
908
diff
changeset
|
619 elif fixture_name.endswith('tar.gz'): |
312f36a425f0
Ignore invalid utf8 in commit messages
David Schleimer <dschleimer@fb.com>
parents:
908
diff
changeset
|
620 repo_path = self.load_repo_tarball(fixture_name) |
312f36a425f0
Ignore invalid utf8 in commit messages
David Schleimer <dschleimer@fb.com>
parents:
908
diff
changeset
|
621 else: |
312f36a425f0
Ignore invalid utf8 in commit messages
David Schleimer <dschleimer@fb.com>
parents:
908
diff
changeset
|
622 assert False, 'Unknown fixture type' |
886
d3ff5807f1bd
fold test_startrev and test_verify into a new test; test_verify_and_startrev
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
874
diff
changeset
|
623 |
1457
019c3e194fba
tests: optimise creating repositories and loading dumps
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
1365
diff
changeset
|
624 return repo_path |
019c3e194fba
tests: optimise creating repositories and loading dumps
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
1365
diff
changeset
|
625 |
019c3e194fba
tests: optimise creating repositories and loading dumps
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
1365
diff
changeset
|
626 def load_and_fetch(self, fixture_name, *args, **opts): |
019c3e194fba
tests: optimise creating repositories and loading dumps
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
1365
diff
changeset
|
627 repo_path = self.load(fixture_name) |
886
d3ff5807f1bd
fold test_startrev and test_verify into a new test; test_verify_and_startrev
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
874
diff
changeset
|
628 return self.fetch(repo_path, *args, **opts), repo_path |
867
50c13e01c7e3
test_util: add a load_and_fetch() returning the repo_path
Patrick Mezard <patrick@mezard.eu>
parents:
866
diff
changeset
|
629 |
50c13e01c7e3
test_util: add a load_and_fetch() returning the repo_path
Patrick Mezard <patrick@mezard.eu>
parents:
866
diff
changeset
|
630 def _load_fixture_and_fetch(self, *args, **kwargs): |
50c13e01c7e3
test_util: add a load_and_fetch() returning the repo_path
Patrick Mezard <patrick@mezard.eu>
parents:
866
diff
changeset
|
631 repo, repo_path = self.load_and_fetch(*args, **kwargs) |
50c13e01c7e3
test_util: add a load_and_fetch() returning the repo_path
Patrick Mezard <patrick@mezard.eu>
parents:
866
diff
changeset
|
632 return repo |
138
40474f6c1f84
diff_cmd: more robust, add tests.
Augie Fackler <durin42@gmail.com>
parents:
112
diff
changeset
|
633 |
868
cc1c870f1758
test_util: pass repo_path to _add_svn_rev() explicitely
Patrick Mezard <patrick@mezard.eu>
parents:
867
diff
changeset
|
634 def add_svn_rev(self, repo_path, changes): |
689
35a1e93b6f78
tests: move _add_svn_rev to test_util for reuse
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
652
diff
changeset
|
635 '''changes is a dict of filename -> contents''' |
35a1e93b6f78
tests: move _add_svn_rev to test_util for reuse
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
652
diff
changeset
|
636 if self.svn_wc is None: |
35a1e93b6f78
tests: move _add_svn_rev to test_util for reuse
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
652
diff
changeset
|
637 self.svn_wc = os.path.join(self.tmpdir, 'testsvn_wc') |
35a1e93b6f78
tests: move _add_svn_rev to test_util for reuse
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
652
diff
changeset
|
638 subprocess.call([ |
868
cc1c870f1758
test_util: pass repo_path to _add_svn_rev() explicitely
Patrick Mezard <patrick@mezard.eu>
parents:
867
diff
changeset
|
639 'svn', 'co', '-q', fileurl(repo_path), |
689
35a1e93b6f78
tests: move _add_svn_rev to test_util for reuse
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
652
diff
changeset
|
640 self.svn_wc |
35a1e93b6f78
tests: move _add_svn_rev to test_util for reuse
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
652
diff
changeset
|
641 ], |
35a1e93b6f78
tests: move _add_svn_rev to test_util for reuse
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
652
diff
changeset
|
642 stdout=subprocess.PIPE, stderr=subprocess.STDOUT) |
35a1e93b6f78
tests: move _add_svn_rev to test_util for reuse
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
652
diff
changeset
|
643 |
35a1e93b6f78
tests: move _add_svn_rev to test_util for reuse
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
652
diff
changeset
|
644 for filename, contents in changes.iteritems(): |
35a1e93b6f78
tests: move _add_svn_rev to test_util for reuse
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
652
diff
changeset
|
645 # filenames are / separated |
35a1e93b6f78
tests: move _add_svn_rev to test_util for reuse
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
652
diff
changeset
|
646 filename = filename.replace('/', os.path.sep) |
35a1e93b6f78
tests: move _add_svn_rev to test_util for reuse
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
652
diff
changeset
|
647 filename = os.path.join(self.svn_wc, filename) |
35a1e93b6f78
tests: move _add_svn_rev to test_util for reuse
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
652
diff
changeset
|
648 open(filename, 'w').write(contents) |
35a1e93b6f78
tests: move _add_svn_rev to test_util for reuse
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
652
diff
changeset
|
649 # may be redundant |
35a1e93b6f78
tests: move _add_svn_rev to test_util for reuse
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
652
diff
changeset
|
650 subprocess.call(['svn', 'add', '-q', filename], |
35a1e93b6f78
tests: move _add_svn_rev to test_util for reuse
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
652
diff
changeset
|
651 stdout=subprocess.PIPE, stderr=subprocess.STDOUT) |
35a1e93b6f78
tests: move _add_svn_rev to test_util for reuse
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
652
diff
changeset
|
652 subprocess.call([ |
35a1e93b6f78
tests: move _add_svn_rev to test_util for reuse
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
652
diff
changeset
|
653 'svn', 'commit', '-q', self.svn_wc, '-m', 'test changes'], |
35a1e93b6f78
tests: move _add_svn_rev to test_util for reuse
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
652
diff
changeset
|
654 stdout=subprocess.PIPE, stderr=subprocess.STDOUT) |
35a1e93b6f78
tests: move _add_svn_rev to test_util for reuse
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
652
diff
changeset
|
655 |
82
71de43e9f614
Extract PushTest common code into test_util.TestBase
Patrick Mezard <pmezard@gmail.com>
parents:
78
diff
changeset
|
656 # define this as a property so that it reloads anytime we need it |
71de43e9f614
Extract PushTest common code into test_util.TestBase
Patrick Mezard <pmezard@gmail.com>
parents:
78
diff
changeset
|
657 @property |
71de43e9f614
Extract PushTest common code into test_util.TestBase
Patrick Mezard <pmezard@gmail.com>
parents:
78
diff
changeset
|
658 def repo(self): |
1554
258fb67fb956
externals: correctly enable hgsubversion externals support during tests
Augie Fackler <raf@durin42.com>
parents:
1552
diff
changeset
|
659 return hg.repository(self.ui(), self.wc_path) |
82
71de43e9f614
Extract PushTest common code into test_util.TestBase
Patrick Mezard <pmezard@gmail.com>
parents:
78
diff
changeset
|
660 |
1078
1afd308b8f46
tests: remove ability to toggle stupidity on less than class level
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
1056
diff
changeset
|
661 def pushrevisions(self, expected_extra_back=0): |
1048
903c9c9dfe6a
tests: count revisions explicitly
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
1041
diff
changeset
|
662 before = repolen(self.repo) |
1078
1afd308b8f46
tests: remove ability to toggle stupidity on less than class level
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
1056
diff
changeset
|
663 self.repo.ui.setconfig('hgsubversion', 'stupid', str(self.stupid)) |
626
8e621dbb82d4
push: return reasonable status codes to the end user
Augie Fackler <durin42@gmail.com>
parents:
621
diff
changeset
|
664 res = commands.push(self.repo.ui, self.repo) |
1048
903c9c9dfe6a
tests: count revisions explicitly
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
1041
diff
changeset
|
665 after = repolen(self.repo) |
355
256863a65141
test_util: make it easier to test odd push cases
Augie Fackler <durin42@gmail.com>
parents:
351
diff
changeset
|
666 self.assertEqual(expected_extra_back, after - before) |
626
8e621dbb82d4
push: return reasonable status codes to the end user
Augie Fackler <durin42@gmail.com>
parents:
621
diff
changeset
|
667 return res |
83
6c9b7cf1c5aa
push_cmd: delete empty svn directories, refactor directory creation
Patrick Mezard <pmezard@gmail.com>
parents:
82
diff
changeset
|
668 |
870
1eb2a4428c42
test_util: pass repo_path to svnco() explicitely
Patrick Mezard <patrick@mezard.eu>
parents:
869
diff
changeset
|
669 def svnco(self, repo_path, svnpath, rev, path): |
764
bc5c176b63eb
svnexternals: support pushing subrepo based externals
Patrick Mezard <pmezard@gmail.com>
parents:
762
diff
changeset
|
670 path = os.path.join(self.wc_path, path) |
bc5c176b63eb
svnexternals: support pushing subrepo based externals
Patrick Mezard <pmezard@gmail.com>
parents:
762
diff
changeset
|
671 subpath = os.path.dirname(path) |
bc5c176b63eb
svnexternals: support pushing subrepo based externals
Patrick Mezard <pmezard@gmail.com>
parents:
762
diff
changeset
|
672 if not os.path.isdir(subpath): |
bc5c176b63eb
svnexternals: support pushing subrepo based externals
Patrick Mezard <pmezard@gmail.com>
parents:
762
diff
changeset
|
673 os.makedirs(subpath) |
870
1eb2a4428c42
test_util: pass repo_path to svnco() explicitely
Patrick Mezard <patrick@mezard.eu>
parents:
869
diff
changeset
|
674 svnpath = fileurl(repo_path + '/' + svnpath) |
764
bc5c176b63eb
svnexternals: support pushing subrepo based externals
Patrick Mezard <pmezard@gmail.com>
parents:
762
diff
changeset
|
675 args = ['svn', 'co', '-r', rev, svnpath, path] |
bc5c176b63eb
svnexternals: support pushing subrepo based externals
Patrick Mezard <pmezard@gmail.com>
parents:
762
diff
changeset
|
676 p = subprocess.Popen(args, |
bc5c176b63eb
svnexternals: support pushing subrepo based externals
Patrick Mezard <pmezard@gmail.com>
parents:
762
diff
changeset
|
677 stdout=subprocess.PIPE, |
bc5c176b63eb
svnexternals: support pushing subrepo based externals
Patrick Mezard <pmezard@gmail.com>
parents:
762
diff
changeset
|
678 stderr=subprocess.STDOUT) |
bc5c176b63eb
svnexternals: support pushing subrepo based externals
Patrick Mezard <pmezard@gmail.com>
parents:
762
diff
changeset
|
679 stdout, stderr = p.communicate() |
bc5c176b63eb
svnexternals: support pushing subrepo based externals
Patrick Mezard <pmezard@gmail.com>
parents:
762
diff
changeset
|
680 if p.returncode: |
bc5c176b63eb
svnexternals: support pushing subrepo based externals
Patrick Mezard <pmezard@gmail.com>
parents:
762
diff
changeset
|
681 raise Exception('svn co failed on %s: %r' % (svnpath, stderr)) |
bc5c176b63eb
svnexternals: support pushing subrepo based externals
Patrick Mezard <pmezard@gmail.com>
parents:
762
diff
changeset
|
682 |
355
256863a65141
test_util: make it easier to test odd push cases
Augie Fackler <durin42@gmail.com>
parents:
351
diff
changeset
|
683 def commitchanges(self, changes, parent='tip', message='automated test'): |
84
01e747937d35
test_util: add commitchanges() to TestBase
Patrick Mezard <pmezard@gmail.com>
parents:
83
diff
changeset
|
684 """Commit changes to mercurial directory |
01e747937d35
test_util: add commitchanges() to TestBase
Patrick Mezard <pmezard@gmail.com>
parents:
83
diff
changeset
|
685 |
01e747937d35
test_util: add commitchanges() to TestBase
Patrick Mezard <pmezard@gmail.com>
parents:
83
diff
changeset
|
686 'changes' is a sequence of tuples (source, dest, data). It can look |
01e747937d35
test_util: add commitchanges() to TestBase
Patrick Mezard <pmezard@gmail.com>
parents:
83
diff
changeset
|
687 like: |
01e747937d35
test_util: add commitchanges() to TestBase
Patrick Mezard <pmezard@gmail.com>
parents:
83
diff
changeset
|
688 - (source, source, data) to set source content to data |
91
7d10165cf3d9
tests: Mock the mercurial.ui.ui class like we really should to capture output.
Augie Fackler <durin42@gmail.com>
parents:
84
diff
changeset
|
689 - (source, dest, None) to set dest content to source one, and mark it as |
84
01e747937d35
test_util: add commitchanges() to TestBase
Patrick Mezard <pmezard@gmail.com>
parents:
83
diff
changeset
|
690 copied from source. |
01e747937d35
test_util: add commitchanges() to TestBase
Patrick Mezard <pmezard@gmail.com>
parents:
83
diff
changeset
|
691 - (source, dest, data) to set dest content to data, and mark it as copied |
01e747937d35
test_util: add commitchanges() to TestBase
Patrick Mezard <pmezard@gmail.com>
parents:
83
diff
changeset
|
692 from source. |
01e747937d35
test_util: add commitchanges() to TestBase
Patrick Mezard <pmezard@gmail.com>
parents:
83
diff
changeset
|
693 - (source, None, None) to remove source. |
01e747937d35
test_util: add commitchanges() to TestBase
Patrick Mezard <pmezard@gmail.com>
parents:
83
diff
changeset
|
694 """ |
01e747937d35
test_util: add commitchanges() to TestBase
Patrick Mezard <pmezard@gmail.com>
parents:
83
diff
changeset
|
695 repo = self.repo |
277
3848a7f9b983
push: Add a test that demonstrates base-text detection works
Augie Fackler <durin42@gmail.com>
parents:
270
diff
changeset
|
696 parentctx = repo[parent] |
84
01e747937d35
test_util: add commitchanges() to TestBase
Patrick Mezard <pmezard@gmail.com>
parents:
83
diff
changeset
|
697 |
01e747937d35
test_util: add commitchanges() to TestBase
Patrick Mezard <pmezard@gmail.com>
parents:
83
diff
changeset
|
698 changed, removed = [], [] |
01e747937d35
test_util: add commitchanges() to TestBase
Patrick Mezard <pmezard@gmail.com>
parents:
83
diff
changeset
|
699 for source, dest, newdata in changes: |
01e747937d35
test_util: add commitchanges() to TestBase
Patrick Mezard <pmezard@gmail.com>
parents:
83
diff
changeset
|
700 if dest is None: |
01e747937d35
test_util: add commitchanges() to TestBase
Patrick Mezard <pmezard@gmail.com>
parents:
83
diff
changeset
|
701 removed.append(source) |
01e747937d35
test_util: add commitchanges() to TestBase
Patrick Mezard <pmezard@gmail.com>
parents:
83
diff
changeset
|
702 else: |
01e747937d35
test_util: add commitchanges() to TestBase
Patrick Mezard <pmezard@gmail.com>
parents:
83
diff
changeset
|
703 changed.append(dest) |
01e747937d35
test_util: add commitchanges() to TestBase
Patrick Mezard <pmezard@gmail.com>
parents:
83
diff
changeset
|
704 |
01e747937d35
test_util: add commitchanges() to TestBase
Patrick Mezard <pmezard@gmail.com>
parents:
83
diff
changeset
|
705 def filectxfn(repo, memctx, path): |
01e747937d35
test_util: add commitchanges() to TestBase
Patrick Mezard <pmezard@gmail.com>
parents:
83
diff
changeset
|
706 if path in removed: |
1238
339b5703000c
test_util: use compat hack for filectxfn for deleted files
Siddharth Agarwal <sid0@fb.com>
parents:
1234
diff
changeset
|
707 return compathacks.filectxfn_deleted(memctx, path) |
84
01e747937d35
test_util: add commitchanges() to TestBase
Patrick Mezard <pmezard@gmail.com>
parents:
83
diff
changeset
|
708 entry = [e for e in changes if path == e[1]][0] |
01e747937d35
test_util: add commitchanges() to TestBase
Patrick Mezard <pmezard@gmail.com>
parents:
83
diff
changeset
|
709 source, dest, newdata = entry |
01e747937d35
test_util: add commitchanges() to TestBase
Patrick Mezard <pmezard@gmail.com>
parents:
83
diff
changeset
|
710 if newdata is None: |
01e747937d35
test_util: add commitchanges() to TestBase
Patrick Mezard <pmezard@gmail.com>
parents:
83
diff
changeset
|
711 newdata = parentctx[source].data() |
01e747937d35
test_util: add commitchanges() to TestBase
Patrick Mezard <pmezard@gmail.com>
parents:
83
diff
changeset
|
712 copied = None |
01e747937d35
test_util: add commitchanges() to TestBase
Patrick Mezard <pmezard@gmail.com>
parents:
83
diff
changeset
|
713 if source != dest: |
01e747937d35
test_util: add commitchanges() to TestBase
Patrick Mezard <pmezard@gmail.com>
parents:
83
diff
changeset
|
714 copied = source |
1203
518a9552f7f9
test_util: call makememfilectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
1174
diff
changeset
|
715 return compathacks.makememfilectx(repo, |
1549
8410a978c650
compathacks: be compatible with upstream 8a0cac20a1ad memfilectx change
Jun Wu <quark@fb.com>
parents:
1541
diff
changeset
|
716 memctx=memctx, |
1203
518a9552f7f9
test_util: call makememfilectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
1174
diff
changeset
|
717 path=dest, |
518a9552f7f9
test_util: call makememfilectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
1174
diff
changeset
|
718 data=newdata, |
518a9552f7f9
test_util: call makememfilectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
1174
diff
changeset
|
719 islink=False, |
518a9552f7f9
test_util: call makememfilectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
1174
diff
changeset
|
720 isexec=False, |
518a9552f7f9
test_util: call makememfilectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
1174
diff
changeset
|
721 copied=copied) |
91
7d10165cf3d9
tests: Mock the mercurial.ui.ui class like we really should to capture output.
Augie Fackler <durin42@gmail.com>
parents:
84
diff
changeset
|
722 |
84
01e747937d35
test_util: add commitchanges() to TestBase
Patrick Mezard <pmezard@gmail.com>
parents:
83
diff
changeset
|
723 ctx = context.memctx(repo, |
01e747937d35
test_util: add commitchanges() to TestBase
Patrick Mezard <pmezard@gmail.com>
parents:
83
diff
changeset
|
724 (parentctx.node(), node.nullid), |
355
256863a65141
test_util: make it easier to test odd push cases
Augie Fackler <durin42@gmail.com>
parents:
351
diff
changeset
|
725 message, |
84
01e747937d35
test_util: add commitchanges() to TestBase
Patrick Mezard <pmezard@gmail.com>
parents:
83
diff
changeset
|
726 changed + removed, |
01e747937d35
test_util: add commitchanges() to TestBase
Patrick Mezard <pmezard@gmail.com>
parents:
83
diff
changeset
|
727 filectxfn, |
01e747937d35
test_util: add commitchanges() to TestBase
Patrick Mezard <pmezard@gmail.com>
parents:
83
diff
changeset
|
728 'an_author', |
1462
7dc5c4368837
test_util: retain parent branch in commitchanges()
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
1458
diff
changeset
|
729 '2008-10-07 20:59:48 -0500', |
7dc5c4368837
test_util: retain parent branch in commitchanges()
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
1458
diff
changeset
|
730 {'branch': parentctx.branch()}) |
84
01e747937d35
test_util: add commitchanges() to TestBase
Patrick Mezard <pmezard@gmail.com>
parents:
83
diff
changeset
|
731 nodeid = repo.commitctx(ctx) |
01e747937d35
test_util: add commitchanges() to TestBase
Patrick Mezard <pmezard@gmail.com>
parents:
83
diff
changeset
|
732 repo = self.repo |
277
3848a7f9b983
push: Add a test that demonstrates base-text detection works
Augie Fackler <durin42@gmail.com>
parents:
270
diff
changeset
|
733 hg.clean(repo, nodeid) |
84
01e747937d35
test_util: add commitchanges() to TestBase
Patrick Mezard <pmezard@gmail.com>
parents:
83
diff
changeset
|
734 return nodeid |
96
9b5e528f67f8
Add a test to check EOLs are correctly converted
Patrick Mezard <pmezard@gmail.com>
parents:
91
diff
changeset
|
735 |
9b5e528f67f8
Add a test to check EOLs are correctly converted
Patrick Mezard <pmezard@gmail.com>
parents:
91
diff
changeset
|
736 def assertchanges(self, changes, ctx): |
9b5e528f67f8
Add a test to check EOLs are correctly converted
Patrick Mezard <pmezard@gmail.com>
parents:
91
diff
changeset
|
737 """Assert that all 'changes' (as in defined in commitchanged()) |
9b5e528f67f8
Add a test to check EOLs are correctly converted
Patrick Mezard <pmezard@gmail.com>
parents:
91
diff
changeset
|
738 went into ctx. |
9b5e528f67f8
Add a test to check EOLs are correctly converted
Patrick Mezard <pmezard@gmail.com>
parents:
91
diff
changeset
|
739 """ |
9b5e528f67f8
Add a test to check EOLs are correctly converted
Patrick Mezard <pmezard@gmail.com>
parents:
91
diff
changeset
|
740 for source, dest, data in changes: |
9b5e528f67f8
Add a test to check EOLs are correctly converted
Patrick Mezard <pmezard@gmail.com>
parents:
91
diff
changeset
|
741 if dest is None: |
9b5e528f67f8
Add a test to check EOLs are correctly converted
Patrick Mezard <pmezard@gmail.com>
parents:
91
diff
changeset
|
742 self.assertTrue(source not in ctx) |
9b5e528f67f8
Add a test to check EOLs are correctly converted
Patrick Mezard <pmezard@gmail.com>
parents:
91
diff
changeset
|
743 continue |
9b5e528f67f8
Add a test to check EOLs are correctly converted
Patrick Mezard <pmezard@gmail.com>
parents:
91
diff
changeset
|
744 self.assertTrue(dest in ctx) |
9b5e528f67f8
Add a test to check EOLs are correctly converted
Patrick Mezard <pmezard@gmail.com>
parents:
91
diff
changeset
|
745 if data is None: |
9b5e528f67f8
Add a test to check EOLs are correctly converted
Patrick Mezard <pmezard@gmail.com>
parents:
91
diff
changeset
|
746 data = ctx.parents()[0][source].data() |
9b5e528f67f8
Add a test to check EOLs are correctly converted
Patrick Mezard <pmezard@gmail.com>
parents:
91
diff
changeset
|
747 self.assertEqual(ctx[dest].data(), data) |
9b5e528f67f8
Add a test to check EOLs are correctly converted
Patrick Mezard <pmezard@gmail.com>
parents:
91
diff
changeset
|
748 if dest != source: |
9b5e528f67f8
Add a test to check EOLs are correctly converted
Patrick Mezard <pmezard@gmail.com>
parents:
91
diff
changeset
|
749 copy = ctx[dest].renamed() |
9b5e528f67f8
Add a test to check EOLs are correctly converted
Patrick Mezard <pmezard@gmail.com>
parents:
91
diff
changeset
|
750 self.assertEqual(copy[0], source) |
527
2be9f14bd23f
test_util: add helper to draw repo with graphlog extension
Patrick Mezard <pmezard@gmail.com>
parents:
522
diff
changeset
|
751 |
621
3e18cdcb6e00
test_util: add assertMultiLineEqual() method.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
576
diff
changeset
|
752 def assertMultiLineEqual(self, first, second, msg=None): |
3e18cdcb6e00
test_util: add assertMultiLineEqual() method.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
576
diff
changeset
|
753 """Assert that two multi-line strings are equal. (Based on Py3k code.) |
3e18cdcb6e00
test_util: add assertMultiLineEqual() method.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
576
diff
changeset
|
754 """ |
744
6d6be5284056
tests: make assertMultiLineEqual call super, if possible.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
743
diff
changeset
|
755 try: |
6d6be5284056
tests: make assertMultiLineEqual call super, if possible.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
743
diff
changeset
|
756 return super(TestBase, self).assertMultiLineEqual(first, second, |
6d6be5284056
tests: make assertMultiLineEqual call super, if possible.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
743
diff
changeset
|
757 msg) |
6d6be5284056
tests: make assertMultiLineEqual call super, if possible.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
743
diff
changeset
|
758 except AttributeError: |
6d6be5284056
tests: make assertMultiLineEqual call super, if possible.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
743
diff
changeset
|
759 pass |
6d6be5284056
tests: make assertMultiLineEqual call super, if possible.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
743
diff
changeset
|
760 |
621
3e18cdcb6e00
test_util: add assertMultiLineEqual() method.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
576
diff
changeset
|
761 self.assert_(isinstance(first, str), |
3e18cdcb6e00
test_util: add assertMultiLineEqual() method.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
576
diff
changeset
|
762 ('First argument is not a string')) |
3e18cdcb6e00
test_util: add assertMultiLineEqual() method.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
576
diff
changeset
|
763 self.assert_(isinstance(second, str), |
3e18cdcb6e00
test_util: add assertMultiLineEqual() method.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
576
diff
changeset
|
764 ('Second argument is not a string')) |
3e18cdcb6e00
test_util: add assertMultiLineEqual() method.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
576
diff
changeset
|
765 |
3e18cdcb6e00
test_util: add assertMultiLineEqual() method.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
576
diff
changeset
|
766 if first != second: |
3e18cdcb6e00
test_util: add assertMultiLineEqual() method.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
576
diff
changeset
|
767 diff = ''.join(difflib.unified_diff(first.splitlines(True), |
3e18cdcb6e00
test_util: add assertMultiLineEqual() method.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
576
diff
changeset
|
768 second.splitlines(True), |
3e18cdcb6e00
test_util: add assertMultiLineEqual() method.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
576
diff
changeset
|
769 fromfile='a', |
3e18cdcb6e00
test_util: add assertMultiLineEqual() method.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
576
diff
changeset
|
770 tofile='b')) |
3e18cdcb6e00
test_util: add assertMultiLineEqual() method.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
576
diff
changeset
|
771 msg = '%s\n%s' % (msg or '', diff) |
3e18cdcb6e00
test_util: add assertMultiLineEqual() method.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
576
diff
changeset
|
772 raise self.failureException, msg |
3e18cdcb6e00
test_util: add assertMultiLineEqual() method.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
576
diff
changeset
|
773 |
952
9c3b4f59e7e6
stupid: do not close branch upon branch-wide revert
Patrick Mezard <patrick@mezard.eu>
parents:
944
diff
changeset
|
774 def getgraph(self, repo): |
527
2be9f14bd23f
test_util: add helper to draw repo with graphlog extension
Patrick Mezard <pmezard@gmail.com>
parents:
522
diff
changeset
|
775 """Helper function displaying a repository graph, especially |
2be9f14bd23f
test_util: add helper to draw repo with graphlog extension
Patrick Mezard <pmezard@gmail.com>
parents:
522
diff
changeset
|
776 useful when debugging comprehensive tests. |
2be9f14bd23f
test_util: add helper to draw repo with graphlog extension
Patrick Mezard <pmezard@gmail.com>
parents:
522
diff
changeset
|
777 """ |
2be9f14bd23f
test_util: add helper to draw repo with graphlog extension
Patrick Mezard <pmezard@gmail.com>
parents:
522
diff
changeset
|
778 # Could be more elegant, but it works with stock hg |
1342
c6b01fd34694
trying to fix progress output
Augie Fackler <raf@durin42.com>
parents:
1337
diff
changeset
|
779 _ui = testui() |
527
2be9f14bd23f
test_util: add helper to draw repo with graphlog extension
Patrick Mezard <pmezard@gmail.com>
parents:
522
diff
changeset
|
780 _ui.setconfig('extensions', 'graphlog', '') |
2be9f14bd23f
test_util: add helper to draw repo with graphlog extension
Patrick Mezard <pmezard@gmail.com>
parents:
522
diff
changeset
|
781 extensions.loadall(_ui) |
2be9f14bd23f
test_util: add helper to draw repo with graphlog extension
Patrick Mezard <pmezard@gmail.com>
parents:
522
diff
changeset
|
782 graphlog = extensions.find('graphlog') |
2be9f14bd23f
test_util: add helper to draw repo with graphlog extension
Patrick Mezard <pmezard@gmail.com>
parents:
522
diff
changeset
|
783 templ = """\ |
1084
ca36d5915dc7
test_util: include Subversion revision when drawing a pretty graph
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
1081
diff
changeset
|
784 changeset: {rev}:{node|short} (r{svnrev}) |
527
2be9f14bd23f
test_util: add helper to draw repo with graphlog extension
Patrick Mezard <pmezard@gmail.com>
parents:
522
diff
changeset
|
785 branch: {branches} |
546
d84116dda52d
test_util: add tags to output of draw
Augie Fackler <durin42@gmail.com>
parents:
531
diff
changeset
|
786 tags: {tags} |
527
2be9f14bd23f
test_util: add helper to draw repo with graphlog extension
Patrick Mezard <pmezard@gmail.com>
parents:
522
diff
changeset
|
787 summary: {desc|firstline} |
2be9f14bd23f
test_util: add helper to draw repo with graphlog extension
Patrick Mezard <pmezard@gmail.com>
parents:
522
diff
changeset
|
788 files: {files} |
2be9f14bd23f
test_util: add helper to draw repo with graphlog extension
Patrick Mezard <pmezard@gmail.com>
parents:
522
diff
changeset
|
789 |
2be9f14bd23f
test_util: add helper to draw repo with graphlog extension
Patrick Mezard <pmezard@gmail.com>
parents:
522
diff
changeset
|
790 """ |
952
9c3b4f59e7e6
stupid: do not close branch upon branch-wide revert
Patrick Mezard <patrick@mezard.eu>
parents:
944
diff
changeset
|
791 _ui.pushbuffer() |
1365
89997a5fc181
stupid: self-disable if svn bindings are too new to work with stupid mode
Augie Fackler <raf@durin42.com>
parents:
1363
diff
changeset
|
792 try: |
89997a5fc181
stupid: self-disable if svn bindings are too new to work with stupid mode
Augie Fackler <raf@durin42.com>
parents:
1363
diff
changeset
|
793 graphlog.graphlog(_ui, repo, rev=None, template=templ) |
89997a5fc181
stupid: self-disable if svn bindings are too new to work with stupid mode
Augie Fackler <raf@durin42.com>
parents:
1363
diff
changeset
|
794 except AttributeError: |
89997a5fc181
stupid: self-disable if svn bindings are too new to work with stupid mode
Augie Fackler <raf@durin42.com>
parents:
1363
diff
changeset
|
795 from mercurial import commands |
89997a5fc181
stupid: self-disable if svn bindings are too new to work with stupid mode
Augie Fackler <raf@durin42.com>
parents:
1363
diff
changeset
|
796 commands.log(_ui, repo, rev=None, template=templ, graph=True) |
952
9c3b4f59e7e6
stupid: do not close branch upon branch-wide revert
Patrick Mezard <patrick@mezard.eu>
parents:
944
diff
changeset
|
797 return _ui.popbuffer() |
9c3b4f59e7e6
stupid: do not close branch upon branch-wide revert
Patrick Mezard <patrick@mezard.eu>
parents:
944
diff
changeset
|
798 |
1464
1a4d0f1563d0
test_util: add utility function for logging the Subversion repository
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
1463
diff
changeset
|
799 def svnlog(self, repo=None): |
1a4d0f1563d0
test_util: add utility function for logging the Subversion repository
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
1463
diff
changeset
|
800 '''log of the remote Subversion repository corresponding to repo |
1a4d0f1563d0
test_util: add utility function for logging the Subversion repository
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
1463
diff
changeset
|
801 |
1a4d0f1563d0
test_util: add utility function for logging the Subversion repository
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
1463
diff
changeset
|
802 In order to make the format suitable for direct comparison in |
1a4d0f1563d0
test_util: add utility function for logging the Subversion repository
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
1463
diff
changeset
|
803 tests, we exclude dates and convert the path operations into |
1a4d0f1563d0
test_util: add utility function for logging the Subversion repository
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
1463
diff
changeset
|
804 a tuple. |
1a4d0f1563d0
test_util: add utility function for logging the Subversion repository
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
1463
diff
changeset
|
805 ''' |
1a4d0f1563d0
test_util: add utility function for logging the Subversion repository
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
1463
diff
changeset
|
806 |
1a4d0f1563d0
test_util: add utility function for logging the Subversion repository
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
1463
diff
changeset
|
807 if repo is None: |
1a4d0f1563d0
test_util: add utility function for logging the Subversion repository
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
1463
diff
changeset
|
808 repo = self.repo |
1a4d0f1563d0
test_util: add utility function for logging the Subversion repository
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
1463
diff
changeset
|
809 |
1a4d0f1563d0
test_util: add utility function for logging the Subversion repository
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
1463
diff
changeset
|
810 return [(r.revnum, r.message, |
1a4d0f1563d0
test_util: add utility function for logging the Subversion repository
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
1463
diff
changeset
|
811 dict((p, (op.action, op.copyfrom_path, int(op.copyfrom_rev))) |
1a4d0f1563d0
test_util: add utility function for logging the Subversion repository
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
1463
diff
changeset
|
812 for (p, op) in r.paths.items())) |
1a4d0f1563d0
test_util: add utility function for logging the Subversion repository
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
1463
diff
changeset
|
813 for r in svnrepo.svnremoterepo(repo.ui).svn.revisions()] |
1a4d0f1563d0
test_util: add utility function for logging the Subversion repository
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
1463
diff
changeset
|
814 |
952
9c3b4f59e7e6
stupid: do not close branch upon branch-wide revert
Patrick Mezard <patrick@mezard.eu>
parents:
944
diff
changeset
|
815 def draw(self, repo): |
9c3b4f59e7e6
stupid: do not close branch upon branch-wide revert
Patrick Mezard <patrick@mezard.eu>
parents:
944
diff
changeset
|
816 sys.stdout.write(self.getgraph(repo)) |