本文整理汇总了Python中mercurial.node.hex函数的典型用法代码示例。如果您正苦于以下问题:Python hex函数的具体用法?Python hex怎么用?Python hex使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了hex函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: save
def save(cls, repo, name, stripnodes):
fp = repo.opener(cls._filename, 'wb')
fp.write('%i\n' % cls._version)
fp.write('%s\n' % name)
fp.write('%s\n' % ' '.join([hex(p) for p in repo.dirstate.parents()]))
fp.write('%s\n' % ' '.join([hex(n) for n in stripnodes]))
fp.close()
开发者ID:jordigh,项目名称:mercurial-crew,代码行数:7,代码来源:shelve.py
示例2: export_hg_tags
def export_hg_tags(self):
for tag, sha in self.repo.tags().iteritems():
# git doesn't like spaces in tag names
tag = tag.replace(" ", "_")
if self.repo.tagtype(tag) in ('global', 'git'):
self.git.refs['refs/tags/' + tag] = self.map_git_get(hex(sha))
self.tags[tag] = hex(sha)
开发者ID:lloyd,项目名称:hg-git,代码行数:7,代码来源:git_handler.py
示例3: pathcopies
def pathcopies(orig, x, y, match=None):
func = lambda: orig(x, y, match=match)
if x._node is not None and y._node is not None and not match:
key = 'pathcopies:%s:%s' % (
node.hex(x._node), node.hex(y._node))
return memoize(func, key, pathcopiesserializer, ui)
return func()
开发者ID:davidshepherd7,项目名称:dotfiles,代码行数:7,代码来源:simplecache.py
示例4: test_push_to_default
def test_push_to_default(self, commit=True):
repo = self.repo
old_tip = repo['tip'].node()
expected_parent = repo['default'].node()
def file_callback(repo, memctx, path):
if path == 'adding_file':
return context.memfilectx(path=path,
data='foo',
islink=False,
isexec=False,
copied=False)
raise IOError(errno.EINVAL, 'Invalid operation: ' + path)
ctx = context.memctx(repo,
(repo['default'].node(), node.nullid),
'automated test',
['adding_file'],
file_callback,
'an_author',
'2008-10-07 20:59:48 -0500',
{'branch': 'default',})
new_hash = repo.commitctx(ctx)
if not commit:
return # some tests use this test as an extended setup.
hg.update(repo, repo['tip'].node())
self.pushrevisions()
tip = self.repo['tip']
self.assertNotEqual(tip.node(), old_tip)
self.assertEqual(node.hex(tip.parents()[0].node()),
node.hex(expected_parent))
self.assertEqual(tip['adding_file'].data(), 'foo')
self.assertEqual(tip.branch(), 'default')
开发者ID:bulwinkel,项目名称:dot-files,代码行数:31,代码来源:test_push_command.py
示例5: puttags
def puttags(self, tags):
try:
parentctx = self.repo[self.tagsbranch]
tagparent = parentctx.node()
except error.RepoError:
parentctx = None
tagparent = nullid
try:
oldlines = sorted(parentctx['.hgtags'].data().splitlines(True))
except:
oldlines = []
newlines = sorted([("%s %s\n" % (tags[tag], tag)) for tag in tags])
if newlines == oldlines:
return None, None
data = "".join(newlines)
def getfilectx(repo, memctx, f):
return context.memfilectx(f, data, False, False, None)
self.ui.status(_("updating tags\n"))
date = "%s 0" % int(time.mktime(time.gmtime()))
extra = {'branch': self.tagsbranch}
ctx = context.memctx(self.repo, (tagparent, None), "update tags",
[".hgtags"], getfilectx, "convert-repo", date,
extra)
self.repo.commitctx(ctx)
return hex(self.repo.changelog.tip()), hex(tagparent)
开发者ID:MezzLabs,项目名称:mercurial,代码行数:28,代码来源:hg.py
示例6: writefirefoxtrees
def writefirefoxtrees(repo):
"""Write the firefoxtrees node mapping to the filesystem."""
lines = []
trees = {}
for tree, node in sorted(repo.firefoxtrees.items()):
assert len(node) == 20
lines.append('%s %s' % (tree, hex(node)))
trees[tree] = hex(node)
_firefoxtreesrepo(repo).vfs.write('firefoxtrees', '\n'.join(lines))
# Old versions of firefoxtrees stored labels in the localtags file. Since
# this file is read by Mercurial and has no relevance to us any more, we
# prune relevant entries from this file so the data isn't redundant with
# what we now write.
localtags = repo.opener.tryread('localtags')
havedata = len(localtags) > 0
taglines = []
for line in localtags.splitlines():
line = line.strip()
node, tag = line.split()
tree, uri = resolve_trees_to_uris([tag])[0]
if not uri:
taglines.append(line)
if havedata:
repo.vfs.write('localtags', '\n'.join(taglines))
开发者ID:armenzg,项目名称:version-control-tools,代码行数:27,代码来源:__init__.py
示例7: computenonoverlap
def computenonoverlap(orig, repo, c1, c2, *args, **kwargs):
u1, u2 = orig(repo, c1, c2, *args, **kwargs)
if shallowrepo.requirement in repo.requirements:
m1 = c1.manifest()
m2 = c2.manifest()
files = []
sparsematch1 = repo.maybesparsematch(c1.rev())
if sparsematch1:
sparseu1 = []
for f in u1:
if sparsematch1(f):
files.append((f, hex(m1[f])))
sparseu1.append(f)
u1 = sparseu1
sparsematch2 = repo.maybesparsematch(c2.rev())
if sparsematch2:
sparseu2 = []
for f in u2:
if sparsematch2(f):
files.append((f, hex(m2[f])))
sparseu2.append(f)
u2 = sparseu2
# batch fetch the needed files from the server
repo.fileservice.prefetch(files)
return u1, u2
开发者ID:davidshepherd7,项目名称:dotfiles,代码行数:28,代码来源:__init__.py
示例8: add
def add(entry, f, isdest):
seen.add(f)
h = entry[3]
p = (entry[1] == "100755")
s = (entry[1] == "120000")
renamesource = (not isdest and entry[4][0] == 'R')
if f == '.gitmodules':
if skipsubmodules:
return
subexists[0] = True
if entry[4] == 'D' or renamesource:
subdeleted[0] = True
changes.append(('.hgsub', hex(nullid)))
else:
changes.append(('.hgsub', ''))
elif entry[1] == '160000' or entry[0] == ':160000':
if not skipsubmodules:
subexists[0] = True
else:
if renamesource:
h = hex(nullid)
self.modecache[(f, h)] = (p and "x") or (s and "l") or ""
changes.append((f, h))
开发者ID:seewindcn,项目名称:tortoisehg,代码行数:25,代码来源:git.py
示例9: fix_hgtags
def fix_hgtags(ui, repo, head_hgtags, tagsmap):
for tf in iter(tagsmap):
ui.debug('fix_hgtags: tagsmap %s -> %s\n' % (tf, tagsmap[tf]))
for old in iter(head_hgtags):
new = map_recursive(tagsmap, old)
ui.debug('fix_hgtags: head %s -> %s\n' % (old, new))
merge.update(repo, repo[new].node(), False, False, False)
tfile = open('.hgtags', 'wb')
lines = StringIO.StringIO(head_hgtags[old])
for line in lines:
if not line:
continue
(nodehex, name) = line.split(" ", 1)
name = name.strip()
nhm = map_recursive(tagsmap, nodehex)
ui.debug('fix_hgtags: hgtags write: %s %s\n' % (nhm, name))
tfile.write('%s %s\n' % (nhm, name))
lines.close()
tfile.close()
wctx = repo[None]
if '.hgtags' not in wctx:
wctx.add(['.hgtags'])
nrev = repo.commit(text="collapse tag fix")
if nrev:
nctx = repo[nrev]
ui.debug(_('fix_hgtags: nctx rev %d node %r files %r\n') %
(nctx.rev(), hex(nctx.node()), nctx.files()))
ui.debug(_('fix_hgtags: nctx parents %r\n') %
([hex(p.node()) for p in nctx.parents()]))
else:
ui.debug(_('fix_hgtags: nctx: None\n'))
开发者ID:ellipsis-index,项目名称:zeekay-dot-files,代码行数:31,代码来源:collapse.py
示例10: test_fresh_fetch_two_revs
def test_fresh_fetch_two_revs(self):
repo = self._load_fixture_and_fetch('two_revs.svndump')
self.assertEqual(node.hex(repo[0].node()),
'434ed487136c1b47c1e8f952edb4dc5a8e6328df')
self.assertEqual(node.hex(repo['tip'].node()),
'c95251e0dd04697deee99b79cc407d7db76e6a5f')
self.assertEqual(repo['tip'], repo[1])
开发者ID:avuori,项目名称:dotfiles,代码行数:7,代码来源:test_fetch_command.py
示例11: changeset
def changeset(self, tmpl, ctx):
n = ctx.node()
showtags = self.showtag(tmpl, 'changesettag', n)
parents = ctx.parents()
p1 = parents[0].node()
files = []
parity = paritygen(self.stripecount)
for f in ctx.files():
files.append(tmpl("filenodelink",
node=hex(n), file=f,
parity=parity.next()))
def diff(**map):
yield self.diff(tmpl, p1, n, None)
return tmpl('changeset',
diff=diff,
rev=ctx.rev(),
node=hex(n),
parent=self.siblings(parents),
child=self.siblings(ctx.children()),
changesettag=showtags,
author=ctx.user(),
desc=ctx.description(),
date=ctx.date(),
files=files,
archives=self.archivelist(hex(n)),
tags=self.nodetagsdict(n),
branch=self.nodebranchnodefault(ctx),
inbranch=self.nodeinbranch(ctx),
branches=self.nodebranchdict(ctx))
开发者ID:c0ns0le,项目名称:cygwin,代码行数:32,代码来源:hgweb_mod.py
示例12: committags
def committags(self, rev, endbranches):
if not self.addedtags and not self.deletedtags:
return
date = self.fixdate(rev.date)
# determine additions/deletions per branch
branches = {}
for tags in (self.addedtags, self.deletedtags):
for tag, (branch, srcrev) in tags.iteritems():
op = srcrev is None and 'rm' or 'add'
branches.setdefault(branch, []).append((op, tag, srcrev))
for b, tags in branches.iteritems():
fromtag = self.get_path_tag(self.remotename(b))
# modify parent's .hgtags source
parent = self.repo[self.get_parent_revision(rev.revnum, b)]
if '.hgtags' not in parent:
src = ''
else:
src = parent['.hgtags'].data()
for op, tag, r in sorted(tags, reverse=True):
if op == 'add':
if fromtag:
if fromtag in self.tags:
tagged = node.hex(self.tags[fromtag])
else:
tagged = node.hex(self.revmap[
self.get_parent_svn_branch_and_rev(r, b)])
else:
tagged = node.hex(node.nullid)
src += '%s %s\n' % (tagged, tag)
self.tags[tag] = node.bin(tagged), rev.revnum
# add new changeset containing updated .hgtags
def fctxfun(repo, memctx, path):
return context.memfilectx(path='.hgtags', data=src,
islink=False, isexec=False,
copied=None)
extra = self.genextra(rev.revnum, b)
if fromtag:
extra['branch'] = parent.extra().get('branch', 'default')
self.mapbranch(extra, b in endbranches or fromtag)
ctx = context.memctx(self.repo,
(parent.node(), node.nullid),
rev.message or ' ',
['.hgtags'],
fctxfun,
self.authors[rev.author],
date,
extra)
new = self.repo.commitctx(ctx)
if not fromtag and (rev.revnum, b) not in self.revmap:
self.revmap[rev.revnum, b] = new
if b in endbranches:
endbranches.pop(b)
bname = b or 'default'
self.ui.status('Marked branch %s as closed.\n' % bname)
开发者ID:chaptastic,项目名称:config_files,代码行数:59,代码来源:svnmeta.py
示例13: __str__
def __str__(self):
"""String representation for storage"""
time = ' '.join(map(str, self.timestamp))
oldhashes = ','.join([node.hex(hash) for hash in self.oldhashes])
newhashes = ','.join([node.hex(hash) for hash in self.newhashes])
return '\n'.join((
time, self.user, self.command, self.namespace, self.name,
oldhashes, newhashes))
开发者ID:motlin,项目名称:cyg,代码行数:8,代码来源:journal.py
示例14: runhooks
def runhooks():
args = hookargs.copy()
args['node'] = hex(added[0])
op.repo.hook("changegroup", **args)
for n in added:
args = hookargs.copy()
args['node'] = hex(n)
op.repo.hook("incoming", **args)
开发者ID:Nephyrin,项目名称:bzexport,代码行数:8,代码来源:__init__.py
示例15: movedescendants
def movedescendants(ui, repo, collapsed, tomove, movemap, tagsmap,
parent_hgtags, movelog, debug_delay):
'Moves the descendants of the source revisions to the collapsed revision'
sorted_tomove = list(tomove)
sorted_tomove.sort()
for r in sorted_tomove:
ui.debug(_('moving revision %r\n') % r)
if debug_delay:
ui.debug(_('sleep debug_delay: %r\n') % debug_delay)
time.sleep(debug_delay)
parents = [p.rev() for p in repo[r].parents()]
nodehex = hex(repo[r].node())
if repo[r].files() == ['.hgtags'] and len(parents) == 1:
movemap[r] = movemap[parents[0]]
phex = hex(repo[parents[0]].node())
assert phex in tagsmap
tagsmap[nodehex] = tagsmap[phex]
else:
if len(parents) == 1:
ui.debug(_('setting parent to %d\n')
% movemap[parents[0]].rev())
repo.dirstate.setparents(movemap[parents[0]].node())
else:
ui.debug(_('setting parents to %d and %d\n') %
(map_or_rev(repo, movemap, parents[0]).rev(),
map_or_rev(repo, movemap, parents[1]).rev()))
repo.dirstate.setparents(map_or_rev(repo, movemap,
parents[0]).node(),
map_or_rev(repo, movemap,
parents[1]).node())
repo.dirstate.write()
ui.debug(_('reverting to revision %d\n') % r)
recreaterev(ui, repo, r)
write_hgtags(parent_hgtags)
newrev = repo.commit(text=repo[r].description(),
user=repo[r].user(), date=repo[r].date(),
force=True)
if newrev == None:
raise util.Abort(_('no commit done: text=%r, user=%r, date=%r')
% (repo[r].description(), repo[r].user(),
repo[r].date()))
ctx = repo[newrev]
movemap[r] = ctx
newhex = hex(ctx.node())
tagsmap[nodehex] = newhex
ui.debug(_('movedescendants %s -> %s\n' % (nodehex, newhex)))
if movelog:
movelog.write('move %s -> %s\n' % (nodehex, newhex))
开发者ID:ellipsis-index,项目名称:zeekay-dot-files,代码行数:58,代码来源:collapse.py
示例16: makecollapsed
def makecollapsed(ui, repo, parent, revs, branch, tagsmap, parent_hgtags,
movelog, opts):
'Creates the collapsed revision on top of parent'
last = max(revs)
ui.debug(_('updating to revision %d\n') % parent)
merge.update(repo, parent.node(), False, False, False)
ui.debug(_('reverting to revision %d\n') % last)
recreaterev(ui, repo, last)
repo.dirstate.setbranch(branch)
msg = ''
nodelist = []
if opts['message'] != "" :
msg = opts['message']
else:
first = True
for r in revs:
nodelist.append(hex(repo[r].node()))
if repo[r].files() != ['.hgtags']:
if not first:
if opts['changelog']:
msg += '\n'
else:
msg += '----------------\n'
first = False
if opts['changelog']:
msg += "* " + ' '.join(repo[r].files()) + ":\n"
msg += repo[r].description() + "\n"
msg += "\nHG: Enter commit message. Lines beginning with 'HG:' are removed.\n"
msg += "HG: Remove all lines to abort the collapse operation.\n"
if ui.config('ui', 'interactive') != 'off':
msg = ui.edit(msg, ui.username())
pattern = re.compile("^HG:.*\n", re.MULTILINE);
msg = re.sub(pattern, "", msg).strip();
if not msg:
raise util.Abort(_('empty commit message, collapse won\'t proceed'))
write_hgtags(parent_hgtags)
newrev = repo.commit(
text=msg,
user=repo[last].user(),
date=repo[last].date())
ctx = repo[newrev]
newhex = hex(ctx.node())
for n in nodelist:
ui.debug(_('makecollapsed %s -> %s\n' % (n, newhex)))
tagsmap[n] = newhex
if movelog:
movelog.write('coll %s -> %s\n' % (n, newhex))
return ctx
开发者ID:ellipsis-index,项目名称:zeekay-dot-files,代码行数:58,代码来源:collapse.py
示例17: save
def save(cls, repo, name, originalwctx, pendingctx, stripnodes):
fp = repo.vfs(cls._filename, 'wb')
fp.write('%i\n' % cls._version)
fp.write('%s\n' % name)
fp.write('%s\n' % hex(originalwctx.node()))
fp.write('%s\n' % hex(pendingctx.node()))
fp.write('%s\n' % ' '.join([hex(p) for p in repo.dirstate.parents()]))
fp.write('%s\n' % ' '.join([hex(n) for n in stripnodes]))
fp.close()
开发者ID:html-shell,项目名称:mozilla-build,代码行数:9,代码来源:shelve.py
示例18: comparison
def comparison(web, req, tmpl):
ctx = webutil.changectx(web.repo, req)
if 'file' not in req.form:
raise ErrorResponse(HTTP_NOT_FOUND, 'file not given')
path = webutil.cleanpath(web.repo, req.form['file'][0])
rename = path in ctx and webutil.renamelink(ctx[path]) or []
parsecontext = lambda v: v == 'full' and -1 or int(v)
if 'context' in req.form:
context = parsecontext(req.form['context'][0])
else:
context = parsecontext(web.config('web', 'comparisoncontext', '5'))
def filelines(f):
if util.binary(f.data()):
mt = mimetypes.guess_type(f.path())[0]
if not mt:
mt = 'application/octet-stream'
return [_('(binary file %s, hash: %s)') % (mt, hex(f.filenode()))]
return f.data().splitlines()
parent = ctx.p1()
leftrev = parent.rev()
leftnode = parent.node()
rightrev = ctx.rev()
rightnode = ctx.node()
if path in ctx:
fctx = ctx[path]
rightlines = filelines(fctx)
if path not in parent:
leftlines = ()
else:
pfctx = parent[path]
leftlines = filelines(pfctx)
else:
rightlines = ()
fctx = ctx.parents()[0][path]
leftlines = filelines(fctx)
comparison = webutil.compare(tmpl, context, leftlines, rightlines)
return tmpl('filecomparison',
file=path,
node=hex(ctx.node()),
rev=ctx.rev(),
date=ctx.date(),
desc=ctx.description(),
extra=ctx.extra(),
author=ctx.user(),
rename=rename,
branch=webutil.nodebranchnodefault(ctx),
parent=webutil.parents(fctx),
child=webutil.children(fctx),
leftrev=leftrev,
leftnode=hex(leftnode),
rightrev=rightrev,
rightnode=hex(rightnode),
comparison=comparison)
开发者ID:ZanderZhang,项目名称:Andriod-Learning,代码行数:57,代码来源:webcommands.py
示例19: generatefiles
def generatefiles(self, changedfiles, linknodes, commonrevs, source):
if requirement in self._repo.requirements:
repo = self._repo
if isinstance(repo, bundlerepo.bundlerepository):
# If the bundle contains filelogs, we can't pull from it, since
# bundlerepo is heavily tied to revlogs. Instead require that
# the user use unbundle instead.
# Force load the filelog data.
bundlerepo.bundlerepository.file(repo, 'foo')
if repo._cgfilespos:
raise error.Abort("cannot pull from full bundles",
hint="use `hg unbundle` instead")
return []
filestosend = self.shouldaddfilegroups(source)
if filestosend == NoFiles:
changedfiles = list([f for f in changedfiles
if not repo.shallowmatch(f)])
else:
files = []
# Prefetch the revisions being bundled
for i, fname in enumerate(sorted(changedfiles)):
filerevlog = repo.file(fname)
linkrevnodes = linknodes(filerevlog, fname)
# Normally we'd prune the linkrevnodes first,
# but that would perform the server fetches one by one.
for fnode, cnode in list(linkrevnodes.iteritems()):
# Adjust linknodes so remote file revisions aren't sent
if filestosend == LocalFiles:
localkey = fileserverclient.getlocalkey(fname,
hex(fnode))
localpath = repo.sjoin(os.path.join("data",
localkey))
if (not os.path.exists(localpath)
and repo.shallowmatch(fname)):
del linkrevnodes[fnode]
else:
files.append((fname, hex(fnode)))
else:
files.append((fname, hex(fnode)))
repo.fileservice.prefetch(files)
# Prefetch the revisions that are going to be diffed against
prevfiles = []
for fname, fnode in files:
if repo.shallowmatch(fname):
fnode = bin(fnode)
filerevlog = repo.file(fname)
ancestormap = filerevlog.ancestormap(fnode)
p1, p2, linknode, copyfrom = ancestormap[fnode]
if p1 != nullid:
prevfiles.append((copyfrom or fname, hex(p1)))
repo.fileservice.prefetch(prevfiles)
return super(shallowcg1packer, self).generatefiles(changedfiles,
linknodes, commonrevs, source)
开发者ID:davidshepherd7,项目名称:dotfiles,代码行数:57,代码来源:shallowbundle.py
示例20: test_oldest_not_trunk_and_tag_vendor_branch
def test_oldest_not_trunk_and_tag_vendor_branch(self):
repo = self._load_fixture_and_fetch(
'tagged_vendor_and_oldest_not_trunk.svndump')
self.assertEqual(node.hex(repo['oldest'].node()),
'926671740dec045077ab20f110c1595f935334fa')
self.assertEqual(repo['tip'].parents()[0].parents()[0],
repo['oldest'])
self.assertEqual(node.hex(repo['tip'].node()),
'1a6c3f30911d57abb67c257ec0df3e7bc44786f7')
开发者ID:avuori,项目名称:dotfiles,代码行数:9,代码来源:test_fetch_command.py
注:本文中的mercurial.node.hex函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论