rem
stringlengths
0
322k
add
stringlengths
0
2.05M
context
stringlengths
8
228k
s = smtplib.SMTP(local_hostname=local_hostname)
tls = ui.config('smtp', 'tls') starttls = tls == 'starttls' or util.parsebool(tls) smtps = tls == 'smtps' if (starttls or smtps) and not hasattr(socket, 'ssl'): raise util.Abort(_("can't use TLS: Python SSL support not installed")) if smtps: ui.note(_('(using smtps)\n')) s = smtplib.SMTP_SSL(local_hostname=local_hostn...
def _smtp(ui): '''build an smtp connection and return a function to send mail''' local_hostname = ui.config('smtp', 'local_hostname') s = smtplib.SMTP(local_hostname=local_hostname) mailhost = ui.config('smtp', 'host') if not mailhost: raise util.Abort(_('smtp.host not configured - cannot send mail')) mailport = util.g...
if ui.configbool('smtp', 'tls'): if not hasattr(socket, 'ssl'): raise util.Abort(_("can't use TLS: Python SSL support " "not installed")) ui.note(_('(using tls)\n'))
if starttls: ui.note(_('(using starttls)\n'))
def _smtp(ui): '''build an smtp connection and return a function to send mail''' local_hostname = ui.config('smtp', 'local_hostname') s = smtplib.SMTP(local_hostname=local_hostname) mailhost = ui.config('smtp', 'host') if not mailhost: raise util.Abort(_('smtp.host not configured - cannot send mail')) mailport = util.g...
val = util.expandpath(val)
if setting in ('username', 'cert', 'key'): val = util.expandpath(val)
def readauthtoken(self, uri): # Read configuration config = dict() for key, val in self.ui.configitems('auth'): if '.' not in key: self.ui.warn(_("ignoring invalid [auth] key '%s'\n") % key) continue group, setting = key.split('.', 1) gdict = config.setdefault(group, dict()) val = util.expandpath(val) gdict[setting] = ...
options.pure = options.pure or 'java' in sys.platform
if 'java' in sys.platform: options.pure = True
def parseargs(): parser = optparse.OptionParser("%prog [options] [tests]") parser.add_option("-C", "--annotate", action="store_true", help="output files annotated with coverage") parser.add_option("--child", type="int", help="run as child process, summary to given fd") parser.add_option("-c", "--cover", action="store_t...
The information shown in the changeset header is: author,
The information shown in the changeset header is: author, date,
def export(ui, repo, *changesets, **opts): """dump the header and diffs for one or more changesets Print the changeset header and diffs for one or more revisions. The information shown in the changeset header is: author, changeset hash, parent(s) and commit comment. NOTE: export may generate unexpected diff output f...
for name in 'SIGBREAK', 'SIGHUP', 'SIGTERM': num = getattr(signal, name, None) if num: signal.signal(num, catchterm)
try: for name in 'SIGBREAK', 'SIGHUP', 'SIGTERM': num = getattr(signal, name, None) if num: signal.signal(num, catchterm) except ValueError: pass
def catchterm(*args): raise error.SignalInterrupt
o = set([cl.rev(r) for r in repo.changelog.nodesbetween(o, None)[0]])
o = set([cl.rev(r) for r in repo.changelog.nodesbetween(o, revs)[0]])
def outgoing(repo, subset, x): import hg # avoid start-up nasties l = getargs(x, 0, 1, _("outgoing wants a repository path")) dest = l and getstring(l[0], _("outgoing wants a repository path")) or '' dest = repo.ui.expandpath(dest or 'default-push', dest or 'default') dest, branches = hg.parseurl(dest) other = hg.repos...
ui.warn(_("abort: could not import module %s!\n") % m)
def catchterm(*args): raise error.SignalInterrupt
ui.status(_('comparing with %s\n') % dest)
ui.status(_('comparing with %s\n') % url.hidepassword(dest))
def getoutgoing(dest, revs): '''Return the revisions present locally but not in dest''' dest = ui.expandpath(dest or 'default-push', dest or 'default') dest, branches = hg.parseurl(dest) revs, checkout = hg.addbranchrevs(repo, repo, branches, revs) if revs: revs = [repo.lookup(rev) for rev in revs] other = hg.repositor...
infix = self._elements[token][2]
if len(e) < 3 or not e[2]: raise error.ParseError("not an infix: %s" % token, pos) infix = e[2]
def _parse(self, bind=0): token, value, pos = self._advance() # handle prefix rules on current token prefix = self._elements[token][1] if not prefix: raise error.ParseError("not a prefix: %s" % token, pos) if len(prefix) == 1: expr = (prefix[0], value) else: if len(prefix) > 2 and prefix[2] == self.current[0]: self._ma...
if not infix[0]: raise error.ParseError("not an infix: %s" % token, pos)
def _parse(self, bind=0): token, value, pos = self._advance() # handle prefix rules on current token prefix = self._elements[token][1] if not prefix: raise error.ParseError("not a prefix: %s" % token, pos) if len(prefix) == 1: expr = (prefix[0], value) else: if len(prefix) > 2 and prefix[2] == self.current[0]: self._ma...
side = state['bad'] if good else state['good']
side = good and state['bad'] or state['good']
def print_result(nodes, good): displayer = cmdutil.show_changeset(ui, repo, {}) if len(nodes) == 1: # narrowed it down to a single revision if good: ui.write(_("The first good revision is:\n")) else: ui.write(_("The first bad revision is:\n")) displayer.show(repo[nodes[0]]) parents = repo[nodes[0]].parents() if len(par...
def tidyprefix(dest, prefix, suffixes):
def tidyprefix(dest, kind, prefix):
def tidyprefix(dest, prefix, suffixes): '''choose prefix to use for names in archive. make sure prefix is safe for consumers.''' if prefix: prefix = util.normpath(prefix) else: if not isinstance(dest, str): raise ValueError('dest must be string if no prefix') prefix = os.path.basename(dest) lower = prefix.lower() for...
for sfx in suffixes:
for sfx in exts.get(kind, []):
def tidyprefix(dest, prefix, suffixes): '''choose prefix to use for names in archive. make sure prefix is safe for consumers.''' if prefix: prefix = util.normpath(prefix) else: if not isinstance(dest, str): raise ValueError('dest must be string if no prefix') prefix = os.path.basename(dest) lower = prefix.lower() for...
def __init__(self, dest, prefix, mtime, kind=''): self.prefix = tidyprefix(dest, prefix, ['.tar', '.tar.bz2', '.tar.gz', '.tgz', '.tbz2'])
def __init__(self, dest, mtime, kind=''):
def __init__(self, dest, prefix, mtime, kind=''): self.prefix = tidyprefix(dest, prefix, ['.tar', '.tar.bz2', '.tar.gz', '.tgz', '.tbz2']) self.mtime = mtime
i = tarfile.TarInfo(self.prefix + name)
i = tarfile.TarInfo(name)
def addfile(self, name, mode, islink, data): i = tarfile.TarInfo(self.prefix + name) i.mtime = self.mtime i.size = len(data) if islink: i.type = tarfile.SYMTYPE i.mode = 0777 i.linkname = data data = None i.size = 0 else: i.mode = mode data = cStringIO.StringIO(data) self.z.addfile(i, data)
def __init__(self, dest, prefix, mtime, compress=True): self.prefix = tidyprefix(dest, prefix, ('.zip',))
def __init__(self, dest, mtime, compress=True):
def __init__(self, dest, prefix, mtime, compress=True): self.prefix = tidyprefix(dest, prefix, ('.zip',)) if not isinstance(dest, str): try: dest.tell() except (AttributeError, IOError): dest = tellable(dest) self.z = zipfile.ZipFile(dest, 'w', compress and zipfile.ZIP_DEFLATED or zipfile.ZIP_STORED) self.date_time = t...
i = zipfile.ZipInfo(self.prefix + name, self.date_time)
i = zipfile.ZipInfo(name, self.date_time)
def addfile(self, name, mode, islink, data): i = zipfile.ZipInfo(self.prefix + name, self.date_time) i.compress_type = self.z.compression # unzip will not honor unix file modes unless file creator is # set to unix (id 3). i.create_system = 3 ftype = stat.S_IFREG if islink: mode = 0777 ftype = stat.S_IFLNK i.external_at...
def __init__(self, name, prefix, mtime): if prefix: raise util.Abort(_('cannot give prefix when archiving to files'))
def __init__(self, name, mtime):
def __init__(self, name, prefix, mtime): if prefix: raise util.Abort(_('cannot give prefix when archiving to files')) self.basedir = name self.opener = util.opener(self.basedir)
'tbz2': lambda name, prefix, mtime: tarit(name, prefix, mtime, 'bz2'), 'tgz': lambda name, prefix, mtime: tarit(name, prefix, mtime, 'gz'), 'uzip': lambda name, prefix, mtime: zipit(name, prefix, mtime, False),
'tbz2': lambda name, mtime: tarit(name, mtime, 'bz2'), 'tgz': lambda name, mtime: tarit(name, mtime, 'gz'), 'uzip': lambda name, mtime: zipit(name, mtime, False),
def done(self): pass
archiver.addfile(name, mode, islink, data)
archiver.addfile(prefix + name, mode, islink, data)
def write(name, mode, islink, getdata): if matchfn and not matchfn(name): return data = getdata() if decode: data = repo.wwritedata(name, data) archiver.addfile(name, mode, islink, data)
archiver = archivers[kind](dest, prefix, mtime or ctx.date()[0])
archiver = archivers[kind](dest, mtime or ctx.date()[0])
def write(name, mode, islink, getdata): if matchfn and not matchfn(name): return data = getdata() if decode: data = repo.wwritedata(name, data) archiver.addfile(name, mode, islink, data)
repair.strip(ui, repo, repo[min(rebased)].node(), "strip")
repair.strip(ui, repo, repo[min(rebased)].node(), "all")
def extrafn(ctx, extra): extra['branch'] = ctx.branch()
repair.strip(repo.ui, repo, repo[strippoint].node(), "strip")
repair.strip(repo.ui, repo, repo[strippoint].node())
def abort(repo, originalwd, target, state): 'Restore the repository to its original state' if set(repo.changelog.descendants(target)) - set(state.values()): repo.ui.warn(_("warning: new changesets detected on target branch, " "not stripping\n")) else: # Strip from the first rebased revision merge.update(repo, repo[orig...
ui.write('%s: ' % ui.label(q.series[idx], 'qguard.patch'))
if q.series[idx] in applied: state = 'applied' elif q.pushable(idx)[0]: state = 'unapplied' else: state = 'guarded' label = 'qguard.patch qguard.%s qseries.%s' % (state, state) ui.write('%s: ' % ui.label(q.series[idx], label))
def status(idx): guards = q.series_guards[idx] or ['unguarded'] ui.write('%s: ' % ui.label(q.series[idx], 'qguard.patch')) for i, guard in enumerate(guards): if guard.startswith('+'): ui.write(guard, label='qguard.positive') elif guard.startswith('-'): ui.write(guard, label='qguard.negative') else: ui.write(guard, labe...
changeset hash, parent(s) and commit comment.
branch name (if non-default), changeset hash, parent(s) and commit comment.
def export(ui, repo, *changesets, **opts): """dump the header and diffs for one or more changesets Print the changeset header and diffs for one or more revisions. The information shown in the changeset header is: author, date, changeset hash, parent(s) and commit comment. NOTE: export may generate unexpected diff ou...
return commit(author=elt.get('author'), date=util.datestr(date), desc=desc.strip(), parents=self.parents[rev])
return commit(author=self.recode(elt.get('author')), date=util.datestr(date), desc=self.recode(desc).strip(), parents=self.parents[rev])
def getcommit(self, rev): elt = self.changes[rev] date = util.strdate(elt.get('local_date'), '%a %b %d %H:%M:%S %Z %Y') desc = elt.findtext('name') + '\n' + elt.findtext('comment', '') return commit(author=elt.get('author'), date=util.datestr(date), desc=desc.strip(), parents=self.parents[rev])
cmd = '%s %s' % (self.definition[1:], ' '.join(args)) return util.system(cmd)
env = {'HG_ARGS': ' '.join((self.name,) + args)} def _checkvar(m): if int(m.groups()[0]) <= len(args): return m.group() else: return '' cmd = re.sub(r'\$(\d+)', _checkvar, self.definition[1:]) replace = dict((str(i + 1), arg) for i, arg in enumerate(args)) replace['0'] = self.name replace['@'] = ' '.join(args) cmd = ut...
def fn(ui, *args): cmd = '%s %s' % (self.definition[1:], ' '.join(args)) return util.system(cmd)
return util.checksignature(self.fn)(ui, *args, **opts)
if self.definition.startswith('!'): return self.fn(ui, *args, **opts) else: return util.checksignature(self.fn)(ui, *args, **opts)
def __call__(self, ui, *args, **opts): if self.shadows: ui.debug("alias '%s' shadows command\n" % self.name)
fh = open(os.path.join(path, '.queue')) curpath = os.path.join(path, fh.read().rstrip())
fh = open(os.path.join(path, 'patches.queue')) cur = fh.read().rstrip() if not cur: curpath = os.path.join(path, 'patches') else: curpath = os.path.join(path, 'patches-' + cur)
def __init__(self, ui, path, patchdir=None): self.basepath = path try: fh = open(os.path.join(path, '.queue')) curpath = os.path.join(path, fh.read().rstrip()) except IOError: curpath = os.path.join(path, 'patches') self.path = patchdir or curpath self.opener = util.opener(self.path) self.ui = ui self.applied_dirty = 0...
_allqueues = '.queues' _activequeue = '.queue'
_allqueues = 'patches.queues' _activequeue = 'patches.queue'
def qqueue(ui, repo, name=None, **opts): '''manage multiple patch queues Supports switching between different patch queues, as well as creating new patch queues and deleting existing ones. Omitting a queue name or specifying -l/--list will show you the registered queues - by default the "normal" patches queue is regi...
return os.path.basename(q.path)
cur = os.path.basename(q.path) if cur.startswith('patches-'): cur = cur[8:] return cur
def _getcurrent(): return os.path.basename(q.path)
fh.write(name)
if name != 'patches': fh.write(name)
def _setactive(name): if q.applied: raise util.Abort(_('patches applied - cannot set new queue active'))
fh = repo.opener('.queues.new', 'w')
fh = repo.opener('patches.queues.new', 'w')
def _addqueue(name): fh = repo.opener(_allqueues, 'a') fh.write('%s\n' % (name,)) fh.close()
util.rename(repo.join('.queues.new'), repo.join(_allqueues))
util.rename(repo.join('patches.queues.new'), repo.join(_allqueues))
def _addqueue(name): fh = repo.opener(_allqueues, 'a') fh.write('%s\n' % (name,)) fh.close()
directory = prefix
def scache(s): "return a shared version of a string" return _scache.setdefault(s, s)
prefix = p + util.normpath(prefix)
if prefix: prefix = p + util.normpath(prefix) else: prefix = p
def scache(s): "return a shared version of a string" return _scache.setdefault(s, s)
return orig(ui, r, *args, **kwargs)
return orig(r.ui, r, *args, **kwargs)
def mqcommand(orig, ui, repo, *args, **kwargs): """Add --mq option to operate on patch repository instead of main""" # some commands do not like getting unknown options mq = kwargs['mq'] del kwargs['mq'] if not mq: return orig(ui, repo, *args, **kwargs) q = repo.mq r = q.qrepo() if not r: raise util.Abort('no queue ...
ui.warn(_('bookmark %s does not exist on the local or remote repository!\n') % b)
ui.warn(_('bookmark %s does not exist on the local' ' or remote repository!\n') % b)
def push(oldpush, ui, repo, dest=None, **opts): dopush = True if opts.get('bookmark'): dopush = False for b in opts['bookmark']: if b in repo._bookmarks: dopush = True opts.setdefault('rev', []).append(b) result = 0 if dopush: result = oldpush(ui, repo, dest, **opts) if opts.get('bookmark'): # this is an unpleasant h...
if self.restrict or lookup:
if self.restrict or lookup or self.record:
def overwrite(self, ctx, candidates, lookup, expand, rekw=False): '''Overwrites selected files expanding/shrinking keywords.''' if self.restrict or lookup: # exclude kw_copy candidates = self.iskwfile(candidates, ctx) if not candidates: return commit = self.restrict and not lookup if self.restrict or expand and lookup:...
commit = self.restrict and not lookup
kwcmd = self.restrict and lookup
def overwrite(self, ctx, candidates, lookup, expand, rekw=False): '''Overwrites selected files expanding/shrinking keywords.''' if self.restrict or lookup: # exclude kw_copy candidates = self.iskwfile(candidates, ctx) if not candidates: return commit = self.restrict and not lookup if self.restrict or expand and lookup:...
if commit:
if kwcmd:
def overwrite(self, ctx, candidates, lookup, expand, rekw=False): '''Overwrites selected files expanding/shrinking keywords.''' if self.restrict or lookup: # exclude kw_copy candidates = self.iskwfile(candidates, ctx) if not candidates: return commit = self.restrict and not lookup if self.restrict or expand and lookup:...
while virtual: real = repos.get(virtual)
virtualrepo = virtual while virtualrepo: real = repos.get(virtualrepo)
def run_wsgi(self, req): try: try: self.refresh()
req.env['REPO_NAME'] = virtual
req.env['REPO_NAME'] = virtualrepo
def run_wsgi(self, req): try: try: self.refresh()
subdir = virtual + '/' if [r for r in repos if r.startswith(subdir)]: req.respond(HTTP_OK, ctype) return self.makeindex(req, tmpl, subdir) up = virtual.rfind('/')
up = virtualrepo.rfind('/')
def run_wsgi(self, req): try: try: self.refresh()
virtual = virtual[:up]
virtualrepo = virtualrepo[:up] subdir = virtual + '/' if [r for r in repos if r.startswith(subdir)]: req.respond(HTTP_OK, ctype) return self.makeindex(req, tmpl, subdir)
def run_wsgi(self, req): try: try: self.refresh()
_GLOBAL_DEFAULT_TIMEOUT = object()
def _ssl_wrap_socket(sock, key_file, cert_file, cert_reqs=CERT_REQUIRED, ca_certs=None): if ca_certs: raise util.Abort(_( 'certificate checking requires Python 2.6'))
return [r for r in subset if repo[r].extra('close')]
return [r for r in subset if repo[r].extra().get('close')]
def closed(repo, subset, x): getargs(x, 0, 0, "closed takes no arguments") return [r for r in subset if repo[r].extra('close')]
except error.UnknownCommand:
except (error.AmbiguousCommand, error.UnknownCommand):
def _checkshellalias(ui, args): cwd = os.getcwd() norepo = commands.norepo options = {} try: args = fancyopts.fancyopts(args, commands.globalopts, options) except fancyopts.getopt.GetoptError: return if not args: return _parseconfig(ui, options['config']) if options['cwd']: os.chdir(options['cwd']) path, lui = _get...
c = l[0] hline = l[:-1]
if l.endswith('\r\n'): hline = l[:-2] else: hline = l[:-1] c = hline[0]
def fix_newline(hunk, a, b): l = hunk[-1] c = l[0] hline = l[:-1] if c == " " or c == "+": b[-1] = l[1:-1] if c == " " or c == "-": a[-1] = hline hunk[-1] = hline return 0
b[-1] = l[1:-1]
b[-1] = hline[1:]
def fix_newline(hunk, a, b): l = hunk[-1] c = l[0] hline = l[:-1] if c == " " or c == "+": b[-1] = l[1:-1] if c == " " or c == "-": a[-1] = hline hunk[-1] = hline return 0
for k, v in copy.items(): copy[v] = k
def getfilectx(f, ctx): fctx = ctx.filectx(f, filelog=cache.get(f)) if f not in cache: if len(cache) > 20: del cache[order.pop(0)] cache[f] = fctx.filelog() else: order.remove(f) order.append(f) return fctx
if f in copy:
if f in copy or f in copyto:
def trydiff(repo, revs, ctx1, ctx2, modified, added, removed, copy, getfilectx, opts, losedatafn): date1 = util.datestr(ctx1.date()) man1 = ctx1.manifest() gone = set() gitmode = {'l': '120000', 'x': '100755', '': '100644'} if opts.git: revs = None for f in sorted(modified + added + removed): to = None tn = None do...
a = copy[f]
if f in copy: a = copy[f] else: a = copyto[f]
def trydiff(repo, revs, ctx1, ctx2, modified, added, removed, copy, getfilectx, opts, losedatafn): date1 = util.datestr(ctx1.date()) man1 = ctx1.manifest() gone = set() gitmode = {'l': '120000', 'x': '100755', '': '100644'} if opts.git: revs = None for f in sorted(modified + added + removed): to = None tn = None do...
if f in copy and copy[f] in added and copy[copy[f]] == f:
if f in copy and copy[f] in added and copyto[copy[f]] == f: dodiff = False elif f in copyto and copyto[f] in added and copy[copyto[f]] == f:
def trydiff(repo, revs, ctx1, ctx2, modified, added, removed, copy, getfilectx, opts, losedatafn): date1 = util.datestr(ctx1.date()) man1 = ctx1.manifest() gone = set() gitmode = {'l': '120000', 'x': '100755', '': '100644'} if opts.git: revs = None for f in sorted(modified + added + removed): to = None tn = None do...
_('update to new tip if changesets were pulled')),
_('update to new branch head if changesets were pulled')),
def version_(ui): """output version and copyright information""" ui.write(_("Mercurial Distributed SCM (version %s)\n") % util.version()) ui.status(_( "\nCopyright (C) 2005-2010 Matt Mackall <mpm@selenic.com> and others\n" "This is free software; see the source for copying conditions. " "There is NO\nwarranty; " "not e...
_('update to new tip if changesets were unbundled'))],
_('update to new branch head if changesets were unbundled'))],
def version_(ui): """output version and copyright information""" ui.write(_("Mercurial Distributed SCM (version %s)\n") % util.version()) ui.status(_( "\nCopyright (C) 2005-2010 Matt Mackall <mpm@selenic.com> and others\n" "This is free software; see the source for copying conditions. " "There is NO\nwarranty; " "not e...
try: lui = ui.copy() lui.readconfig(os.path.join(path, ".hg", "hgrc")) except IOError: pass
lui = ui.copy() lui.readconfig(os.path.join(path, ".hg", "hgrc"))
def _getlocal(ui, rpath): """Return (path, local ui object) for the given target path. Takes paths in [cwd]/.hg/hgrc into account." """ try: wd = os.getcwd() except OSError, e: raise util.Abort(_("error getting current working directory: %s") % e.strerror) path = cmdutil.findrepo(wd) or "" if not path: lui = ui else: ...
branch = (None, [])
branch = (None, branch or [])
def clone(ui, source, dest=None, pull=False, rev=None, update=True, stream=False, branch=None): """Make a copy of an existing repository. Create a copy of an existing repository in a new directory. The source and destination are URLs, as passed to the repository function. Returns a pair of repository objects, the so...
extra['console'] = ['hg']
def hasfunction(cc, funcname): tmpdir = tempfile.mkdtemp(prefix='hg-install-') devnull = oldstderr = None try: try: fname = os.path.join(tmpdir, 'funcname.c') f = open(fname, 'w') f.write('int main(void) {\n') f.write(' %s();\n' % funcname) f.write('}\n') f.close() # Redirect stderr to /dev/null to hide any error me...
version=version,
version=setupversion,
def ordinarypath(p): return p and p[0] != '.' and p[-1] != '~'
optionalrepo = ("identify paths serve showconfig debugancestor")
optionalrepo = ("identify paths serve showconfig debugancestor debugdag")
def version_(ui): """output version and copyright information""" ui.write(_("Mercurial Distributed SCM (version %s)\n") % util.version()) ui.status(_( "\nCopyright (C) 2005-2010 Matt Mackall <mpm@selenic.com> and others\n" "This is free software; see the source for copying conditions. " "There is NO\nwarranty; " "not e...
def fixconfig(self, root=None): root = root or os.getcwd() for c in self._tcfg, self._ucfg, self._ocfg: for n, p in c.items('paths'): if not p: continue if '%%' in p: self.warn(_("(deprecated '%%' in path %s=%s from %s)\n") % (n, p, self.configsource('paths', n))) p = p.replace('%%', '%') p = util.expandpath(p) if ':...
def fixconfig(self, root=None, section=None): if section in (None, 'paths'): root = root or os.getcwd() for c in self._tcfg, self._ucfg, self._ocfg: for n, p in c.items('paths'): if not p: continue if '%%' in p: self.warn(_("(deprecated '%%' in path %s=%s from %s)\n") % (n, p, self.configsource('paths', n))) p = p.re...
def fixconfig(self, root=None): # expand vars and ~ # translate paths relative to root (or home) into absolute paths root = root or os.getcwd() for c in self._tcfg, self._ucfg, self._ocfg: for n, p in c.items('paths'): if not p: continue if '%%' in p: self.warn(_("(deprecated '%%' in path %s=%s from %s)\n") % (n, p, se...
self.fixconfig()
self.fixconfig(section=section)
def setconfig(self, section, name, value, overlay=True): if overlay: self._ocfg.set(section, name, value) self._tcfg.set(section, name, value) self._ucfg.set(section, name, value) self.fixconfig()
shutil.rmtree(self._ctx.repo.join(self._path))
shutil.rmtree(self._ctx._repo.wjoin(self._path))
def remove(self): if self.dirty(): self._ui.warn(_('not removing repo %s because ' 'it has changes.\n' % self._path)) return self._ui.note(_('removing subrepo %s\n') % self._path) shutil.rmtree(self._ctx.repo.join(self._path))
This command is deprecated; use hg --mq commit instead."""
This command is deprecated; use hg commit --mq instead."""
def commit(ui, repo, *pats, **opts): """commit changes in the queue repository (DEPRECATED) This command is deprecated; use hg --mq commit instead.""" q = repo.mq r = q.qrepo() if not r: raise util.Abort('no queue repository') commands.commit(r.ui, r, *pats, **opts)
('p', 'port', 8000, _('port to listen on')),
('p', 'port', '', _('port to listen on (default: 8000')),
def version_(ui): """output version and copyright information""" ui.write(_("Mercurial Distributed SCM (version %s)\n") % util.version()) ui.status(_( "\nCopyright (C) 2005-2010 Matt Mackall <mpm@selenic.com> and others\n" "This is free software; see the source for copying conditions. " "There is NO\nwarranty; " "not e...
goodb = not nullb and os.path.exists(bfile)
goodb = not nullb and os.path.lexists(bfile)
def selectfile(afile_orig, bfile_orig, hunk, strip): nulla = afile_orig == "/dev/null" nullb = bfile_orig == "/dev/null" abase, afile = pathstrip(afile_orig, strip) gooda = not nulla and util.lexists(afile) bbase, bfile = pathstrip(bfile_orig, strip) if afile == bfile: goodb = gooda else: goodb = not nullb and os.path....
if not hasattr(sys.stdout, 'closed') or not sys.stdout.closed:
if not getattr(sys.stdout, 'closed', False):
def write_err(self, *args): try: if not hasattr(sys.stdout, 'closed') or not sys.stdout.closed: sys.stdout.flush() for a in args: sys.stderr.write(str(a)) # stderr may be buffered under win32 when redirected to files, # including stdout. if not sys.stderr.closed: sys.stderr.flush() except IOError, inst: if inst.errno !...
if not sys.stderr.closed:
if not getattr(sys.stderr, 'closed', False):
def write_err(self, *args): try: if not hasattr(sys.stdout, 'closed') or not sys.stdout.closed: sys.stdout.flush() for a in args: sys.stderr.write(str(a)) # stderr may be buffered under win32 when redirected to files, # including stdout. if not sys.stderr.closed: sys.stderr.flush() except IOError, inst: if inst.errno !...
showaddr = '%s %s' % (showaddr, addrs) showaddrs.append(showaddr)
showaddrs.append('%s %s' % (showaddr, addrs))
def getaddrs(opt, prpt=None, default=None): addrs = opts.get(opt.replace('-', '_')) if opt != 'reply-to': showaddr = '%s:' % opt.capitalize() else: showaddr = 'Reply-To:'
r'(---|\*\*\*)[ \t].*?' r'^(\+\+\+|\*\*\*)[ \t])', re.MULTILINE|re.DOTALL)
r'---[ \t].*?^\+\+\+[ \t]|' r'\*\*\*[ \t].*?^---[ \t])', re.MULTILINE|re.DOTALL)
def extract(ui, fileobj): '''extract patch from data read from fileobj. patch can be a normal patch or contained in an email message. return tuple (filename, message, user, date, node, p1, p2). Any item in the returned tuple can be None. If filename is None, fileobj did not contain a patch. Caller must unlink filenam...
pass
break
def readOthers(self): """Reads the answers, authorities and additionals section of the packet""" format = '!HHiH' length = struct.calcsize(format) n = self.numAnswers + self.numAuthorities + self.numAdditionals for i in range(0, n): domain = self.readName() info = struct.unpack(format, self.data[self.offset:self.offset...
result = self.data[offset:offset+len] try: return result.decode('utf-8') except UnicodeDecodeError: return result.decode('utf-16')
return self.data[offset:offset+len].decode('utf-8')
def readUTF(self, offset, len): """Reads a UTF-8 string of a given length from the packet""" result = self.data[offset:offset+len] try: return result.decode('utf-8') except UnicodeDecodeError: return result.decode('utf-16')
self.ui.write(output)
for l in output.splitlines(True): self.ui.status(_('remote: '), l)
def unbundle(self, cg, heads, source): # have to stream bundle to a temp file because we do not have # http 1.1 chunked transfer.
dopatch = True
def iterhunks(ui, fp, sourcefile=None): """Read a patch and yield the following events: - ("file", afile, bfile, firsthunk): select a new target file. - ("hunk", hunk): a new hunk is ready to be applied, follows a "file" event. - ("git", gitchanges): current diff is in git format, gitchanges maps filenames to gitpatch ...
gitworkdone = False
empty = False
def iterhunks(ui, fp, sourcefile=None): """Read a patch and yield the following events: - ("file", afile, bfile, firsthunk): select a new target file. - ("hunk", hunk): a new hunk is ready to be applied, follows a "file" event. - ("git", gitchanges): current diff is in git format, gitchanges maps filenames to gitpatch ...
dopatch, gitpatches = scangitpatch(lr, x)
gitpatches = scangitpatch(lr, x)[1]
def iterhunks(ui, fp, sourcefile=None): """Read a patch and yield the following events: - ("file", afile, bfile, firsthunk): select a new target file. - ("hunk", hunk): a new hunk is ready to be applied, follows a "file" event. - ("git", gitchanges): current diff is in git format, gitchanges maps filenames to gitpatch ...
if gp and gp.op in ('COPY', 'DELETE', 'RENAME', 'ADD'):
if gp and (gp.op in ('COPY', 'DELETE', 'RENAME', 'ADD') or gp.mode):
def iterhunks(ui, fp, sourcefile=None): """Read a patch and yield the following events: - ("file", afile, bfile, firsthunk): select a new target file. - ("hunk", hunk): a new hunk is ready to be applied, follows a "file" event. - ("git", gitchanges): current diff is in git format, gitchanges maps filenames to gitpatch ...
if hunknum == 0 and dopatch and not gitworkdone:
if (empty is None and not gitworkdone) or empty:
def iterhunks(ui, fp, sourcefile=None): """Read a patch and yield the following events: - ("file", afile, bfile, firsthunk): select a new target file. - ("hunk", hunk): a new hunk is ready to be applied, follows a "file" event. - ("git", gitchanges): current diff is in git format, gitchanges maps filenames to gitpatch ...
posixpath.normpath(r.path),
posixpath.normpath(r[2]),
def _abssource(repo, push=False): if hasattr(repo, '_subparent'): source = repo._subsource if source.startswith('/') or '://' in source: return source parent = _abssource(repo._subparent, push) if '://' in parent: if parent[-1] == '/': parent = parent[:-1] r = urlparse.urlparse(parent + '/' + source) r = urlparse.urlun...
"linenumber": "% 6d" % (lineno + 1)}
"linenumber": "% 6d" % (lineno + 1), "revdate": f.date()}
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)) for lineno, ((f, targetline), l) in lines: ...
:``%H``: changeset hash (40 bytes of hexadecimal)
:``%H``: changeset hash (40 hexadecimal digits)
def export(ui, repo, *changesets, **opts): """dump the header and diffs for one or more changesets Print the changeset header and diffs for one or more revisions. The information shown in the changeset header is: author, date, branch name (if non-default), changeset hash, parent(s) and commit comment. NOTE: export m...
:``%h``: short-form changeset hash (12 bytes of hexadecimal)
:``%h``: short-form changeset hash (12 hexadecimal digits)
def export(ui, repo, *changesets, **opts): """dump the header and diffs for one or more changesets Print the changeset header and diffs for one or more revisions. The information shown in the changeset header is: author, date, branch name (if non-default), changeset hash, parent(s) and commit comment. NOTE: export m...
"getopt":"c:", "help":"-c <page> Name of hidden page (default hidden.htm)", "order": 1}
"getopt" : "c:", "longopt" : "page", "help":"-c, --page=<page> Name of hidden page (default hidden.htm)", "required" : "0", "shortdesc" : "Name of hidden page", "default" : "hidden.htm", "order": 1 }
def eps_define_new_opts(): all_opt["hidden_page"]={ "getopt":"c:", "help":"-c <page> Name of hidden page (default hidden.htm)", "order": 1}
if (not options.has_key("-c")): options["-c"]="hidden.htm"
def main(): device_opt = [ "help", "version", "agent", "quiet", "verbose", "debug", "action", "ipaddr", "login", "passwd", "passwd_script", "test", "port", "hidden_page", "no_login", "no_password", "separator" ] atexit.register(atexit_handler) eps_define_new_opts() options = check_input(device_opt,process_input(dev...
"test", "separator", "inet4_only", "inet6_only",
"test", "separator", "inet4_only", "inet6_only", "ipport",
def main(): device_opt = [ "help", "version", "agent", "quiet", "verbose", "debug", "action", "ipaddr", "login", "passwd", "passwd_script", "cmd_prompt", "secure", "identity_file", "port", "no_login", "no_password", "test", "separator", "inet4_only", "inet6_only", "power_timeout", "shell_timeout", "login_timeout", "po...
conn = fspawn('%s %s' % (TELNET_PATH, options["-a"]))
conn = fspawn(TELNET_PATH) conn.send("set binary\n") conn.send("open %s -%s\n"%(options["-a"], options["-u"]))
def main(): device_opt = [ "help", "version", "agent", "quiet", "verbose", "debug", "action", "ipaddr", "login", "passwd", "passwd_script", "cmd_prompt", "secure", "identity_file", "port", "no_login", "no_password", "test", "separator", "inet4_only", "inet6_only", "power_timeout", "shell_timeout", "login_timeout", "po...
print "<resource-agent name=\"" + os.path.basename(sys.argv[0])[:-3] + "\" shortdesc=\"" + docs["shortdesc"] + "\" >"
print "<resource-agent name=\"" + os.path.basename(sys.argv[0]) + "\" shortdesc=\"" + docs["shortdesc"] + "\" >"
def metadata(avail_opt, options, docs): global all_opt sorted_list = [ (key, all_opt[key]) for key in avail_opt ] sorted_list.sort(lambda x, y: cmp(x[1]["order"], y[1]["order"])) print "<?xml version=\"1.0\" ?>" print "<resource-agent name=\"" + os.path.basename(sys.argv[0])[:-3] + "\" shortdesc=\"" + docs["shortdesc...
mapping=(('d','v'), ('c','c'),('b','a'),('E','l'),('B','x'),('P','X'),('p','A'),('l','u'))
mapping=(('d','v'),('c','c'))
def prepare_cmd(self,command): cmd="@SNMPBIN@/%s -m '' -Oeqn "%(command)
if (res_code!=0):
if (res_code!=0) or (re.search("^Error ", res_output, re.MULTILINE) != None):
def run_command(self,command,additional_timemout=0): try: self.log_command(command)
all_opt["login_timeout"]["default"] = 15 all_opt["secure"]["default"] = 1
all_opt["login_timeout"]["default"] = "15" all_opt["secure"]["default"] = "1"
def main(): device_opt = [ "help", "version", "agent", "quiet", "verbose", "debug", "action", "ipaddr", "login", "passwd", "passwd_script", "secure", "identity_file", "partition", "managed", "hmc_version", "cmd_prompt", "separator", "inet4_only", "inet6_only", "ipport", "power_timeout", "shell_timeout", "login_timeout...
' + inputTag_.instance() + \":\"', ' + inputTag_.process() + \" are not found.\";\n', ' IgCollection& collection = storage->getCollection(\"Errors_V1\");', ' IgProperty ERROR_MSG = collection.addProperty(\"Error\", std::string());', ' IgCollectionItem ite...
' + inputTag_.instance() + \" are not found\";', ' config->error(error);',
'#ifdef EXAMPLE',
fixed_items.append("'%s'" % str_to_unicode(item.replace("'", "''")))
fixed_items.append("'%s'" % py3_str(item.replace("'", "''")))
def _list_to_printable(value): """ Takes a list of mixed types and outputs a unicode string. For example, a list [42, 'foo', None, "foo's' string"], this returns the string: (42, 'foo', NULL, 'foo''s'' string') Single quotes are escaped as ''. This is suitable for use in SQL queries. """ fixed_items = [] for item i...
str_to_unicode() to try to decode them intelligently.
py3_str() to try to decode them intelligently.
def _score_terms(self, terms_list): """ Scores the terms given in terms_list, which is a list of tuples (terms, coeff, split, ivtidx), where terms is the string or sequence of terms to be scored, coeff is the weight to give each term in this part (1.0 is normal), split is the function or regular expression used to spli...
term = str_to_unicode(term)
def _score_terms(self, terms_list): """ Scores the terms given in terms_list, which is a list of tuples (terms, coeff, split, ivtidx), where terms is the string or sequence of terms to be scored, coeff is the weight to give each term in this part (1.0 is normal), split is the function or regular expression used to spli...
terms = [term for term in split(str_to_unicode(terms).lower()) if term]
terms = [term for term in split(py3_str(terms).lower()) if term]
def _query_inverted_index(self, ivtidx, terms, limit = 100, object_type = None): """ Queries the inverted index ivtidx for the terms supplied in the terms argument. If terms is a string, it is parsed into individual terms based on the split for the given ivtidx. The terms argument may also be a list or tuple, in whic...
terms = [term for term in split.split(str_to_unicode(terms).lower()) if term]
terms = [term for term in split.split(py3_str(terms).lower()) if term]
def _query_inverted_index(self, ivtidx, terms, limit = 100, object_type = None): """ Queries the inverted index ivtidx for the terms supplied in the terms argument. If terms is a string, it is parsed into individual terms based on the split for the given ivtidx. The terms argument may also be a list or tuple, in whic...
terms = [ str_to_unicode(x).lower() for x in terms ]
terms = [ py3_str(x).lower() for x in terms ]
def _query_inverted_index(self, ivtidx, terms, limit = 100, object_type = None): """ Queries the inverted index ivtidx for the terms supplied in the terms argument. If terms is a string, it is parsed into individual terms based on the split for the given ivtidx. The terms argument may also be a list or tuple, in whic...
if self._buffer_size:
if sock and self._buffer_size:
def wrap(self, sock, mode=IO_READ|IO_WRITE): """ Wraps an existing low-level socket object. addr specifies the 4-tuple address corresponding to the socket. """ super(Socket, self).wrap(sock, mode) if self._buffer_size: self._set_buffer_size(sock, self._buffer_size)