本文整理汇总了Python中util.hg.clone函数的典型用法代码示例。如果您正苦于以下问题:Python clone函数的具体用法?Python clone怎么用?Python clone使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了clone函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: testCloneWithBundleMissingRevs
def testCloneWithBundleMissingRevs(self):
# First create the bundle
bundle = os.path.join(self.tmpdir, 'bundle')
run_cmd(['hg', 'bundle', '-a', bundle], cwd=self.repodir)
# Create a commit
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)
# 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(
getRevisions(self.repodir), getRevisions(self.wc))
self.assertEquals(called, [True])
finally:
hg.unbundle = orig_unbundle
示例2: testPushWithForce
def testPushWithForce(self):
clone(self.repodir, self.wc, revision=self.revisions[0],
clone_by_rev=True)
run_cmd(['touch', 'newfile'], cwd=self.wc)
run_cmd(['hg', 'add', 'newfile'], cwd=self.wc)
run_cmd(['hg', 'commit', '-m', '"re-add newfile"'], cwd=self.wc)
push(self.repodir, self.wc, push_new_branches=False, force=True)
示例3: testCloneWithBundleMissingRevs
def testCloneWithBundleMissingRevs(self):
# First create the bundle
bundle = os.path.join(self.tmpdir, "bundle")
run_cmd(["hg", "bundle", "-a", bundle], cwd=self.repodir)
# Create a commit
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)
# 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(getRevisions(self.repodir), getRevisions(self.wc))
self.assertEquals(called, [True])
finally:
hg.unbundle = orig_unbundle
示例4: testPushForceFail
def testPushForceFail(self):
clone(self.repodir, self.wc, revision=self.revisions[0], clone_by_rev=True)
run_cmd(['touch', 'newfile'], cwd=self.wc)
run_cmd(['hg', 'add', 'newfile'], cwd=self.wc)
run_cmd(['hg', 'commit', '-m', '"add newfile"'], cwd=self.wc)
self.assertRaises(Exception, push, self.repodir, self.wc,
push_new_branches=False, force=False)
示例5: testShareExtraFiles
def testShareExtraFiles(self):
shareBase = os.path.join(self.tmpdir, 'share')
backup = os.path.join(self.tmpdir, 'backup')
# Clone the original repo
mercurial(self.repodir, self.wc, shareBase=shareBase)
clone(self.repodir, backup)
# Make the working repo have a new file. We need it to have an earlier
# timestamp to trigger the odd behavior in hg, so use '-d yesterday'
run_cmd(['touch', '-d', 'yesterday', 'newfile'], cwd=self.wc)
run_cmd(['hg', 'add', 'newfile'], cwd=self.wc)
run_cmd(['hg', 'commit', '-m', '"add newfile"'], cwd=self.wc)
# Reset the share base to remove the 'add newfile' commit. We
# overwrite repodir with the backup that doesn't have the commit,
# then clone the repodir to a throwaway dir to create the new
# shareBase. Now self.wc still points to shareBase, but the
# changeset that self.wc was on is lost.
shutil.rmtree(self.repodir)
shutil.rmtree(shareBase)
clone(backup, self.repodir)
throwaway = os.path.join(self.tmpdir, 'throwaway')
mercurial(self.repodir, throwaway, shareBase=shareBase)
# Try and update our working copy
mercurial(self.repodir, self.wc, shareBase=shareBase)
self.assertFalse(os.path.exists(os.path.join(self.wc, 'newfile')))
示例6: testPurgeUntrackedFile
def testPurgeUntrackedFile(self):
clone(self.repodir, self.wc)
fileToPurge = os.path.join(self.wc, "fileToPurge")
with file(fileToPurge, "a") as f:
f.write("purgeme")
purge(self.wc)
self.assertFalse(os.path.exists(fileToPurge))
示例7: testApplyAndPushFail
def testApplyAndPushFail(self):
clone(self.repodir, self.wc)
def c(repo, attempt, remote):
run_cmd(['hg', 'tag', '-f', 'TEST'], cwd=repo)
run_cmd(['hg', 'tag', '-f', 'CONFLICTING_TAG'], cwd=remote)
self.assertRaises(HgUtilError, apply_and_push, self.wc, self.repodir,
lambda r, a: c(r, a, self.repodir), max_attempts=2)
示例8: testCloneBranch
def testCloneBranch(self):
clone(self.repodir, self.wc, branch="branch2", update_dest=False, clone_by_rev=True)
# On hg 1.6, we should only have a subset of the revisions
if hg_ver() >= (1, 6, 0):
self.assertEquals(self.revisions[1:], getRevisions(self.wc))
else:
self.assertEquals(self.revisions, getRevisions(self.wc))
示例9: testCloneRevision
def testCloneRevision(self):
clone(self.repodir, self.wc,
revision=self.revisions[0], update_dest=False,
clone_by_rev=True)
# We'll only get a subset of the revisions
self.assertEquals(self.revisions[:1] + self.revisions[2:],
getRevisions(self.wc))
示例10: testOutofSyncMirrorFailingMaster
def testOutofSyncMirrorFailingMaster(self):
# First create the mirror
mirror = os.path.join(self.tmpdir, "repo2")
clone(self.repodir, mirror)
shareBase = os.path.join(self.tmpdir, "share")
os.mkdir(shareBase)
mercurial(self.repodir, self.wc, shareBase=shareBase, mirrors=[mirror])
# Create a bundle
bundle = os.path.join(self.tmpdir, "bundle")
run_cmd(["hg", "bundle", "-a", bundle], cwd=self.repodir)
# Move our repodir out of the way so that pulling/cloning from it fails
os.rename(self.repodir, self.repodir + "-bad")
# Try and update to a non-existent revision using our mirror and
# bundle, with the master failing. We should fail
self.assertRaises(
subprocess.CalledProcessError,
mercurial,
self.repodir,
self.wc,
shareBase=shareBase,
mirrors=[mirror],
bundles=[bundle],
revision="1234567890",
)
示例11: testApplyAndPush
def testApplyAndPush(self):
clone(self.repodir, self.wc)
def c(repo, attempt):
run_cmd(['hg', 'tag', '-f', 'TEST'], cwd=repo)
apply_and_push(self.wc, self.repodir, c)
self.assertEquals(getRevisions(self.wc), getRevisions(self.repodir))
示例12: testApplyAndPushWithNoChange
def testApplyAndPushWithNoChange(self):
clone(self.repodir, self.wc)
def c(r, a):
pass
self.assertRaises(
HgUtilError, apply_and_push, self.wc, self.repodir, c)
示例13: testPullDefault
def testPullDefault(self):
clone(self.repodir, self.wc)
run_cmd(['hg', 'tag', '-f', 'TAG1'], cwd=self.repodir)
revisions = getRevisions(self.repodir)
rev = pull(self.repodir, self.wc, revision='default')
self.assertEquals(rev, revisions[0])
self.assertEquals(getRevisions(self.wc), revisions)
示例14: testPurgeTrackedFile
def testPurgeTrackedFile(self):
clone(self.repodir, self.wc)
fileToModify = os.path.join(self.wc, "hello.txt")
with open(fileToModify, "w") as f:
f.write("hello!")
purge(self.wc)
with open(fileToModify, "r") as f:
content = f.read()
self.assertEqual(content, "hello!")
示例15: testPull
def testPull(self):
# Clone just the first rev
clone(self.repodir, self.wc, revision=self.revisions[-1], update_dest=False, clone_by_rev=True)
self.assertEquals(getRevisions(self.wc), self.revisions[-1:])
# Now pull in new changes
rev = pull(self.repodir, self.wc, update_dest=False)
self.assertEquals(rev, None)
self.assertEquals(getRevisions(self.wc), self.revisions)