本文整理汇总了Python中mercurial.hg.update函数的典型用法代码示例。如果您正苦于以下问题:Python update函数的具体用法?Python update怎么用?Python update使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了update函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: finishfold
def finishfold(ui, repo, ctx, oldctx, newnode, opts, internalchanges):
parent = ctx.parents()[0].node()
hg.update(repo, parent)
fd, patchfile = tempfile.mkstemp(prefix='hg-histedit-')
fp = os.fdopen(fd, 'w')
diffopts = patch.diffopts(ui, opts)
diffopts.git = True
gen = patch.diff(repo, parent, newnode, opts=diffopts)
for chunk in gen:
fp.write(chunk)
fp.close()
files = {}
try:
patch.patch(patchfile, ui, cwd=repo.root, files=files, eolmode=None)
finally:
files = patch.updatedir(ui, repo, files)
os.unlink(patchfile)
newmessage = '\n***\n'.join(
[ctx.description(), ] +
[repo[r].description() for r in internalchanges] +
[oldctx.description(), ])
newmessage = ui.edit(newmessage, ui.username())
n = repo.commit(text=newmessage, user=ui.username(), date=max(ctx.date(), oldctx.date()),
extra=oldctx.extra())
return repo[n], [n, ], [oldctx.node(), ctx.node() ], [newnode, ] # xxx
开发者ID:Garoth,项目名称:Configs,代码行数:25,代码来源:__init__.py
示例2: pick
def pick(ui, repo, ctx, ha, opts):
oldctx = repo[ha]
if oldctx.parents()[0] == ctx:
ui.debug('node %s unchanged\n' % ha)
return oldctx, [], [], []
hg.update(repo, ctx.node())
fd, patchfile = tempfile.mkstemp(prefix='hg-histedit-')
fp = os.fdopen(fd, 'w')
diffopts = patch.diffopts(ui, opts)
diffopts.git = True
gen = patch.diff(repo, oldctx.parents()[0].node(), ha, opts=diffopts)
for chunk in gen:
fp.write(chunk)
fp.close()
try:
files = {}
try:
patch.patch(patchfile, ui, cwd=repo.root, files=files, eolmode=None)
if not files:
ui.warn(_('%s: empty changeset')
% node.hex(ha))
return ctx, [], [], []
finally:
files = patch.updatedir(ui, repo, files)
os.unlink(patchfile)
except Exception, inst:
raise util.Abort(_('Fix up the change and run '
'hg histedit --continue'))
开发者ID:Garoth,项目名称:Configs,代码行数:28,代码来源:__init__.py
示例3: 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
示例4: 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
示例5: pullrebase
def pullrebase(orig, ui, repo, *args, **opts):
'Call rebase after pull if the latter has been invoked with --rebase'
if opts.get('rebase'):
if opts.get('update'):
del opts['update']
ui.debug('--update and --rebase are not compatible, ignoring '
'the update flag\n')
cmdutil.bail_if_changed(repo)
revsprepull = len(repo)
origpostincoming = commands.postincoming
def _dummy(*args, **kwargs):
pass
commands.postincoming = _dummy
try:
orig(ui, repo, *args, **opts)
finally:
commands.postincoming = origpostincoming
revspostpull = len(repo)
if revspostpull > revsprepull:
rebase(ui, repo, **opts)
branch = repo[None].branch()
dest = repo[branch].rev()
if dest != repo['.'].rev():
# there was nothing to rebase we force an update
hg.update(repo, dest)
else:
orig(ui, repo, *args, **opts)
开发者ID:ThissDJ,项目名称:designhub,代码行数:28,代码来源:rebase.py
示例6: pullrebaseif
def pullrebaseif(orig, ui, repo, *args, **opts):
'''Call rebaseif after pull if the latter has been invoked with --rebaseif'''
# this function is taken in verbatim from rebase extension, with rebase replaced with rebaseif
if opts.get('rebaseif'):
if opts.get('update'):
del opts['update']
ui.debug(_('--update and --rebaseif are not compatible, ignoring the update flag\n'))
try:
cmdutil.bailifchanged(repo) # 1.9
except AttributeError:
cmdutil.bail_if_changed(repo) # < 1.9
revsprepull = len(repo)
origpostincoming = commands.postincoming
def _dummy(*args, **kwargs):
pass
commands.postincoming = _dummy
try:
orig(ui, repo, *args, **opts)
finally:
commands.postincoming = origpostincoming
revspostpull = len(repo)
if revspostpull > revsprepull:
rebaseif(ui, repo, **opts)
branch = repo[None].branch()
dest = repo[branch].rev()
if dest != repo['.'].rev():
# there was nothing to rebase we force an update
hg.update(repo, dest)
else:
orig(ui, repo, *args, **opts)
开发者ID:SeanTAllen,项目名称:dotfiles,代码行数:33,代码来源:rebaseif.py
示例7: 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
示例8: 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
示例9: 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
示例10: 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
示例11: 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
示例12: test_push_two_that_modify_same_file
def test_push_two_that_modify_same_file(self):
'''
Push performs a rebase if two commits touch the same file.
This test verifies that code path works.
'''
oldlen = test_util.repolen(self.repo)
oldtiphash = self.repo['default'].node()
changes = [('gamma', 'gamma', 'sometext')]
newhash = self.commitchanges(changes)
changes = [('gamma', 'gamma', 'sometext\n moretext'),
('delta', 'delta', 'sometext\n moretext'),
]
newhash = self.commitchanges(changes)
repo = self.repo
hg.update(repo, newhash)
commands.push(repo.ui, repo)
self.assertEqual(test_util.repolen(self.repo), oldlen + 2)
# verify that both commits are pushed
commit1 = self.repo['tip']
self.assertEqual(commit1.files(), ['delta', 'gamma'])
prefix = 'svn:' + self.repo.svnmeta().uuid
self.assertEqual(util.getsvnrev(commit1),
prefix + '/branches/[email protected]')
commit2 = commit1.parents()[0]
self.assertEqual(commit2.files(), ['gamma'])
self.assertEqual(util.getsvnrev(commit2),
prefix + '/branches/[email protected]')
开发者ID:fuzzball81,项目名称:dotfiles,代码行数:32,代码来源:test_push_command.py
示例13: test_push_without_pushing_children
def test_push_without_pushing_children(self):
'''
Verify that a push of a nontip node, keeps the tip child
on top of the pushed commit.
'''
oldlen = test_util.repolen(self.repo)
oldtiphash = self.repo['default'].node()
changes = [('gamma', 'gamma', 'sometext')]
newhash1 = self.commitchanges(changes)
changes = [('delta', 'delta', 'sometext')]
newhash2 = self.commitchanges(changes)
# push only the first commit
repo = self.repo
hg.update(repo, newhash1)
commands.push(repo.ui, repo)
self.assertEqual(test_util.repolen(self.repo), oldlen + 2)
# verify that the first commit is pushed, and the second is not
commit2 = self.repo['tip']
self.assertEqual(commit2.files(), ['delta', ])
self.assertEqual(util.getsvnrev(commit2), None)
commit1 = commit2.parents()[0]
self.assertEqual(commit1.files(), ['gamma', ])
prefix = 'svn:' + self.repo.svnmeta().uuid
self.assertEqual(util.getsvnrev(commit1),
prefix + '/branches/[email protected]')
开发者ID:fuzzball81,项目名称:dotfiles,代码行数:30,代码来源:test_push_command.py
示例14: 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
示例15: pullrebase
def pullrebase(orig, ui, repo, *args, **opts):
'Call rebase after pull if the latter has been invoked with --rebase'
if opts.get('rebase'):
if opts.get('update'):
del opts['update']
ui.debug('--update and --rebase are not compatible, ignoring '
'the update flag\n')
movemarkfrom = repo['.'].node()
cmdutil.bailifchanged(repo)
revsprepull = len(repo)
origpostincoming = commands.postincoming
def _dummy(*args, **kwargs):
pass
commands.postincoming = _dummy
try:
orig(ui, repo, *args, **opts)
finally:
commands.postincoming = origpostincoming
revspostpull = len(repo)
if revspostpull > revsprepull:
rebase(ui, repo, **opts)
branch = repo[None].branch()
dest = repo[branch].rev()
if dest != repo['.'].rev():
# there was nothing to rebase we force an update
hg.update(repo, dest)
if bookmarks.update(repo, [movemarkfrom], repo['.'].node()):
ui.status(_("updating bookmark %s\n")
% repo._bookmarkcurrent)
else:
if opts.get('tool'):
raise util.Abort(_('--tool can only be used with --rebase'))
orig(ui, repo, *args, **opts)
开发者ID:Pelonza,项目名称:Learn2Mine-Main,代码行数:34,代码来源:rebase.py
示例16: 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
示例17: fold
def fold(ui, repo, ctx, ha, opts):
oldctx = repo[ha]
hg.update(repo, ctx.node())
fd, patchfile = tempfile.mkstemp(prefix='hg-histedit-')
fp = os.fdopen(fd, 'w')
diffopts = patch.diffopts(ui, opts)
diffopts.git = True
diffopts.ignorews = False
diffopts.ignorewsamount = False
diffopts.ignoreblanklines = False
gen = patch.diff(repo, oldctx.parents()[0].node(), ha, opts=diffopts)
for chunk in gen:
fp.write(chunk)
fp.close()
try:
files = set()
try:
applypatch(ui, repo, patchfile, files=files, eolmode=None)
if not files:
ui.warn(_('%s: empty changeset')
% node.hex(ha))
return ctx, [], [], []
finally:
os.unlink(patchfile)
except Exception, inst:
raise util.Abort(_('Fix up the change and run '
'hg histedit --continue'))
开发者ID:SeanTAllen,项目名称:dotfiles,代码行数:27,代码来源:hg_histedit.py
示例18: 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
示例19: finishfold
def finishfold(ui, repo, ctx, oldctx, newnode, opts, internalchanges):
parent = ctx.parents()[0].node()
hg.update(repo, parent)
fd, patchfile = tempfile.mkstemp(prefix='hg-histedit-')
fp = os.fdopen(fd, 'w')
diffopts = patch.diffopts(ui, opts)
diffopts.git = True
diffopts.ignorews = False
diffopts.ignorewsamount = False
diffopts.ignoreblanklines = False
gen = patch.diff(repo, parent, newnode, opts=diffopts)
for chunk in gen:
fp.write(chunk)
fp.close()
files = set()
try:
applypatch(ui, repo, patchfile, files=files, eolmode=None)
finally:
os.unlink(patchfile)
newmessage = '\n***\n'.join(
[ctx.description(), ] +
[repo[r].description() for r in internalchanges] +
[oldctx.description(), ])
# If the changesets are from the same author, keep it.
if ctx.user() == oldctx.user():
username = ctx.user()
else:
username = ui.username()
newmessage = ui.edit(newmessage, username)
n = repo.commit(text=newmessage, user=username, date=max(ctx.date(), oldctx.date()),
extra=oldctx.extra())
return repo[n], [n, ], [oldctx.node(), ctx.node() ], [newnode, ] # xxx
开发者ID:SeanTAllen,项目名称:dotfiles,代码行数:32,代码来源:hg_histedit.py
示例20: domergecmd
def domergecmd(ui, repo, *revs, **opts):
node = (list(revs) + opts.get('rev'))[0]
originalCtx = repo[None].parents()[0]
originalRev = originalCtx.rev()
ui.write('Updating to revision %s \n' % node)
hg.updaterepo(repo, node, True)
defaultRev = repo['default'].rev()
ui.write('Merging with default revision %s \n' % defaultRev)
hg.merge(repo, defaultRev)
#TODO: handle conflict case
ui.write('Committing after merge... \n')
commitMsg = getMergeDescription(repo[None].parents()[0].description())
ui.write(' Commit message: %s \n' % commitMsg)
repo.commit(commitMsg)
if (originalRev != repo[None].parents()[0].parents()[0].rev()): # update to original rev in case branches are different
ui.write('Updating to original revision %s \n' % originalRev)
hg.update(repo, originalRev)
return 0
开发者ID:nguyen190887,项目名称:MercurialExt-DefaultMerge,代码行数:25,代码来源:defaultmerge.py
注:本文中的mercurial.hg.update函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论