本文整理汇总了Python中util.hg.path函数的典型用法代码示例。如果您正苦于以下问题:Python path函数的具体用法?Python path怎么用?Python path使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了path函数的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: testBustedHgrc
def testBustedHgrc(self):
# Test that we can recover from hgrc being lost
mercurial(self.repodir, self.wc)
# Delete .hg/hgrc
os.unlink(os.path.join(self.wc, '.hg', 'hgrc'))
# path is busted now
p = path(self.wc)
self.assertEquals(p, None)
# cloning again should fix this up
mercurial(self.repodir, self.wc)
p = path(self.wc)
self.assertEquals(p, self.repodir)
示例2: testCloneWithBadMirror
def testCloneWithBadMirror(self):
mirror = os.path.join(self.tmpdir, 'repo2')
# Now clone from the mirror
clone(self.repodir, self.wc, mirrors=[mirror])
# We still end up with a valid repo
self.assertEquals(self.revisions, getRevisions(self.wc))
self.assertEquals(self.repodir, path(self.wc))
示例3: testAdjustPaths
def testAdjustPaths(self):
mercurial(self.repodir, self.wc)
# Make sure our default path is correct
self.assertEquals(path(self.wc), self.repodir)
# Add a comment, make sure it's still there if we don't change
# anything
hgrc = os.path.join(self.wc, '.hg', 'hgrc')
open(hgrc, 'a').write("# Hello world")
adjust_paths(self.wc, default=self.repodir)
self.assert_("Hello world" in open(hgrc).read())
# Add a path, and the comment goes away
adjust_paths(self.wc, test=self.repodir)
self.assert_("Hello world" not in open(hgrc).read())
# Make sure our paths are correct
self.assertEquals(path(self.wc), self.repodir)
self.assertEquals(path(self.wc, 'test'), self.repodir)
示例4: testBustedHgrcWithShare
def testBustedHgrcWithShare(self):
# Test that we can recover from hgrc being lost
shareBase = os.path.join(self.tmpdir, 'share')
sharerepo = os.path.join(shareBase, self.repodir.lstrip("/"))
os.mkdir(shareBase)
mercurial(self.repodir, self.wc, shareBase=shareBase)
# Delete .hg/hgrc
for d in sharerepo, self.wc:
f = os.path.join(d, '.hg', 'hgrc')
os.unlink(f)
# path is busted now
p = path(self.wc)
self.assertEquals(p, None)
# cloning again should fix this up
mercurial(self.repodir, self.wc, shareBase=shareBase)
p = path(self.wc)
self.assertEquals(p, self.repodir)
示例5: testPullWithBadMirror
def testPullWithBadMirror(self):
mirror = os.path.join(self.tmpdir, 'repo2')
# Now clone from the original
clone(self.repodir, self.wc)
# Create a new commit in the original repo
open(os.path.join(self.repodir, 'test.txt'), 'w').write('hello!')
run_cmd(['hg', 'add', 'test.txt'], cwd=self.repodir)
run_cmd(['hg', 'commit', '-m', 'adding changeset'], cwd=self.repodir)
# Pull using the mirror
pull(self.repodir, self.wc, mirrors=[mirror])
self.assertEquals(getRevisions(self.wc), getRevisions(self.repodir))
# Our default path should point to the original repo
self.assertEquals(self.repodir, path(self.wc))
示例6: testCloneWithMirror
def testCloneWithMirror(self):
mirror = os.path.join(self.tmpdir, 'repo2')
clone(self.repodir, mirror)
# Create a commit in the original repo
open(os.path.join(self.repodir, 'test.txt'), 'w').write('hello!')
run_cmd(['hg', 'add', 'test.txt'], cwd=self.repodir)
run_cmd(['hg', 'commit', '-m', 'adding changeset'], cwd=self.repodir)
# Now clone from the mirror
clone(self.repodir, self.wc, mirrors=[mirror])
# We'll be missing the new revision from repodir
self.assertNotEquals(getRevisions(self.repodir), getRevisions(self.wc))
# But we should have everything from the mirror
self.assertEquals(getRevisions(mirror), getRevisions(self.wc))
# Our default path should point to the original repo though.
self.assertEquals(self.repodir, path(self.wc))
示例7: testCloneWithRevAndMirror
def testCloneWithRevAndMirror(self):
mirror = os.path.join(self.tmpdir, "repo2")
clone(self.repodir, mirror)
# Create a commit in the original repo
open(os.path.join(self.repodir, "test.txt"), "w").write("hello!")
run_cmd(["hg", "add", "test.txt"], cwd=self.repodir)
run_cmd(["hg", "commit", "-m", "adding changeset"], cwd=self.repodir)
# Now clone from the mirror
revisions = getRevisions(self.repodir)
clone(self.repodir, self.wc, revision=revisions[0], mirrors=[mirror], clone_by_rev=True)
# We'll be missing the middle revision (on another branch)
self.assertEquals(revisions[:2] + revisions[3:], getRevisions(self.wc))
# But not from the mirror
self.assertNotEquals(getRevisions(mirror), getRevisions(self.wc))
# Our default path should point to the original repo though.
self.assertEquals(self.repodir, path(self.wc))
示例8: testCloneWithRevAndMirror
def testCloneWithRevAndMirror(self):
mirror = os.path.join(self.tmpdir, 'repo2')
clone(self.repodir, mirror)
# Create a commit in the original repo
open(os.path.join(self.repodir, 'test.txt'), 'w').write('hello!')
run_cmd(['hg', 'add', 'test.txt'], cwd=self.repodir)
run_cmd(['hg', 'commit', '-m', 'adding changeset'], cwd=self.repodir)
# Now clone from the mirror
revisions = getRevisions(self.repodir)
clone(self.repodir, self.wc, revision=revisions[0],
mirrors=[mirror], clone_by_rev=True)
# We'll be missing the middle revision (on another branch)
self.assertEquals(revisions[:2] + revisions[3:], getRevisions(self.wc))
# But not from the mirror
self.assertNotEquals(getRevisions(mirror), getRevisions(self.wc))
# Our default path should point to the original repo though.
self.assertEquals(self.repodir, path(self.wc))
示例9: testPullWithUnrelatedMirror
def testPullWithUnrelatedMirror(self):
mirror = os.path.join(self.tmpdir, "repo2")
run_cmd(["%s/init_hgrepo.sh" % os.path.dirname(__file__), mirror])
# Now clone from the original
clone(self.repodir, self.wc)
# Create a new commit in the original repo
open(os.path.join(self.repodir, "test.txt"), "w").write("hello!")
run_cmd(["hg", "add", "test.txt"], cwd=self.repodir)
run_cmd(["hg", "commit", "-m", "adding changeset"], cwd=self.repodir)
# Pull using the mirror
pull(self.repodir, self.wc, mirrors=[mirror])
self.assertEquals(getRevisions(self.wc), getRevisions(self.repodir))
# We shouldn't have anything from the unrelated mirror
self.assertEquals(set(), set(getRevisions(mirror)).intersection(set(getRevisions(self.wc))))
# Our default path should point to the original repo
self.assertEquals(self.repodir, path(self.wc))
示例10: testCloneWithBundle
def testCloneWithBundle(self):
# First create the bundle
bundle = os.path.join(self.tmpdir, 'bundle')
run_cmd(['hg', 'bundle', '-a', bundle], cwd=self.repodir)
# Wrap unbundle so we can tell if it got called
orig_unbundle = unbundle
try:
called = []
def new_unbundle(*args, **kwargs):
called.append(True)
return orig_unbundle(*args, **kwargs)
hg.unbundle = new_unbundle
# Now clone it using the bundle
clone(self.repodir, self.wc, bundles=[bundle])
self.assertEquals(self.revisions, getRevisions(self.wc))
self.assertEquals(called, [True])
self.assertEquals(path(self.wc), self.repodir)
finally:
hg.unbundle = orig_unbundle
示例11: testPullWithUnrelatedMirror
def testPullWithUnrelatedMirror(self):
mirror = os.path.join(self.tmpdir, 'repo2')
run_cmd(['%s/init_hgrepo.sh' % os.path.dirname(__file__), mirror])
# Now clone from the original
clone(self.repodir, self.wc)
# Create a new commit in the original repo
open(os.path.join(self.repodir, 'test.txt'), 'w').write('hello!')
run_cmd(['hg', 'add', 'test.txt'], cwd=self.repodir)
run_cmd(['hg', 'commit', '-m', 'adding changeset'], cwd=self.repodir)
# Pull using the mirror
pull(self.repodir, self.wc, mirrors=[mirror])
self.assertEquals(getRevisions(self.wc), getRevisions(self.repodir))
# We shouldn't have anything from the unrelated mirror
self.assertEquals(set(),
set(getRevisions(mirror)).intersection(set(getRevisions(self.wc))))
# Our default path should point to the original repo
self.assertEquals(self.repodir, path(self.wc))
示例12: testPath
def testPath(self):
clone(self.repodir, self.wc)
p = path(self.wc)
self.assertEquals(p, self.repodir)