本文整理汇总了Python中mercurial.commands.log函数的典型用法代码示例。如果您正苦于以下问题:Python log函数的具体用法?Python log怎么用?Python log使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了log函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: urls
def urls(ui, repo, *paths, **opts):
'''Display a list of urls for the last several commits.
These are merely heuristic guesses and are intended for pasting into
bugs after landing. If that makes no sense to you, then you are probably
not the intended audience. It's mainly a Mozilla thing.
Note that this will display the URL for your default repo, which may very
well be something local. So you may need to give your outbound repo as
an argument.
'''
opts['template'] = '{node|short} {desc|firstline}\n'
ui.pushbuffer()
commands.log(ui, repo, **opts)
lines = ui.popbuffer()
if len(paths) == 0:
paths = ['default']
ui.pushbuffer()
commands.paths(ui, repo, *paths)
url = ui.popbuffer().rstrip()
url = re.sub(r'^\w+', 'http', url)
url = re.sub(r'(\w|\%|\.|-)+\@', '', url) # Remove usernames
for line in lines.split('\n'):
if len(line) > 0:
rev, desc = line.split(' ', 1)
ui.write(url + '/rev/' + rev + '\n ' + desc + '\n\n')
示例2: list_commits
def list_commits(self, branch):
if self.vcs_type == 'git':
branch = branch or 'HEAD'
# using walker and a ref (branch)
branches = self.r.get_refs()
if branch not in branches:
branch = 'HEAD'
if branch in branches:
w = self.r.get_walker([self.r.refs[branch]])
#w = r.get_walker([r.refs['refs/heads/sqlite']])
l = [x.commit for x in w]
else:
l = ["Nothing has yet been done on your repo..."]
elif self.vcs_type == 'hg':
branch = branch or 'default'
branches = self.r.branchmap().keys()
if branch not in branches:
branch = 'default'
#if s['branch'] not in branches:
try:
self.ui.pushbuffer()
hg.log(self.ui, self.r, branch=[branch])
l = self.ui.popbuffer().split('\n\n')
except:
branch = 'default'
l = ["Nothing has yet been done on your repo..."]
return branch, l
示例3: test_svn_revsets
def test_svn_revsets(self):
repo = self._load_fixture_and_fetch('two_revs.svndump')
# we want one commit that isn't from Subversion
self.commitchanges([('foo', 'foo', 'frobnicate\n')])
defaults = {'date': None, 'rev': ['fromsvn()'], 'user': None}
ui = CapturingUI()
commands.log(ui, repo, template='{rev}:{svnrev} ', **defaults)
self.assertEqual(ui._output, '0:2 1:3 ')
defaults = {'date': None, 'rev': ['svnrev(2)'], 'user': None}
ui = CapturingUI()
commands.log(ui, repo, template='{rev}:{svnrev} ', **defaults)
self.assertEqual(ui._output, '0:2 ')
defaults = {'date': None, 'rev': ['fromsvn(1)'], 'user': None}
self.assertRaises(error.ParseError,
commands.log, self.ui(), repo,
template='{rev}:{svnrev} ', **defaults)
defaults = {'date': None, 'rev': ['svnrev(1, 2)'], 'user': None}
self.assertRaises(error.ParseError,
commands.log, self.ui(), repo,
template='{rev}:{svnrev} ', **defaults)
示例4: get_version_info
def get_version_info(data_dir, path, info_encoding):
"""
Obtains information about a file via Mercurial Python API
arguments:
data_dir -- path to a Mercurial repository (= riki data directory)
path -- a file we want log information about
info_encoding -- encoding used on data fetched from hg (system dependent)
returns:
a dictionary {'date': str, 'user': str, 'changeset': str, 'summary' : str}
"""
from mercurial import commands, ui, hg, error
if type(path) is unicode: # mercurial API does not like unicode path
path = path.encode('utf-8')
ans = {}
try:
repo = hg.repository(ui.ui(), data_dir)
repo.ui.pushbuffer()
commands.log(repo.ui, repo, path)
output = repo.ui.popbuffer()
for item in re.split(r'\n', output):
srch = re.match(r'^(\w+):\s+(.+)$', item)
if srch:
v = srch.groups()[1]
ans[srch.groups()[0]] = v if info_encoding.lower() == 'utf-8' else v.decode(info_encoding)
except error.Abort as e:
logging.getLogger(__name__).warning('Failed to fetch version info about [%s]: %s' % (path, e))
if 'user' not in ans:
ans['user'] = 'unknown'
return ans
示例5: hg_log
def hg_log():
opts = { 'template': '{rev} {desc}\n', 'rev': None, 'date': None, 'user': None }
_ui.pushbuffer()
commands.log(_ui, get_sandbox_repo(), **opts)
output = _ui.popbuffer()
return output
示例6: get_revision_before_date
def get_revision_before_date(self, date):
datestr = "<%s" % self.date_as_string(date)
branch = self.repo[None].branch()
self.ui.pushbuffer()
commands.log(self.ui, self.repo, branch=[branch], template="{node}\n", date=datestr, rev='', user='', limit=10)
hexids = self.ui.popbuffer()
#loop over up to 10 changesets to find first non-bogus one
for hexid in hexids.split():
if not self.changeset_is_bogus(self.repo[hexid]):
return hexid.strip()
return None
示例7: log
def log(self, filename):
self.hgui.pushbuffer()
commands.log(self.hgui, self.repo, filename, follow=True, date="", rev="", user="")
_log=self.hgui.popbuffer()
changesets=[_c for _c in _log.split('\n\n') if _c not in ('')]
history=[]
for changeset in changesets:
_dict={}
for _f in changeset.split("\n"):
kkk, vvv=_f.split(": ")
_dict[kkk.strip()]=vvv.strip()
history.append(_dict)
return history
示例8: security_check
def security_check(ui, repo, **kwargs):
ui.debug("running security_check\n")
error = False
ui.pushbuffer()
_quiet(
ui,
lambda: commands.log(
ui, repo, rev=["%s:tip" % kwargs["node"]], template="{node}\n", date=None, user=None, logfile=None
),
)
nodes = ui.popbuffer().split("\n")
# reenable this code if we need to blacklist a node
for node in nodes:
if node.startswith("8555e8551203") or node.startswith("e09bb3ece6c7"):
ui.warn("blacklisted changeid found: node %s is blacklisted\n" % node)
error = True # fail the push
# Look for blacklisted bugs
blacklist = [
# Serrano
580489,
604354,
# Wasabi
507624,
# Cyril
570049,
628834,
]
bugs = re.compile("(%s)" % "|".join([str(bug) for bug in blacklist]))
ui.pushbuffer()
_quiet(
ui,
lambda: commands.log(
ui, repo, rev=["%s:tip" % kwargs["node"]], template="{desc}", date=None, user=None, logfile=None
),
)
descs = ui.popbuffer()
searchDescs = bugs.search(descs)
if searchDescs:
ui.warn("blacklisted bug found: %s\n" % searchDescs.groups()[0])
error = True
return error
示例9: perflog
def perflog(ui, repo, **opts):
timer, fm = gettimer(ui, opts)
ui.pushbuffer()
timer(lambda: commands.log(ui, repo, rev=[], date='', user='',
copies=opts.get('rename')))
ui.popbuffer()
fm.end()
示例10: perftemplating
def perftemplating(ui, repo, **opts):
timer, fm = gettimer(ui, opts)
ui.pushbuffer()
timer(lambda: commands.log(ui, repo, rev=[], date='', user='',
template='{date|shortdate} [{rev}:{node|short}]'
' {author|person}: {desc|firstline}\n'))
ui.popbuffer()
fm.end()
示例11: getLog
def getLog(_ui, srepo, opts):
_ui.pushbuffer()
try:
commands.log(_ui, srepo, **opts)
logOutput = _ui.popbuffer()
except error.ParseError, e:
# Some mercurial versions have a bug that results in
# saving a subrepo node id in the .hgsubstate file
# which ends with a "+" character. If that is the
# case, add a warning to the output, but try to
# get the revision information anyway
logOutput = ''
for n, rev in enumerate(opts['rev']):
if rev.endswith('+'):
logOutput += _('[WARNING] Invalid subrepo '
'revision ID:\n\t%s\n\n') % rev
opts['rev'][n] = rev[:-1]
commands.log(_ui, srepo, **opts)
logOutput += _ui.popbuffer()
示例12: glog
def glog(ui, repo, *pats, **opts):
"""show revision history alongside an ASCII revision graph
Print a revision history alongside a revision graph drawn with
ASCII characters.
Nodes printed as an @ character are parents of the working
directory.
"""
opts['graph'] = True
return commands.log(ui, repo, *pats, **opts)
示例13: rhlog
def rhlog(ui, repo, *pats, **opts):
rev = opts.pop('rev')
bra0 = opts.pop('branch')
from_rev = urllib.unquote_plus(opts.pop('from', None))
to_rev = urllib.unquote_plus(opts.pop('to' , None))
bra = urllib.unquote_plus(opts.pop('rhbranch', None))
from_rev = from_rev.replace('"', '\\"')
to_rev = to_rev.replace('"', '\\"')
opts['rev'] = ['"%s":"%s"' % (from_rev, to_rev)]
opts['branch'] = [bra]
return commands.log(ui, repo, *map(urllib.unquote_plus, pats), **opts)
示例14: _getLog
def _getLog(self, limit=None):
"""Read log entries into a list of dictionaries."""
self.ui.pushbuffer()
commands.log(self.ui, self.repo, limit=limit, date=None, rev=None, user=None)
res = self.ui.popbuffer().strip()
logList = []
for logentry in res.split("\n\n"):
log = {}
logList.append(log)
for line in logentry.split("\n"):
k, v = line.split(":", 1)
assert k in ("changeset", "tag", "user", "date", "summary")
log[k.strip()] = v.strip()
log["parsed_date"] = util.parseTimeString(log["date"])
local_id, unid = log["changeset"].split(":")
log["local_id"] = int(local_id)
log["unid"] = unid
# pprint(logList)
return logList
示例15: hg_commits
def hg_commits(filename):
face = ui.ui()
repo = hg.repository(face, blog_dir)
location = get_location(filename)
face.pushbuffer()
commands.log(face, repo, os.path.join(blog_dir, location, filename),
date='', rev=[], follow=True,
template="node:{node}\ndesc:{desc}\nmove:{file_copies}\n\n")
output = face.popbuffer()
commit = []
commits = []
for line in output.splitlines():
if line:
commit.append(line.split(':'))
else:
commits.append(dict(commit))
commit = []
return commits