Details
Details
Diff Detail
Diff Detail
- Repository
- rHG Mercurial
- Lint
Automatic diff as part of commit; lint not applicable. - Unit
Automatic diff as part of commit; unit tests not applicable.
Automatic diff as part of commit; lint not applicable. |
Automatic diff as part of commit; unit tests not applicable. |
Path | Packages | |||
---|---|---|---|---|
M | hgext/journal.py (6 lines) | |||
M | hgext/mq.py (4 lines) | |||
M | hgext/patchbomb.py (4 lines) | |||
M | hgext/schemes.py (2 lines) |
with self.jlock(vfs): | with self.jlock(vfs): | ||||
version = None | version = None | ||||
# open file in amend mode to ensure it is created if missing | # open file in amend mode to ensure it is created if missing | ||||
with vfs('namejournal', mode='a+b') as f: | with vfs('namejournal', mode='a+b') as f: | ||||
f.seek(0, os.SEEK_SET) | f.seek(0, os.SEEK_SET) | ||||
# Read just enough bytes to get a version number (up to 2 | # Read just enough bytes to get a version number (up to 2 | ||||
# digits plus separator) | # digits plus separator) | ||||
version = f.read(3).partition('\0')[0] | version = f.read(3).partition('\0')[0] | ||||
if version and version != str(storageversion): | if version and version != "%d" % storageversion: | ||||
# different version of the storage. Exit early (and not | # different version of the storage. Exit early (and not | ||||
# write anything) if this is not a version we can handle or | # write anything) if this is not a version we can handle or | ||||
# the file is corrupt. In future, perhaps rotate the file | # the file is corrupt. In future, perhaps rotate the file | ||||
# instead? | # instead? | ||||
self.ui.warn( | self.ui.warn( | ||||
_("unsupported journal file version '%s'\n") % version) | _("unsupported journal file version '%s'\n") % version) | ||||
return | return | ||||
if not version: | if not version: | ||||
# empty file, write version first | # empty file, write version first | ||||
f.write(str(storageversion) + '\0') | f.write(("%d" % storageversion) + '\0') | ||||
f.seek(0, os.SEEK_END) | f.seek(0, os.SEEK_END) | ||||
f.write(bytes(entry) + '\0') | f.write(bytes(entry) + '\0') | ||||
def filtered(self, namespace=None, name=None): | def filtered(self, namespace=None, name=None): | ||||
"""Yield all journal entries with the given namespace or name | """Yield all journal entries with the given namespace or name | ||||
Both the namespace and the name are optional; if neither is given all | Both the namespace and the name are optional; if neither is given all | ||||
entries in the journal are produced. | entries in the journal are produced. | ||||
if not vfs.exists(filename): | if not vfs.exists(filename): | ||||
return | return | ||||
with vfs(filename) as f: | with vfs(filename) as f: | ||||
raw = f.read() | raw = f.read() | ||||
lines = raw.split('\0') | lines = raw.split('\0') | ||||
version = lines and lines[0] | version = lines and lines[0] | ||||
if version != str(storageversion): | if version != "%d" % storageversion: | ||||
version = version or _('not available') | version = version or _('not available') | ||||
raise error.Abort(_("unknown journal file version '%s'") % version) | raise error.Abort(_("unknown journal file version '%s'") % version) | ||||
# Skip the first line, it's a version number. Normally we iterate over | # Skip the first line, it's a version number. Normally we iterate over | ||||
# these in reverse order to list newest first; only when copying across | # these in reverse order to list newest first; only when copying across | ||||
# a shared storage do we forgo reversing. | # a shared storage do we forgo reversing. | ||||
lines = lines[1:] | lines = lines[1:] | ||||
if _newestfirst: | if _newestfirst: |
self.ui.write(patchname, label='qseries.' + state) | self.ui.write(patchname, label='qseries.' + state) | ||||
self.ui.write('\n') | self.ui.write('\n') | ||||
applied = set([p.name for p in self.applied]) | applied = set([p.name for p in self.applied]) | ||||
if length is None: | if length is None: | ||||
length = len(self.series) - start | length = len(self.series) - start | ||||
if not missing: | if not missing: | ||||
if self.ui.verbose: | if self.ui.verbose: | ||||
idxwidth = len(str(start + length - 1)) | idxwidth = len("%d" % (start + length - 1)) | ||||
for i in xrange(start, start + length): | for i in xrange(start, start + length): | ||||
patch = self.series[i] | patch = self.series[i] | ||||
if patch in applied: | if patch in applied: | ||||
char, state = 'A', 'applied' | char, state = 'A', 'applied' | ||||
elif self.pushable(i)[0]: | elif self.pushable(i)[0]: | ||||
char, state = 'U', 'unapplied' | char, state = 'U', 'unapplied' | ||||
else: | else: | ||||
char, state = 'G', 'guarded' | char, state = 'G', 'guarded' | ||||
return nextpatch(end + 1) | return nextpatch(end + 1) | ||||
return nextpatch(end) | return nextpatch(end) | ||||
def appliedname(self, index): | def appliedname(self, index): | ||||
pname = self.applied[index].name | pname = self.applied[index].name | ||||
if not self.ui.verbose: | if not self.ui.verbose: | ||||
p = pname | p = pname | ||||
else: | else: | ||||
p = str(self.series.index(pname)) + " " + pname | p = ("%d" % self.series.index(pname)) + " " + pname | ||||
return p | return p | ||||
def qimport(self, repo, files, patchname=None, rev=None, existing=None, | def qimport(self, repo, files, patchname=None, rev=None, existing=None, | ||||
force=None, git=False): | force=None, git=False): | ||||
def checkseries(patchname): | def checkseries(patchname): | ||||
if patchname in self.series: | if patchname in self.series: | ||||
raise error.Abort(_('patch %s is already in the series file') | raise error.Abort(_('patch %s is already in the series file') | ||||
% patchname) | % patchname) |
"""build prefix to patch subject""" | """build prefix to patch subject""" | ||||
flag = _formatflags(ui, repo, rev, flags) | flag = _formatflags(ui, repo, rev, flags) | ||||
if flag: | if flag: | ||||
flag = ' ' + flag | flag = ' ' + flag | ||||
if not numbered: | if not numbered: | ||||
return '[PATCH%s]' % flag | return '[PATCH%s]' % flag | ||||
else: | else: | ||||
tlen = len(str(total)) | tlen = len("%d" % total) | ||||
return '[PATCH %0*d of %d%s]' % (tlen, idx, total, flag) | return '[PATCH %0*d of %d%s]' % (tlen, idx, total, flag) | ||||
def makepatch(ui, repo, rev, patchlines, opts, _charsets, idx, total, numbered, | def makepatch(ui, repo, rev, patchlines, opts, _charsets, idx, total, numbered, | ||||
patchname=None): | patchname=None): | ||||
desc = [] | desc = [] | ||||
node = None | node = None | ||||
body = '' | body = '' | ||||
if bookmark not in repo._bookmarks: | if bookmark not in repo._bookmarks: | ||||
raise error.Abort(_("bookmark '%s' not found") % bookmark) | raise error.Abort(_("bookmark '%s' not found") % bookmark) | ||||
revs = repair.stripbmrevset(repo, bookmark) | revs = repair.stripbmrevset(repo, bookmark) | ||||
revs = scmutil.revrange(repo, revs) | revs = scmutil.revrange(repo, revs) | ||||
if outgoing: | if outgoing: | ||||
revs = _getoutgoing(repo, dest, revs) | revs = _getoutgoing(repo, dest, revs) | ||||
if bundle: | if bundle: | ||||
opts['revs'] = [str(r) for r in revs] | opts['revs'] = ["%d" % r for r in revs] | ||||
# check if revision exist on the public destination | # check if revision exist on the public destination | ||||
publicurl = repo.ui.config('patchbomb', 'publicurl') | publicurl = repo.ui.config('patchbomb', 'publicurl') | ||||
if publicurl: | if publicurl: | ||||
repo.ui.debug('checking that revision exist in the public repo\n') | repo.ui.debug('checking that revision exist in the public repo\n') | ||||
try: | try: | ||||
publicpeer = hg.peer(repo, {}, publicurl) | publicpeer = hg.peer(repo, {}, publicurl) | ||||
except error.RepoError: | except error.RepoError: |
except IndexError: | except IndexError: | ||||
raise error.Abort(_("no '://' in scheme url '%s'") % url) | raise error.Abort(_("no '://' in scheme url '%s'") % url) | ||||
parts = url.split('/', self.parts) | parts = url.split('/', self.parts) | ||||
if len(parts) > self.parts: | if len(parts) > self.parts: | ||||
tail = parts[-1] | tail = parts[-1] | ||||
parts = parts[:-1] | parts = parts[:-1] | ||||
else: | else: | ||||
tail = '' | tail = '' | ||||
context = dict((str(i + 1), v) for i, v in enumerate(parts)) | context = dict(('%d' % (i + 1), v) for i, v in enumerate(parts)) | ||||
return ''.join(self.templater.process(self.url, context)) + tail | return ''.join(self.templater.process(self.url, context)) + tail | ||||
def hasdriveletter(orig, path): | def hasdriveletter(orig, path): | ||||
if path: | if path: | ||||
for scheme in schemes: | for scheme in schemes: | ||||
if path.startswith(scheme + ':'): | if path.startswith(scheme + ':'): | ||||
return False | return False | ||||
return orig(path) | return orig(path) |