Details
Details
- Reviewers
durin42 - Group Reviewers
hg-reviewers - Commits
- rHG34758397ad1b: py3: use b"%d" instead of str() to convert integers to bytes
Diff Detail
Diff Detail
- Repository
- rHG Mercurial
- Lint
Lint Skipped - Unit
Unit Tests Skipped
( )
durin42 |
hg-reviewers |
Lint Skipped |
Unit Tests Skipped |
Path | Packages | |||
---|---|---|---|---|
M | hgext/convert/__init__.py (2 lines) | |||
M | hgext/convert/cvs.py (6 lines) | |||
M | hgext/convert/cvsps.py (8 lines) | |||
M | mercurial/lock.py (2 lines) |
dates.''' | dates.''' | ||||
return cvsps.debugcvsps(ui, *args, **opts) | return cvsps.debugcvsps(ui, *args, **opts) | ||||
def kwconverted(context, mapping, name): | def kwconverted(context, mapping, name): | ||||
ctx = context.resource(mapping, 'ctx') | ctx = context.resource(mapping, 'ctx') | ||||
rev = ctx.extra().get('convert_revision', '') | rev = ctx.extra().get('convert_revision', '') | ||||
if rev.startswith('svn:'): | if rev.startswith('svn:'): | ||||
if name == 'svnrev': | if name == 'svnrev': | ||||
return str(subversion.revsplit(rev)[2]) | return (b"%d" % subversion.revsplit(rev)[2]) | ||||
elif name == 'svnpath': | elif name == 'svnpath': | ||||
return subversion.revsplit(rev)[1] | return subversion.revsplit(rev)[1] | ||||
elif name == 'svnuuid': | elif name == 'svnuuid': | ||||
return subversion.revsplit(rev)[0] | return subversion.revsplit(rev)[0] | ||||
return rev | return rev | ||||
templatekeyword = registrar.templatekeyword() | templatekeyword = registrar.templatekeyword() | ||||
db = cvsps.createchangeset(self.ui, db, | db = cvsps.createchangeset(self.ui, db, | ||||
fuzz=int(self.ui.config('convert', 'cvsps.fuzz')), | fuzz=int(self.ui.config('convert', 'cvsps.fuzz')), | ||||
mergeto=self.ui.config('convert', 'cvsps.mergeto'), | mergeto=self.ui.config('convert', 'cvsps.mergeto'), | ||||
mergefrom=self.ui.config('convert', 'cvsps.mergefrom')) | mergefrom=self.ui.config('convert', 'cvsps.mergefrom')) | ||||
for cs in db: | for cs in db: | ||||
if maxrev and cs.id > maxrev: | if maxrev and cs.id > maxrev: | ||||
break | break | ||||
id = str(cs.id) | id = (b"%d" % cs.id) | ||||
cs.author = self.recode(cs.author) | cs.author = self.recode(cs.author) | ||||
self.lastbranch[cs.branch] = id | self.lastbranch[cs.branch] = id | ||||
cs.comment = self.recode(cs.comment) | cs.comment = self.recode(cs.comment) | ||||
if self.ui.configbool('convert', 'localtimezone'): | if self.ui.configbool('convert', 'localtimezone'): | ||||
cs.date = makedatetimestamp(cs.date[0]) | cs.date = makedatetimestamp(cs.date[0]) | ||||
date = dateutil.datestr(cs.date, '%Y-%m-%d %H:%M:%S %1%2') | date = dateutil.datestr(cs.date, '%Y-%m-%d %H:%M:%S %1%2') | ||||
self.tags.update(dict.fromkeys(cs.tags, id)) | self.tags.update(dict.fromkeys(cs.tags, id)) | ||||
files = {} | files = {} | ||||
for f in cs.entries: | for f in cs.entries: | ||||
files[f.file] = "%s%s" % ('.'.join([str(x) | files[f.file] = "%s%s" % ('.'.join([(b"%d" % x) | ||||
for x in f.revision]), | for x in f.revision]), | ||||
['', '(DEAD)'][f.dead]) | ['', '(DEAD)'][f.dead]) | ||||
# add current commit to set | # add current commit to set | ||||
c = commit(author=cs.author, date=date, | c = commit(author=cs.author, date=date, | ||||
parents=[str(p.id) for p in cs.parents], | parents=[(b"%d" % p.id) for p in cs.parents], | ||||
desc=cs.comment, branch=cs.branch or '') | desc=cs.comment, branch=cs.branch or '') | ||||
self.changeset[id] = c | self.changeset[id] = c | ||||
self.files[id] = files | self.files[id] = files | ||||
self.heads = self.lastbranch.values() | self.heads = self.lastbranch.values() | ||||
finally: | finally: | ||||
os.chdir(d) | os.chdir(d) | ||||
ui.write(('Tag%s: %s \n' % (['', 's'][len(cs.tags) > 1], | ui.write(('Tag%s: %s \n' % (['', 's'][len(cs.tags) > 1], | ||||
','.join(cs.tags) or '(none)'))) | ','.join(cs.tags) or '(none)'))) | ||||
if cs.branchpoints: | if cs.branchpoints: | ||||
ui.write(('Branchpoints: %s \n') % | ui.write(('Branchpoints: %s \n') % | ||||
', '.join(sorted(cs.branchpoints))) | ', '.join(sorted(cs.branchpoints))) | ||||
if opts["parents"] and cs.parents: | if opts["parents"] and cs.parents: | ||||
if len(cs.parents) > 1: | if len(cs.parents) > 1: | ||||
ui.write(('Parents: %s\n' % | ui.write(('Parents: %s\n' % | ||||
(','.join([str(p.id) for p in cs.parents])))) | (','.join([(b"%d" % p.id) for p in cs.parents])))) | ||||
else: | else: | ||||
ui.write(('Parent: %d\n' % cs.parents[0].id)) | ui.write(('Parent: %d\n' % cs.parents[0].id)) | ||||
if opts["ancestors"]: | if opts["ancestors"]: | ||||
b = cs.branch | b = cs.branch | ||||
r = [] | r = [] | ||||
while b: | while b: | ||||
b, c = ancestors[b] | b, c = ancestors[b] | ||||
r.append('%s:%d:%d' % (b or "HEAD", c, branches[b])) | r.append('%s:%d:%d' % (b or "HEAD", c, branches[b])) | ||||
if r: | if r: | ||||
ui.write(('Ancestors: %s\n' % (','.join(r)))) | ui.write(('Ancestors: %s\n' % (','.join(r)))) | ||||
ui.write(('Log:\n')) | ui.write(('Log:\n')) | ||||
ui.write('%s\n\n' % cs.comment) | ui.write('%s\n\n' % cs.comment) | ||||
ui.write(('Members: \n')) | ui.write(('Members: \n')) | ||||
for f in cs.entries: | for f in cs.entries: | ||||
fn = f.file | fn = f.file | ||||
if fn.startswith(opts["prefix"]): | if fn.startswith(opts["prefix"]): | ||||
fn = fn[len(opts["prefix"]):] | fn = fn[len(opts["prefix"]):] | ||||
ui.write('\t%s:%s->%s%s \n' % ( | ui.write('\t%s:%s->%s%s \n' % ( | ||||
fn, '.'.join([str(x) for x in f.parent]) or 'INITIAL', | fn, '.'.join([str(x) for x in f.parent]) or 'INITIAL', | ||||
'.'.join([str(x) for x in f.revision]), | '.'.join([(b"%d" % x) for x in f.revision]), | ||||
['', '(DEAD)'][f.dead])) | ['', '(DEAD)'][f.dead])) | ||||
ui.write('\n') | ui.write('\n') | ||||
# have we seen the start tag? | # have we seen the start tag? | ||||
if revisions and off: | if revisions and off: | ||||
if revisions[0] == str(cs.id) or \ | if revisions[0] == (b"%d" % cs.id) or \ | ||||
revisions[0] in cs.tags: | revisions[0] in cs.tags: | ||||
off = False | off = False | ||||
# see if we reached the end tag | # see if we reached the end tag | ||||
if len(revisions) > 1 and not off: | if len(revisions) > 1 and not off: | ||||
if revisions[1] == str(cs.id) or \ | if revisions[1] == (b"%d" % cs.id) or \ | ||||
revisions[1] in cs.tags: | revisions[1] in cs.tags: | ||||
break | break |
'inherit cannot be called while lock is already inherited') | 'inherit cannot be called while lock is already inherited') | ||||
if self._inheritchecker is not None: | if self._inheritchecker is not None: | ||||
self._inheritchecker() | self._inheritchecker() | ||||
if self.releasefn: | if self.releasefn: | ||||
self.releasefn() | self.releasefn() | ||||
if self._parentheld: | if self._parentheld: | ||||
lockname = self.parentlock | lockname = self.parentlock | ||||
else: | else: | ||||
lockname = '%s:%s' % (lock._host, self.pid) | lockname = b'%s:%d' % (lock._host, self.pid) | ||||
self._inherited = True | self._inherited = True | ||||
try: | try: | ||||
yield lockname | yield lockname | ||||
finally: | finally: | ||||
if self.acquirefn: | if self.acquirefn: | ||||
self.acquirefn() | self.acquirefn() | ||||
self._inherited = False | self._inherited = False | ||||