Mercurial > hgsubversion
annotate tests/test_hooks.py @ 1002:117b3b421294
buildmeta: verify uuid when passed explicit url
2c87bdc43d3c changed buildmeta to read the uuid from local disk, if
it's available. As a side effect, it disabled the validation of the
uuid we've recorded locall in the commits against the uuid of the repo
we are building against. This is probably reasonable when someone
runs a bare updatemeta or rebuildmeta. I think it's a worthwhile
sanity check when someone passes an explicit repository url to
rebuild/updatemeta. This restores the validation in that case, and
fixes a failing test in the process.
author | David Schleimer <dschleimer@fb.com> |
---|---|
date | Fri, 12 Apr 2013 10:51:42 -0700 |
parents | 92bd7b3678ea |
children | d741f536f23a |
rev | line source |
---|---|
919
92bd7b3678ea
Add a changegroup hook to update svn metadata
Brad Hall <bhall@fb.com>
parents:
diff
changeset
|
1 import sys |
92bd7b3678ea
Add a changegroup hook to update svn metadata
Brad Hall <bhall@fb.com>
parents:
diff
changeset
|
2 import test_util |
92bd7b3678ea
Add a changegroup hook to update svn metadata
Brad Hall <bhall@fb.com>
parents:
diff
changeset
|
3 import unittest |
92bd7b3678ea
Add a changegroup hook to update svn metadata
Brad Hall <bhall@fb.com>
parents:
diff
changeset
|
4 |
92bd7b3678ea
Add a changegroup hook to update svn metadata
Brad Hall <bhall@fb.com>
parents:
diff
changeset
|
5 from mercurial import hg |
92bd7b3678ea
Add a changegroup hook to update svn metadata
Brad Hall <bhall@fb.com>
parents:
diff
changeset
|
6 from mercurial import commands |
92bd7b3678ea
Add a changegroup hook to update svn metadata
Brad Hall <bhall@fb.com>
parents:
diff
changeset
|
7 |
92bd7b3678ea
Add a changegroup hook to update svn metadata
Brad Hall <bhall@fb.com>
parents:
diff
changeset
|
8 class TestHooks(test_util.TestBase): |
92bd7b3678ea
Add a changegroup hook to update svn metadata
Brad Hall <bhall@fb.com>
parents:
diff
changeset
|
9 def setUp(self): |
92bd7b3678ea
Add a changegroup hook to update svn metadata
Brad Hall <bhall@fb.com>
parents:
diff
changeset
|
10 super(TestHooks, self).setUp() |
92bd7b3678ea
Add a changegroup hook to update svn metadata
Brad Hall <bhall@fb.com>
parents:
diff
changeset
|
11 |
92bd7b3678ea
Add a changegroup hook to update svn metadata
Brad Hall <bhall@fb.com>
parents:
diff
changeset
|
12 def _loadupdate(self, fixture_name, *args, **kwargs): |
92bd7b3678ea
Add a changegroup hook to update svn metadata
Brad Hall <bhall@fb.com>
parents:
diff
changeset
|
13 kwargs = kwargs.copy() |
92bd7b3678ea
Add a changegroup hook to update svn metadata
Brad Hall <bhall@fb.com>
parents:
diff
changeset
|
14 kwargs.update(stupid=False, noupdate=False) |
92bd7b3678ea
Add a changegroup hook to update svn metadata
Brad Hall <bhall@fb.com>
parents:
diff
changeset
|
15 repo, repo_path = self.load_and_fetch(fixture_name, *args, **kwargs) |
92bd7b3678ea
Add a changegroup hook to update svn metadata
Brad Hall <bhall@fb.com>
parents:
diff
changeset
|
16 return repo, repo_path |
92bd7b3678ea
Add a changegroup hook to update svn metadata
Brad Hall <bhall@fb.com>
parents:
diff
changeset
|
17 |
92bd7b3678ea
Add a changegroup hook to update svn metadata
Brad Hall <bhall@fb.com>
parents:
diff
changeset
|
18 def test_updatemetahook(self): |
92bd7b3678ea
Add a changegroup hook to update svn metadata
Brad Hall <bhall@fb.com>
parents:
diff
changeset
|
19 repo, repo_path = self._loadupdate('single_rev.svndump') |
92bd7b3678ea
Add a changegroup hook to update svn metadata
Brad Hall <bhall@fb.com>
parents:
diff
changeset
|
20 state = repo.parents() |
92bd7b3678ea
Add a changegroup hook to update svn metadata
Brad Hall <bhall@fb.com>
parents:
diff
changeset
|
21 self.add_svn_rev(repo_path, {'trunk/alpha': 'Changed'}) |
92bd7b3678ea
Add a changegroup hook to update svn metadata
Brad Hall <bhall@fb.com>
parents:
diff
changeset
|
22 commands.pull(self.repo.ui, self.repo) |
92bd7b3678ea
Add a changegroup hook to update svn metadata
Brad Hall <bhall@fb.com>
parents:
diff
changeset
|
23 |
92bd7b3678ea
Add a changegroup hook to update svn metadata
Brad Hall <bhall@fb.com>
parents:
diff
changeset
|
24 # Clone to a new repository and add a hook |
92bd7b3678ea
Add a changegroup hook to update svn metadata
Brad Hall <bhall@fb.com>
parents:
diff
changeset
|
25 new_wc_path = "%s-2" % self.wc_path |
92bd7b3678ea
Add a changegroup hook to update svn metadata
Brad Hall <bhall@fb.com>
parents:
diff
changeset
|
26 commands.clone(self.repo.ui, self.wc_path, new_wc_path) |
92bd7b3678ea
Add a changegroup hook to update svn metadata
Brad Hall <bhall@fb.com>
parents:
diff
changeset
|
27 newrepo = hg.repository(test_util.testui(), new_wc_path) |
92bd7b3678ea
Add a changegroup hook to update svn metadata
Brad Hall <bhall@fb.com>
parents:
diff
changeset
|
28 newrepo.ui.setconfig('hooks', 'changegroup.meta', |
92bd7b3678ea
Add a changegroup hook to update svn metadata
Brad Hall <bhall@fb.com>
parents:
diff
changeset
|
29 'python:hgsubversion.hooks.updatemeta.hook') |
92bd7b3678ea
Add a changegroup hook to update svn metadata
Brad Hall <bhall@fb.com>
parents:
diff
changeset
|
30 |
92bd7b3678ea
Add a changegroup hook to update svn metadata
Brad Hall <bhall@fb.com>
parents:
diff
changeset
|
31 # Commit a rev that should trigger svn meta update |
92bd7b3678ea
Add a changegroup hook to update svn metadata
Brad Hall <bhall@fb.com>
parents:
diff
changeset
|
32 self.add_svn_rev(repo_path, {'trunk/alpha': 'Changed Again'}) |
92bd7b3678ea
Add a changegroup hook to update svn metadata
Brad Hall <bhall@fb.com>
parents:
diff
changeset
|
33 commands.pull(self.repo.ui, self.repo) |
92bd7b3678ea
Add a changegroup hook to update svn metadata
Brad Hall <bhall@fb.com>
parents:
diff
changeset
|
34 |
92bd7b3678ea
Add a changegroup hook to update svn metadata
Brad Hall <bhall@fb.com>
parents:
diff
changeset
|
35 self.called = False |
92bd7b3678ea
Add a changegroup hook to update svn metadata
Brad Hall <bhall@fb.com>
parents:
diff
changeset
|
36 import hgsubversion.svncommands |
92bd7b3678ea
Add a changegroup hook to update svn metadata
Brad Hall <bhall@fb.com>
parents:
diff
changeset
|
37 oldupdatemeta = hgsubversion.svncommands.updatemeta |
92bd7b3678ea
Add a changegroup hook to update svn metadata
Brad Hall <bhall@fb.com>
parents:
diff
changeset
|
38 def _updatemeta(ui, repo, args=[]): |
92bd7b3678ea
Add a changegroup hook to update svn metadata
Brad Hall <bhall@fb.com>
parents:
diff
changeset
|
39 self.called = True |
92bd7b3678ea
Add a changegroup hook to update svn metadata
Brad Hall <bhall@fb.com>
parents:
diff
changeset
|
40 hgsubversion.svncommands.updatemeta = _updatemeta |
92bd7b3678ea
Add a changegroup hook to update svn metadata
Brad Hall <bhall@fb.com>
parents:
diff
changeset
|
41 |
92bd7b3678ea
Add a changegroup hook to update svn metadata
Brad Hall <bhall@fb.com>
parents:
diff
changeset
|
42 # Pull and make sure our updatemeta function gets called |
92bd7b3678ea
Add a changegroup hook to update svn metadata
Brad Hall <bhall@fb.com>
parents:
diff
changeset
|
43 commands.pull(newrepo.ui, newrepo) |
92bd7b3678ea
Add a changegroup hook to update svn metadata
Brad Hall <bhall@fb.com>
parents:
diff
changeset
|
44 hgsubversion.svncommands.updatemeta = oldupdatemeta |
92bd7b3678ea
Add a changegroup hook to update svn metadata
Brad Hall <bhall@fb.com>
parents:
diff
changeset
|
45 self.assertTrue(self.called) |
92bd7b3678ea
Add a changegroup hook to update svn metadata
Brad Hall <bhall@fb.com>
parents:
diff
changeset
|
46 |
92bd7b3678ea
Add a changegroup hook to update svn metadata
Brad Hall <bhall@fb.com>
parents:
diff
changeset
|
47 def suite(): |
92bd7b3678ea
Add a changegroup hook to update svn metadata
Brad Hall <bhall@fb.com>
parents:
diff
changeset
|
48 return unittest.findTestCases(sys.modules[__name__]) |