本文整理汇总了Python中mercurial.util.makedate函数的典型用法代码示例。如果您正苦于以下问题:Python makedate函数的具体用法?Python makedate怎么用?Python makedate使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了makedate函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
def __init__(self, patchpath, repo, pf=None, rev=None):
""" Read patch context from file
:param pf: currently ignored
The provided handle is used to read the patch and
the patchpath contains the name of the patch.
The handle is NOT closed.
"""
self._path = patchpath
if rev:
assert isinstance(rev, str)
self._patchname = rev
else:
self._patchname = os.path.basename(patchpath)
self._repo = repo
self._rev = rev or 'patch'
self._status = [[], [], []]
self._fileorder = []
self._user = ''
self._desc = ''
self._branch = ''
self._node = node.nullid
self._mtime = None
self._fsize = 0
self._parseerror = None
self._phase = 'draft'
try:
self._mtime = os.path.getmtime(patchpath)
self._fsize = os.path.getsize(patchpath)
ph = mq.patchheader(self._path)
self._ph = ph
except EnvironmentError:
self._date = util.makedate()
return
try:
self._branch = ph.branch or ''
self._node = binascii.unhexlify(ph.nodeid)
if self._repo.ui.configbool('mq', 'secret'):
self._phase = 'secret'
except TypeError:
pass
except AttributeError:
# hacks to try to deal with older versions of mq.py
self._branch = ''
ph.diffstartline = len(ph.comments)
if ph.message:
ph.diffstartline += 1
except error.ConfigError:
pass
self._user = ph.user or ''
self._desc = ph.message and '\n'.join(ph.message).strip() or ''
try:
self._date = ph.date and util.parsedate(ph.date) or util.makedate()
except error.Abort:
self._date = util.makedate()
示例2: chash
def chash(manifest, files, desc, p1, p2, user, date, extra):
"""Compute changeset hash from the changeset pieces."""
user = user.strip()
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()
extra = extra.copy()
if 'signature' in extra:
del extra['signature']
if extra.get("branch") in ("default", ""):
del extra["branch"]
if extra:
extra = changelog.encodeextra(extra)
parseddate = "%s %s" % (parseddate, extra)
l = [hex(manifest), user, parseddate] + sorted(files) + ["", desc]
text = "\n".join(l)
return revlog.hash(text, p1, p2)
示例3: entries
def entries(sortcolumn="", descending=False, subdir="", **map):
rows = []
parity = common.paritygen(stripecount)
for repo in Repository.objects.has_view_permission(request.user):
contact = smart_str(repo.owner.get_full_name())
lastchange = (common.get_mtime(repo.location), util.makedate()[1])
row = dict(contact=contact or "unknown",
contact_sort=contact.upper() or "unknown",
name=smart_str(repo.name),
name_sort=smart_str(repo.name),
url=repo.get_absolute_url(),
description=smart_str(repo.description) or "unknown",
description_sort=smart_str(repo.description.upper()) or "unknown",
lastchange=lastchange,
lastchange_sort=lastchange[1]-lastchange[0],
archives=archivelist(u, "tip", url))
if (not sortcolumn or (sortcolumn, descending) == sortdefault):
# fast path for unsorted output
row['parity'] = parity.next()
yield row
else:
rows.append((row["%s_sort" % sortcolumn], row))
if rows:
rows.sort()
if descending:
rows.reverse()
for key, row in rows:
row['parity'] = parity.next()
yield row
示例4: record
def record(self, namespace, name, oldhashes, newhashes):
"""Record a new journal entry
* namespace: an opaque string; this can be used to filter on the type
of recorded entries.
* name: the name defining this entry; for bookmarks, this is the
bookmark name. Can be filtered on when retrieving entries.
* oldhashes and newhashes: each a single binary hash, or a list of
binary hashes. These represent the old and new position of the named
item.
"""
if not isinstance(oldhashes, list):
oldhashes = [oldhashes]
if not isinstance(newhashes, list):
newhashes = [newhashes]
entry = journalentry(
util.makedate(), self.user, self.command, namespace, name,
oldhashes, newhashes)
vfs = self.vfs
if self.sharedvfs is not None:
# write to the shared repository if this feature is being
# shared between working copies.
if sharednamespaces.get(namespace) in self.sharedfeatures:
vfs = self.sharedvfs
self._write(vfs, entry)
示例5: template_pushheaddates
def template_pushheaddates(repo, ctx, **args):
""":pushheaddates: List of date information. The dates this changeset
was pushed to various trees as a push head."""
node = ctx.node()
pushes = repo.changetracker.pushes_for_changeset(ctx.node())
return [util.makedate(p[2]) for p in pushes if str(p[4]) == node]
示例6: filelog
def filelog(orig, web, req, tmpl):
"""Wraps webcommands.filelog to provide pushlog metadata to template."""
if hasattr(web.repo, 'pushlog'):
class _tmpl(object):
def __init__(self):
self.defaults = tmpl.defaults
def __call__(self, *args, **kwargs):
self.args = args
self.kwargs = kwargs
return self
class _ctx(object):
def __init__(self, hex):
self._hex = hex
def hex(self):
return self._hex
t = orig(web, req, _tmpl())
for entry in t.kwargs['entries']:
pushinfo = web.repo.pushlog.pushfromchangeset(_ctx(entry['node']))
entry['pushid'] = pushinfo[0]
entry['pushdate'] = util.makedate(pushinfo[2])
return tmpl(*t.args, **t.kwargs)
else:
return orig(web, req, tmpl)
示例7: maxWidthValueForColumn
def maxWidthValueForColumn(self, col):
if self.graph is None:
return 'XXXX'
column = self._columns[col]
if column == 'Rev':
return '8' * len(str(len(self.repo))) + '+'
if column == 'Node':
return '8' * 12 + '+'
if column in ('LocalTime', 'UTCTime'):
return hglib.displaytime(util.makedate())
if column in ('Tags', 'Latest tags'):
try:
return sorted(self.repo.tags().keys(), key=lambda x: len(x))[-1][:10]
except IndexError:
pass
if column == 'Branch':
try:
return sorted(self.repo.branchtags().keys(), key=lambda x: len(x))[-1]
except IndexError:
pass
if column == 'Filename':
return self.filename
if column == 'Graph':
res = self.col2x(self.graph.max_cols)
return min(res, 150)
if column == 'Changes':
return 'Changes'
# Fall through for Description
return None
示例8: setupheaderopts
def setupheaderopts(ui, opts):
"""sets the user and date; copied from mq"""
def do(opt, val):
if not opts.get(opt) and opts.get('current' + opt):
opts[opt] = val
do('user', ui.username())
do('date', '%d %d' % util.makedate())
示例9: makepatch
def makepatch(ui, repo, name=None, pats=[], opts={}):
"""sets up the call for attic.createpatch and makes the call"""
s = repo.attic
force = opts.get('force')
if name and s.exists(name) and name != s.applied and not force:
raise util.Abort(_('attempting to overwrite existing patch'))
if name and s.applied and name != s.applied and not force:
raise util.Abort(_('a different patch is active'))
if not name:
name = s.applied
if not name:
raise util.Abort(_('you need to supply a patch name'))
date, user, message = None, None, ''
if s.applied:
data = patch.extract(ui, open(s.join(s.applied), 'r'))
tmpname, message, user, date, branch, nodeid, p1, p2 = data
os.unlink(tmpname)
msg = cmdutil.logmessage(opts)
if not msg:
msg = message
if opts.get('edit'):
msg = ui.edit(msg, ui.username())
setupheaderopts(ui, opts)
if opts.get('user'):
user=opts['user']
if not user:
user = ui.username()
if opts.get('date'):
date=opts['date']
if not date:
date = util.makedate()
date = util.parsedate(date)
s.createpatch(repo, name, msg, user, date, pats, opts)
示例10: template_firstpushdate
def template_firstpushdate(repo, ctx, **args):
""":firstpushdate: Date information. The date of the first push of this
changeset."""
pushes = list(repo.changetracker.pushes_for_changeset(ctx.node()))
if not pushes:
return None
return util.makedate(pushes[0][2])
示例11: rawentries
def rawentries(subdir="", **map):
descend = self.ui.configbool('web', 'descend', True)
for name, path in self.repos:
if not name.startswith(subdir):
continue
name = name[len(subdir):]
if not descend and '/' in name:
continue
u = self.ui.copy()
try:
u.readconfig(os.path.join(path, '.hg', 'hgrc'))
except Exception, e:
u.warn(_('error reading %s/.hg/hgrc: %s\n') % (path, e))
continue
def get(section, name, default=None):
return u.config(section, name, default, untrusted=True)
if u.configbool("web", "hidden", untrusted=True):
continue
if not self.read_allowed(u, req):
continue
parts = [name]
if 'PATH_INFO' in req.env:
parts.insert(0, req.env['PATH_INFO'].rstrip('/'))
if req.env['SCRIPT_NAME']:
parts.insert(0, req.env['SCRIPT_NAME'])
url = re.sub(r'/+', '/', '/'.join(parts) + '/')
# update time with local timezone
try:
r = hg.repository(self.ui, path)
except error.RepoError:
u.warn(_('error accessing repository at %s\n') % path)
continue
try:
d = (get_mtime(r.spath), util.makedate()[1])
except OSError:
continue
contact = get_contact(get)
description = get("web", "description", "")
name = get("web", "name", name)
row = dict(contact=contact or "unknown",
contact_sort=contact.upper() or "unknown",
name=name,
name_sort=name,
url=url,
description=description or "unknown",
description_sort=description.upper() or "unknown",
lastchange=d,
lastchange_sort=d[1]-d[0],
archives=archivelist(u, "tip", url))
yield row
示例12: entries
def entries(sortcolumn="", descending=False, subdir="", **map):
rows = []
parity = paritygen(self.stripecount)
for name, path in self.repos:
if not name.startswith(subdir):
continue
name = name[len(subdir):]
u = self.ui.copy()
try:
u.readconfig(os.path.join(path, '.hg', 'hgrc'))
except Exception, e:
u.warn(_('error reading %s/.hg/hgrc: %s\n') % (path, e))
continue
def get(section, name, default=None):
return u.config(section, name, default, untrusted=True)
if u.configbool("web", "hidden", untrusted=True):
continue
if not self.read_allowed(u, req):
continue
parts = [name]
if 'PATH_INFO' in req.env:
parts.insert(0, req.env['PATH_INFO'].rstrip('/'))
if req.env['SCRIPT_NAME']:
parts.insert(0, req.env['SCRIPT_NAME'])
m = re.match('((?:https?://)?)(.*)', '/'.join(parts))
# squish repeated slashes out of the path component
url = m.group(1) + re.sub('/+', '/', m.group(2)) + '/'
# update time with local timezone
try:
d = (get_mtime(path), util.makedate()[1])
except OSError:
continue
contact = get_contact(get)
description = get("web", "description", "")
name = get("web", "name", name)
row = dict(contact=contact or "unknown",
contact_sort=contact.upper() or "unknown",
name=name,
name_sort=name,
url=url,
description=description or "unknown",
description_sort=description.upper() or "unknown",
lastchange=d,
lastchange_sort=d[1]-d[0],
archives=archivelist(u, "tip", url))
if (not sortcolumn or (sortcolumn, descending) == sortdefault):
# fast path for unsorted output
row['parity'] = parity.next()
yield row
else:
rows.append((row["%s_sort" % sortcolumn], row))
示例13: addpushmetadata
def addpushmetadata(repo, ctx, d):
if not hasattr(repo, 'pushlog'):
return
pushinfo = repo.pushlog.pushfromchangeset(ctx)
if pushinfo:
d['pushid'] = pushinfo[0]
d['pushuser'] = pushinfo[1]
d['pushdate'] = util.makedate(pushinfo[2])
d['pushnodes'] = pushinfo[3]
d['pushhead'] = pushinfo[3][-1]
示例14: timetravel
def timetravel(ui, repo):
"Change date of commit."
ctx = repo[None].p1()
while ctx.phase():
ctx = ctx.p1()
parent = ctx
date = util.makedate()
update_node, strip_nodes = copy_branch(repo, ctx, parent, date)
if update_node:
hg.update(repo, update_node)
if strip_nodes:
repair.strip(ui, repo, strip_nodes)
示例15: listcmd
def listcmd(ui, repo, pats, opts):
"""subcommand that displays the list of shelves"""
pats = set(pats)
width = 80
if not ui.plain():
width = ui.termwidth()
namelabel = 'shelve.newest'
for mtime, name in listshelves(repo):
sname = util.split(name)[1]
if pats and sname not in pats:
continue
ui.write(sname, label=namelabel)
namelabel = 'shelve.name'
if ui.quiet:
ui.write('\n')
continue
ui.write(' ' * (16 - len(sname)))
used = 16
age = '(%s)' % templatefilters.age(util.makedate(mtime), abbrev=True)
ui.write(age, label='shelve.age')
ui.write(' ' * (12 - len(age)))
used += 12
fp = open(name + '.patch', 'rb')
try:
while True:
line = fp.readline()
if not line:
break
if not line.startswith('#'):
desc = line.rstrip()
if ui.formatted():
desc = util.ellipsis(desc, width - used)
ui.write(desc)
break
ui.write('\n')
if not (opts['patch'] or opts['stat']):
continue
difflines = fp.readlines()
if opts['patch']:
for chunk, label in patch.difflabel(iter, difflines):
ui.write(chunk, label=label)
if opts['stat']:
for chunk, label in patch.diffstatui(difflines, width=width,
git=True):
ui.write(chunk, label=label)
finally:
fp.close()