本文整理汇总了Python中mercurial.patch.diffopts函数的典型用法代码示例。如果您正苦于以下问题:Python diffopts函数的具体用法?Python diffopts怎么用?Python diffopts使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了diffopts函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: cdm_pdiffs
def cdm_pdiffs(ui, repo, *pats, **opts):
'''diff workspace against its parent
Show differences between this workspace and its parent workspace
in the same manner as 'hg diff'.
For a description of the changeset used to represent the parent
workspace, see The Parent in the extension documentation ('hg help
cdm').
'''
act = wslist[repo].active(opts.get('parent'))
if not act.revs:
return
#
# If no patterns were specified, either explicitly or via -I or -X
# use the active list files to avoid a workspace walk.
#
if pats or opts.get('include') or opts.get('exclude'):
matchfunc = wslist[repo].matcher(pats=pats, opts=opts)
else:
matchfunc = wslist[repo].matcher(files=act.files())
opts = patch.diffopts(ui, opts)
diffs = wslist[repo].diff(act.parenttip.node(), act.localtip.node(),
match=matchfunc, opts=opts)
if diffs:
ui.write(diffs)
开发者ID:apprisi,项目名称:illumos-gate,代码行数:29,代码来源:cdm.py
示例2: savediff
def savediff():
opts = {'git': True}
fp = opener('.saved', 'w')
for chunk in patch.diff(repo, head, None,
opts=patch.diffopts(self.ui, opts)):
fp.write(chunk)
fp.close()
开发者ID:axtl,项目名称:dotfiles,代码行数:7,代码来源:attic.py
示例3: diff
def diff(orig, ui, repo, *args, **opts):
"""show a diff of the most recent revision against its parent from svn
"""
if not opts.get('svn', False) or opts.get('change', None):
return orig(ui, repo, *args, **opts)
meta = repo.svnmeta()
hashes = meta.revmap.hashes()
if not opts.get('rev', None):
parent = repo.parents()[0]
o_r = util.outgoing_revisions(repo, hashes, parent.node())
if o_r:
parent = repo[o_r[-1]].parents()[0]
opts['rev'] = ['%s:.' % node.hex(parent.node()), ]
node1, node2 = cmdutil.revpair(repo, opts['rev'])
baserev, _junk = hashes.get(node1, (-1, 'junk'))
newrev, _junk = hashes.get(node2, (-1, 'junk'))
it = patch.diff(repo, node1, node2,
opts=patch.diffopts(ui, opts={'git': True,
'show_function': False,
'ignore_all_space': False,
'ignore_space_change': False,
'ignore_blank_lines': False,
'unified': True,
'text': False,
}))
ui.write(util.filterdiff(''.join(it), baserev, newrev))
开发者ID:chaptastic,项目名称:config_files,代码行数:26,代码来源:wrappers.py
示例4: autodiff
def autodiff(ui, repo, *pats, **opts):
diffopts = patch.diffopts(ui, opts)
git = opts.get('git', 'no')
brokenfiles = set()
losedatafn = None
if git in ('yes', 'no'):
diffopts.git = git == 'yes'
diffopts.upgrade = False
elif git == 'auto':
diffopts.git = False
diffopts.upgrade = True
elif git == 'warn':
diffopts.git = False
diffopts.upgrade = True
def losedatafn(fn=None, **kwargs):
brokenfiles.add(fn)
return True
elif git == 'abort':
diffopts.git = False
diffopts.upgrade = True
def losedatafn(fn=None, **kwargs):
raise util.Abort('losing data for %s' % fn)
else:
raise util.Abort('--git must be yes, no or auto')
node1, node2 = scmutil.revpair(repo, [])
m = scmutil.match(repo[node2], pats, opts)
it = patch.diff(repo, node1, node2, match=m, opts=diffopts,
losedatafn=losedatafn)
for chunk in it:
ui.write(chunk)
for fn in sorted(brokenfiles):
ui.write(('data lost for: %s\n' % fn))
开发者ID:chuchiperriman,项目名称:hg-stable,代码行数:33,代码来源:autodiff.py
示例5: recordfunc
def recordfunc(ui, repo, message, match, opts):
"""This is generic record driver.
Its job is to interactively filter local changes, and
accordingly prepare working directory into a state in which the
job can be delegated to a non-interactive commit command such as
'commit' or 'qrefresh'.
After the actual job is done by non-interactive command, the
working directory is restored to its original state.
In the end we'll record interesting changes, and everything else
will be left in place, so the user can continue working.
"""
cmdutil.checkunfinished(repo, commit=True)
merge = len(repo[None].parents()) > 1
if merge:
raise util.Abort(_("cannot partially commit a merge " '(use "hg commit" instead)'))
status = repo.status(match=match)
diffopts = opts.copy()
diffopts["nodates"] = True
diffopts["git"] = True
diffopts = patch.diffopts(ui, opts=diffopts)
chunks = patch.diff(repo, changes=status, opts=diffopts)
fp = cStringIO.StringIO()
fp.write("".join(chunks))
fp.seek(0)
# 1. filter patch, so we have intending-to apply subset of it
try:
chunks = filterpatch(ui, parsepatch(fp))
except patch.PatchError, err:
raise util.Abort(_("error parsing patch: %s") % err)
开发者ID:ZanderZhang,项目名称:Andriod-Learning,代码行数:35,代码来源:record.py
示例6: __init__
def __init__(self, repoagent, parent=None):
super(AnnotateView, self).__init__(parent)
self.setReadOnly(True)
self.setMarginLineNumbers(1, True)
self.setMarginType(2, qsci.TextMarginRightJustified)
self.setMouseTracking(False)
self._repoagent = repoagent
repo = repoagent.rawRepo()
# TODO: replace by repoagent if sci.repo = bundlerepo can be removed
self.repo = repo
self._annotation_enabled = False
self._links = [] # by line
self._anncache = {} # by rev
self._revmarkers = {} # by rev
self._lastrev = None
diffopts = patch.diffopts(repo.ui, section='annotate')
self._thread = AnnotateThread(self, diffopts=diffopts)
self._thread.finished.connect(self.fillModel)
self._initAnnotateOptionActions()
self._repoagent.configChanged.connect(self.configChanged)
self.configChanged()
self._loadAnnotateSettings()
开发者ID:velorientc,项目名称:git_test7,代码行数:27,代码来源:fileview.py
示例7: dohgdiff
def dohgdiff():
difftext = StringIO.StringIO()
try:
if len(files) != 0:
wfiles = [self.repo.wjoin(x) for x in files]
fns, matchfn, anypats = cmdutil.matchpats(self.repo, wfiles, self.opts)
patch.diff(self.repo, self._node1, self._node2, fns, match=matchfn,
fp=difftext, opts=patch.diffopts(self.ui, self.opts))
buffer = gtk.TextBuffer()
buffer.create_tag('removed', foreground='#900000')
buffer.create_tag('added', foreground='#006400')
buffer.create_tag('position', foreground='#FF8000')
buffer.create_tag('header', foreground='#000090')
difftext.seek(0)
iter = buffer.get_start_iter()
for line in difftext:
line = toutf(line)
if line.startswith('---') or line.startswith('+++'):
buffer.insert_with_tags_by_name(iter, line, 'header')
elif line.startswith('-'):
buffer.insert_with_tags_by_name(iter, line, 'removed')
elif line.startswith('+'):
buffer.insert_with_tags_by_name(iter, line, 'added')
elif line.startswith('@@'):
buffer.insert_with_tags_by_name(iter, line, 'position')
else:
buffer.insert(iter, line)
self.diff_text.set_buffer(buffer)
finally:
difftext.close()
开发者ID:tdjordan,项目名称:tortoisegit,代码行数:33,代码来源:status.py
示例8: finishfold
def finishfold(ui, repo, ctx, oldctx, newnode, opts, internalchanges):
parent = ctx.parents()[0].node()
hg.update(repo, parent)
fd, patchfile = tempfile.mkstemp(prefix='hg-histedit-')
fp = os.fdopen(fd, 'w')
diffopts = patch.diffopts(ui, opts)
diffopts.git = True
gen = patch.diff(repo, parent, newnode, opts=diffopts)
for chunk in gen:
fp.write(chunk)
fp.close()
files = {}
try:
patch.patch(patchfile, ui, cwd=repo.root, files=files, eolmode=None)
finally:
files = patch.updatedir(ui, repo, files)
os.unlink(patchfile)
newmessage = '\n***\n'.join(
[ctx.description(), ] +
[repo[r].description() for r in internalchanges] +
[oldctx.description(), ])
newmessage = ui.edit(newmessage, ui.username())
n = repo.commit(text=newmessage, user=ui.username(), date=max(ctx.date(), oldctx.date()),
extra=oldctx.extra())
return repo[n], [n, ], [oldctx.node(), ctx.node() ], [newnode, ] # xxx
开发者ID:Garoth,项目名称:Configs,代码行数:25,代码来源:__init__.py
示例9: pick
def pick(ui, repo, ctx, ha, opts):
oldctx = repo[ha]
if oldctx.parents()[0] == ctx:
ui.debug('node %s unchanged\n' % ha)
return oldctx, [], [], []
hg.update(repo, ctx.node())
fd, patchfile = tempfile.mkstemp(prefix='hg-histedit-')
fp = os.fdopen(fd, 'w')
diffopts = patch.diffopts(ui, opts)
diffopts.git = True
gen = patch.diff(repo, oldctx.parents()[0].node(), ha, opts=diffopts)
for chunk in gen:
fp.write(chunk)
fp.close()
try:
files = {}
try:
patch.patch(patchfile, ui, cwd=repo.root, files=files, eolmode=None)
if not files:
ui.warn(_('%s: empty changeset')
% node.hex(ha))
return ctx, [], [], []
finally:
files = patch.updatedir(ui, repo, files)
os.unlink(patchfile)
except Exception, inst:
raise util.Abort(_('Fix up the change and run '
'hg histedit --continue'))
开发者ID:Garoth,项目名称:Configs,代码行数:28,代码来源:__init__.py
示例10: finishfold
def finishfold(ui, repo, ctx, oldctx, newnode, opts, internalchanges):
parent = ctx.parents()[0].node()
hg.update(repo, parent)
fd, patchfile = tempfile.mkstemp(prefix='hg-histedit-')
fp = os.fdopen(fd, 'w')
diffopts = patch.diffopts(ui, opts)
diffopts.git = True
diffopts.ignorews = False
diffopts.ignorewsamount = False
diffopts.ignoreblanklines = False
gen = patch.diff(repo, parent, newnode, opts=diffopts)
for chunk in gen:
fp.write(chunk)
fp.close()
files = set()
try:
applypatch(ui, repo, patchfile, files=files, eolmode=None)
finally:
os.unlink(patchfile)
newmessage = '\n***\n'.join(
[ctx.description(), ] +
[repo[r].description() for r in internalchanges] +
[oldctx.description(), ])
# If the changesets are from the same author, keep it.
if ctx.user() == oldctx.user():
username = ctx.user()
else:
username = ui.username()
newmessage = ui.edit(newmessage, username)
n = repo.commit(text=newmessage, user=username, date=max(ctx.date(), oldctx.date()),
extra=oldctx.extra())
return repo[n], [n, ], [oldctx.node(), ctx.node() ], [newnode, ] # xxx
开发者ID:SeanTAllen,项目名称:dotfiles,代码行数:32,代码来源:hg_histedit.py
示例11: fold
def fold(ui, repo, ctx, ha, opts):
oldctx = repo[ha]
hg.update(repo, ctx.node())
fd, patchfile = tempfile.mkstemp(prefix='hg-histedit-')
fp = os.fdopen(fd, 'w')
diffopts = patch.diffopts(ui, opts)
diffopts.git = True
diffopts.ignorews = False
diffopts.ignorewsamount = False
diffopts.ignoreblanklines = False
gen = patch.diff(repo, oldctx.parents()[0].node(), ha, opts=diffopts)
for chunk in gen:
fp.write(chunk)
fp.close()
try:
files = set()
try:
applypatch(ui, repo, patchfile, files=files, eolmode=None)
if not files:
ui.warn(_('%s: empty changeset')
% node.hex(ha))
return ctx, [], [], []
finally:
os.unlink(patchfile)
except Exception, inst:
raise util.Abort(_('Fix up the change and run '
'hg histedit --continue'))
开发者ID:SeanTAllen,项目名称:dotfiles,代码行数:27,代码来源:hg_histedit.py
示例12: _show
def _show(self, ctx, copies, matchfn, props):
if not matchfn:
matchfn = self.patch
node = ctx.node()
diffopts = patch.diffopts(self.ui, self.diffopts)
prev = self.repo.changelog.parents(node)[0]
self.diff(diffopts, prev, node, match=matchfn)
self.ui.write("\n")
开发者ID:humitos,项目名称:bash-dotfiles,代码行数:9,代码来源:blametrail.py
示例13: getpatches
def getpatches(revs):
prev = repo['.'].rev()
for r in scmutil.revrange(repo, revs):
if r == prev and (repo[None].files() or repo[None].deleted()):
ui.warn(_('warning: working directory has '
'uncommitted changes\n'))
output = cStringIO.StringIO()
cmdutil.export(repo, [r], fp=output,
opts=patch.diffopts(ui, opts))
yield output.getvalue().split('\n')
开发者ID:ZanderZhang,项目名称:Andriod-Learning,代码行数:10,代码来源:patchbomb.py
示例14: diffs
def diffs(repo, tmpl, ctx, basectx, files, parity, style):
def countgen():
start = 1
while True:
yield start
start += 1
blockcount = countgen()
def prettyprintlines(diff, blockno):
for lineno, l in enumerate(diff.splitlines(True)):
difflineno = "%d.%d" % (blockno, lineno + 1)
if l.startswith('+'):
ltype = "difflineplus"
elif l.startswith('-'):
ltype = "difflineminus"
elif l.startswith('@'):
ltype = "difflineat"
else:
ltype = "diffline"
yield tmpl(ltype,
line=l,
lineno=lineno + 1,
lineid="l%s" % difflineno,
linenumber="% 8s" % difflineno)
if files:
m = match.exact(repo.root, repo.getcwd(), files)
else:
m = match.always(repo.root, repo.getcwd())
diffopts = patch.diffopts(repo.ui, untrusted=True)
if basectx is None:
parents = ctx.parents()
if parents:
node1 = parents[0].node()
else:
node1 = nullid
else:
node1 = basectx.node()
node2 = ctx.node()
block = []
for chunk in patch.diff(repo, node1, node2, m, opts=diffopts):
if chunk.startswith('diff') and block:
blockno = blockcount.next()
yield tmpl('diffblock', parity=parity.next(), blockno=blockno,
lines=prettyprintlines(''.join(block), blockno))
block = []
if chunk.startswith('diff') and style != 'raw':
chunk = ''.join(chunk.splitlines(True)[1:])
block.append(chunk)
blockno = blockcount.next()
yield tmpl('diffblock', parity=parity.next(), blockno=blockno,
lines=prettyprintlines(''.join(block), blockno))
开发者ID:html-shell,项目名称:mozilla-build,代码行数:55,代码来源:webutil.py
示例15: getdiff
def getdiff(ui, repo, r, parent, opts):
'''return diff for the specified revision'''
output = ""
if opts.get('git') or ui.configbool('diff', 'git'):
# Git diffs don't include the revision numbers with each file, so
# we have to put them in the header instead.
output += "# Node ID " + node.hex(r.node()) + "\n"
output += "# Parent " + node.hex(parent.node()) + "\n"
diffopts = patch.diffopts(ui, opts)
for chunk in patch.diff(repo, parent.node(), r.node(), opts=diffopts):
output += chunk
return output
开发者ID:Elsvent,项目名称:Shell-Config,代码行数:12,代码来源:__init__.py
示例16: annotate
def annotate(web, req, tmpl):
fctx = webutil.filectx(web.repo, req)
f = fctx.path()
parity = paritygen(web.stripecount)
diffopts = patch.diffopts(web.repo.ui, untrusted=True, section="annotate")
def annotate(**map):
last = None
if binary(fctx.data()):
mt = mimetypes.guess_type(fctx.path())[0] or "application/octet-stream"
lines = enumerate([((fctx.filectx(fctx.filerev()), 1), "(binary:%s)" % mt)])
else:
lines = enumerate(fctx.annotate(follow=True, linenumber=True, diffopts=diffopts))
for lineno, ((f, targetline), l) in lines:
fnode = f.filenode()
if last != fnode:
last = fnode
yield {
"parity": parity.next(),
"node": f.hex(),
"rev": f.rev(),
"author": f.user(),
"desc": f.description(),
"extra": f.extra(),
"file": f.path(),
"targetline": targetline,
"line": l,
"lineid": "l%d" % (lineno + 1),
"linenumber": "% 6d" % (lineno + 1),
"revdate": f.date(),
}
return tmpl(
"fileannotate",
file=f,
annotate=annotate,
path=webutil.up(f),
rev=fctx.rev(),
node=fctx.hex(),
author=fctx.user(),
date=fctx.date(),
desc=fctx.description(),
extra=fctx.extra(),
rename=webutil.renamelink(fctx),
branch=webutil.nodebranchnodefault(fctx),
parent=webutil.parents(fctx),
child=webutil.children(fctx),
permissions=fctx.manifest().flags(f),
)
开发者ID:guitao,项目名称:hg-stable,代码行数:51,代码来源:webcommands.py
示例17: difftree
def difftree(ui, repo, node1=None, node2=None, *files, **opts):
"""diff trees from two commits"""
def __difftree(repo, node1, node2, files=[]):
assert node2 is not None
mmap = repo[node1].manifest()
mmap2 = repo[node2].manifest()
m = cmdutil.match(repo, files)
modified, added, removed = repo.status(node1, node2, m)[:3]
empty = short(nullid)
for f in modified:
# TODO get file permissions
ui.write(":100664 100664 %s %s M\t%s\t%s\n" %
(short(mmap[f]), short(mmap2[f]), f, f))
for f in added:
ui.write(":000000 100664 %s %s N\t%s\t%s\n" %
(empty, short(mmap2[f]), f, f))
for f in removed:
ui.write(":100664 000000 %s %s D\t%s\t%s\n" %
(short(mmap[f]), empty, f, f))
##
while True:
if opts['stdin']:
try:
line = raw_input().split(' ')
node1 = line[0]
if len(line) > 1:
node2 = line[1]
else:
node2 = None
except EOFError:
break
node1 = repo.lookup(node1)
if node2:
node2 = repo.lookup(node2)
else:
node2 = node1
node1 = repo.changelog.parents(node1)[0]
if opts['patch']:
if opts['pretty']:
catcommit(ui, repo, node2, "")
m = cmdutil.match(repo, files)
chunks = patch.diff(repo, node1, node2, match=m,
opts=patch.diffopts(ui, {'git': True}))
for chunk in chunks:
ui.write(chunk)
else:
__difftree(repo, node1, node2, files=files)
if not opts['stdin']:
break
开发者ID:MezzLabs,项目名称:mercurial,代码行数:51,代码来源:hgk.py
示例18: diffopts
def diffopts(self, opts={}, patchfn=None):
diffopts = patchmod.diffopts(self.ui, opts)
if self.gitmode == 'auto':
diffopts.upgrade = True
elif self.gitmode == 'keep':
pass
elif self.gitmode in ('yes', 'no'):
diffopts.git = self.gitmode == 'yes'
else:
raise util.Abort(_('mq.git option can be auto/keep/yes/no'
' got %s') % self.gitmode)
if patchfn:
diffopts = self.patchopts(diffopts, patchfn)
return diffopts
开发者ID:peiyaoyao,项目名称:intellij-community,代码行数:14,代码来源:mq.py
示例19: _get_diffs
def _get_diffs(self, repository=None, filepath=None):
diffs = []
for repo, root in self.repositories:
if repository and root != repository:
continue
#commands.pull(thisui, user_repo)
# The hg diff command returns the entire set of diffs as one big
# chunk. The following code is lifted from the source (version
# 1.2) as the method for getting the individual diffs. As such,
# this is prone to break in the case of internal changes. We
# should try and get an external method to do the same thing.
node1, node2 = cmdutil.revpair(repo, None)
match = cmdutil.match(repo, (), {})
repodiffs = []
for diff in patch.diff(repo, node1, node2, match=match, opts=patch.diffopts(self.ui)):
diffheader = diff.split('\n')[0]
filename = DIFF_FILE.match(diffheader).groups()[0]
if filepath and filepath == filename:
return {'repository':root,
'filename':filename,
'diff': highlight(diff, DiffLexer(), HtmlFormatter())}
# Should I instantiate a single lexer and formatter and share them?
repodiffs.append({'repository':root,
'filename':filename,
'diff': highlight(diff, DiffLexer(), HtmlFormatter())})
# At the repo level, we want to go through all found files and look
# for related issues
try:
issues = yamltrak.issues([repo.root])[root]
except KeyError:
# There is no issue database, or maybe just no open issues...
issues = {}
for diff in repodiffs:
relatedissues = yamltrak.relatedissues(repo.root, filename=diff['filename'], ids=issues.keys())
related = {}
for issue in relatedissues:
related[issue] = {'repo':root,
'title':issues[issue]['title']}
diff['relatedissues'] = related
diffs += repodiffs
# Done collecting the diffs
if filepath:
# User wanted a specific diff, and we didn't find it. This
# probably isn't the best exception, but it will have to do...
raise LookupError
return diffs
开发者ID:dmayle,项目名称:DVDev,代码行数:49,代码来源:dv.py
示例20: diff_branch
def diff_branch(ui, repo, branch, **opts):
"""Shows the changes from a branch"""
if branch not in repo.branchtags():
ui.warn("Branch %s does not exist! (use 'hg branches' to get a list of branches)\n" % branch)
return
curr = repo[None].branch()
if branch == curr:
ui.status("Already on branch %s\n" % branch)
return
rev = repo.branchtip(branch)
dest = "default"
drev = repo.branchtip(dest)
ancestor = repo.changelog.ancestor(rev, drev)
diffopts = patch.diffopts(ui, opts)
cmdutil.diffordiffstat(ui, repo, diffopts, ancestor, rev, None)
开发者ID:jbowtie,项目名称:hg-branching,代码行数:15,代码来源:__init__.py
注:本文中的mercurial.patch.diffopts函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论