本文整理汇总了Python中mercurial.context.memctx函数的典型用法代码示例。如果您正苦于以下问题:Python memctx函数的具体用法?Python memctx怎么用?Python memctx使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了memctx函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: test_push_two_revs_different_local_branch
def test_push_two_revs_different_local_branch(self):
def filectxfn(repo, memctx, path):
return context.memfilectx(path=path,
data=path,
islink=False,
isexec=False,
copied=False)
oldtiphash = self.repo['default'].node()
ctx = context.memctx(self.repo,
(self.repo[0].node(), revlog.nullid, ),
'automated test',
['gamma', ],
filectxfn,
'testy',
'2008-12-21 16:32:00 -0500',
{'branch': 'localbranch', })
newhash = self.repo.commitctx(ctx)
ctx = context.memctx(self.repo,
(newhash, revlog.nullid),
'automated test2',
['delta', ],
filectxfn,
'testy',
'2008-12-21 16:32:00 -0500',
{'branch': 'localbranch', })
newhash = self.repo.commitctx(ctx)
repo = self.repo
hg.update(repo, newhash)
commands.push(repo.ui, repo)
self.assertEqual(self.repo['tip'].parents()[0].parents()[0].node(), oldtiphash)
self.assertEqual(self.repo['tip'].files(), ['delta', ])
self.assertEqual(self.repo['tip'].manifest().keys(),
['alpha', 'beta', 'gamma', 'delta'])
开发者ID:bulwinkel,项目名称:dot-files,代码行数:33,代码来源:test_push_command.py
示例2: test_push_single_dir_renamed_branch
def test_push_single_dir_renamed_branch(self, stupid=False):
# Tests pulling and pushing with a renamed branch
# Based on test_push_single_dir
test_util.load_svndump_fixture(self.repo_path,
'branch_from_tag.svndump')
cmd = ['clone', '--layout=single', '--branch=flaf']
if stupid:
cmd.append('--stupid')
cmd += [test_util.fileurl(self.repo_path), self.wc_path]
dispatch.dispatch(cmd)
def file_callback(repo, memctx, path):
if path == 'adding_file':
return context.memfilectx(path=path,
data='foo',
islink=False,
isexec=False,
copied=False)
raise IOError(errno.EINVAL, 'Invalid operation: ' + path)
ctx = context.memctx(self.repo,
(self.repo['tip'].node(), node.nullid),
'automated test',
['adding_file'],
file_callback,
'an_author',
'2009-10-19 18:49:30 -0500',
{'branch': 'default',})
self.repo.commitctx(ctx)
hg.update(self.repo, self.repo['tip'].node())
self.pushrevisions()
self.assertTrue('adding_file' in self.svnls(''))
self.assertEquals(set(['flaf']),
set(self.repo[i].branch() for i in self.repo))
开发者ID:bulwinkel,项目名称:dot-files,代码行数:34,代码来源:test_single_dir_clone.py
示例3: test_push_to_default
def test_push_to_default(self, commit=True):
repo = self.repo
old_tip = repo['tip'].node()
expected_parent = repo['default'].node()
def file_callback(repo, memctx, path):
if path == 'adding_file':
return context.memfilectx(path=path,
data='foo',
islink=False,
isexec=False,
copied=False)
raise IOError(errno.EINVAL, 'Invalid operation: ' + path)
ctx = context.memctx(repo,
(repo['default'].node(), node.nullid),
'automated test',
['adding_file'],
file_callback,
'an_author',
'2008-10-07 20:59:48 -0500',
{'branch': 'default',})
new_hash = repo.commitctx(ctx)
if not commit:
return # some tests use this test as an extended setup.
hg.update(repo, repo['tip'].node())
self.pushrevisions()
tip = self.repo['tip']
self.assertNotEqual(tip.node(), old_tip)
self.assertEqual(node.hex(tip.parents()[0].node()),
node.hex(expected_parent))
self.assertEqual(tip['adding_file'].data(), 'foo')
self.assertEqual(tip.branch(), 'default')
开发者ID:bulwinkel,项目名称:dot-files,代码行数:31,代码来源:test_push_command.py
示例4: test_push_single_dir_one_incoming_and_two_outgoing
def test_push_single_dir_one_incoming_and_two_outgoing(self):
# Tests simple pushing from default branch to a single dir repo
# Pushes two outgoing over one incoming svn rev
# (used to cause an "unknown revision")
# This can happen if someone committed to svn since our last pull (race).
repo = self._load_fixture_and_fetch('branch_from_tag.svndump',
stupid=False,
layout='single',
subdir='trunk')
self._add_svn_rev({'trunk/alpha': 'Changed'})
def file_callback(repo, memctx, path):
return context.memfilectx(path=path,
data='data of %s' % path,
islink=False,
isexec=False,
copied=False)
for fn in ['one', 'two']:
ctx = context.memctx(repo,
(repo['tip'].node(), node.nullid),
'automated test',
[fn],
file_callback,
'an_author',
'2009-10-19 18:49:30 -0500',
{'branch': 'default',})
repo.commitctx(ctx)
hg.update(repo, repo['tip'].node())
self.pushrevisions(expected_extra_back=1)
self.assertTrue('trunk/one' in self.svnls(''))
self.assertTrue('trunk/two' in self.svnls(''))
开发者ID:bulwinkel,项目名称:dot-files,代码行数:30,代码来源:test_single_dir_clone.py
示例5: test_push_single_dir_at_subdir
def test_push_single_dir_at_subdir(self):
repo = self._load_fixture_and_fetch('branch_from_tag.svndump',
stupid=False,
layout='single',
subdir='trunk')
def filectxfn(repo, memctx, path):
return context.memfilectx(path=path,
data='contents of %s' % path,
islink=False,
isexec=False,
copied=False)
ctx = context.memctx(repo,
(repo['tip'].node(), node.nullid),
'automated test',
['bogus'],
filectxfn,
'an_author',
'2009-10-19 18:49:30 -0500',
{'branch': 'localhacking',})
n = repo.commitctx(ctx)
self.assertEqual(self.repo['tip']['bogus'].data(),
'contents of bogus')
before = repo['tip'].hex()
hg.update(repo, self.repo['tip'].hex())
self.pushrevisions()
self.assertNotEqual(before, self.repo['tip'].hex())
self.assertEqual(self.repo['tip']['bogus'].data(),
'contents of bogus')
开发者ID:bulwinkel,项目名称:dot-files,代码行数:28,代码来源:test_single_dir_clone.py
示例6: putcommit
def putcommit(self, files, modes, copies, commit):
def getfilectx(repo, memctx, name):
fileid = files[name]
if fileid is None: # deleted file
raise IOError
data = self.getblob(fileid)
ctx = context.memfilectx(name, data, 'l' in modes,
'x' in modes, copies.get(name))
return ctx
parents = list(set(commit.parents))
nparents = len(parents)
if len(parents) < 2:
parents.append(nullid)
if len(parents) < 2:
parents.append(nullid)
p2 = parents.pop(0)
text = commit.desc
extra = commit.extra.copy()
if self.branchnames and commit.branch:
extra['branch'] = commit.branch
while parents:
p1 = p2
p2 = parents.pop(0)
ctx = context.memctx(self.repo, (p1, p2), text, files.keys(),
getfilectx, commit.author, commit.date, extra)
self.repo.commitctx(ctx)
text = "(octopus merge fixup)\n"
p2 = hex(self.repo.changelog.tip())
return p2
开发者ID:Grahack,项目名称:git,代码行数:35,代码来源:hgimport.py
示例7: test_push_to_branch
def test_push_to_branch(self, push=True):
repo = self.repo
def file_callback(repo, memctx, path):
if path == 'adding_file':
return context.memfilectx(path=path,
data='foo',
islink=False,
isexec=False,
copied=False)
raise IOError(errno.EINVAL, 'Invalid operation: ' + path)
ctx = context.memctx(repo,
(repo['the_branch'].node(), node.nullid),
'automated test',
['adding_file'],
file_callback,
'an_author',
'2008-10-07 20:59:48 -0500',
{'branch': 'the_branch',})
new_hash = repo.commitctx(ctx)
hg.update(repo, repo['tip'].node())
if push:
self.pushrevisions()
tip = self.repo['tip']
self.assertNotEqual(tip.node(), new_hash)
self.assertEqual(tip['adding_file'].data(), 'foo')
self.assertEqual(tip.branch(), 'the_branch')
开发者ID:bulwinkel,项目名称:dot-files,代码行数:26,代码来源:test_push_command.py
示例8: test_push_symlink_file
def test_push_symlink_file(self):
self.test_push_to_default(commit=True)
repo = self.repo
def file_callback(repo, memctx, path):
if path == 'gamma':
return context.memfilectx(path=path,
data='foo',
islink=True,
isexec=False,
copied=False)
raise IOError(errno.EINVAL, 'Invalid operation: ' + path)
ctx = context.memctx(repo,
(repo['tip'].node(), node.nullid),
'message',
['gamma', ],
file_callback,
'author',
'2008-10-29 21:26:00 -0500',
{'branch': 'default', })
new_hash = repo.commitctx(ctx)
hg.update(repo, repo['tip'].node())
self.pushrevisions()
tip = self.repo['tip']
self.assertNotEqual(tip.node(), new_hash)
self.assertEqual(tip['gamma'].flags(), 'l')
self.assertEqual(tip['gamma'].data(), 'foo')
self.assertEqual([x for x in tip.manifest().keys() if 'l' not in
tip[x].flags()], ['alpha', 'beta', 'adding_file', ])
开发者ID:bulwinkel,项目名称:dot-files,代码行数:28,代码来源:test_push_command.py
示例9: test_outgoing_output
def test_outgoing_output(self):
self._load_fixture_and_fetch('two_heads.svndump')
u = self.ui()
parents = (self.repo['the_branch'].node(), revlog.nullid, )
def filectxfn(repo, memctx, path):
return context.memfilectx(path=path,
data='added',
islink=False,
isexec=False,
copied=False)
ctx = context.memctx(self.repo,
parents,
'automated test',
['added_bogus_file', 'other_added_file', ],
filectxfn,
'testy',
'2008-12-21 16:32:00 -0500',
{'branch': 'localbranch', })
new = self.repo.commitctx(ctx)
hg.update(self.repo, new)
u.pushbuffer()
commands.outgoing(u, self.repo, self.repourl)
actual = u.popbuffer()
self.assertTrue(node.hex(self.repo['localbranch'].node())[:8] in actual)
self.assertEqual(actual.strip(), '5:6de15430fa20')
hg.update(self.repo, 'default')
u.pushbuffer()
commands.outgoing(u, self.repo, self.repourl)
actual = u.popbuffer()
self.assertEqual(actual, '')
开发者ID:chaptastic,项目名称:config_files,代码行数:30,代码来源:test_utility_commands.py
示例10: test_push_single_dir
def test_push_single_dir(self):
# Tests simple pushing from default branch to a single dir repo
repo = self._load_fixture_and_fetch('branch_from_tag.svndump',
stupid=False,
layout='single',
subdir='')
def file_callback(repo, memctx, path):
if path == 'adding_file':
return context.memfilectx(path=path,
data='foo',
islink=False,
isexec=False,
copied=False)
raise IOError(errno.EINVAL, 'Invalid operation: ' + path)
ctx = context.memctx(repo,
(repo['tip'].node(), node.nullid),
'automated test',
['adding_file'],
file_callback,
'an_author',
'2009-10-19 18:49:30 -0500',
{'branch': 'default',})
repo.commitctx(ctx)
hg.update(repo, repo['tip'].node())
self.pushrevisions()
self.assertTrue('adding_file' in self.svnls(''))
开发者ID:bulwinkel,项目名称:dot-files,代码行数:26,代码来源:test_single_dir_clone.py
示例11: test_rebase
def test_rebase(self):
self._load_fixture_and_fetch('two_revs.svndump')
parents = (self.repo[0].node(), revlog.nullid, )
def filectxfn(repo, memctx, path):
return context.memfilectx(path=path,
data='added',
islink=False,
isexec=False,
copied=False)
ctx = context.memctx(self.repo,
parents,
'automated test',
['added_bogus_file', 'other_added_file', ],
filectxfn,
'testy',
'2008-12-21 16:32:00 -0500',
{'branch': 'localbranch', })
self.repo.commitctx(ctx)
self.assertEqual(self.repo['tip'].branch(), 'localbranch')
beforerebasehash = self.repo['tip'].node()
hg.update(self.repo, 'tip')
wrappers.rebase(rebase.rebase, self.ui(), self.repo, svn=True)
self.assertEqual(self.repo['tip'].branch(), 'localbranch')
self.assertEqual(self.repo['tip'].parents()[0].parents()[0], self.repo[0])
self.assertNotEqual(beforerebasehash, self.repo['tip'].node())
开发者ID:chaptastic,项目名称:config_files,代码行数:25,代码来源:test_utility_commands.py
示例12: puttags
def puttags(self, tags):
try:
parentctx = self.repo[self.tagsbranch]
tagparent = parentctx.node()
except error.RepoError:
parentctx = None
tagparent = nullid
try:
oldlines = sorted(parentctx['.hgtags'].data().splitlines(True))
except:
oldlines = []
newlines = sorted([("%s %s\n" % (tags[tag], tag)) for tag in tags])
if newlines == oldlines:
return None, None
data = "".join(newlines)
def getfilectx(repo, memctx, f):
return context.memfilectx(f, data, False, False, None)
self.ui.status(_("updating tags\n"))
date = "%s 0" % int(time.mktime(time.gmtime()))
extra = {'branch': self.tagsbranch}
ctx = context.memctx(self.repo, (tagparent, None), "update tags",
[".hgtags"], getfilectx, "convert-repo", date,
extra)
self.repo.commitctx(ctx)
return hex(self.repo.changelog.tip()), hex(tagparent)
开发者ID:MezzLabs,项目名称:mercurial,代码行数:28,代码来源:hg.py
示例13: test_cant_push_with_changes
def test_cant_push_with_changes(self):
repo = self.repo
def file_callback(repo, memctx, path):
return compathacks.makememfilectx(repo,
path=path,
data='foo',
islink=False,
isexec=False,
copied=False)
ctx = context.memctx(repo,
(repo['default'].node(), node.nullid),
'automated test',
['adding_file'],
file_callback,
'an_author',
'2008-10-07 20:59:48 -0500',
{'branch': 'default', })
new_hash = repo.commitctx(ctx)
hg.update(repo, repo['tip'].node())
# Touch an existing file
repo.wwrite('beta', 'something else', '')
try:
self.pushrevisions()
except hgutil.Abort:
pass
tip = self.repo['tip']
self.assertEqual(new_hash, tip.node())
开发者ID:fuzzball81,项目名称:dotfiles,代码行数:27,代码来源:test_push_command.py
示例14: _commitcontext
def _commitcontext(rdst, parents, ctx, dstfiles, getfilectx, revmap):
mctx = context.memctx(rdst, parents, ctx.description(), dstfiles,
getfilectx, ctx.user(), ctx.date(), ctx.extra())
ret = rdst.commitctx(mctx)
lfutil.copyalltostore(rdst, ret)
rdst.setparents(ret)
revmap[ctx.node()] = rdst.changelog.tip()
开发者ID:RayFerr000,项目名称:PLTL,代码行数:7,代码来源:lfcommands.py
示例15: commit
def commit(self, items):
def file_callback(repo, memctx, path):
return context.memfilectx(
path=path,
data=items[path],
islink=False,
isexec=False,
copied=False,
)
local_repo = self._local_repo
remote_repo = self._remote_repo
lock = local_repo.lock()
try:
if remote_repo:
local_repo.pull(self._remote_repo)
ctx = context.memctx(
repo=local_repo,
parents=('tip', None),
text=revision.message,
files=items.keys(),
filectxfn=file_callback,
user=str(revision.user.id),
)
version = node.hex(local_repo.commitctx(ctx))
# TODO: if we want the working copy of the repository to be updated as well add logic to enable this.
# hg.update(local_repo, local_repo['tip'].node())
if remote_repo:
local_repo.push(remote_repo)
return version
finally:
lock.release()
开发者ID:acdha,项目名称:django-versions,代码行数:34,代码来源:base.py
示例16: test_cant_push_empty_ctx
def test_cant_push_empty_ctx(self):
repo = self.repo
def file_callback(repo, memctx, path):
if path == 'adding_file':
return compathacks.makememfilectx(repo,
path=path,
data='foo',
islink=False,
isexec=False,
copied=False)
raise IOError()
ctx = context.memctx(repo,
(repo['default'].node(), node.nullid),
'automated test',
[],
file_callback,
'an_author',
'2008-10-07 20:59:48 -0500',
{'branch': 'default', })
new_hash = repo.commitctx(ctx)
hg.update(repo, repo['tip'].node())
old_tip = repo['tip'].node()
self.pushrevisions()
tip = self.repo['tip']
self.assertEqual(tip.node(), old_tip)
开发者ID:fuzzball81,项目名称:dotfiles,代码行数:25,代码来源:test_push_command.py
示例17: copy_commit
def copy_commit(repo, ctx, parent, date):
mf = ctx.manifest()
copied = copies.pathcopies(ctx.p1(), ctx)
def _filectxfn(repo, memctx, path):
if path in mf:
fctx = ctx[path]
flags = fctx.flags()
return context.memfilectx(
fctx.path(),
fctx.data(),
islink='l' in flags,
isexec='x' in flags,
copied=copied.get(path))
raise IOError
new = context.memctx(
repo,
parents=(parent.node(), repo[-1].node()),
text=ctx.description(),
files=ctx.files(),
filectxfn=_filectxfn,
user=ctx.user(),
date=date,
extra=ctx.extra())
return repo.commitctx(new)
开发者ID:jdufresne,项目名称:timetravel,代码行数:26,代码来源:timetravel.py
示例18: _graft
def _graft(repo, rev, mapping):
'''duplicate changeset "rev" with parents from "mapping"'''
oldp1 = rev.p1().node()
oldp2 = rev.p2().node()
newp1 = mapping.get(oldp1, oldp1)
newp2 = mapping.get(oldp2, oldp2)
m = rev.manifest()
def getfilectx(repo, memctx, path):
if path in m:
fctx = rev[path]
flags = fctx.flags()
copied = fctx.renamed()
if copied:
copied = copied[0]
return context.memfilectx(repo, fctx.path(), fctx.data(),
islink='l' in flags,
isexec='x' in flags,
copied=copied)
else:
return None
# If the incoming commit has no parents, but requested a rebase,
# allow it only for the first commit. The null/null commit will always
# be the first commit since we only allow a nullid->nonnullid mapping if the
# incoming commits are a completely distinct history (see `sharedparents` in
# getrevs()), so there's no risk of commits with a single null parent
# accidentally getting translated first.
if oldp1 == nullid and oldp2 == nullid:
if newp1 != nullid:
newp2 = nullid
del mapping[nullid]
if oldp1 != nullid and oldp2 != nullid:
# If it's a merge commit, Mercurial's rev.files() only returns the files
# that are different from both p1 and p2, so it would not capture all of
# the incoming changes from p2 (for instance, new files in p2). The fix
# is to manually diff the rev manifest and it's p1 to get the list of
# files that have changed. We only need to diff against p1, and not p2,
# because Mercurial constructs new commits by applying our specified
# files on top of a copy of the p1 manifest, so we only need the diff
# against p1.
bundlerepo = rev._repo
files = rev.manifest().diff(bundlerepo[oldp1].manifest()).keys()
else:
files = rev.files()
date = rev.date()
if repo.ui.configbool('pushrebase', 'rewritedates'):
date = (time.time(), date[1])
return context.memctx(repo,
[newp1, newp2],
rev.description(),
files,
getfilectx,
rev.user(),
date,
rev.extra(),
).commit()
开发者ID:kilikkuo,项目名称:version-control-tools,代码行数:60,代码来源:__init__.py
示例19: harvest
def harvest(ui, repo, branch, dest="default", **opts):
"""Close and merge a named branch into the destination branch"""
if branch not in repo.branchtags():
ui.warn("Branch %s does not exist! (use 'hg branches' to get a list of branches)\n" % branch)
return
if dest not in repo.branchtags():
ui.warn("Destination branch %s does not exist! (use 'hg branches' to get a list of branches)\n" % branch)
return
heads = repo.branchheads(branch)
if len(heads) == 0:
ui.warn("Cannot harvest branch %s because it is currently closed. \nUse 'hg merge' to merge it manually.\n" % branch)
return
if len(heads) > 1:
ui.warn("Branch %s has multiple heads. \nUse 'hg merge' to merge it manually.\n" % branch)
return
rev = repo.branchtip(branch)
newrev = context.memctx(repo, [rev, None], "Closed branch %s" % branch, [], None, opts.get('user'), opts.get('date'), extra={'close':1, 'branch':branch})
newrev.commit()
#don't need to switch if already on destination branch
curr = repo[None].branch()
if dest != curr:
hg.clean(repo, dest, False)
ui.status("Switched to branch %s before merging\n" % dest)
failed = hg.merge(repo, branch, remind = False)
if not failed:
repo.commit("Merged %s" % branch, opts.get('user'), opts.get('date'), None)
ui.status("Completed merge of %s into %s\n" % (branch, dest))
开发者ID:jbowtie,项目名称:hg-branching,代码行数:33,代码来源:__init__.py
示例20: committags
def committags(self, rev, endbranches):
if not self.addedtags and not self.deletedtags:
return
date = self.fixdate(rev.date)
# determine additions/deletions per branch
branches = {}
for tags in (self.addedtags, self.deletedtags):
for tag, (branch, srcrev) in tags.iteritems():
op = srcrev is None and 'rm' or 'add'
branches.setdefault(branch, []).append((op, tag, srcrev))
for b, tags in branches.iteritems():
fromtag = self.get_path_tag(self.remotename(b))
# modify parent's .hgtags source
parent = self.repo[self.get_parent_revision(rev.revnum, b)]
if '.hgtags' not in parent:
src = ''
else:
src = parent['.hgtags'].data()
for op, tag, r in sorted(tags, reverse=True):
if op == 'add':
if fromtag:
if fromtag in self.tags:
tagged = node.hex(self.tags[fromtag])
else:
tagged = node.hex(self.revmap[
self.get_parent_svn_branch_and_rev(r, b)])
else:
tagged = node.hex(node.nullid)
src += '%s %s\n' % (tagged, tag)
self.tags[tag] = node.bin(tagged), rev.revnum
# add new changeset containing updated .hgtags
def fctxfun(repo, memctx, path):
return context.memfilectx(path='.hgtags', data=src,
islink=False, isexec=False,
copied=None)
extra = self.genextra(rev.revnum, b)
if fromtag:
extra['branch'] = parent.extra().get('branch', 'default')
self.mapbranch(extra, b in endbranches or fromtag)
ctx = context.memctx(self.repo,
(parent.node(), node.nullid),
rev.message or ' ',
['.hgtags'],
fctxfun,
self.authors[rev.author],
date,
extra)
new = self.repo.commitctx(ctx)
if not fromtag and (rev.revnum, b) not in self.revmap:
self.revmap[rev.revnum, b] = new
if b in endbranches:
endbranches.pop(b)
bname = b or 'default'
self.ui.status('Marked branch %s as closed.\n' % bname)
开发者ID:chaptastic,项目名称:config_files,代码行数:59,代码来源:svnmeta.py
注:本文中的mercurial.context.memctx函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论