rem
stringlengths
0
322k
add
stringlengths
0
2.05M
context
stringlengths
8
228k
q.pop(repo, i - 1)
q.pop(repo, str(i - 1))
def select(ui, repo, *args, **opts): '''set or print guarded patches to push Use the :hg:`qguard` command to set or print guards on patch, then use qselect to tell mq which guards to use. A patch will be pushed if it has no guards or any positive guards match the currently selected guard, but will not be pushed if any...
if line.startswith('diff --git'):
if (line.startswith('diff --git') or (diffstart and line.startswith('+++ '))):
def eatempty(lines): while lines: l = lines[-1] if re.match('\s*$', l): del lines[-1] else: break
if diffstart: if line.startswith('+++ '): diffstart = 2 break
diffstart = 0
def eatempty(lines): while lines: l = lines[-1] if re.match('\s*$', l): del lines[-1] else: break
cachedrev = nullrev
cachedrev = None
def revision(self, node): """return an uncompressed revision of a given node""" cachedrev = nullrev if node == nullid: return "" if self._cache: if self._cache[0] == node: return self._cache[2] cachedrev = self._cache[1]
def diffopts(ui, opts=None, untrusted=False): def get(key, name=None, getter=ui.configbool): return ((opts and opts.get(key)) or getter('diff', name or key, None, untrusted=untrusted)) return mdiff.diffopts( text=opts and opts.get('text'), git=get('git'), nodates=get('nodates'), showfunc=get('show_function', 'showfunc'...
def diffopts(ui, opts=None, untrusted=False): def get(key, name=None, getter=ui.configbool): return ((opts and opts.get(key)) or getter('diff', name or key, None, untrusted=untrusted)) return mdiff.diffopts( text=opts and opts.get('text'), git=get('git'), nodates=get('nodates'), showfunc=get('show_function', 'showfunc'...
return tuple (filename, message, user, date, node, p1, p2).
return tuple (filename, message, user, date, branch, node, p1, p2).
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...
'bold_background': FOREGROUND_INTENSITY,
'bold_background': BACKGROUND_INTENSITY,
def colorcmd(orig, ui_, opts, cmd, cmdfunc): if (opts['color'] == 'always' or (opts['color'] == 'auto' and (os.environ.get('TERM') != 'dumb' and sys.__stdout__.isatty()))): global _buffers _buffers = ui_._buffers extensions.wrapfunction(ui_, 'popbuffer', popbuffer) extensions.wrapfunction(ui_, 'write', write) extension...
revs.append((filelog.linkrev(j),
revs.append((linkrev, parentlinkrevs,
def filerevgen(filelog, last): cl_count = len(repo) revs = [] for j in xrange(0, last + 1): linkrev = filelog.linkrev(j) if linkrev < minrev: continue # only yield rev for which we have the changelog, it can # happen while doing "hg log" during a pull or commit if linkrev > maxrev or linkrev >= cl_count: break n = file...
for rev, copied in filerevgen(filelog, last):
ancestors = set([filelog.linkrev(last)]) for rev, flparentlinkrevs, copied in filerevgen(filelog, last): if rev not in ancestors: continue if flparentlinkrevs: ancestors.update(flparentlinkrevs)
def iterfiles(): for filename in match.files(): yield filename, None for filename_node in copies: yield filename_node
" debugindex debugindexdot debugdate debuginstall debugfsinfo")
" debugindex debugindexdot debugdate debuginstall debugfsinfo" " debugpushkey")
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 iterhunks(ui, fp, sourcefile=None):
def iterhunks(ui, fp):
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 ((sourcefile or state == BFILE) and ((not context and x[0] == '@') or
if (state == BFILE and ((not context and x[0] == '@') or
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 ...
def applydiff(ui, fp, changed, strip=1, sourcefile=None, eolmode='strict'):
def applydiff(ui, fp, changed, strip=1, eolmode='strict'):
def applydiff(ui, fp, changed, strip=1, sourcefile=None, eolmode='strict'): """Reads a patch from fp and tries to apply it. The dict 'changed' is filled in with all of the filenames changed by the patch. Returns 0 for a clean patch, -1 if any rejects were found and 1 if there was any fuzz. If 'eolmode' is 'strict', t...
return _applydiff( ui, fp, patchfile, copyfile, changed, strip=strip, sourcefile=sourcefile, eolmode=eolmode) def _applydiff(ui, fp, patcher, copyfn, changed, strip=1, sourcefile=None, eolmode='strict'):
return _applydiff(ui, fp, patchfile, copyfile, changed, strip=strip, eolmode=eolmode) def _applydiff(ui, fp, patcher, copyfn, changed, strip=1, eolmode='strict'):
def applydiff(ui, fp, changed, strip=1, sourcefile=None, eolmode='strict'): """Reads a patch from fp and tries to apply it. The dict 'changed' is filled in with all of the filenames changed by the patch. Returns 0 for a clean patch, -1 if any rejects were found and 1 if there was any fuzz. If 'eolmode' is 'strict', t...
for state, values in iterhunks(ui, fp, sourcefile):
for state, values in iterhunks(ui, fp):
def closefile(): if not current_file: return 0 if current_file.dirty: current_file.writelines(current_file.fname, current_file.lines) current_file.write_rej() return len(current_file.rej)
if sourcefile: current_file = patcher(ui, sourcefile, opener, eolmode=eolmode) else: current_file, missing = selectfile(afile, bfile, first_hunk, strip) current_file = patcher(ui, current_file, opener, missing=missing, eolmode=eolmode)
current_file, missing = selectfile(afile, bfile, first_hunk, strip) current_file = patcher(ui, current_file, opener, missing=missing, eolmode=eolmode)
def closefile(): if not current_file: return 0 if current_file.dirty: current_file.writelines(current_file.fname, current_file.lines) current_file.write_rej() return len(current_file.rej)
empty = None
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 ...
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 ...
if empty: raise NoHunks empty = not gitworkdone
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 (empty is None and not gitworkdone) or empty: raise NoHunks
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 ...
else: try: return internalpatch(patchname, ui, strip, cwd, files, eolmode) except NoHunks: ui.warn(_('internal patcher failed\n' 'please report details to ' 'http://mercurial.selenic.com/bts/\n' 'or mercurial@selenic.com\n')) patcher = (util.find_exe('gpatch') or util.find_exe('patch') or 'patch') ui.debug('no valid hu...
return internalpatch(patchname, ui, strip, cwd, files, eolmode)
def patch(patchname, ui, strip=1, cwd=None, files=None, eolmode='strict'): """Apply <patchname> to the working directory. 'eolmode' specifies how end of lines should be handled. It can be: - 'strict': inputs are read in binary mode, EOLs are preserved - 'crlf': EOLs are ignored when patching and reset to CRLF - 'lf': ...
proc = win32api.GetCurrentProcess() try: filename = win32process.GetModuleFileNameEx(proc, 0) except: filename = win32api.GetModuleFileName(0)
filename = win32api.GetModuleFileName(0)
def system_rcpath_win32(): '''return default os-specific hgrc search path''' proc = win32api.GetCurrentProcess() try: # This will fail on windows < NT filename = win32process.GetModuleFileNameEx(proc, 0) except: filename = win32api.GetModuleFileName(0) # Use mercurial.ini found in directory with hg.exe progrc = os.path...
cmd = "p4 -G describe %s" % change
cmd = "p4 -G describe -s %s" % change
def _parse(self, ui, path): "Prepare list of P4 filenames and revisions to import" ui.status(_('reading p4 views\n'))
def invalidate(self): for a in "changelog manifest".split(): if a in self.__dict__: delattr(self, a)
def invalidatecaches(self):
def invalidate(self): for a in "changelog manifest".split(): if a in self.__dict__: delattr(self, a) self._tags = None self._tagtypes = None self.nodetagscache = None self._branchcache = None # in UTF-8 self._branchcachetip = None
tags_.findglobaltags(self.ui, self, {}, {})
self.invalidatecaches()
def destroyed(self): '''Inform the repository that nodes have been destroyed. Intended for use by strip and rollback, so there's a common place for anything that has to be done after destroying history.''' # XXX it might be nice if we could take the list of destroyed # nodes, but I don't see an easy way for rollback() ...
revrange = xrange(nullrev, len(repo) - 1)
revlist = xrange(nullrev, len(repo) - 1)
def iterfiles(): for filename in match.files(): yield filename, None for filename_node in copies: yield filename_node
revrange = sorted(revs) for i in revrange:
revlist = sorted(revs) for i in revlist:
def iterfiles(): for filename in match.files(): yield filename, None for filename_node in copies: yield filename_node
sys.stderr.write("(%s)\n" % inst.hint)
sys.stderr.write(_("(%s)\n") % inst.hint)
def dispatch(args): "run the command specified in args" try: u = uimod.ui() if '--traceback' in args: u.setconfig('ui', 'traceback', 'on') except util.Abort, inst: sys.stderr.write(_("abort: %s\n") % inst) if inst.hint: sys.stderr.write("(%s)\n" % inst.hint) return -1 except error.ParseError, inst: if len(inst.args) > ...
missing=False, eol=None):
missing=False, eolmode=None):
def kwpatchfile_init(orig, self, ui, fname, opener, missing=False, eol=None): '''Monkeypatch/wrap patch.patchfile.__init__ to avoid rejects or conflicts due to expanded keywords in working dir.''' orig(self, ui, fname, opener, missing, eol) # shrink keywords read from working dir self.lines = kwt.shrinklines(self.fname...
orig(self, ui, fname, opener, missing, eol)
orig(self, ui, fname, opener, missing, eolmode)
def kwpatchfile_init(orig, self, ui, fname, opener, missing=False, eol=None): '''Monkeypatch/wrap patch.patchfile.__init__ to avoid rejects or conflicts due to expanded keywords in working dir.''' orig(self, ui, fname, opener, missing, eol) # shrink keywords read from working dir self.lines = kwt.shrinklines(self.fname...
if 'pairs' in req.form: pairs = [map(bin, p.split("-")) for p in req.form['pairs'][0].split(" ")]
pairs = [map(bin, p.split("-")) for p in req.form['pairs'][0].split(" ")]
def between(repo, req): if 'pairs' in req.form: pairs = [map(bin, p.split("-")) for p in req.form['pairs'][0].split(" ")] resp = cStringIO.StringIO() for b in repo.between(pairs): resp.write(" ".join(map(hex, b)) + "\n") resp = resp.getvalue() req.respond(HTTP_OK, HGTYPE, length=len(resp)) yield resp
mergeq=None, all=False, move=False):
mergeq=None, all=False, move=False, exact=False):
def push(self, repo, patch=None, force=False, list=False, mergeq=None, all=False, move=False): diffopts = self.diffopts() wlock = repo.wlock() try: heads = [] for b, ls in repo.branchmap().iteritems(): heads += ls if not heads: heads = [nullid] if repo.dirstate.parents()[0] not in heads: self.ui.status(_("(working dire...
if repo.dirstate.parents()[0] not in heads:
if repo.dirstate.parents()[0] not in heads and not exact:
def push(self, repo, patch=None, force=False, list=False, mergeq=None, all=False, move=False): diffopts = self.diffopts() wlock = repo.wlock() try: heads = [] for b, ls in repo.branchmap().iteritems(): heads += ls if not heads: heads = [nullid] if repo.dirstate.parents()[0] not in heads: self.ui.status(_("(working dire...
mergeq=mergeq, all=opts.get('all'), move=opts.get('move'))
mergeq=mergeq, all=opts.get('all'), move=opts.get('move'), exact=opts.get('exact'))
def push(ui, repo, patch=None, **opts): """push the next patch onto the stack When -f/--force is applied, all local changes in patched files will be lost. Return 0 on succces. """ q = repo.mq mergeq = None if opts.get('merge'): if opts.get('name'): newpath = repo.join(opts.get('name')) else: newpath, i = lastsavenam...
or name.startswith('.mq') or ' or (os.name == 'nt' and ':' in name)):
or name.startswith('.mq') or '
def check_reserved_name(self, name): if (name in self._reserved or name.startswith('.hg') or name.startswith('.mq') or '#' in name or (os.name == 'nt' and ':' in name)): raise util.Abort(_('"%s" cannot be used as the name of a patch') % name)
_debug(ui, "reading tags from %d head(s): %s\n" % (len(heads), map(short, reversed(heads))))
def findglobaltags(ui, repo, alltags, tagtypes): '''Find global tags in repo by reading .hgtags from every head that has a distinct version of it, using a cache to avoid excess work. Updates the dicts alltags, tagtypes in place: alltags maps tag name to (node, hist) pair (see _readtags() below), and tagtypes maps tag n...
_debug(ui, 'reading tag cache from %s\n' % cachefile.name)
def _readtagcache(ui, repo): '''Read the tag cache and return a tuple (heads, fnodes, cachetags, shouldwrite). If the cache is completely up-to-date, cachetags is a dict of the form returned by _readtags(); otherwise, it is None and heads and fnodes are set. In that case, heads is the list of all heads currently in t...
_debug(ui, "tag cache: tip unchanged\n")
def _readtagcache(ui, repo): '''Read the tag cache and return a tuple (heads, fnodes, cachetags, shouldwrite). If the cache is completely up-to-date, cachetags is a dict of the form returned by _readtags(); otherwise, it is None and heads and fnodes are set. In that case, heads is the list of all heads currently in t...
if not cacheheads: _debug(ui, 'tag cache: cache file missing or empty\n')
def _readtagcache(ui, repo): '''Read the tag cache and return a tuple (heads, fnodes, cachetags, shouldwrite). If the cache is completely up-to-date, cachetags is a dict of the form returned by _readtags(); otherwise, it is None and heads and fnodes are set. In that case, heads is the list of all heads currently in t...
elif cacheheads and tiprev < cacherevs[0]: _debug(ui, 'tag cache: tip rev decremented (from %d to %d), ' 'so we must be destroying nodes\n' % (cacherevs[0], tiprev))
def _readtagcache(ui, repo): '''Read the tag cache and return a tuple (heads, fnodes, cachetags, shouldwrite). If the cache is completely up-to-date, cachetags is a dict of the form returned by _readtags(); otherwise, it is None and heads and fnodes are set. In that case, heads is the list of all heads currently in t...
else: _debug(ui, 'tag cache: tip has changed (%d:%s); must find new heads\n' % (tiprev, short(tipnode)))
def _readtagcache(ui, repo): '''Read the tag cache and return a tuple (heads, fnodes, cachetags, shouldwrite). If the cache is completely up-to-date, cachetags is a dict of the form returned by _readtags(); otherwise, it is None and heads and fnodes are set. In that case, heads is the list of all heads currently in t...
_debug(ui, 'tag cache: found %d head(s) not in cache: %s\n' % (len(newheads), map(short, newheads)))
def _readtagcache(ui, repo): '''Read the tag cache and return a tuple (heads, fnodes, cachetags, shouldwrite). If the cache is completely up-to-date, cachetags is a dict of the form returned by _readtags(); otherwise, it is None and heads and fnodes are set. In that case, heads is the list of all heads currently in t...
return int(entries[0].getAttribute('revision') or 0)
return str(entries[0].getAttribute('revision')) or '0'
def _wcrev(self): output = self._svncommand(['info', '--xml']) doc = xml.dom.minidom.parseString(output) entries = doc.getElementsByTagName('entry') if not entries: return 0 return int(entries[0].getAttribute('revision') or 0)
mergeq=None, all=False):
mergeq=None, all=False, move=False):
def push(self, repo, patch=None, force=False, list=False, mergeq=None, all=False): diffopts = self.diffopts() wlock = repo.wlock() try: heads = [] for b, ls in repo.branchmap().iteritems(): heads += ls if not heads: heads = [nullid] if repo.dirstate.parents()[0] not in heads: self.ui.status(_("(working directory not at...
mergeq=mergeq, all=opts.get('all'))
mergeq=mergeq, all=opts.get('all'), move=opts.get('move'))
def push(ui, repo, patch=None, **opts): """push the next patch onto the stack When -f/--force is applied, all local changes in patched files will be lost. """ q = repo.mq mergeq = None if opts['merge']: if opts['name']: newpath = repo.join(opts['name']) else: newpath, i = lastsavename(q.path) if not newpath: ui.warn(...
('n', 'name', '', _('merge queue name (DEPRECATED)'))], _('hg qpush [-f] [-l] [-a] [-m] [-n NAME] [PATCH | INDEX]')),
('n', 'name', '', _('merge queue name (DEPRECATED)')), ('', 'move', None, _('reorder patch series and apply only the patch'))], _('hg qpush [-f] [-l] [-a] [-m] [-n NAME] [--move] [PATCH | INDEX]')),
def uisetup(ui): mqopt = [('', 'mq', None, _("operate on patch repository"))] extensions.wrapcommand(commands.table, 'import', mqimport) entry = extensions.wrapcommand(commands.table, 'init', mqinit) entry[1].extend(mqopt) norepo = commands.norepo.split(" ") for cmd in commands.table.keys(): cmd = cmdutil.parsealias...
_('[-ac] [-r STARTREV] [REV]...')),
_('[-ac] [-r REV] [REV]...')),
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 __init__(self, name, globals, locals):
def __init__(self, name, globals, locals, level):
def __init__(self, name, globals, locals): if '.' in name: head, rest = name.split('.', 1) after = [rest] else: head = name after = [] object.__setattr__(self, "_data", (head, globals, locals, after)) object.__setattr__(self, "_module", None)
object.__setattr__(self, "_data", (head, globals, locals, after))
object.__setattr__(self, "_data", (head, globals, locals, after, level))
def __init__(self, name, globals, locals): if '.' in name: head, rest = name.split('.', 1) after = [rest] else: head = name after = [] object.__setattr__(self, "_data", (head, globals, locals, after)) object.__setattr__(self, "_module", None)
head, globals, locals, after = self._data mod = _origimport(head, globals, locals)
head, globals, locals, after, level = self._data if level is not None: mod = _origimport(head, globals, locals, level) else: mod = _origimport(head, globals, locals)
def _load(self): if not self._module: head, globals, locals, after = self._data mod = _origimport(head, globals, locals) # load submodules def subload(mod, p): h, t = p, None if '.' in p: h, t = p.split('.', 1) if not hasattr(mod, h): setattr(mod, h, _demandmod(p, mod.__dict__, mod.__dict__)) elif t: subload(getattr(mo...
setattr(mod, h, _demandmod(p, mod.__dict__, mod.__dict__))
submod = _demandmod(p, mod.__dict__, mod.__dict__, level=level) setattr(mod, h, submod)
def subload(mod, p): h, t = p, None if '.' in p: h, t = p.split('.', 1) if not hasattr(mod, h): setattr(mod, h, _demandmod(p, mod.__dict__, mod.__dict__)) elif t: subload(getattr(mod, h), t)
return _origimport(name, globals, locals, fromlist)
if level is not None: return _origimport(name, globals, locals, fromlist, level) else: return _origimport(name, globals, locals, fromlist)
def _demandimport(name, globals=None, locals=None, fromlist=None, level=None): if not locals or name in ignore or fromlist == ('*',): # these cases we can't really delay if level is None: return _origimport(name, globals, locals, fromlist) else: return _origimport(name, globals, locals, fromlist, level) elif not fromli...
return _demandmod(name, globals, locals)
return _demandmod(name, globals, locals, level=level)
def _demandimport(name, globals=None, locals=None, fromlist=None, level=None): if not locals or name in ignore or fromlist == ('*',): # these cases we can't really delay if level is None: return _origimport(name, globals, locals, fromlist) else: return _origimport(name, globals, locals, fromlist, level) elif not fromli...
return _origimport(name, globals, locals, fromlist, level) mod = _origimport(name, globals, locals)
mod = _origimport(name, globals, locals, level=level) else: mod = _origimport(name, globals, locals)
def _demandimport(name, globals=None, locals=None, fromlist=None, level=None): if not locals or name in ignore or fromlist == ('*',): # these cases we can't really delay if level is None: return _origimport(name, globals, locals, fromlist) else: return _origimport(name, globals, locals, fromlist, level) elif not fromli...
setattr(mod, comp, _demandmod(comp, mod.__dict__, mod.__dict__))
submod = _demandmod(comp, mod.__dict__, mod.__dict__, level=level) setattr(mod, comp, submod)
def _demandimport(name, globals=None, locals=None, fromlist=None, level=None): if not locals or name in ignore or fromlist == ('*',): # these cases we can't really delay if level is None: return _origimport(name, globals, locals, fromlist) else: return _origimport(name, globals, locals, fromlist, level) elif not fromli...
setattr(mod, x, _demandmod(x, mod.__dict__, locals))
submod = _demandmod(x, mod.__dict__, locals, level=level) setattr(mod, x, submod)
def _demandimport(name, globals=None, locals=None, fromlist=None, level=None): if not locals or name in ignore or fromlist == ('*',): # these cases we can't really delay if level is None: return _origimport(name, globals, locals, fromlist) else: return _origimport(name, globals, locals, fromlist, level) elif not fromli...
branches=[], parent=None, synthetic=False)
branches=[], parent=None)
def scache(s): "return a shared version of a string" return _scache.setdefault(s, s)
synth = getattr(c.entries[0], 'synthetic', None) c.synthetic = (len(c.entries) == 1 and synth)
c.synthetic = len(c.entries) == 1 and c.entries[0].synthetic
def createchangeset(ui, log, fuzz=60, mergefrom=None, mergeto=None): '''Convert log into changesets.''' ui.status(_('creating changesets\n')) # Merge changesets log.sort(key=lambda x: (x.comment, x.author, x.branch, x.date)) changesets = [] files = set() c = None for i, e in enumerate(log): # Check if log entry be...
revmatchfn = cmdutil.match(repo, fns)
revmatchfn = cmdutil.match(repo, fns, default='path')
def prep(ctx, fns): rev = ctx.rev() parents = [p for p in repo.changelog.parentrevs(rev) if p != nullrev] if opts.get('no_merges') and len(parents) == 2: return if opts.get('only_merges') and len(parents) != 2: return if opts.get('branch') and ctx.branch() not in opts['branch']: return if df and not df(ctx.date()[0]): ...
def debugindex(ui, file_):
def debugindex(ui, repo, file_):
def debugindex(ui, file_): """dump the contents of an index file""" r = revlog.revlog(util.opener(os.getcwd(), audit=False), file_) ui.write(" rev offset length base linkrev" " nodeid p1 p2\n") for i in r: node = r.node(i) try: pp = r.parents(node) except: pp = [nullid, nullid] ui.write("% 6d % ...
r = revlog.revlog(util.opener(os.getcwd(), audit=False), file_)
r = None if repo: filelog = repo.file(file_) if len(filelog): r = filelog if not r: r = revlog.revlog(util.opener(os.getcwd(), audit=False), file_)
def debugindex(ui, file_): """dump the contents of an index file""" r = revlog.revlog(util.opener(os.getcwd(), audit=False), file_) ui.write(" rev offset length base linkrev" " nodeid p1 p2\n") for i in r: node = r.node(i) try: pp = r.parents(node) except: pp = [nullid, nullid] ui.write("% 6d % ...
def debugindexdot(ui, file_):
def debugindexdot(ui, repo, file_):
def debugindexdot(ui, file_): """dump an index DAG as a graphviz dot file""" r = revlog.revlog(util.opener(os.getcwd(), audit=False), file_) ui.write("digraph G {\n") for i in r: node = r.node(i) pp = r.parents(node) ui.write("\t%d -> %d\n" % (r.rev(pp[0]), i)) if pp[1] != nullid: ui.write("\t%d -> %d\n" % (r.rev(pp[1]...
r = revlog.revlog(util.opener(os.getcwd(), audit=False), file_)
r = None if repo: filelog = repo.file(file_) if len(filelog): r = filelog if not r: r = revlog.revlog(util.opener(os.getcwd(), audit=False), file_)
def debugindexdot(ui, file_): """dump an index DAG as a graphviz dot file""" r = revlog.revlog(util.opener(os.getcwd(), audit=False), file_) ui.write("digraph G {\n") for i in r: node = r.node(i) pp = r.parents(node) ui.write("\t%d -> %d\n" % (r.rev(pp[0]), i)) if pp[1] != nullid: ui.write("\t%d -> %d\n" % (r.rev(pp[1]...
" debugindex debugindexdot debugdate debuginstall debugfsinfo" " debugpushkey")
" debugdate debuginstall debugfsinfo debugpushkey")
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...
" debugdata")
" debugdata debugindex debugindexdot")
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 __del__(self): self.close_all()
def __del__(self): self.close_all()
def __init__(self, pf):
def __init__(self, pf, plainmode=False):
def __init__(self, pf): def eatdiff(lines): while lines: l = lines[-1] if (l.startswith("diff -") or l.startswith("Index:") or l.startswith("===========")): del lines[-1] else: break def eatempty(lines): while lines: l = lines[-1] if re.match('\s*$', l): del lines[-1] else: break
if self._hasheader(['Date: ']):
if self.plainmode or self._hasheader(['Date: ']):
def setuser(self, user): if not self.updateheader(['From: ', '# User '], user): try: patchheaderat = self.comments.index('# HG changeset patch') self.comments.insert(patchheaderat + 1, '# User ' + user) except ValueError: if self._hasheader(['Date: ']): self.comments = ['From: ' + user] + self.comments else: tmp = ['# ...
if self._hasheader(['From: ']):
if self.plainmode or self._hasheader(['From: ']):
def setdate(self, date): if not self.updateheader(['Date: ', '# Date '], date): try: patchheaderat = self.comments.index('# HG changeset patch') self.comments.insert(patchheaderat + 1, '# Date ' + date) except ValueError: if self._hasheader(['From: ']): self.comments = ['Date: ' + date] + self.comments else: tmp = ['# ...
ph = patchheader(mergeq.join(patch))
ph = patchheader(mergeq.join(patch), self.plainmode)
def mergeone(self, repo, mergeq, head, patch, rev, diffopts): # first try just applying the patch (err, n) = self.apply(repo, [patch], update_status=False, strict=True, merge=rev)
ph = patchheader(self.join(patchname))
ph = patchheader(self.join(patchname), self.plainmode)
def _apply(self, repo, series, list=False, update_status=True, strict=False, patchdir=None, merge=None, all_files={}): '''returns (error, hash) error = 1 for unable to read, 2 for patch failed, 3 for patch fuzz''' # TODO unify with commands.py if not patchdir: patchdir = self.path err = 0 n = None for patchname in seri...
if date:
if self.plainmode: if user: p.write("From: " + user + "\n") if not date: p.write("\n") if date: p.write("Date: %d %d\n\n" % date) else:
def badfn(f, msg): raise util.Abort('%s: %s' % (f, msg))
p.write(" elif user: p.write("From: " + user + "\n\n")
if date: p.write("
def badfn(f, msg): raise util.Abort('%s: %s' % (f, msg))
ph = patchheader(self.join(patchfn))
ph = patchheader(self.join(patchfn), self.plainmode)
def refresh(self, repo, pats=None, **opts): if len(self.applied) == 0: self.ui.write(_("no patches applied\n")) return 1 msg = opts.get('msg', '').rstrip() newuser = opts.get('user') newdate = opts.get('date') if newdate: newdate = '%d %d' % util.parsedate(newdate) wlock = repo.wlock()
ph = patchheader(self.join(patchname))
ph = patchheader(self.join(patchname), self.plainmode)
def displayname(pfx, patchname): if summary: ph = patchheader(self.join(patchname)) msg = ph.message and ph.message[0] or '' if self.ui.interactive(): width = util.termwidth() - len(pfx) - len(patchname) - 2 if width > 0: msg = util.ellipsis(msg, width) else: msg = '' msg = "%s%s: %s" % (pfx, patchname, msg) else: msg ...
ph = patchheader(q.join(patch))
ph = patchheader(q.join(patch), q.plainmode)
def refresh(ui, repo, *pats, **opts): """update the current patch If any file patterns are provided, the refreshed patch will contain only the modifications that match those patterns; the remaining modifications will remain in the working directory. If -s/--short is specified, files currently included in the patch wi...
ph = patchheader(q.join(p))
ph = patchheader(q.join(p), q.plainmode)
def fold(ui, repo, *files, **opts): """fold the named patches into the current patch Patches must not yet be applied. Each patch will be successively applied to the current patch in the order given. If all the patches apply successfully, the current patch will be refreshed with the new cumulative patch, and the folded...
ph = patchheader(q.join(parent))
ph = patchheader(q.join(parent), q.plainmode)
def fold(ui, repo, *files, **opts): """fold the named patches into the current patch Patches must not yet be applied. Each patch will be successively applied to the current patch in the order given. If all the patches apply successfully, the current patch will be refreshed with the new cumulative patch, and the folded...
ph = patchheader(repo.mq.join(patch))
ph = patchheader(q.join(patch), q.plainmode)
def header(ui, repo, patch=None): """print the header of the topmost or specified patch""" q = repo.mq if patch: patch = q.lookup(patch) else: if not q.applied: ui.write('no patches applied\n') return 1 patch = q.lookup('qtip') ph = patchheader(repo.mq.join(patch)) ui.write('\n'.join(ph.message) + '\n')
for cmd in commands.table:
for cmd in commands.table.keys():
def uisetup(ui): mqopt = [('Q', 'mq', None, _("operate on patch repository"))] extensions.wrapcommand(commands.table, 'import', mqimport) entry = extensions.wrapcommand(commands.table, 'init', mqinit) entry[1].extend(mqopt) for cmd in commands.table: cmd = cmdutil.parsealiases(cmd)[0] if cmd in commands.norepo: cont...
""" raw_strings = [ (r'\\n', r'\n', '\n'), (r'\\r', r'\r', '\r'), (r'\\t', r'\t', '\t'), ] for a, b, c in raw_strings: if a in st: st = st.replace(a, b) else: st = st.replace(b, c) return st.replace(r'\"', '"').replace(r'\\', '\\')
>>> unescape(r'\\\\n\\n') '\\\\n\\n' """ def unescape_repl(m): m = m.group(1) if m == 'n': return '\n' if m == 't': return '\t' if m == 'r': return '\r' if m == '\\': return '\\' return m return re.sub(r'\\(\\|n|t|r|")', unescape_repl, st)
def unescape(st): """ Unescape special chars and return the given string *st*. **Examples**: >>> unescape('\\\\t and \\\\n and \\\\r and \\\\" and \\\\\\\\') '\\t and \\n and \\r and " and \\\\' >>> unescape(r'\\n') '\\n' >>> unescape(r'\\\\n') '\\\\n' """ raw_strings = [ (r'\\n', r'\n', '\n'), (r'\\r', r'\r', '\r'),...
commands = ['--no-pager'] + commands
def _gitdir(self, commands, env=None, stream=False): commands = ['--no-pager'] + commands return self._gitnodir(commands, env=env, stream=stream, cwd=self._path)
command = None for arg in commands: if not arg.startswith('-'): command = arg break
command = commands[0]
def _gitnodir(self, commands, env=None, stream=False, cwd=None): """Calls the git command
raise util.Abort('git %s error %d' % (command, p.returncode))
raise util.Abort('git %s error %d in %s' % (command, p.returncode, self._relpath))
def _gitnodir(self, commands, env=None, stream=False, cwd=None): """Calls the git command
patches = list(patches)
realpatches.append(patch)
def delete(self, repo, patches, opts): if not patches and not opts.get('rev'): raise util.Abort(_('qdelete requires at least one revision or ' 'patch name'))
patches += revpatches
realpatches += revpatches
def delete(self, repo, patches, opts): if not patches and not opts.get('rev'): raise util.Abort(_('qdelete requires at least one revision or ' 'patch name'))
self._cleanup(patches, numrevs, opts.get('keep'))
self._cleanup(realpatches, numrevs, opts.get('keep'))
def delete(self, repo, patches, opts): if not patches and not opts.get('rev'): raise util.Abort(_('qdelete requires at least one revision or ' 'patch name'))
Revision non-ambiguously specified by the given hex string prefix
Revision non-ambiguously specified by the given hex string prefix.
def node(repo, subset, x): """``id(string)`` Revision non-ambiguously specified by the given hex string prefix """ # i18n: "id" is a keyword l = getargs(x, 1, 1, _("id requires one argument")) # i18n: "id" is a keyword n = getstring(l[0], _("id requires a string")) if len(n) == 40: rn = repo[n].rev() else: rn = repo.ch...
def __init__(self, node, name=None): if not name: fields = node.split(':', 1) if len(fields) == 2: n, name = fields self.node, self.name = bin(n), name else: self.node, self.name = None, None else: self.node, self.name = node, name
def __init__(self, node, name): self.node, self.name = node, name
def __init__(self, node, name=None): if not name: fields = node.split(':', 1) if len(fields) == 2: n, name = fields self.node, self.name = bin(n), name else: self.node, self.name = None, None else: self.node, self.name = node, name
return [statusentry(l) for l in lines]
return [parse(l) for l in lines]
def applied(self): if os.path.exists(self.join(self.status_path)): lines = self.opener(self.status_path).read().splitlines() return [statusentry(l) for l in lines] return []
se = statusentry(l) file_ = se.name if se.node: applied.append(se) else: series.append(file_)
try: n, name = l.split(':', 1) except ValueError: series.append(l) else: applied.append(statusentry(bin(n), name))
def restore(self, repo, rev, delete=None, qupdate=None): desc = repo[rev].description().strip() lines = desc.splitlines() i = 0 datastart = None series = [] applied = [] qpp = None for i, line in enumerate(lines): if line == 'Patch Data:': datastart = i + 1 elif line.startswith('Dirstate:'): l = line.rstrip() l = l[10:...
branch = None
branch = (None, [])
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...
description. Next, (optionally) if the diffstat program is installed and -d/--diffstat is used, the result of running diffstat on the patch. Finally, the patch itself, as generated by :hg:`export`.
description. With the -d/--diffstat option, if the diffstat program is installed, the result of running diffstat on the patch is inserted. Finally, the patch itself, as generated by :hg:`export`. With the -d/--diffstat or -c/--confirm options, you will be presented with a final summary of all messages and asked for ...
def patchbomb(ui, repo, *revs, **opts): '''send changesets by email By default, diffs are sent in the format generated by :hg:`export`, one per message. The series starts with a "[PATCH 0 of N]" introduction, which describes the series as a whole. Each patch email has a Subject line of "[PATCH M of N] ...", using the...
a = getset(repo, subset, l[0]) b = getset(repo, subset, l[1]) if len(a) > 1 or len(b) > 1:
r = range(len(repo)) a = getset(repo, r, l[0]) b = getset(repo, r, l[1]) if len(a) != 1 or len(b) != 1:
def ancestor(repo, subset, x): l = getargs(x, 2, 2, _("ancestor wants two arguments")) a = getset(repo, subset, l[0]) b = getset(repo, subset, l[1]) if len(a) > 1 or len(b) > 1: raise error.ParseError(_("ancestor arguments must be single revisions")) return [repo[a[0]].ancestor(repo[b[0]]).rev()]
return [repo[a[0]].ancestor(repo[b[0]]).rev()]
an = [repo[a[0]].ancestor(repo[b[0]]).rev()] return [r for r in an if r in subset]
def ancestor(repo, subset, x): l = getargs(x, 2, 2, _("ancestor wants two arguments")) a = getset(repo, subset, l[0]) b = getset(repo, subset, l[1]) if len(a) > 1 or len(b) > 1: raise error.ParseError(_("ancestor arguments must be single revisions")) return [repo[a[0]].ancestor(repo[b[0]]).rev()]
cmd = ['svn'] + commands + [self._path]
path = os.path.join(self._ctx._repo.origroot, self._path) cmd = ['svn'] + commands + [path]
def _svncommand(self, commands): cmd = ['svn'] + commands + [self._path] cmd = [util.shellquote(arg) for arg in cmd] cmd = util.quotecommand(' '.join(cmd)) env = dict(os.environ) # Avoid localized output, preserve current locale for everything else. env['LC_MESSAGES'] = 'C' write, read, err = util.popen3(cmd, env=env, ...
if cr and (cr.path() == f or cr.path == c2.path()):
if of == f or of == c2.path():
def checkcopies(f, m1, m2): '''check possible copies of f from m1 to m2''' of = None seen = set([f]) for oc in ctx(f, m1[f]).ancestors(): ocr = oc.rev() of = oc.path() if of in seen: # check limit late - grab last rename before if ocr < limit: break continue seen.add(of)
be enclosed in double quotes ("..."), with "\" as escape character.
be enclosed in double quotes ("..."), with "\\" as escape character.
def debugbuilddag(ui, repo, text, mergeable_file=False, appended_file=False, overwritten_file=False, new_file=False): """builds a repo with a given dag from scratch in the current empty repo Elements: - "+n" is a linear run of n nodes based on the current default parent - "." is a single node based on the current def...
cmd = 'p4 -G changes -s submitted "%s"' % path
cmd = 'p4 -G changes -s submitted %s' % util.shellquote(path)
def _parse_view(self, path): "Read changes affecting the path" cmd = 'p4 -G changes -s submitted "%s"' % path stdout = util.popen(cmd, mode='rb') for d in loaditer(stdout): c = d.get("change", None) if c: self.p4changes[c] = True
cmd = 'p4 -G client -o "%s"' % path
cmd = 'p4 -G client -o %s' % util.shellquote(path)
def _parse(self, ui, path): "Prepare list of P4 filenames and revisions to import" ui.status(_('reading p4 views\n'))