tests/test-hgwebdir-paths.py
author Patrick Mezard <pmezard@gmail.com>
Sat, 22 Jan 2011 16:15:40 +0100
branchstable
changeset 13287 d0e0d3d43e14
parent 8529 a767998f0a78
child 15355 dbdb777502dc
permissions -rw-r--r--
subrepo: compare svn subrepo state to last committed revision A subversion project revisions are a subset of the repository revisions, you can ask subversion to update a working directory from one revision to another without changing anything. Unfortunately, Mercurial will think the subrepository has changed and will commit it again. To avoid useless commits, we compare the subrepository state to its actual "parent" revision. To ensure ascending compatibility with existing subrepositories which might reference fake revisions, we also keep comparing with the subrepo working directory revision. NOTE: not sure if this should go in stable or not.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
8529
a767998f0a78 hgweb: make hgwebdir handle dict/list paths the same as config paths
Jeremy Whitlock <jcscoobyrs@gmail.com>
parents:
diff changeset
     1
import os
a767998f0a78 hgweb: make hgwebdir handle dict/list paths the same as config paths
Jeremy Whitlock <jcscoobyrs@gmail.com>
parents:
diff changeset
     2
from mercurial import hg, ui
a767998f0a78 hgweb: make hgwebdir handle dict/list paths the same as config paths
Jeremy Whitlock <jcscoobyrs@gmail.com>
parents:
diff changeset
     3
from mercurial.hgweb.hgwebdir_mod import hgwebdir
a767998f0a78 hgweb: make hgwebdir handle dict/list paths the same as config paths
Jeremy Whitlock <jcscoobyrs@gmail.com>
parents:
diff changeset
     4
a767998f0a78 hgweb: make hgwebdir handle dict/list paths the same as config paths
Jeremy Whitlock <jcscoobyrs@gmail.com>
parents:
diff changeset
     5
os.mkdir('webdir')
a767998f0a78 hgweb: make hgwebdir handle dict/list paths the same as config paths
Jeremy Whitlock <jcscoobyrs@gmail.com>
parents:
diff changeset
     6
os.chdir('webdir')
a767998f0a78 hgweb: make hgwebdir handle dict/list paths the same as config paths
Jeremy Whitlock <jcscoobyrs@gmail.com>
parents:
diff changeset
     7
a767998f0a78 hgweb: make hgwebdir handle dict/list paths the same as config paths
Jeremy Whitlock <jcscoobyrs@gmail.com>
parents:
diff changeset
     8
webdir = os.path.realpath('.')
a767998f0a78 hgweb: make hgwebdir handle dict/list paths the same as config paths
Jeremy Whitlock <jcscoobyrs@gmail.com>
parents:
diff changeset
     9
a767998f0a78 hgweb: make hgwebdir handle dict/list paths the same as config paths
Jeremy Whitlock <jcscoobyrs@gmail.com>
parents:
diff changeset
    10
u = ui.ui()
a767998f0a78 hgweb: make hgwebdir handle dict/list paths the same as config paths
Jeremy Whitlock <jcscoobyrs@gmail.com>
parents:
diff changeset
    11
hg.repository(u, 'a', create=1)
a767998f0a78 hgweb: make hgwebdir handle dict/list paths the same as config paths
Jeremy Whitlock <jcscoobyrs@gmail.com>
parents:
diff changeset
    12
hg.repository(u, 'b', create=1)
a767998f0a78 hgweb: make hgwebdir handle dict/list paths the same as config paths
Jeremy Whitlock <jcscoobyrs@gmail.com>
parents:
diff changeset
    13
os.chdir('b')
a767998f0a78 hgweb: make hgwebdir handle dict/list paths the same as config paths
Jeremy Whitlock <jcscoobyrs@gmail.com>
parents:
diff changeset
    14
hg.repository(u, 'd', create=1)
a767998f0a78 hgweb: make hgwebdir handle dict/list paths the same as config paths
Jeremy Whitlock <jcscoobyrs@gmail.com>
parents:
diff changeset
    15
os.chdir('..')
a767998f0a78 hgweb: make hgwebdir handle dict/list paths the same as config paths
Jeremy Whitlock <jcscoobyrs@gmail.com>
parents:
diff changeset
    16
hg.repository(u, 'c', create=1)
a767998f0a78 hgweb: make hgwebdir handle dict/list paths the same as config paths
Jeremy Whitlock <jcscoobyrs@gmail.com>
parents:
diff changeset
    17
os.chdir('..')
a767998f0a78 hgweb: make hgwebdir handle dict/list paths the same as config paths
Jeremy Whitlock <jcscoobyrs@gmail.com>
parents:
diff changeset
    18
a767998f0a78 hgweb: make hgwebdir handle dict/list paths the same as config paths
Jeremy Whitlock <jcscoobyrs@gmail.com>
parents:
diff changeset
    19
