本文整理汇总了Python中util.makedate函数的典型用法代码示例。如果您正苦于以下问题:Python makedate函数的具体用法?Python makedate怎么用?Python makedate使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了makedate函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: add
def add(self, manifest, files, desc, transaction, p1, p2,
user, date=None, extra={}):
user = user.strip()
# An empty username or a username with a "\n" will make the
# revision text contain two "\n\n" sequences -> corrupt
# repository since read cannot unpack the revision.
if not user:
raise error.RevlogError(_("empty username"))
if "\n" in user:
raise error.RevlogError(_("username %s contains a newline")
% repr(user))
# strip trailing whitespace and leading and trailing empty lines
desc = '\n'.join([l.rstrip() for l in desc.splitlines()]).strip('\n')
user, desc = encoding.fromlocal(user), encoding.fromlocal(desc)
if date:
parseddate = "%d %d" % util.parsedate(date)
else:
parseddate = "%d %d" % util.makedate()
if extra and extra.get("branch") in ("default", ""):
del extra["branch"]
if extra:
extra = encodeextra(extra)
parseddate = "%s %s" % (parseddate, extra)
l = [hex(manifest), user, parseddate] + sorted(files) + ["", desc]
text = "\n".join(l)
return self.addrevision(text, transaction, len(self), p1, p2)
开发者ID:Nurb432,项目名称:plan9front,代码行数:29,代码来源:changelog.py
示例2: create
def create(self, transaction, prec, succs=(), flag=0, metadata=None):
"""obsolete: add a new obsolete marker
* ensuring it is hashable
* check mandatory metadata
* encode metadata
If you are a human writing code creating marker you want to use the
`createmarkers` function in this module instead.
return True if a new marker have been added, False if the markers
already existed (no op).
"""
if metadata is None:
metadata = {}
if 'date' not in metadata:
metadata['date'] = "%d %d" % util.makedate()
if len(prec) != 20:
raise ValueError(prec)
for succ in succs:
if len(succ) != 20:
raise ValueError(succ)
if prec in succs:
raise ValueError(_('in-marker cycle with %s') % node.hex(prec))
marker = (str(prec), tuple(succs), int(flag), encodemeta(metadata))
return bool(self.add(transaction, [marker]))
开发者ID:roopakparikh,项目名称:crane-node-hello,代码行数:26,代码来源:obsolete.py
示例3: create
def create(self, transaction, prec, succs=(), flag=0, parents=None,
date=None, metadata=None):
"""obsolete: add a new obsolete marker
* ensuring it is hashable
* check mandatory metadata
* encode metadata
If you are a human writing code creating marker you want to use the
`createmarkers` function in this module instead.
return True if a new marker have been added, False if the markers
already existed (no op).
"""
if metadata is None:
metadata = {}
if date is None:
if 'date' in metadata:
# as a courtesy for out-of-tree extensions
date = util.parsedate(metadata.pop('date'))
else:
date = util.makedate()
if len(prec) != 20:
raise ValueError(prec)
for succ in succs:
if len(succ) != 20:
raise ValueError(succ)
if prec in succs:
raise ValueError(_('in-marker cycle with %s') % node.hex(prec))
metadata = tuple(sorted(metadata.iteritems()))
marker = (str(prec), tuple(succs), int(flag), metadata, date, parents)
return bool(self.add(transaction, [marker]))
开发者ID:areshero,项目名称:ThirdWorldApp,代码行数:34,代码来源:obsolete.py
示例4: createmarkers
def createmarkers(repo, relations, flag=0, metadata=None):
"""Add obsolete markers between changesets in a repo
<relations> must be an iterable of (<old>, (<new>, ...)) tuple.
`old` and `news` are changectx.
Trying to obsolete a public changeset will raise an exception.
Current user and date are used except if specified otherwise in the
metadata attribute.
This function operates within a transaction of its own, but does
not take any lock on the repo.
"""
# prepare metadata
if metadata is None:
metadata = {}
if "date" not in metadata:
metadata["date"] = "%i %i" % util.makedate()
if "user" not in metadata:
metadata["user"] = repo.ui.username()
tr = repo.transaction("add-obsolescence-marker")
try:
for prec, sucs in relations:
if not prec.mutable():
raise util.Abort("cannot obsolete immutable changeset: %s" % prec)
nprec = prec.node()
nsucs = tuple(s.node() for s in sucs)
if nprec in nsucs:
raise util.Abort("changeset %s cannot obsolete itself" % prec)
repo.obsstore.create(tr, nprec, nsucs, flag, metadata)
repo.filteredrevcache.clear()
tr.close()
finally:
tr.release()
开发者ID:spraints,项目名称:for-example,代码行数:35,代码来源:obsolete.py
示例5: __init__
def __init__(self, repo, parents, text, files, filectxfn, user=None, date=None, extra=None):
self._repo = repo
self._rev = None
self._node = None
self._text = text
self._date = date and util.parsedate(date) or util.makedate()
self._user = user
parents = [(p or nullid) for p in parents]
p1, p2 = parents
self._parents = [changectx(self._repo, p) for p in (p1, p2)]
files = sorted(set(files))
self._status = [files, [], [], [], []]
self._filectxfn = filectxfn
self._extra = extra and extra.copy() or {}
if self._extra.get("branch", "") == "":
self._extra["branch"] = "default"
开发者ID:yonas,项目名称:HgWeb-Syntax-Highlighter,代码行数:17,代码来源:context.py
示例6: create
def create(self, transaction, prec, succs=(), flag=0, metadata=None):
"""obsolete: add a new obsolete marker
* ensuring it is hashable
* check mandatory metadata
* encode metadata
"""
if metadata is None:
metadata = {}
if 'date' not in metadata:
metadata['date'] = "%d %d" % util.makedate()
if len(prec) != 20:
raise ValueError(prec)
for succ in succs:
if len(succ) != 20:
raise ValueError(succ)
marker = (str(prec), tuple(succs), int(flag), encodemeta(metadata))
self.add(transaction, [marker])
开发者ID:jordigh,项目名称:mercurial-crew,代码行数:18,代码来源:obsolete.py
示例7: add
def add(self, manifest, list, desc, transaction, p1=None, p2=None,
user=None, date=None, extra={}):
user, desc = util.fromlocal(user), util.fromlocal(desc)
if date:
parseddate = "%d %d" % util.parsedate(date)
else:
parseddate = "%d %d" % util.makedate()
if extra and extra.get("branch") in ("default", ""):
del extra["branch"]
if extra:
extra = self.encode_extra(extra)
parseddate = "%s %s" % (parseddate, extra)
list.sort()
l = [hex(manifest), user, parseddate] + list + ["", desc]
text = "\n".join(l)
return self.addrevision(text, transaction, self.count(), p1, p2)
开发者ID:c0ns0le,项目名称:cygwin,代码行数:18,代码来源:changelog.py
示例8: createmarkers
def createmarkers(repo, relations, flag=0, metadata=None):
"""Add obsolete markers between changesets in a repo
<relations> must be an iterable of (<old>, (<new>, ...)[,{metadata}])
tuple. `old` and `news` are changectx. metadata is an optional dictionary
containing metadata for this marker only. It is merged with the global
metadata specified through the `metadata` argument of this function,
Trying to obsolete a public changeset will raise an exception.
Current user and date are used except if specified otherwise in the
metadata attribute.
This function operates within a transaction of its own, but does
not take any lock on the repo.
"""
# prepare metadata
if metadata is None:
metadata = {}
if 'date' not in metadata:
metadata['date'] = '%i %i' % util.makedate()
if 'user' not in metadata:
metadata['user'] = repo.ui.username()
tr = repo.transaction('add-obsolescence-marker')
try:
for rel in relations:
prec = rel[0]
sucs = rel[1]
localmetadata = metadata.copy()
if 2 < len(rel):
localmetadata.update(rel[2])
if not prec.mutable():
raise util.Abort("cannot obsolete immutable changeset: %s"
% prec)
nprec = prec.node()
nsucs = tuple(s.node() for s in sucs)
if nprec in nsucs:
raise util.Abort("changeset %s cannot obsolete itself" % prec)
repo.obsstore.create(tr, nprec, nsucs, flag, localmetadata)
repo.filteredrevcache.clear()
tr.close()
finally:
tr.release()
开发者ID:roopakparikh,项目名称:crane-node-hello,代码行数:44,代码来源:obsolete.py
示例9: __init__
def __init__(self, repo, parents, text, files, filectxfn, user=None,
date=None, extra=None):
self._repo = repo
self._rev = None
self._node = None
self._text = text
self._date = date and util.parsedate(date) or util.makedate()
self._user = user
parents = [(p or nullid) for p in parents]
p1, p2 = parents
self._parents = [changectx(self._repo, p) for p in (p1, p2)]
files = util.sort(util.unique(files))
self._status = [files, [], [], [], []]
self._filectxfn = filectxfn
self._extra = extra and extra.copy() or {}
if 'branch' not in self._extra:
self._extra['branch'] = 'default'
elif self._extra.get('branch') == '':
self._extra['branch'] = 'default'
开发者ID:pombredanne,项目名称:SmartNotes,代码行数:20,代码来源:context.py
示例10: add
def add(self, manifest, files, desc, transaction, p1=None, p2=None,
user=None, date=None, extra={}):
user = user.strip()
if "\n" in user:
raise error.RevlogError(_("username %s contains a newline")
% repr(user))
user, desc = util.fromlocal(user), util.fromlocal(desc)
if date:
parseddate = "%d %d" % util.parsedate(date)
else:
parseddate = "%d %d" % util.makedate()
if extra and extra.get("branch") in ("default", ""):
del extra["branch"]
if extra:
extra = self.encode_extra(extra)
parseddate = "%s %s" % (parseddate, extra)
l = [hex(manifest), user, parseddate] + util.sort(files) + ["", desc]
text = "\n".join(l)
return self.addrevision(text, transaction, len(self), p1, p2)
开发者ID:pombredanne,项目名称:SmartNotes,代码行数:21,代码来源:changelog.py
示例11: add
def add(self, manifest, files, desc, transaction, p1, p2,
user, date=None, extra=None):
# Convert to UTF-8 encoded bytestrings as the very first
# thing: calling any method on a localstr object will turn it
# into a str object and the cached UTF-8 string is thus lost.
user, desc = encoding.fromlocal(user), encoding.fromlocal(desc)
user = user.strip()
# An empty username or a username with a "\n" will make the
# revision text contain two "\n\n" sequences -> corrupt
# repository since read cannot unpack the revision.
if not user:
raise error.RevlogError(_("empty username"))
if "\n" in user:
raise error.RevlogError(_("username %s contains a newline")
% repr(user))
# strip trailing whitespace and leading and trailing empty lines
desc = '\n'.join([l.rstrip() for l in desc.splitlines()]).strip('\n')
if date:
parseddate = "%d %d" % util.parsedate(date)
else:
parseddate = "%d %d" % util.makedate()
if extra:
branch = extra.get("branch")
if branch in ("default", ""):
del extra["branch"]
elif branch in (".", "null", "tip"):
raise error.RevlogError(_('the name \'%s\' is reserved')
% branch)
if extra:
extra = encodeextra(extra)
parseddate = "%s %s" % (parseddate, extra)
l = [hex(manifest), user, parseddate] + sorted(files) + ["", desc]
text = "\n".join(l)
return self.addrevision(text, transaction, len(self), p1, p2)
开发者ID:agbiotec,项目名称:galaxy-tools-vcr,代码行数:37,代码来源:changelog.py
示例12: fill
"stripdir": stripdir,
"age": age,
"date": lambda x: util.datestr(x),
"domain": domain,
"email": util.email,
"escape": lambda x: cgi.escape(x, True),
"fill68": lambda x: fill(x, width=68),
"fill76": lambda x: fill(x, width=76),
"firstline": firstline,
"tabindent": lambda x: indent(x, '\t'),
"hgdate": lambda x: "%d %d" % x,
"isodate": lambda x: util.datestr(x, '%Y-%m-%d %H:%M %1%2'),
"isodatesec": lambda x: util.datestr(x, '%Y-%m-%d %H:%M:%S %1%2'),
"json": json,
"jsonescape": jsonescape,
"localdate": lambda x: (x[0], util.makedate()[1]),
"nonempty": nonempty,
"obfuscate": obfuscate,
"permissions": permissions,
"person": person,
"rfc822date": lambda x: util.datestr(x, "%a, %d %b %Y %H:%M:%S %1%2"),
"rfc3339date": lambda x: util.datestr(x, "%Y-%m-%dT%H:%M:%S%1:%2"),
"short": lambda x: x[:12],
"shortdate": util.shortdate,
"stringify": stringify,
"strip": lambda x: x.strip(),
"urlescape": lambda x: urllib.quote(x),
"user": lambda x: util.shortuser(x),
"stringescape": lambda x: x.encode('string_escape'),
"xmlescape": xmlescape,
}
开发者ID:Nurb432,项目名称:plan9front,代码行数:31,代码来源:templatefilters.py
示例13: _date
def _date(self):
return util.makedate()
开发者ID:yonas,项目名称:HgWeb-Syntax-Highlighter,代码行数:2,代码来源:context.py
示例14: localdate
def localdate(text):
""":localdate: Date. Converts a date to local date."""
return (util.parsedate(text)[0], util.makedate()[1])
开发者ID:chuchiperriman,项目名称:hg-stable,代码行数:3,代码来源:templatefilters.py
示例15: date
def date(self): return util.makedate()
def description(self): return ""
开发者ID:carlgao,项目名称:lenga,代码行数:2,代码来源:context.py
注:本文中的util.makedate函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论