本文整理汇总了Python中mercurial.util.datestr函数的典型用法代码示例。如果您正苦于以下问题:Python datestr函数的具体用法?Python datestr怎么用?Python datestr使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了datestr函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: diff
def diff(self, tmpl, node1, node2, files):
def filterfiles(filters, files):
l = [x for x in files if x in filters]
for t in filters:
if t and t[-1] != os.sep:
t += os.sep
l += [x for x in files if x.startswith(t)]
return l
parity = paritygen(self.stripecount)
def diffblock(diff, f, fn):
yield tmpl(
"diffblock", lines=prettyprintlines(diff), parity=parity.next(), file=f, filenode=hex(fn or nullid)
)
blockcount = webutil.countgen()
def prettyprintlines(diff):
blockno = blockcount.next()
for lineno, l in enumerate(diff.splitlines(1)):
if blockno == 0:
lineno = lineno + 1
else:
lineno = "%d.%d" % (blockno, lineno + 1)
if l.startswith("+"):
ltype = "difflineplus"
elif l.startswith("-"):
ltype = "difflineminus"
elif l.startswith("@"):
ltype = "difflineat"
else:
ltype = "diffline"
yield tmpl(ltype, line=l, lineid="l%s" % lineno, linenumber="% 8s" % lineno)
r = self.repo
c1 = r[node1]
c2 = r[node2]
date1 = util.datestr(c1.date())
date2 = util.datestr(c2.date())
modified, added, removed, deleted, unknown = r.status(node1, node2)[:5]
if files:
modified, added, removed = map(lambda x: filterfiles(files, x), (modified, added, removed))
for f in modified:
to = c1.filectx(f).data()
tn = c2.filectx(f).data()
yield diffblock(mdiff.unidiff(to, date1, tn, date2, f, f), f, tn)
for f in added:
to = None
tn = c2.filectx(f).data()
yield diffblock(mdiff.unidiff(to, date1, tn, date2, f, f), f, tn)
for f in removed:
to = c1.filectx(f).data()
tn = None
yield diffblock(mdiff.unidiff(to, date1, tn, date2, f, f), f, tn)
开发者ID:pombredanne,项目名称:SmartNotes,代码行数:58,代码来源:hgapp_mod.py
示例2: log_api
def log_api(self, branch=None):
def enc(string):
try:
for e in ('utf8', 'latin1', 'windows-1250', 'windows-1252'):
return string.decode(e)
except UnicodeError:
return string.decode('ascii', 'ignore')
repo = hg.repository(ui.ui(), self.repo_path)
as_list, as_dict = [], defaultdict(list)
for rev in repo:
rev_obj = repo[rev]
branch_ = rev_obj.branch()
if branch and branch != branch_:
continue
node = rev_obj.hex()
date = self._parse_date(datestr(rev_obj.date()))
one = dict(branch=branch_, mess=rev_obj.description(), author=rev_obj.user(),
date=date, files=map(enc, rev_obj.files()), tags=rev_obj.tags(),
rev=rev, node=node, short=node[:12]
)
as_list.insert(0, one)
as_dict[branch_].insert(0, one)
return as_list, dict(as_dict)
开发者ID:outcomm,项目名称:dvcswrapper,代码行数:29,代码来源:wrapper.py
示例3: _parse
def _parse(self):
if self.changeset is not None:
return
self.changeset = {}
maxrev = 0
if self.revs:
if len(self.revs) > 1:
raise util.Abort(_('cvs source does not support specifying '
'multiple revs'))
# TODO: handle tags
try:
# patchset number?
maxrev = int(self.revs[0])
except ValueError:
raise util.Abort(_('revision %s is not a patchset number')
% self.revs[0])
d = os.getcwd()
try:
os.chdir(self.path)
id = None
cache = 'update'
if not self.ui.configbool('convert', 'cvsps.cache', True):
cache = None
db = cvsps.createlog(self.ui, cache=cache)
db = cvsps.createchangeset(self.ui, db,
fuzz=int(self.ui.config('convert', 'cvsps.fuzz', 60)),
mergeto=self.ui.config('convert', 'cvsps.mergeto', None),
mergefrom=self.ui.config('convert', 'cvsps.mergefrom', None))
for cs in db:
if maxrev and cs.id > maxrev:
break
id = str(cs.id)
cs.author = self.recode(cs.author)
self.lastbranch[cs.branch] = id
cs.comment = self.recode(cs.comment)
if self.ui.configbool('convert', 'localtimezone'):
cs.date = makedatetimestamp(cs.date[0])
date = util.datestr(cs.date, '%Y-%m-%d %H:%M:%S %1%2')
self.tags.update(dict.fromkeys(cs.tags, id))
files = {}
for f in cs.entries:
files[f.file] = "%s%s" % ('.'.join([str(x)
for x in f.revision]),
['', '(DEAD)'][f.dead])
# add current commit to set
c = commit(author=cs.author, date=date,
parents=[str(p.id) for p in cs.parents],
desc=cs.comment, branch=cs.branch or '')
self.changeset[id] = c
self.files[id] = files
self.heads = self.lastbranch.values()
finally:
os.chdir(d)
开发者ID:CSCI-362-02-2015,项目名称:RedTeam,代码行数:60,代码来源:cvs.py
示例4: log
def log(self, event, *msg, **opts):
global lastblackbox
super(blackboxui, self).log(event, *msg, **opts)
if not '*' in self.track and not event in self.track:
return
if util.safehasattr(self, '_blackbox'):
blackbox = self._blackbox
elif util.safehasattr(self, '_bbopener'):
try:
self._blackbox = self._openlogfile()
except (IOError, OSError) as err:
self.debug('warning: cannot write to blackbox.log: %s\n' %
err.strerror)
del self._bbopener
self._blackbox = None
blackbox = self._blackbox
else:
# certain ui instances exist outside the context of
# a repo, so just default to the last blackbox that
# was seen.
blackbox = lastblackbox
if blackbox:
date = util.datestr(None, '%Y/%m/%d %H:%M:%S')
user = util.getuser()
formattedmsg = msg[0] % msg[1:]
try:
blackbox.write('%s %s> %s' % (date, user, formattedmsg))
except IOError as err:
self.debug('warning: cannot write to blackbox.log: %s\n' %
err.strerror)
lastblackbox = blackbox
开发者ID:pierfort123,项目名称:mercurial,代码行数:34,代码来源:blackbox.py
示例5: send
def send(self, ctx, count, data):
'''send message.'''
p = email.Parser.Parser()
msg = p.parsestr(data)
# store sender and subject
sender, subject = msg['From'], msg['Subject']
del msg['From'], msg['Subject']
# store remaining headers
headers = msg.items()
# create fresh mime message from msg body
text = msg.get_payload()
# for notification prefer readability over data precision
msg = mail.mimeencode(self.ui, text, self.charsets, self.test)
# reinstate custom headers
for k, v in headers:
msg[k] = v
msg['Date'] = util.datestr(format="%a, %d %b %Y %H:%M:%S %1%2")
# try to make subject line exist and be useful
if not subject:
if count > 1:
subject = _('%s: %d new changesets') % (self.root, count)
else:
s = ctx.description().lstrip().split('\n', 1)[0].rstrip()
subject = '%s: %s' % (self.root, s)
maxsubject = int(self.ui.config('notify', 'maxsubject', 67))
if maxsubject and len(subject) > maxsubject:
subject = subject[:maxsubject-3] + '...'
msg['Subject'] = mail.headencode(self.ui, subject,
self.charsets, self.test)
# try to make message have proper sender
if not sender:
sender = self.ui.config('email', 'from') or self.ui.username()
if '@' not in sender or '@localhost' in sender:
sender = self.fixmail(sender)
msg['From'] = mail.addressencode(self.ui, sender,
self.charsets, self.test)
msg['X-Hg-Notification'] = 'changeset %s' % ctx
if not msg['Message-Id']:
msg['Message-Id'] = ('<hg.%s.%s.%[email protected]%s>' %
(ctx, int(time.time()),
hash(self.repo.root), socket.getfqdn()))
msg['To'] = ', '.join(self.subs)
msgtext = msg.as_string(0)
if self.test:
self.ui.write(msgtext)
if not msgtext.endswith('\n'):
self.ui.write('\n')
else:
self.ui.status(_('notify: sending %d subscribers %d changes\n') %
(len(self.subs), count))
mail.sendmail(self.ui, util.email(msg['From']),
self.subs, msgtext)
开发者ID:wangbiaouestc,项目名称:WindowsMingWMC,代码行数:59,代码来源:notify.py
示例6: getcommit
def getcommit(self, rev):
certs = self.mtngetcerts(rev)
return commit(
author=certs["author"],
date=util.datestr(util.strdate(certs["date"], "%Y-%m-%dT%H:%M:%S")),
desc=certs["changelog"],
rev=rev,
parents=self.mtnrun("parents", rev).splitlines(),
branch=certs["branch"])
开发者ID:carlgao,项目名称:lenga,代码行数:9,代码来源:monotone.py
示例7: getcommit
def getcommit(self, rev):
elt = self.changes[rev]
date = util.strdate(elt.get('local_date'), '%a %b %d %H:%M:%S %Z %Y')
desc = elt.findtext('name') + '\n' + elt.findtext('comment', '')
# etree can return unicode objects for name, comment, and author,
# so recode() is used to ensure str objects are emitted.
return common.commit(author=self.recode(elt.get('author')),
date=util.datestr(date, '%Y-%m-%d %H:%M:%S %1%2'),
desc=self.recode(desc).strip(),
parents=self.parents[rev])
开发者ID:cmjonze,项目名称:mercurial,代码行数:10,代码来源:darcs.py
示例8: getcommit
def getcommit(self, rev):
ctx = self.changectx(rev)
parents = [hex(p.node()) for p in ctx.parents() if p.node() != nullid]
if self.saverev:
crev = rev
else:
crev = None
return commit(author=ctx.user(), date=util.datestr(ctx.date()),
desc=ctx.description(), rev=crev, parents=parents,
branch=ctx.branch(), extra=ctx.extra())
开发者ID:c0ns0le,项目名称:cygwin,代码行数:10,代码来源:hg.py
示例9: send
def send(self, node, count, data):
'''send message.'''
p = email.Parser.Parser()
msg = p.parsestr(data)
def fix_subject():
'''try to make subject line exist and be useful.'''
subject = msg['Subject']
if not subject:
if count > 1:
subject = _('%s: %d new changesets') % (self.root, count)
else:
changes = self.repo.changelog.read(node)
s = changes[4].lstrip().split('\n', 1)[0].rstrip()
subject = '%s: %s' % (self.root, s)
maxsubject = int(self.ui.config('notify', 'maxsubject', 67))
if maxsubject and len(subject) > maxsubject:
subject = subject[:maxsubject-3] + '...'
del msg['Subject']
msg['Subject'] = subject
def fix_sender():
'''try to make message have proper sender.'''
sender = msg['From']
if not sender:
sender = self.ui.config('email', 'from') or self.ui.username()
if '@' not in sender or '@localhost' in sender:
sender = self.fixmail(sender)
del msg['From']
msg['From'] = sender
msg['Date'] = util.datestr(format="%a, %d %b %Y %H:%M:%S %1%2")
fix_subject()
fix_sender()
msg['X-Hg-Notification'] = 'changeset ' + short(node)
if not msg['Message-Id']:
msg['Message-Id'] = ('<hg.%s.%s.%[email protected]%s>' %
(short(node), int(time.time()),
hash(self.repo.root), socket.getfqdn()))
msg['To'] = ', '.join(self.subs)
msgtext = msg.as_string(0)
if self.ui.configbool('notify', 'test', True):
self.ui.write(msgtext)
if not msgtext.endswith('\n'):
self.ui.write('\n')
else:
self.ui.status(_('notify: sending %d subscribers %d changes\n') %
(len(self.subs), count))
mail.sendmail(self.ui, util.email(msg['From']),
self.subs, msgtext)
开发者ID:carlgao,项目名称:lenga,代码行数:55,代码来源:notify.py
示例10: getcommit
def getcommit(self, rev):
ctx = self.changectx(rev)
parents = [p.hex() for p in self.parents(ctx)]
crev = rev
return commit(author=ctx.user(),
date=util.datestr(ctx.date(), '%Y-%m-%d %H:%M:%S %1%2'),
desc=ctx.description(), rev=crev, parents=parents,
branch=ctx.branch(), extra=ctx.extra(),
sortkey=ctx.rev(), saverev=self.saverev,
phase=ctx.phase())
开发者ID:pierfort123,项目名称:mercurial,代码行数:11,代码来源:hg.py
示例11: getcommit
def getcommit(self, rev):
ctx = self.changectx(rev)
parents = [p.hex() for p in self.parents(ctx)]
if self.saverev:
crev = rev
else:
crev = None
return commit(author=ctx.user(), date=util.datestr(ctx.date()),
desc=ctx.description(), rev=crev, parents=parents,
branch=ctx.branch(), extra=ctx.extra(),
sortkey=ctx.rev())
开发者ID:MezzLabs,项目名称:mercurial,代码行数:11,代码来源:hg.py
示例12: info
def info(ui, repo, **opts):
"""show Subversion details similar to `svn info'
"""
if repo is None:
raise error.RepoError("There is no Mercurial repository" " here (.hg not found)")
meta = repo.svnmeta()
hashes = meta.revmap.hashes()
if opts.get("rev"):
parent = repo[opts["rev"]]
else:
parent = util.parentrev(ui, repo, meta, hashes)
pn = parent.node()
if pn not in hashes:
ui.status("Not a child of an svn revision.\n")
return 0
r, br = hashes[pn]
subdir = parent.extra()["convert_revision"][40:].split("@")[0]
if meta.layout == "single":
branchpath = ""
elif br == None:
branchpath = "/trunk"
elif br.startswith("../"):
branchpath = "/%s" % br[3:]
subdir = subdir.replace("branches/../", "")
else:
branchpath = "/branches/%s" % br
remoterepo = svnrepo.svnremoterepo(repo.ui)
url = "%s%s" % (remoterepo.svnurl, branchpath)
author = meta.authors.reverselookup(parent.user())
# cleverly figure out repo root w/o actually contacting the server
reporoot = url[: len(url) - len(subdir)]
ui.write(
"""URL: %(url)s
Repository Root: %(reporoot)s
Repository UUID: %(uuid)s
Revision: %(revision)s
Node Kind: directory
Last Changed Author: %(author)s
Last Changed Rev: %(revision)s
Last Changed Date: %(date)s\n"""
% {
"reporoot": reporoot,
"uuid": meta.uuid,
"url": url,
"author": author,
"revision": r,
# TODO I'd like to format this to the user's local TZ if possible
"date": hgutil.datestr(parent.date(), "%Y-%m-%d %H:%M:%S %1%2 (%a, %d %b %Y)"),
}
)
开发者ID:avuori,项目名称:dotfiles,代码行数:54,代码来源:svncommands.py
示例13: get_diffs
def get_diffs(self):
from mercurial import mdiff, util, patch
from repo_browser.integration import Diff
ctx = self.ctx
parent = ctx.parents()[0]
parent_date = util.datestr(parent.date())
this_date = util.datestr(ctx.date())
diffopts = patch.diffopts(self.repo.repo.ui, untrusted=True)
# Returns a tuple of modified, added, removed, deleted, unknown
# TODO: look up in the api what FIXME* are
modified, added, removed, deleted, unknown, FIXME, FIXME2 = \
self.repo.repo.status(
parent.node(),
ctx.node(),)
for modified_file in modified:
filectx = ctx.filectx(modified_file)
parent_filectx = parent.filectx(modified_file)
this_data = filectx.data()
parent_data = parent_filectx.data()
yield Diff(mdiff.unidiff(parent_data, parent_date,
this_data,this_date,
modified_file, modified_file,
opts=diffopts))
for added_file in added:
filectx = ctx.filectx(added_file)
this_data = filectx.data()
yield Diff(mdiff.unidiff(
None, parent_date, this_data, this_date,
added_file, added_file, opts=diffopts))
for removed_file in removed:
parent_filectx = parent.filectx(removed_file)
parent_data = parent_filectx.data()
yield Diff(mdiff.unidiff(
parent_data, parent_date, None, ctx.date(),
removed_file, removed_file, opts=diffopts))
开发者ID:AdamG,项目名称:django-repo-browser,代码行数:41,代码来源:commit.py
示例14: sendemail
def sendemail(self, address, data):
p = email.Parser.Parser()
msg = p.parsestr(data)
msg["Date"] = util.datestr(format="%a, %d %b %Y %H:%M:%S %1%2")
msg["To"] = address
msg["From"] = self.emailfrom
msg["Subject"] = "DeliverXML"
msg["Content-type"] = "text/xml"
msgtext = msg.as_string()
self.ui.status(_("hgcia: sending update to %s\n") % address)
mail.sendmail(self.ui, util.email(self.emailfrom), [address], msgtext)
开发者ID:yonas,项目名称:HgWeb-Syntax-Highlighter,代码行数:12,代码来源:hgcia.py
示例15: info
def info(ui, repo, **opts):
"""show Subversion details similar to `svn info'
"""
if repo is None:
raise error.RepoError("There is no Mercurial repository"
" here (.hg not found)")
meta = repo.svnmeta()
hashes = meta.revmap.hashes()
if opts.get('rev'):
parent = repo[opts['rev']]
else:
parent = util.parentrev(ui, repo, meta, hashes)
pn = parent.node()
if pn not in hashes:
ui.status('Not a child of an svn revision.\n')
return 0
r, br = hashes[pn]
subdir = parent.extra()['convert_revision'][40:].split('@')[0]
if meta.layout == 'single':
branchpath = ''
elif br == None:
branchpath = '/trunk'
elif br.startswith('../'):
branchpath = '/%s' % br[3:]
subdir = subdir.replace('branches/../', '')
else:
branchpath = '/branches/%s' % br
remoterepo = svnrepo.svnremoterepo(repo.ui)
url = '%s%s' % (remoterepo.svnurl, branchpath)
author = meta.authors.reverselookup(parent.user())
# cleverly figure out repo root w/o actually contacting the server
reporoot = url[:len(url)-len(subdir)]
ui.write('''URL: %(url)s
Repository Root: %(reporoot)s
Repository UUID: %(uuid)s
Revision: %(revision)s
Node Kind: directory
Last Changed Author: %(author)s
Last Changed Rev: %(revision)s
Last Changed Date: %(date)s\n''' %
{'reporoot': reporoot,
'uuid': meta.uuid,
'url': url,
'author': author,
'revision': r,
# TODO I'd like to format this to the user's local TZ if possible
'date': hgutil.datestr(parent.date(),
'%Y-%m-%d %H:%M:%S %1%2 (%a, %d %b %Y)')
})
开发者ID:TerminalSpirit,项目名称:dotfiles,代码行数:53,代码来源:svncommands.py
示例16: getcommit
def getcommit(self, rev):
elt = self.changes[rev]
date = util.strdate(elt.get("local_date"), "%a %b %d %H:%M:%S %Z %Y")
desc = elt.findtext("name") + "\n" + elt.findtext("comment", "")
# etree can return unicode objects for name, comment, and author,
# so recode() is used to ensure str objects are emitted.
return commit(
author=self.recode(elt.get("author")),
date=util.datestr(date),
desc=self.recode(desc).strip(),
parents=self.parents[rev],
)
开发者ID:helloandre,项目名称:cr48,代码行数:12,代码来源:darcs.py
示例17: sendemail
def sendemail(self, address, data):
p = email.Parser.Parser()
msg = p.parsestr(data)
msg['Date'] = util.datestr(format="%a, %d %b %Y %H:%M:%S %1%2")
msg['To'] = address
msg['From'] = self.emailfrom
msg['Subject'] = 'DeliverXML'
msg['Content-type'] = 'text/xml'
msgtext = msg.as_string()
self.ui.status(_('hgcia: sending update to %s\n') % address)
mail.sendmail(self.ui, util.email(self.emailfrom),
[address], msgtext)
开发者ID:rybesh,项目名称:mysite-lib,代码行数:13,代码来源:hgcia.py
示例18: getcommit
def getcommit(self, rev):
extra = {}
certs = self.mtngetcerts(rev)
if certs.get('suspend') == certs["branch"]:
extra['close'] = 1
return commit(
author=certs["author"],
date=util.datestr(util.strdate(certs["date"], "%Y-%m-%dT%H:%M:%S")),
desc=certs["changelog"],
rev=rev,
parents=self.mtnrun("parents", rev).splitlines(),
branch=certs["branch"],
extra=extra)
开发者ID:CSCI-362-02-2015,项目名称:RedTeam,代码行数:13,代码来源:monotone.py
示例19: _format_changelog
def _format_changelog(ctx):
""" Format the log message for a changeset.
:param ctx:
The Mercurial change context containing the tags.
:return:
The formatted change log.
"""
from mercurial.util import datestr
log = "changeset: %s\ndate: %s\n%s" % (str(ctx), datestr(ctx.date()), ctx.description())
return log
开发者ID:BALL-Contrib,项目名称:sip,代码行数:14,代码来源:build.py
示例20: get_property_pages
def get_property_pages(self, vfs_files):
if len(vfs_files) != 1:
return
file = vfs_files[0]
path = self.get_path_for_vfs_file(file)
if path is None or file.is_directory():
return
repo = self.get_repo_for_path(path)
if repo is None:
return
localpath = path[len(repo.root)+1:]
emblem, status = self._get_file_status(path, repo)
# Get the information from Mercurial
ctx = repo['.']
try:
fctx = ctx.filectx(localpath)
rev = fctx.filelog().linkrev(fctx.filerev())
except:
rev = ctx.rev()
ctx = repo.changectx(rev)
node = short(ctx.node())
date = util.datestr(ctx.date(), '%Y-%m-%d %H:%M:%S %1%2')
parents = '\n'.join([short(p.node()) for p in ctx.parents()])
description = ctx.description()
user = ctx.user()
user = markup_escape_text(user)
tags = ', '.join(ctx.tags())
branch = ctx.branch()
self.property_label = gtk.Label('Mercurial')
self.table = gtk.Table(7, 2, False)
self.table.set_border_width(5)
self.table.set_row_spacings(5)
self.table.set_col_spacings(5)
self.__add_row(0, '<b>Status</b>:', status)
self.__add_row(1, '<b>Last-Commit-Revision</b>:', str(rev))
self.__add_row(2, '<b>Last-Commit-Description</b>:', description)
self.__add_row(3, '<b>Last-Commit-Date</b>:', date)
self.__add_row(4, '<b>Last-Commit-User</b>:', user)
if tags:
self.__add_row(5, '<b>Tags</b>:', tags)
if branch != 'default':
self.__add_row(6, '<b>Branch</b>:', branch)
self.table.show()
return caja.PropertyPage("MercurialPropertyPage::status",
self.property_label, self.table),
开发者ID:gilshwartz,项目名称:tortoisehg-caja,代码行数:50,代码来源:caja-thg.py
注:本文中的mercurial.util.datestr函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论