paths = {'t/a/': '%s/a' % webdir,
a767998f0a78 hgweb: make hgwebdir handle dict/list paths the same as config paths
Jeremy Whitlock <jcscoobyrs@gmail.com>
parents:
diff changeset
    20
         'b': '%s/b' % webdir,
a767998f0a78 hgweb: make hgwebdir handle dict/list paths the same as config paths
Jeremy Whitlock <jcscoobyrs@gmail.com>
parents:
diff changeset
    21
         'coll': '%s/*' % webdir,
a767998f0a78 hgweb: make hgwebdir handle dict/list paths the same as config paths
Jeremy Whitlock <jcscoobyrs@gmail.com>
parents:
diff changeset
    22
         'rcoll': '%s/**' % webdir}
a767998f0a78 hgweb: make hgwebdir handle dict/list paths the same as config paths
Jeremy Whitlock <jcscoobyrs@gmail.com>
parents:
diff changeset
    23
a767998f0a78 hgweb: make hgwebdir handle dict/list paths the same as config paths
Jeremy Whitlock <jcscoobyrs@gmail.com>
parents:
diff changeset
    24
config = os.path.join(webdir, 'hgwebdir.conf')
a767998f0a78 hgweb: make hgwebdir handle dict/list paths the same as config paths
Jeremy Whitlock <jcscoobyrs@gmail.com>
parents:
diff changeset
    25
configfile = open(config, 'w')
a767998f0a78 hgweb: make hgwebdir handle dict/list paths the same as config paths
Jeremy Whitlock <jcscoobyrs@gmail.com>
parents:
diff changeset
    26
configfile.write('[paths]\n')
a767998f0a78 hgweb: make hgwebdir handle dict/list paths the same as config paths
Jeremy Whitlock <jcscoobyrs@gmail.com>
parents:
diff changeset
    27
for k, v in paths.items():
a767998f0a78 hgweb: make hgwebdir handle dict/list paths the same as config paths
Jeremy Whitlock <jcscoobyrs@gmail.com>
parents:
diff changeset
    28
    configfile.write('%s = %s\n' % (k, v))
a767998f0a78 hgweb: make hgwebdir handle dict/list paths the same as config paths
Jeremy Whitlock <jcscoobyrs@gmail.com>
parents:
diff changeset
    29
configfile.close()
a767998f0a78 hgweb: make hgwebdir handle dict/list paths the same as config paths
Jeremy Whitlock <jcscoobyrs@gmail.com>
parents:
diff changeset
    30
a767998f0a78 hgweb: make hgwebdir handle dict/list paths the same as config paths
Jeremy Whitlock <jcscoobyrs@gmail.com>
parents:
diff changeset
    31
confwd = hgwebdir(config)
a767998f0a78 hgweb: make hgwebdir handle dict/list paths the same as config paths
Jeremy Whitlock <jcscoobyrs@gmail.com>
parents:
diff changeset
    32
dictwd = hgwebdir(paths)
a767998f0a78 hgweb: make hgwebdir handle dict/list paths the same as config paths
Jeremy Whitlock <jcscoobyrs@gmail.com>
parents:
diff changeset
    33
a767998f0a78 hgweb: make hgwebdir handle dict/list paths the same as config paths
Jeremy Whitlock <jcscoobyrs@gmail.com>
parents:
diff changeset
    34
assert len(confwd.repos) == len(dictwd.repos), 'different numbers'
a767998f0a78 hgweb: make hgwebdir handle dict/list paths the same as config paths
Jeremy Whitlock <jcscoobyrs@gmail.com>
parents:
diff changeset
    35
assert len(confwd.repos) == 9, 'expected 9 repos, found %d' % len(confwd.repos)
a767998f0a78 hgweb: make hgwebdir handle dict/list paths the same as config paths
Jeremy Whitlock <jcscoobyrs@gmail.com>
parents:
diff changeset
    36
a767998f0a78 hgweb: make hgwebdir handle dict/list paths the same as config paths
Jeremy Whitlock <jcscoobyrs@gmail.com>
parents:
diff changeset
    37
found = dict(confwd.repos)
a767998f0a78 hgweb: make hgwebdir handle dict/list paths the same as config paths
Jeremy Whitlock <jcscoobyrs@gmail.com>
parents:
diff changeset
    38
for key, path in dictwd.repos:
a767998f0a78 hgweb: make hgwebdir handle dict/list paths the same as config paths
Jeremy Whitlock <jcscoobyrs@gmail.com>
parents:
diff changeset
    39
    assert key in found, 'repository %s was not found' % key
a767998f0a78 hgweb: make hgwebdir handle dict/list paths the same as config paths
Jeremy Whitlock <jcscoobyrs@gmail.com>
parents:
diff changeset
    40
    assert found[key] == path, 'different paths for repo %s' % key