本文整理汇总了Python中mercurial.node.bin函数的典型用法代码示例。如果您正苦于以下问题:Python bin函数的具体用法?Python bin怎么用?Python bin使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了bin函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: load
def load(cls, repo):
fp = repo.opener(cls._filename)
try:
version = int(fp.readline().strip())
if version != cls._version:
raise util.Abort(_('this version of shelve is incompatible '
'with the version used in this repo'))
name = fp.readline().strip()
wctx = fp.readline().strip()
pendingctx = fp.readline().strip()
parents = [bin(h) for h in fp.readline().split()]
stripnodes = [bin(h) for h in fp.readline().split()]
unknownfiles = fp.readline()[:-1].split('\0')
finally:
fp.close()
obj = cls()
obj.name = name
obj.wctx = repo[bin(wctx)]
obj.pendingctx = repo[bin(pendingctx)]
obj.parents = parents
obj.stripnodes = stripnodes
obj.unknownfiles = unknownfiles
return obj
示例2: get_refs
def get_refs(self, remote):
self.export_commits()
client, path = self.get_transport_and_path(remote)
old_refs = {}
new_refs = {}
def changed(refs):
old_refs.update(refs)
to_push = set(self.local_heads().values() + self.tags.values())
new_refs.update(self.get_changed_refs(refs, to_push, True))
# don't push anything
return {}
try:
client.send_pack(path, changed, lambda have, want: [])
changed_refs = [ref for ref, sha in new_refs.iteritems()
if sha != old_refs.get(ref)]
new = [bin(self.map_hg_get(new_refs[ref])) for ref in changed_refs]
old = {}
for r in old_refs:
old_ref = self.map_hg_get(old_refs[r])
if old_ref:
old[bin(old_ref)] = 1
return old, new
except (HangupException, GitProtocolError), e:
raise hgutil.Abort(_("git remote error: ") + str(e))
示例3: updatefromremote
def updatefromremote(ui, repo, remotemarks, path, trfunc, explicit=()):
ui.debug("checking for updated bookmarks\n")
localmarks = repo._bookmarks
(addsrc, adddst, advsrc, advdst, diverge, differ, invalid, same
) = compare(repo, remotemarks, localmarks, dsthex=hex)
status = ui.status
warn = ui.warn
if ui.configbool('ui', 'quietbookmarkmove', False):
status = warn = ui.debug
explicit = set(explicit)
changed = []
for b, scid, dcid in addsrc:
if scid in repo: # add remote bookmarks for changes we already have
changed.append((b, bin(scid), status,
_("adding remote bookmark %s\n") % (b)))
elif b in explicit:
explicit.remove(b)
ui.warn(_("remote bookmark %s points to locally missing %s\n")
% (b, scid[:12]))
for b, scid, dcid in advsrc:
changed.append((b, bin(scid), status,
_("updating bookmark %s\n") % (b)))
# remove normal movement from explicit set
explicit.difference_update(d[0] for d in changed)
for b, scid, dcid in diverge:
if b in explicit:
explicit.discard(b)
changed.append((b, bin(scid), status,
_("importing bookmark %s\n") % (b)))
else:
snode = bin(scid)
db = _diverge(ui, b, path, localmarks, snode)
if db:
changed.append((db, snode, warn,
_("divergent bookmark %s stored as %s\n") %
(b, db)))
else:
warn(_("warning: failed to assign numbered name "
"to divergent bookmark %s\n") % (b))
for b, scid, dcid in adddst + advdst:
if b in explicit:
explicit.discard(b)
changed.append((b, bin(scid), status,
_("importing bookmark %s\n") % (b)))
for b, scid, dcid in differ:
if b in explicit:
explicit.remove(b)
ui.warn(_("remote bookmark %s points to locally missing %s\n")
% (b, scid[:12]))
if changed:
tr = trfunc()
for b, node, writer, msg in sorted(changed):
localmarks[b] = node
writer(msg)
localmarks.recordchange(tr)
示例4: load
def load(cls, repo):
fp = repo.vfs(cls._filename)
try:
version = int(fp.readline().strip())
if version != cls._version:
raise error.Abort(_('this version of shelve is incompatible '
'with the version used in this repo'))
name = fp.readline().strip()
wctx = nodemod.bin(fp.readline().strip())
pendingctx = nodemod.bin(fp.readline().strip())
parents = [nodemod.bin(h) for h in fp.readline().split()]
stripnodes = [nodemod.bin(h) for h in fp.readline().split()]
branchtorestore = fp.readline().strip()
except (ValueError, TypeError) as err:
raise error.CorruptedState(str(err))
finally:
fp.close()
try:
obj = cls()
obj.name = name
obj.wctx = repo[wctx]
obj.pendingctx = repo[pendingctx]
obj.parents = parents
obj.stripnodes = stripnodes
obj.branchtorestore = branchtorestore
except error.RepoLookupError as err:
raise error.CorruptedState(str(err))
return obj
示例5: load
def load(cls, repo):
fp = repo.vfs(cls._filename)
try:
version = int(fp.readline().strip())
if version != cls._version:
raise error.Abort(_('this version of shelve is incompatible '
'with the version used in this repo'))
name = fp.readline().strip()
wctx = fp.readline().strip()
pendingctx = fp.readline().strip()
parents = [nodemod.bin(h) for h in fp.readline().split()]
stripnodes = [nodemod.bin(h) for h in fp.readline().split()]
branchtorestore = fp.readline().strip()
finally:
fp.close()
obj = cls()
obj.name = name
obj.wctx = repo[nodemod.bin(wctx)]
obj.pendingctx = repo[nodemod.bin(pendingctx)]
obj.parents = parents
obj.stripnodes = stripnodes
obj.branchtorestore = branchtorestore
return obj
示例6: parse_manifest
def parse_manifest(mfdict, fdict, lines):
for l in lines.splitlines():
f, n = l.split('\0')
if len(n) > 40:
fdict[f] = n[40:]
mfdict[f] = bin(n[:40])
else:
mfdict[f] = bin(n)
示例7: fromstorage
def fromstorage(cls, line):
(time, user, command, namespace, name,
oldhashes, newhashes) = line.split('\n')
timestamp, tz = time.split()
timestamp, tz = float(timestamp), int(tz)
oldhashes = tuple(node.bin(hash) for hash in oldhashes.split(','))
newhashes = tuple(node.bin(hash) for hash in newhashes.split(','))
return cls(
(timestamp, tz), user, command, namespace, name,
oldhashes, newhashes)
示例8: __init__
def __init__(self, repo):
self._repo = repo
self._vfs = scmutil.vfs(repo.vfs.join('reviewboard'), audit=False)
# Maps review identifiers to identifierrecord instances.
self._identifiers = {}
# Maps parent review id to identifierrecord instances. Shares the same
# object instances as _identifiers.
self._prids = {}
# Maps nodes to noderecord instances.
self._nodes = {}
self.baseurl = None
self.remoteurl = None
try:
for line in repo.vfs('reviews'):
line = line.strip()
if not line:
continue
fields = line.split(' ', 1)
if len(fields) != 2:
repo.ui.warn(_('malformed line in reviews file: %r\n') %
line)
continue
t, d = fields
# Identifier to parent review ID.
if t == 'p':
ident, rrid = d.split(' ', 1)
r = identifierrecord(parentrrid=rrid)
self._identifiers[ident] = r
self._prids[rrid] = r
# Node to review id.
elif t == 'c':
node, rid = d.split(' ', 1)
assert len(node) == 40
r = self._nodes.setdefault(bin(node), noderecord())
r.rrids.add(rid)
# Node to parent id.
elif t == 'pc':
node, pid = d.split(' ', 1)
assert len(node) == 40
self._nodes[bin(node)].parentrrids.add(pid)
elif t == 'u':
self.baseurl = d
elif t == 'r':
self.remoteurl = d
except IOError as inst:
if inst.errno != errno.ENOENT:
raise
示例9: _verifyandtransform
def _verifyandtransform(cls, d):
"""Some basic shelvestate syntactic verification and transformation"""
try:
d['originalwctx'] = nodemod.bin(d['originalwctx'])
d['pendingctx'] = nodemod.bin(d['pendingctx'])
d['parents'] = [nodemod.bin(h)
for h in d['parents'].split(' ')]
d['nodestoremove'] = [nodemod.bin(h)
for h in d['nodestoremove'].split(' ')]
except (ValueError, TypeError, KeyError) as err:
raise error.CorruptedState(str(err))
示例10: putcommit
def putcommit(self, files, copies, parents, commit, source, revmap):
files = dict(files)
def getfilectx(repo, memctx, f):
v = files[f]
data, mode = source.getfile(f, v)
if f == '.hgtags':
data = self._rewritetags(source, revmap, data)
return context.memfilectx(f, data, 'l' in mode, 'x' in mode,
copies.get(f))
pl = []
for p in parents:
if p not in pl:
pl.append(p)
parents = pl
nparents = len(parents)
if self.filemapmode and nparents == 1:
m1node = self.repo.changelog.read(bin(parents[0]))[0]
parent = parents[0]
if len(parents) < 2:
parents.append(nullid)
if len(parents) < 2:
parents.append(nullid)
p2 = parents.pop(0)
text = commit.desc
extra = commit.extra.copy()
if self.branchnames and commit.branch:
extra['branch'] = commit.branch
if commit.rev:
extra['convert_revision'] = commit.rev
while parents:
p1 = p2
p2 = parents.pop(0)
ctx = context.memctx(self.repo, (p1, p2), text, files.keys(),
getfilectx, commit.author, commit.date, extra)
self.repo.commitctx(ctx)
text = "(octopus merge fixup)\n"
p2 = hex(self.repo.changelog.tip())
if self.filemapmode and nparents == 1:
man = self.repo.manifest
mnode = self.repo.changelog.read(bin(p2))[0]
closed = 'close' in commit.extra
if not closed and not man.cmp(m1node, man.revision(mnode)):
self.ui.status(_("filtering out empty revision\n"))
self.repo.rollback()
return parent
return p2
示例11: _obsdeserialise
def _obsdeserialise(flike):
"""read a file like object serialised with _obsserialise
this desierialize into a {subject -> objects} mapping
this was the very first format ever."""
rels = {}
for line in flike:
subhex, objhex = line.split()
subnode = bin(subhex)
if subnode == nullid:
subnode = None
rels.setdefault( subnode, set()).add(bin(objhex))
return rels
示例12: _getcommonheads
def _getcommonheads(repo):
commonheads = []
f = _getfile(repo, hgheadsfile)
if f:
commonheads = f.readlines()
commonheads = [bin(x.strip()) for x in commonheads]
return commonheads
示例13: bundle2pushkey
def bundle2pushkey(orig, op, part):
replacements = dict(sum([record.items()
for record
in op.records[rebaseparttype]],
[]))
namespace = pushkey.decode(part.params['namespace'])
if namespace == 'phases':
key = pushkey.decode(part.params['key'])
part.params['key'] = pushkey.encode(replacements.get(key, key))
if namespace == 'bookmarks':
new = pushkey.decode(part.params['new'])
part.params['new'] = pushkey.encode(replacements.get(new, new))
serverbin = op.repo._bookmarks.get(part.params['key'])
clienthex = pushkey.decode(part.params['old'])
if serverbin and clienthex:
cl = op.repo.changelog
revserver = cl.rev(serverbin)
revclient = cl.rev(bin(clienthex))
if revclient in cl.ancestors([revserver]):
# if the client's bookmark origin is an lagging behind the
# server's location for that bookmark (usual for pushrebase)
# then update the old location to match the real location
#
# TODO: We would prefer to only do this for pushrebase pushes
# but that isn't straightforward so we just do it always here.
# This forbids moving bookmarks backwards from clients.
part.params['old'] = pushkey.encode(hex(serverbin))
return orig(op, part)
示例14: getkeys
def getkeys(ui, repo, mygpg, sigdata, context):
"""get the keys who signed a data"""
fn, ln = context
node, version, sig = sigdata
prefix = "%s:%d" % (fn, ln)
node = hgnode.bin(node)
data = node2txt(repo, node, version)
sig = binascii.a2b_base64(sig)
err, keys = mygpg.verify(data, sig)
if err:
ui.warn("%s:%d %s\n" % (fn, ln, err))
return None
validkeys = []
# warn for expired key and/or sigs
for key in keys:
if key[0] == "BADSIG":
ui.write(_('%s Bad signature from "%s"\n') % (prefix, key[2]))
continue
if key[0] == "EXPSIG":
ui.write(_("%s Note: Signature has expired" ' (signed by: "%s")\n') % (prefix, key[2]))
elif key[0] == "EXPKEYSIG":
ui.write(_("%s Note: This key has expired" ' (signed by: "%s")\n') % (prefix, key[2]))
validkeys.append((key[1], key[2], key[3]))
return validkeys
示例15: hook
def hook(ui, repo, hooktype, node=None, source=None, **kwargs):
'''send email notifications to interested subscribers.
if used as changegroup hook, send one email for all changesets in
changegroup. else send one email per changeset.'''
n = notifier(ui, repo, hooktype)
if not n.subs:
ui.debug(_('notify: no subscribers to repo %s\n') % n.root)
return
if n.skipsource(source):
ui.debug(_('notify: changes have source "%s" - skipping\n') %
source)
return
node = bin(node)
ui.pushbuffer()
if hooktype == 'changegroup':
start = repo.changelog.rev(node)
end = repo.changelog.count()
count = end - start
for rev in xrange(start, end):
n.node(repo.changelog.node(rev))
n.diff(node, repo.changelog.tip())
else:
count = 1
n.node(node)
n.diff(node, node)
data = ui.popbuffer()
n.send(node, count, data)