本文整理汇总了Python中mercurial.commands.commit函数的典型用法代码示例。如果您正苦于以下问题:Python commit函数的具体用法?Python commit怎么用?Python commit使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了commit函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: qdelete_wrapper
def qdelete_wrapper(self, repo, *patches, **opts):
'''This function takes a list of patches, which makes the message
substitution rather weird. %a and %p will be replaced with the
action ('DELETE') and patch name, as usual, but one line per patch
will be generated. In addition the %m (multi?) replacement string,
if given, will be replaced with a prefix message "DELETE (n)
patches: patch1 patch2..." that is NOT repeated per patch. It
probably would have been cleaner to give two formats, one for the
header and one for the per-patch lines.'''
mqmessage = opts.pop('mqmessage', None)
mqcommit, q, r = mqcommit_info(self, repo, opts)
if mqcommit and mqmessage:
patchnames = [ q.lookup(p) for p in patches ]
mq.delete(self, repo, *patches, **opts)
if mqcommit and mqmessage:
mqmessage = mqmessage.replace("%a", 'DELETE')
if (len(patches) > 1) and (mqmessage.find("%m") != -1):
rep_message = mqmessage.replace("%m", "")
mqmessage = "DELETE %d patches: %s\n" % (len(patches), " ".join(patchnames))
mqmessage += "\n".join([ rep_message.replace("%p", p) for p in patchnames ])
else:
mqmessage = mqmessage.replace("%m", "")
mqmessage = "\n".join([ mqmessage.replace("%p", p) for p in patchnames ])
commands.commit(r.ui, r, message=mqmessage)
开发者ID:hotsphink,项目名称:mqext,代码行数:28,代码来源:__init__.py
示例2: test_file_only_copied
def test_file_only_copied(self):
"""Change by copying a file with no content editing"""
ui = mock_ui()
hgcommands.init(ui, self.repo)
hgrepo = repository(ui, self.repo)
(
open(hgrepo.pathto("file.dtd"), "w").write(
"""
<!ENTITY key1 "Hello">
<!ENTITY key2 "Cruel">
"""
)
)
hgcommands.addremove(ui, hgrepo)
hgcommands.commit(ui, hgrepo, user="Jane Doe <[email protected]>", message="initial commit")
rev0 = hgrepo[0].hex()
hgcommands.copy(ui, hgrepo, hgrepo.pathto("file.dtd"), hgrepo.pathto("newnamefile.dtd"))
hgcommands.commit(ui, hgrepo, user="Jane Doe <[email protected]>", message="Second commit")
rev1 = hgrepo[1].hex()
Repository.objects.create(name=self.repo_name, url="http://localhost:8001/%s/" % self.repo_name)
url = reverse("pushes.views.diff")
response = self.client.get(url, {"repo": self.repo_name, "from": rev0, "to": rev1})
eq_(response.status_code, 200)
html_diff = response.content.split("Changed files:")[1]
ok_("copied from file.dtd" in re.sub("<.*?>", "", html_diff))
ok_(re.findall(">\s*newnamefile\.dtd\s*<", html_diff))
ok_(not re.findall(">\s*Hello\s*<", html_diff))
ok_(not re.findall(">\s*Cruel\s*<", html_diff))
开发者ID:gerv,项目名称:elmo,代码行数:31,代码来源:tests.py
示例3: qrefresh_wrapper
def qrefresh_wrapper(orig, self, repo, *pats, **opts):
mqmessage = opts.pop('mqmessage', '') or '%a: %p\n%s%Q'
mqcommit, q, r = mqcommit_info(self, repo, opts)
diffstat = ""
if mqcommit and mqmessage:
if mqmessage.find("%s") != -1:
self.pushbuffer()
m = cmdutil.matchmod.match(repo.root, repo.getcwd(), [],
opts.get('include'), opts.get('exclude'),
'relpath', auditor=repo.auditor)
cmdutil.diffordiffstat(self, repo, mdiff.diffopts(),
repo.dirstate.parents()[0], None, m,
stat=True)
diffstat = self.popbuffer()
ret = orig(self, repo, *pats, **opts)
if ret:
return ret
if mqcommit and len(q.applied) > 0:
patch = q.applied[-1].name
if r is None:
raise util.Abort("no patch repository found when using -Q option")
mqmessage = substitute_mqmessage(mqmessage, repo, { 'p': patch,
'a': 'UPDATE',
's': diffstat })
commands.commit(r.ui, r, message=mqmessage)
开发者ID:Nephyrin,项目名称:bzexport,代码行数:28,代码来源:__init__.py
示例4: test_files
def test_files(self):
new_file = 'a.rst'
# add a file to repo
with codecs.open(os.path.join(self.repo_path, new_file), 'w',
encoding='utf-8') as fp:
fp.write('testing\n')
# before commit files
ctx = self.get_ctx()
for f in self.repo_files:
self.assertTrue(f in ctx.files, 'file not found in stable state: '
'%s' % f)
self.assertFalse(new_file in ctx.files, 'stable state is '
'listing uncommited file.')
commands.commit(self.ui, self.repo, message='foo', user='foo',
addremove=True)
# after commit files
ctx = self.get_ctx()
for f in self.repo_files + [new_file]:
self.assertTrue(f in ctx.files, 'file not found in stable '
'state: %s' % f)
开发者ID:foyslei,项目名称:blohg,代码行数:25,代码来源:changectx.py
示例5: test_filectx_needs_reload
def test_filectx_needs_reload(self):
# add a file to repo
with codecs.open(os.path.join(self.repo.path, 'a.rst'), 'w',
encoding='utf-8') as fp:
fp.write('testing\n')
ctx = self.get_ctx()
filectx = ctx.get_filectx('a.rst')
self.assertTrue(ctx.filectx_needs_reload(filectx))
with codecs.open(os.path.join(self.repo.path, 'a.rst'), 'w',
encoding='utf-8') as fp:
fp.write('testing\n')
# should always be true
self.assertTrue(ctx.filectx_needs_reload(filectx))
commands.commit(self.ui, self.repo, message='foo', user='foo',
addremove=True)
# should need a reload now, after the commit
self.assertTrue(ctx.filectx_needs_reload(filectx))
# reload
ctx = self.get_ctx()
filectx = ctx.get_filectx('a.rst')
# should still need a reload, right after the reload
self.assertTrue(ctx.filectx_needs_reload(filectx))
开发者ID:foyslei,项目名称:blohg,代码行数:31,代码来源:changectx.py
示例6: update_html
def update_html(head, jar_chk, zip_chk):
ui_ = ui.ui()
repo = hg.repository(ui_, REPO_DIR)
site_usk = PUBLIC_SITE % (latest_site_index(repo) + 1)
html = simple_templating(open(INDEX_HTML_TEMPLATE).read(),
{'__HEAD__':head,
'__JAR_CHK__': jar_chk,
'__SRC_CHK__': zip_chk,
'__RELEASE_NOTES__' : html_escape(get_release_notes()),
'__SITE_USK__': site_usk,
'__INDEX_FDW__': FREENET_DOC_WIKI_IDX,
'__INDEX_FNIKI__': FNIKI_IDX,
'__INDEX_REPO__': REPO_IDX,
'__INDEX_DFC__': DFC_IDX,
})
updated = open(INDEX_HTML, 'w')
updated.write(html)
updated.close()
if JUST_CHECK_HTML:
print "Just checking html. Didn't tag repo."
return
commit_msg = "index.html:%s" % head
commands.commit(ui_, repo, pat = (INDEX_HTML, ),
include = [], addremove = None, close_branch = None,
user = '', date = '',
exclude = [], logfile = '',
message = commit_msg)
tag_site_index(ui_, repo)
开发者ID:SeekingFor,项目名称:jfniki,代码行数:32,代码来源:cut_release.py
示例7: record
def record(ui, repo, *pats, **opts):
'''interactively select changes to commit
If a list of files is omitted, all changes reported by :hg:`status`
will be candidates for recording.
See :hg:`help dates` for a list of formats valid for -d/--date.
You will be prompted for whether to record changes to each
modified file, and for files with multiple changes, for each
change to use. For each query, the following responses are
possible::
y - record this change
n - skip this change
e - edit this change manually
s - skip remaining changes to this file
f - record remaining changes to this file
d - done, skip remaining changes and files
a - record all changes to all remaining files
q - quit, recording no changes
? - display help
This command is not available when committing a merge.'''
opts["interactive"] = True
backup = ui.backupconfig('experimental', 'crecord')
try:
ui.setconfig('experimental', 'crecord', False, 'record')
commands.commit(ui, repo, *pats, **opts)
finally:
ui.restoreconfig(backup)
开发者ID:pierfort123,项目名称:mercurial,代码行数:35,代码来源:record.py
示例8: test_file_edited_broken_encoding
def test_file_edited_broken_encoding(self):
"""Change by editing a good with a broken edit"""
ui = mock_ui()
hgcommands.init(ui, self.repo)
hgrepo = repository(ui, self.repo)
(open(hgrepo.pathto("file.dtd"), "w").write(u'<!ENTITY key1 "Hello">\n'))
hgcommands.addremove(ui, hgrepo)
hgcommands.commit(ui, hgrepo, user="Jane Doe <[email protected]>", message="initial commit")
rev0 = hgrepo[0].hex()
# do this to trigger an exception on Mozilla.Parser.readContents
_content = u'<!ENTITY key1 "Hell\xe3">\n'
(codecs.open(hgrepo.pathto("file.dtd"), "w", "latin1").write(_content))
hgcommands.commit(ui, hgrepo, user="Jane Doe <[email protected]>", message="Second commit")
rev1 = hgrepo[1].hex()
repo_url = "http://localhost:8001/" + self.repo_name + "/"
Repository.objects.create(name=self.repo_name, url=repo_url)
url = reverse("pushes.views.diff")
response = self.client.get(url, {"repo": self.repo_name, "from": rev0, "to": rev1})
eq_(response.status_code, 200)
html_diff = response.content.split("Changed files:")[1]
ok_("Cannot parse file" in html_diff)
# also, expect a link to this file
change_url = repo_url + "file/%s/file.dtd" % rev1
ok_('href="%s"' % change_url in html_diff)
开发者ID:gerv,项目名称:elmo,代码行数:30,代码来源:tests.py
示例9: wkcommit
def wkcommit(ui, repo, *pats, **opts):
'''Another Mercurial Extension
this extension using clang-format to format files with suffix like ``.cpp``,
``.c`` and ``.h`` before you commit them to the local repository.
How to Use this Extension:(.hgrc)
[extensions]
wkcommit = /path/to/this/extension
'''
modified, added, removed, deleted, unknown, ignored, clean = repo.status()
if len(pats) == 0:
for file in (modified + added):
clangFormat(ui, file)
else:
for file in pats:
if file in (modified + added):
clangFormat(ui, file)
ui.flush()
commands.commit(ui, repo, *pats, **opts)
return 0
开发者ID:jay2013,项目名称:justforfun,代码行数:26,代码来源:wkcommit.py
示例10: test_handlePushes_repeated
def test_handlePushes_repeated(self):
repo = Repository.objects.create(name="mozilla-central", url="file:///" + self.repo)
self.assertEqual(handlePushes(repo.pk, []), None)
ui = mock_ui()
hgcommands.init(ui, self.repo)
hgrepo = repository(ui, self.repo)
(
open(hgrepo.pathto("file.dtd"), "w").write(
"""
<!ENTITY key1 "Hello">
<!ENTITY key2 "Cruel">
"""
)
)
hgcommands.addremove(ui, hgrepo)
hgcommands.commit(ui, hgrepo, user="Jane Doe <[email protected]>", message="initial commit")
rev0 = hgrepo[0].hex()
timestamp = int(time.time())
pushjs0 = PushJS(100, {"date": timestamp, "changesets": [rev0], "user": "jdoe"})
# first time
pushes_initial = Push.objects.all().count()
result = handlePushes(repo.pk, [pushjs0])
self.assertEqual(result, 1)
pushes_after = Push.objects.all().count()
self.assertEqual(pushes_initial, pushes_after - 1)
# a second time should be harmless
result = handlePushes(repo.pk, [pushjs0])
self.assertEqual(result, 1)
pushes_after_after = Push.objects.all().count()
self.assertEqual(pushes_after, pushes_after_after)
开发者ID:gerv,项目名称:elmo,代码行数:35,代码来源:tests.py
示例11: setUp
def setUp(self):
self.repo_path = mkdtemp()
self.ui = ui.ui()
self.ui.setconfig('ui', 'username', 'foo <[email protected]>')
self.ui.setconfig('ui', 'quiet', True)
commands.init(self.ui, self.repo_path)
self.repo = hg.repository(self.ui, self.repo_path)
file_dir = os.path.join(self.repo_path, 'content')
if not os.path.isdir(file_dir):
os.makedirs(file_dir)
for i in range(3):
file_path = os.path.join(file_dir, 'page-%i.rst' % i)
with codecs.open(file_path, 'w', encoding='utf-8') as fp:
fp.write(SAMPLE_PAGE)
commands.add(self.ui, self.repo, file_path)
file_path = os.path.join(file_dir, 'about.rst')
with codecs.open(file_path, 'w', encoding='utf-8') as fp:
fp.write(SAMPLE_PAGE + """
.. aliases: 301:/my-old-post-location/,/another-old-location/""")
commands.add(self.ui, self.repo, file_path)
file_dir = os.path.join(self.repo_path, 'content', 'post')
if not os.path.isdir(file_dir):
os.makedirs(file_dir)
for i in range(3):
file_path = os.path.join(file_dir, 'post-%i.rst' % i)
with codecs.open(file_path, 'w', encoding='utf-8') as fp:
fp.write(SAMPLE_POST)
commands.add(self.ui, self.repo, file_path)
file_path = os.path.join(file_dir, 'foo.rst')
with codecs.open(file_path, 'w', encoding='utf-8') as fp:
# using the page template, because we want to set tags manually
fp.write(SAMPLE_PAGE + """
.. tags: foo, bar, lol""")
commands.add(self.ui, self.repo, file_path)
commands.commit(self.ui, self.repo, message='foo', user='foo')
开发者ID:GoGoBunny,项目名称:blohg,代码行数:35,代码来源:models.py
示例12: _createBranch
def _createBranch(self, branch_name, message, from_branch = None):
if not from_branch is None:
#first update to from_branch
commands.update(self.ui, self.repo, from_branch)
commands.branch(self.ui, self.repo, branch_name)
commands.commit(self.ui, self.repo, message = message)
开发者ID:djm,项目名称:dotfiles,代码行数:7,代码来源:hgflow.py
示例13: test_error_handling
def test_error_handling(self):
"""Test various bad request parameters to the diff_app
and assure that it responds with the right error codes."""
ui = mock_ui()
hgcommands.init(ui, self.repo)
url = reverse("pushes.views.diff")
response = self.client.get(url, {})
eq_(response.status_code, 400)
response = self.client.get(url, {"repo": "junk"})
eq_(response.status_code, 404)
hgrepo = repository(ui, self.repo)
(
open(hgrepo.pathto("file.dtd"), "w").write(
"""
<!ENTITY key1 "Hello">
<!ENTITY key2 "Cruel">
"""
)
)
hgcommands.addremove(ui, hgrepo)
hgcommands.commit(ui, hgrepo, user="Jane Doe <[email protected]>", message="initial commit")
rev0 = hgrepo[0].hex()
Repository.objects.create(name=self.repo_name, url="http://localhost:8001/%s/" % self.repo_name)
# missing 'from' and 'to'
response = self.client.get(url, {"repo": self.repo_name})
eq_(response.status_code, 400)
# missing 'to'
response = self.client.get(url, {"repo": self.repo_name, "from": rev0})
eq_(response.status_code, 400)
开发者ID:gerv,项目名称:elmo,代码行数:34,代码来源:tests.py
示例14: qrefresh_wrapper
def qrefresh_wrapper(self, repo, *pats, **opts):
mqmessage = opts.pop('mqmessage', None)
mqcommit, q, r = mqcommit_info(self, repo, opts)
diffstat = ""
if mqcommit and mqmessage:
if mqmessage.find("%s") != -1:
buffer = StringIO.StringIO()
m = cmdutil.match(repo, None, {})
diffopts = mdiff.diffopts()
cmdutil.diffordiffstat(self, repo, diffopts,
repo.dirstate.parents()[0], None, m,
stat=True, fp = buffer)
diffstat = buffer.getvalue()
buffer.close()
mq.refresh(self, repo, *pats, **opts)
if mqcommit and len(q.applied) > 0:
patch = q.applied[-1].name
if r is None:
raise util.Abort("no patch repository found when using -Q option")
mqmessage = mqmessage.replace("%p", patch)
mqmessage = mqmessage.replace("%a", 'UPDATE')
mqmessage = mqmessage.replace("%s", diffstat)
commands.commit(r.ui, r, message=mqmessage)
开发者ID:hotsphink,项目名称:mqext,代码行数:26,代码来源:__init__.py
示例15: test_remove_file_no_parser
def test_remove_file_no_parser(self):
"""Change by removing a file, without parser"""
ui = mock_ui()
hgcommands.init(ui, self.repo)
hgrepo = repository(ui, self.repo)
(open(hgrepo.pathto("file.txt"), "w").write("line 1\nline 2\n"))
hgcommands.addremove(ui, hgrepo)
hgcommands.commit(ui, hgrepo, user="Jane Doe <[email protected]>", message="initial commit")
rev0 = hgrepo[0].hex()
hgcommands.remove(ui, hgrepo, "path:file.txt")
hgcommands.commit(ui, hgrepo, user="Jane Doe <[email protected]>", message="Second commit")
rev1 = hgrepo[1].hex()
repo_url = "http://localhost:8001/%s/" % self.repo_name
Repository.objects.create(name=self.repo_name, url=repo_url)
url = reverse("pushes.views.diff")
response = self.client.get(url, {"repo": self.repo_name, "from": rev0, "to": rev1})
eq_(response.status_code, 200)
html_diff = response.content.split("Changed files:")[1]
ok_(re.findall(">\s*file\.txt\s*<", html_diff))
# 1 removed file
eq_(html_diff.count('<div class="diff file-removed">'), 1)
# also, expect a link to the old revision of the file
change_ref = 'href="%sfile/%s/file.txt"' % (repo_url, rev0)
ok_(change_ref in html_diff)
ok_(not re.findall(">\s*line 1\s*<", html_diff))
ok_(not re.findall(">\s*line 2\s*<", html_diff))
开发者ID:gerv,项目名称:elmo,代码行数:30,代码来源:tests.py
示例16: test_remove_file
def test_remove_file(self):
"""Change by removing a file, with parser"""
ui = mock_ui()
hgcommands.init(ui, self.repo)
hgrepo = repository(ui, self.repo)
(
open(hgrepo.pathto("file.dtd"), "w").write(
"""
<!ENTITY key1 "Hello">
<!ENTITY key2 "Cruel">
"""
)
)
hgcommands.addremove(ui, hgrepo)
hgcommands.commit(ui, hgrepo, user="Jane Doe <[email protected]>", message="initial commit")
rev0 = hgrepo[0].hex()
hgcommands.remove(ui, hgrepo, "path:file.dtd")
hgcommands.commit(ui, hgrepo, user="Jane Doe <[email protected]>", message="Second commit")
rev1 = hgrepo[1].hex()
Repository.objects.create(name=self.repo_name, url="http://localhost:8001/%s/" % self.repo_name)
url = reverse("pushes.views.diff")
response = self.client.get(url, {"repo": self.repo_name, "from": rev0, "to": rev1})
eq_(response.status_code, 200)
html_diff = response.content.split("Changed files:")[1]
ok_(re.findall(">\s*file\.dtd\s*<", html_diff))
# 2 entities with 2 rows each
eq_(html_diff.count('<tr class="line-removed">'), 4)
ok_(re.findall(">\s*key1\s*<", html_diff))
ok_(re.findall(">\s*Hello\s*<", html_diff))
ok_(re.findall(">\s*key2\s*<", html_diff))
ok_(re.findall(">\s*Cruel\s*<", html_diff))
开发者ID:gerv,项目名称:elmo,代码行数:35,代码来源:tests.py
示例17: _commit
def _commit(self, message):
user = self.environ.get("http_authenticator.username") or "Anonymous"
commands.commit(self.provider.ui, self.provider.repo,
self.localHgPath,
addremove=True,
user=user,
message=message)
开发者ID:meeh420,项目名称:wsgidav,代码行数:7,代码来源:hg_dav_provider.py
示例18: commit
def commit(self, path=None, message=None, user=None):
from mercurial import commands, hg, ui, error
log.debug("Commit to Mercurial repository.")
path = path or self.path
message = message or self.message
user = user or self.user
strings = [user.first_name, '<%s>' % user.email]
author = ' '.join(filter(None, strings)) # Only if not empty
# For some reason default push path is not set properly
import configparser, codecs
config = configparser.ConfigParser()
with codecs.open(os.path.join(path, '.hg/hgrc'), 'r', 'utf-8') as f:
try:
config.read_file(f)
except Exception as e:
raise CommitToRepositoryException(str(e))
default_path = config.get('paths', 'default')
try:
u = ui.ui()
u.setconfig('paths', 'default', default_path)
repo = hg.repository(u, path)
commands.commit(u, repo, message=message, user=author)
commands.push(u, repo)
log.info(message)
except Exception as e:
raise CommitToRepositoryException(str(e))
开发者ID:diasks2,项目名称:pontoon,代码行数:33,代码来源:vcs.py
示例19: test_handlePushes_space_files
def test_handlePushes_space_files(self):
repo = Repository.objects.create(name="mozilla-central", url="file:///" + self.repo)
self.assertEqual(handlePushes(repo.pk, []), None)
ui = mock_ui()
hgcommands.init(ui, self.repo)
hgrepo = repository(ui, self.repo)
(
open(hgrepo.pathto("file.dtd "), "w").write( # deliberate trailing space
"""
<!ENTITY key1 "Hello">
<!ENTITY key2 "Cruel">
"""
)
)
hgcommands.addremove(ui, hgrepo)
hgcommands.commit(ui, hgrepo, user="Jane Doe <[email protected]>", message="initial commit")
rev0 = hgrepo[0].hex()
timestamp = int(time.time())
pushjs0 = PushJS(100, {"date": timestamp, "changesets": [rev0], "user": "jdoe"})
handlePushes(repo.pk, [pushjs0])
file_, = File.objects.all()
self.assertEqual(file_.path, "file.dtd ")
开发者ID:gerv,项目名称:elmo,代码行数:27,代码来源:tests.py
示例20: commit
def commit(self):
"""Use the list of files given by the user to commit to the repository"""
# The variable passing schema we use means that we'll have problems
# with a repository named 'on'. We should look into a fix for that.
url = request.environ['routes.url']
# We send out a form with two inputs per file, one hidden with the
# repository, and one checkbox. We get back two values for the file if
# the checkbox is checked, and one otherwise. It's not perfect, but it
# works for now.
message = request.params['message']
if not message:
redirect(url.current(action='index'))
for repo, root in self.repositories:
if root not in request.params:
continue
repochroot = Chroot(repo.root)
try:
files = (repochroot(path.join(repo.root, file)) for file in request.params.getall(root))
except IOError:
error = 'Bad Filename'
redirect(url(controller='dv', action='index', error=error))
self.ui.pushbuffer()
commands.commit(self.ui, repo, message=message, logfile=None, *files)
output = self.ui.popbuffer()
redirect(url.current(action='index'))
开发者ID:dmayle,项目名称:DVDev,代码行数:26,代码来源:dv.py
注:本文中的mercurial.commands.commit函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论