本文整理汇总了Python中node.hex函数的典型用法代码示例。如果您正苦于以下问题:Python hex函数的具体用法?Python hex怎么用?Python hex使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了hex函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: write
def write(self, repo):
try:
f = repo.vfs(_filename(repo), "w", atomictemp=True)
cachekey = [hex(self.tipnode), str(self.tiprev)]
if self.filteredhash is not None:
cachekey.append(hex(self.filteredhash))
f.write(" ".join(cachekey) + '\n')
nodecount = 0
for label, nodes in sorted(self.iteritems()):
for node in nodes:
nodecount += 1
if node in self._closednodes:
state = 'c'
else:
state = 'o'
f.write("%s %s %s\n" % (hex(node), state,
encoding.fromlocal(label)))
f.close()
repo.ui.log('branchcache',
'wrote %s branch cache with %d labels and %d nodes\n',
repo.filtername, len(self), nodecount)
except (IOError, OSError, util.Abort), inst:
repo.ui.debug("couldn't write branch cache: %s\n" % inst)
# Abort may be raise by read only opener
pass
开发者ID:areshero,项目名称:ThirdWorldApp,代码行数:25,代码来源:branchmap.py
示例2: _writetagcache
def _writetagcache(ui, repo, valid, cachetags):
filename = _filename(repo)
try:
cachefile = repo.vfs(filename, 'w', atomictemp=True)
except (OSError, IOError):
return
ui.log('tagscache', 'writing .hg/%s with %d tags\n',
filename, len(cachetags))
if valid[2]:
cachefile.write('%d %s %s\n' % (valid[0], hex(valid[1]), hex(valid[2])))
else:
cachefile.write('%d %s\n' % (valid[0], hex(valid[1])))
# Tag names in the cache are in UTF-8 -- which is the whole reason
# we keep them in UTF-8 throughout this module. If we converted
# them local encoding on input, we would lose info writing them to
# the cache.
for (name, (node, hist)) in sorted(cachetags.iteritems()):
for n in hist:
cachefile.write("%s %s\n" % (hex(n), name))
cachefile.write("%s %s\n" % (hex(node), name))
try:
cachefile.close()
except (OSError, IOError):
pass
开发者ID:RayFerr000,项目名称:PLTL,代码行数:28,代码来源:tags.py
示例3: single
def single(rev, seqno, fp):
ctx = repo[rev]
node = ctx.node()
parents = [p.node() for p in ctx.parents() if p]
branch = ctx.branch()
if switch_parent:
parents.reverse()
prev = (parents and parents[0]) or nullid
if not fp:
fp = cmdutil.make_file(repo, template, node, total=total,
seqno=seqno, revwidth=revwidth,
mode='ab')
if fp != sys.stdout and hasattr(fp, 'name'):
repo.ui.note("%s\n" % fp.name)
fp.write("# HG changeset patch\n")
fp.write("# User %s\n" % ctx.user())
fp.write("# Date %d %d\n" % ctx.date())
if branch and (branch != 'default'):
fp.write("# Branch %s\n" % branch)
fp.write("# Node ID %s\n" % hex(node))
fp.write("# Parent %s\n" % hex(prev))
if len(parents) > 1:
fp.write("# Parent %s\n" % hex(parents[1]))
fp.write(ctx.description().rstrip())
fp.write("\n\n")
for chunk in diff(repo, prev, node, opts=opts):
fp.write(chunk)
开发者ID:Nurb432,项目名称:plan9front,代码行数:30,代码来源:patch.py
示例4: commit
def commit(self):
"""Write current state on disk (if necessary)"""
if self._dirty:
records = []
records.append(('L', hex(self._local)))
records.append(('O', hex(self._other)))
for d, v in self._state.iteritems():
records.append(('F', '\0'.join([d] + v)))
self._writerecords(records)
self._dirty = False
开发者ID:RayFerr000,项目名称:PLTL,代码行数:10,代码来源:merge.py
示例5: write
def write(self, repo):
try:
f = repo.opener(_filename(repo), "w", atomictemp=True)
cachekey = [hex(self.tipnode), str(self.tiprev)]
if self.filteredhash is not None:
cachekey.append(hex(self.filteredhash))
f.write(" ".join(cachekey) + '\n')
for label, nodes in sorted(self.iteritems()):
for node in nodes:
f.write("%s %s\n" % (hex(node), encoding.fromlocal(label)))
f.close()
except (IOError, OSError, util.Abort):
# Abort may be raise by read only opener
pass
开发者ID:32bitfloat,项目名称:intellij-community,代码行数:14,代码来源:branchmap.py
示例6: 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
示例7: edit
def edit(self, text, user, extra={}):
(fd, name) = tempfile.mkstemp(prefix="hg-editor-", suffix=".txt",
text=True)
try:
f = os.fdopen(fd, "w")
f.write(text)
f.close()
environ = {'HGUSER': user}
if 'transplant_source' in extra:
environ.update({'HGREVISION': hex(extra['transplant_source'])})
for label in ('source', 'rebase_source'):
if label in extra:
environ.update({'HGREVISION': extra[label]})
break
editor = self.geteditor()
util.system("%s \"%s\"" % (editor, name),
environ=environ,
onerr=util.Abort, errprefix=_("edit failed"),
out=self.fout)
f = open(name)
t = f.read()
f.close()
finally:
os.unlink(name)
return t
开发者ID:roopakparikh,项目名称:crane-node-hello,代码行数:30,代码来源:ui.py
示例8: checkhash
def checkhash(self, text, p1, p2, node, rev=None):
if node != self.hash(text, p1, p2):
revornode = rev
if revornode is None:
revornode = templatefilters.short(hex(node))
raise RevlogError(_("integrity check failed on %s:%s")
% (self.indexfile, revornode))
开发者ID:ZanderZhang,项目名称:Andriod-Learning,代码行数:7,代码来源:revlog.py
示例9: metadata
def metadata():
base = 'repo: %s\nnode: %s\nbranch: %s\n' % (
hex(repo.changelog.node(0)), hex(node), ctx.branch())
tags = ''.join('tag: %s\n' % t for t in ctx.tags()
if repo.tagtype(t) == 'global')
if not tags:
repo.ui.pushbuffer()
opts = {'template': '{latesttag}\n{latesttagdistance}',
'style': '', 'patch': None, 'git': None}
cmdutil.show_changeset(repo.ui, repo, opts).show(ctx)
ltags, dist = repo.ui.popbuffer().split('\n')
tags = ''.join('latesttag: %s\n' % t for t in ltags.split(':'))
tags += 'latesttagdistance: %s\n' % dist
return base + tags
开发者ID:Frostman,项目名称:intellij-community,代码行数:16,代码来源:archival.py
示例10: listphases
def listphases(repo):
"""List phases root for serialisation over pushkey"""
keys = {}
value = '%i' % draft
for root in repo._phaseroots[draft]:
keys[hex(root)] = value
if repo.ui.configbool('phases', 'publish', True):
# Add an extra data to let remote know we are a publishing repo.
# Publishing repo can't just pretend they are old repo. When pushing to
# a publishing repo, the client still need to push phase boundary
#
# Push do not only push changeset. It also push phase data. New
# phase data may apply to common changeset which won't be push (as they
# are common). Here is a very simple example:
#
# 1) repo A push changeset X as draft to repo B
# 2) repo B make changeset X public
# 3) repo B push to repo A. X is not pushed but the data that X as now
# public should
#
# The server can't handle it on it's own as it has no idea of client
# phase data.
keys['publishing'] = 'True'
return keys
开发者ID:Pelonza,项目名称:Learn2Mine-Main,代码行数:25,代码来源:phases.py
示例11: 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
示例12: 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
示例13: _changegroupinfo
def _changegroupinfo(repo, nodes, source):
if repo.ui.verbose or source == 'bundle':
repo.ui.status(_("%d changesets found\n") % len(nodes))
if repo.ui.debugflag:
repo.ui.debug("list of changesets:\n")
for node in nodes:
repo.ui.debug("%s\n" % hex(node))
开发者ID:leetaizhu,项目名称:Odoo_ENV_MAC_OS,代码行数:7,代码来源:changegroup.py
示例14: _partialmatch
def _partialmatch(self, id):
try:
return self.index.partialmatch(id)
except RevlogError:
# parsers.c radix tree lookup gave multiple matches
raise LookupError(id, self.indexfile, _("ambiguous identifier"))
except (AttributeError, ValueError):
# we are pure python, or key was too short to search radix tree
pass
if id in self._pcache:
return self._pcache[id]
if len(id) < 40:
try:
# hex(node)[:...]
l = len(id) // 2 # grab an even number of digits
prefix = bin(id[:l * 2])
nl = [e[7] for e in self.index if e[7].startswith(prefix)]
nl = [n for n in nl if hex(n).startswith(id)]
if len(nl) > 0:
if len(nl) == 1:
self._pcache[id] = nl[0]
return nl[0]
raise LookupError(id, self.indexfile,
_('ambiguous identifier'))
return None
except TypeError:
pass
开发者ID:chuchiperriman,项目名称:hg-stable,代码行数:29,代码来源:revlog.py
示例15: lookup
def lookup(repo, proto, key):
try:
r = hex(repo.lookup(key))
success = 1
except Exception, inst:
r = str(inst)
success = 0
开发者ID:helloandre,项目名称:cr48,代码行数:7,代码来源:wireproto.py
示例16: lookup
def lookup(repo, proto, key):
try:
r = hex(repo.lookup(encoding.tolocal(key)))
success = 1
except Exception, inst:
r = str(inst)
success = 0
开发者ID:MezzLabs,项目名称:mercurial,代码行数:7,代码来源:wireproto.py
示例17: listphases
def listphases(repo):
"""List phases root for serialization over pushkey"""
keys = {}
value = "%i" % draft
for root in repo._phasecache.phaseroots[draft]:
keys[hex(root)] = value
if repo.ui.configbool("phases", "publish", True):
# Add an extra data to let remote know we are a publishing
# repo. Publishing repo can't just pretend they are old repo.
# When pushing to a publishing repo, the client still need to
# push phase boundary
#
# Push do not only push changeset. It also push phase data.
# New phase data may apply to common changeset which won't be
# push (as they are common). Here is a very simple example:
#
# 1) repo A push changeset X as draft to repo B
# 2) repo B make changeset X public
# 3) repo B push to repo A. X is not pushed but the data that
# X as now public should
#
# The server can't handle it on it's own as it has no idea of
# client phase data.
keys["publishing"] = "True"
return keys
开发者ID:ZanderZhang,项目名称:Andriod-Learning,代码行数:26,代码来源:phases.py
示例18: rev
def rev(self, node):
"""filtered version of revlog.rev"""
r = super(changelog, self).rev(node)
if r in self.filteredrevs:
raise error.FilteredLookupError(hex(node), self.indexfile,
_('filtered node'))
return r
开发者ID:pierfort123,项目名称:mercurial,代码行数:7,代码来源:changelog.py
示例19: add
def add(self, fcl, fco, fca, fd):
"""add a new (potentially?) conflicting file the merge state
fcl: file context for local,
fco: file context for remote,
fca: file context for ancestors,
fd: file path of the resulting merge.
note: also write the local version to the `.hg/merge` directory.
"""
hash = util.sha1(fcl.path()).hexdigest()
self._repo.vfs.write('merge/' + hash, fcl.data())
self._state[fd] = ['u', hash, fcl.path(),
fca.path(), hex(fca.filenode()),
fco.path(), hex(fco.filenode()),
fcl.flags()]
self._dirty = True
开发者ID:RayFerr000,项目名称:PLTL,代码行数:16,代码来源:merge.py
示例20: commit
def commit(self):
if self._dirty:
f = self._repo.opener("merge/state", "w")
f.write(hex(self._local) + "\n")
for d, v in self._state.iteritems():
f.write("\0".join([d] + v) + "\n")
self._dirty = False
开发者ID:helloandre,项目名称:cr48,代码行数:7,代码来源:merge.py
注:本文中的node.hex函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论