##// END OF EJS Templates
style: kill ersatz if-else ternary operators...
Jordi Gutiérrez Hermoso -
r24306:6ddc86ee default
parent child Browse files
Show More
@@ -359,7 +359,10 b' def synthesize(ui, repo, descpath, **opt'
359 files.iterkeys(), filectxfn, ui.username(),
359 files.iterkeys(), filectxfn, ui.username(),
360 '%d %d' % util.makedate())
360 '%d %d' % util.makedate())
361 initnode = mc.commit()
361 initnode = mc.commit()
362 hexfn = ui.debugflag and hex or short
362 if ui.debugflag:
363 hexfn = hex
364 else:
365 hexfn = short
363 ui.status(_('added commit %s with %d files\n')
366 ui.status(_('added commit %s with %d files\n')
364 % (hexfn(initnode), len(files)))
367 % (hexfn(initnode), len(files)))
365
368
@@ -475,7 +478,10 b' def renamedirs(dirs, words):'
475 if dirpath in replacements:
478 if dirpath in replacements:
476 return replacements[dirpath]
479 return replacements[dirpath]
477 head, _ = os.path.split(dirpath)
480 head, _ = os.path.split(dirpath)
478 head = head and rename(head) or ''
481 if head:
482 head = rename(head)
483 else:
484 head = ''
479 renamed = os.path.join(head, wordgen.next())
485 renamed = os.path.join(head, wordgen.next())
480 replacements[dirpath] = renamed
486 replacements[dirpath] = renamed
481 return renamed
487 return renamed
@@ -31,7 +31,10 b' class MissingTool(Exception):'
31 def checktool(exe, name=None, abort=True):
31 def checktool(exe, name=None, abort=True):
32 name = name or exe
32 name = name or exe
33 if not util.findexe(exe):
33 if not util.findexe(exe):
34 exc = abort and util.Abort or MissingTool
34 if abort:
35 exc = util.Abort
36 else:
37 exc = MissingTool
35 raise exc(_('cannot find required "%s" tool') % name)
38 raise exc(_('cannot find required "%s" tool') % name)
36
39
37 class NoRepo(Exception):
40 class NoRepo(Exception):
@@ -515,7 +515,11 b' def convert(ui, src, dest=None, revmapfi'
515 sortmode = [m for m in sortmodes if opts.get(m)]
515 sortmode = [m for m in sortmodes if opts.get(m)]
516 if len(sortmode) > 1:
516 if len(sortmode) > 1:
517 raise util.Abort(_('more than one sort mode specified'))
517 raise util.Abort(_('more than one sort mode specified'))
518 sortmode = sortmode and sortmode[0] or defaultsort
518 if sortmode:
519 sortmode = sortmode[0]
520 else:
521 sortmode = defaultsort
522
519 if sortmode == 'sourcesort' and not srcc.hasnativeorder():
523 if sortmode == 'sourcesort' and not srcc.hasnativeorder():
520 raise util.Abort(_('--sourcesort is not supported by this data source'))
524 raise util.Abort(_('--sourcesort is not supported by this data source'))
521 if sortmode == 'closesort' and not srcc.hasnativeclose():
525 if sortmode == 'closesort' and not srcc.hasnativeclose():
@@ -209,7 +209,10 b' class gnuarch_source(converter_source, c'
209 mode = os.lstat(os.path.join(self.tmppath, name)).st_mode
209 mode = os.lstat(os.path.join(self.tmppath, name)).st_mode
210 if stat.S_ISLNK(mode):
210 if stat.S_ISLNK(mode):
211 data = os.readlink(os.path.join(self.tmppath, name))
211 data = os.readlink(os.path.join(self.tmppath, name))
212 mode = mode and 'l' or ''
212 if mode:
213 mode = 'l'
214 else:
215 mode = ''
213 else:
216 else:
214 data = open(os.path.join(self.tmppath, name), 'rb').read()
217 data = open(os.path.join(self.tmppath, name), 'rb').read()
215 mode = (mode & 0111) and 'x' or ''
218 mode = (mode & 0111) and 'x' or ''
@@ -87,7 +87,10 b' class mercurial_sink(converter_sink):'
87 if not branch:
87 if not branch:
88 branch = 'default'
88 branch = 'default'
89 pbranches = [(b[0], b[1] and b[1] or 'default') for b in pbranches]
89 pbranches = [(b[0], b[1] and b[1] or 'default') for b in pbranches]
90 pbranch = pbranches and pbranches[0][1] or 'default'
90 if pbranches:
91 pbranch = pbranches[0][1]
92 else:
93 pbranch = 'default'
91
94
92 branchpath = os.path.join(self.path, branch)
95 branchpath = os.path.join(self.path, branch)
93 if setbranch:
96 if setbranch:
@@ -871,8 +871,16 b' class svn_source(converter_source):'
871 if self.ui.configbool('convert', 'localtimezone'):
871 if self.ui.configbool('convert', 'localtimezone'):
872 date = makedatetimestamp(date[0])
872 date = makedatetimestamp(date[0])
873
873
874 log = message and self.recode(message) or ''
874 if message:
875 author = author and self.recode(author) or ''
875 log = self.recode(message)
876 else:
877 log = ''
878
879 if author:
880 author = self.recode(author)
881 else:
882 author = ''
883
876 try:
884 try:
877 branch = self.module.split("/")[-1]
885 branch = self.module.split("/")[-1]
878 if branch == self.trunkname:
886 if branch == self.trunkname:
@@ -1118,7 +1126,10 b' class svn_sink(converter_sink, commandli'
1118 self.opener = scmutil.opener(self.wc)
1126 self.opener = scmutil.opener(self.wc)
1119 self.wopener = scmutil.opener(self.wc)
1127 self.wopener = scmutil.opener(self.wc)
1120 self.childmap = mapfile(ui, self.join('hg-childmap'))
1128 self.childmap = mapfile(ui, self.join('hg-childmap'))
1121 self.is_exec = util.checkexec(self.wc) and util.isexec or None
1129 if util.checkexec(self.wc):
1130 self.is_exec = util.isexec
1131 else:
1132 self.is_exec = None
1122
1133
1123 if created:
1134 if created:
1124 hook = os.path.join(created, 'hooks', 'pre-revprop-change')
1135 hook = os.path.join(created, 'hooks', 'pre-revprop-change')
@@ -121,7 +121,10 b' class ciamsg(object):'
121 return patch.diffstat(pbuf.lines) or ''
121 return patch.diffstat(pbuf.lines) or ''
122
122
123 def logmsg(self):
123 def logmsg(self):
124 diffstat = self.cia.diffstat and self.diffstat() or ''
124 if self.cia.diffstat:
125 diffstat = self.diffstat()
126 else:
127 diffstat = ''
125 self.cia.ui.pushbuffer()
128 self.cia.ui.pushbuffer()
126 self.cia.templater.show(self.ctx, changes=self.ctx.changeset(),
129 self.cia.templater.show(self.ctx, changes=self.ctx.changeset(),
127 baseurl=self.cia.ui.config('web', 'baseurl'),
130 baseurl=self.cia.ui.config('web', 'baseurl'),
@@ -199,7 +202,10 b' class hgcia(object):'
199 style = self.ui.config('cia', 'style')
202 style = self.ui.config('cia', 'style')
200 template = self.ui.config('cia', 'template')
203 template = self.ui.config('cia', 'template')
201 if not template:
204 if not template:
202 template = self.diffstat and self.dstemplate or self.deftemplate
205 if self.diffstat:
206 template = self.dstemplate
207 else:
208 template = self.deftemplate
203 template = templater.parsestring(template, quoted=False)
209 template = templater.parsestring(template, quoted=False)
204 t = cmdutil.changeset_templater(self.ui, self.repo, False, None,
210 t = cmdutil.changeset_templater(self.ui, self.repo, False, None,
205 template, style, False)
211 template, style, False)
@@ -506,7 +506,10 b' def files(ui, repo, *pats, **opts):'
506 kwt = kwtools['templater']
506 kwt = kwtools['templater']
507 wctx = repo[None]
507 wctx = repo[None]
508 status = _status(ui, repo, wctx, kwt, *pats, **opts)
508 status = _status(ui, repo, wctx, kwt, *pats, **opts)
509 cwd = pats and repo.getcwd() or ''
509 if pats:
510 cwd = repo.getcwd()
511 else:
512 cwd = ''
510 files = []
513 files = []
511 if not opts.get('unknown') or opts.get('all'):
514 if not opts.get('unknown') or opts.get('all'):
512 files = sorted(status.modified + status.added + status.clean)
515 files = sorted(status.modified + status.added + status.clean)
@@ -418,7 +418,10 b' class queue(object):'
418 gitmode = ui.configbool('mq', 'git', None)
418 gitmode = ui.configbool('mq', 'git', None)
419 if gitmode is None:
419 if gitmode is None:
420 raise error.ConfigError
420 raise error.ConfigError
421 self.gitmode = gitmode and 'yes' or 'no'
421 if gitmode:
422 self.gitmode = 'yes'
423 else:
424 self.gitmode = 'no'
422 except error.ConfigError:
425 except error.ConfigError:
423 self.gitmode = ui.config('mq', 'git', 'auto').lower()
426 self.gitmode = ui.config('mq', 'git', 'auto').lower()
424 self.plainmode = ui.configbool('mq', 'plain', False)
427 self.plainmode = ui.configbool('mq', 'plain', False)
@@ -610,7 +613,11 b' class queue(object):'
610 return True, ''
613 return True, ''
611
614
612 def explainpushable(self, idx, all_patches=False):
615 def explainpushable(self, idx, all_patches=False):
613 write = all_patches and self.ui.write or self.ui.warn
616 if all_patches:
617 write = self.ui.write
618 else:
619 write = self.ui.warn
620
614 if all_patches or self.ui.verbose:
621 if all_patches or self.ui.verbose:
615 if isinstance(idx, str):
622 if isinstance(idx, str):
616 idx = self.series.index(idx)
623 idx = self.series.index(idx)
@@ -1825,7 +1832,11 b' class queue(object):'
1825 self.ui.write(pfx)
1832 self.ui.write(pfx)
1826 if summary:
1833 if summary:
1827 ph = patchheader(self.join(patchname), self.plainmode)
1834 ph = patchheader(self.join(patchname), self.plainmode)
1828 msg = ph.message and ph.message[0] or ''
1835 if ph.message:
1836 msg = ph.message[0]
1837 else:
1838 msg = ''
1839
1829 if self.ui.formatted():
1840 if self.ui.formatted():
1830 width = self.ui.termwidth() - len(pfx) - len(patchname) - 2
1841 width = self.ui.termwidth() - len(pfx) - len(patchname) - 2
1831 if width > 0:
1842 if width > 0:
@@ -2228,7 +2239,10 b' def unapplied(ui, repo, patch=None, **op'
2228 ui.write(_("all patches applied\n"))
2239 ui.write(_("all patches applied\n"))
2229 return 1
2240 return 1
2230
2241
2231 length = opts.get('first') and 1 or None
2242 if opts.get('first'):
2243 length = 1
2244 else:
2245 length = None
2232 q.qseries(repo, start=start, length=length, status='U',
2246 q.qseries(repo, start=start, length=length, status='U',
2233 summary=opts.get('summary'))
2247 summary=opts.get('summary'))
2234
2248
@@ -2454,7 +2468,11 b' def top(ui, repo, **opts):'
2454
2468
2455 Returns 0 on success."""
2469 Returns 0 on success."""
2456 q = repo.mq
2470 q = repo.mq
2457 t = q.applied and q.seriesend(True) or 0
2471 if q.applied:
2472 t = q.seriesend(True)
2473 else:
2474 t = 0
2475
2458 if t:
2476 if t:
2459 q.qseries(repo, start=t - 1, length=1, status='A',
2477 q.qseries(repo, start=t - 1, length=1, status='A',
2460 summary=opts.get('summary'))
2478 summary=opts.get('summary'))
@@ -340,7 +340,10 b' class notifier(object):'
340
340
341 maxdiff = int(self.ui.config('notify', 'maxdiff', 300))
341 maxdiff = int(self.ui.config('notify', 'maxdiff', 300))
342 prev = ctx.p1().node()
342 prev = ctx.p1().node()
343 ref = ref and ref.node() or ctx.node()
343 if ref:
344 ref = ref.node()
345 else:
346 ref = ctx.node()
344 chunks = patch.diff(self.repo, prev, ref,
347 chunks = patch.diff(self.repo, prev, ref,
345 opts=patch.diffallopts(self.ui))
348 opts=patch.diffallopts(self.ui))
346 difflines = ''.join(chunks).splitlines()
349 difflines = ''.join(chunks).splitlines()
@@ -489,7 +489,10 b' def patchbomb(ui, repo, *revs, **opts):'
489 if outgoing or bundle:
489 if outgoing or bundle:
490 if len(revs) > 1:
490 if len(revs) > 1:
491 raise util.Abort(_("too many destinations"))
491 raise util.Abort(_("too many destinations"))
492 dest = revs and revs[0] or None
492 if revs:
493 dest = revs[0]
494 else:
495 dest = None
493 revs = []
496 revs = []
494
497
495 if rev:
498 if rev:
@@ -437,8 +437,15 b' class _BaseFile(list):'
437 # the keys are sorted in the .mo file
437 # the keys are sorted in the .mo file
438 def cmp(_self, other):
438 def cmp(_self, other):
439 # msgfmt compares entries with msgctxt if it exists
439 # msgfmt compares entries with msgctxt if it exists
440 self_msgid = _self.msgctxt and _self.msgctxt or _self.msgid
440 if _self.msgctxt:
441 other_msgid = other.msgctxt and other.msgctxt or other.msgid
441 self_msgid = _self.msgctxt
442 else:
443 self_msgid = _self.msgid
444
445 if other.msgctxt:
446 other_msgid = other.msgctxt
447 else:
448 other_msgid = other.msgid
442 if self_msgid > other_msgid:
449 if self_msgid > other_msgid:
443 return 1
450 return 1
444 elif self_msgid < other_msgid:
451 elif self_msgid < other_msgid:
@@ -435,7 +435,10 b' def diff(ui, dst, src):'
435
435
436 diff = sorted(set(smarks) - set(dmarks))
436 diff = sorted(set(smarks) - set(dmarks))
437 for k in diff:
437 for k in diff:
438 mark = ui.debugflag and smarks[k] or smarks[k][:12]
438 if ui.debugflag:
439 mark = smarks[k]
440 else:
441 mark = smarks[k][:12]
439 ui.write(" %-25s %s\n" % (k, mark))
442 ui.write(" %-25s %s\n" % (k, mark))
440
443
441 if len(diff) <= 0:
444 if len(diff) <= 0:
@@ -426,7 +426,10 b' def getremotechanges(ui, repo, other, on'
426 rheads = None
426 rheads = None
427 else:
427 else:
428 cg = other.changegroupsubset(incoming, rheads, 'incoming')
428 cg = other.changegroupsubset(incoming, rheads, 'incoming')
429 bundletype = localrepo and "HG10BZ" or "HG10UN"
429 if localrepo:
430 bundletype = "HG10BZ"
431 else:
432 bundletype = "HG10UN"
430 fname = bundle = changegroup.writebundle(ui, cg, bundlename, bundletype)
433 fname = bundle = changegroup.writebundle(ui, cg, bundlename, bundletype)
431 # keep written bundle?
434 # keep written bundle?
432 if bundlename:
435 if bundlename:
@@ -274,7 +274,11 b' class FTPRangeHandler(urllib2.FTPHandler'
274 dirs = dirs[1:]
274 dirs = dirs[1:]
275 try:
275 try:
276 fw = self.connect_ftp(user, passwd, host, port, dirs)
276 fw = self.connect_ftp(user, passwd, host, port, dirs)
277 type = file and 'I' or 'D'
277 if file:
278 type = 'I'
279 else:
280 type = 'D'
281
278 for attr in attrs:
282 for attr in attrs:
279 attr, value = splitattr(attr)
283 attr, value = splitattr(attr)
280 if attr.lower() == 'type' and \
284 if attr.lower() == 'type' and \
@@ -398,7 +398,10 b' def makefileobj(repo, pat, node=None, de'
398 writable = mode not in ('r', 'rb')
398 writable = mode not in ('r', 'rb')
399
399
400 if not pat or pat == '-':
400 if not pat or pat == '-':
401 fp = writable and repo.ui.fout or repo.ui.fin
401 if writable:
402 fp = repo.ui.fout
403 else:
404 fp = repo.ui.fin
402 if util.safehasattr(fp, 'fileno'):
405 if util.safehasattr(fp, 'fileno'):
403 return os.fdopen(os.dup(fp.fileno()), mode)
406 return os.fdopen(os.dup(fp.fileno()), mode)
404 else:
407 else:
@@ -474,7 +477,10 b' def copy(ui, repo, pats, opts, rename=Fa'
474
477
475 def walkpat(pat):
478 def walkpat(pat):
476 srcs = []
479 srcs = []
477 badstates = after and '?' or '?r'
480 if after:
481 badstates = '?'
482 else:
483 badstates = '?r'
478 m = scmutil.match(repo[None], [pat], opts, globbed=True)
484 m = scmutil.match(repo[None], [pat], opts, globbed=True)
479 for abs in repo.walk(m):
485 for abs in repo.walk(m):
480 state = repo.dirstate[abs]
486 state = repo.dirstate[abs]
@@ -693,7 +699,10 b' def service(opts, parentfn=None, initfn='
693
699
694 def writepid(pid):
700 def writepid(pid):
695 if opts['pid_file']:
701 if opts['pid_file']:
696 mode = appendpid and 'a' or 'w'
702 if appendpid:
703 mode = 'a'
704 else:
705 mode = 'w'
697 fp = open(opts['pid_file'], mode)
706 fp = open(opts['pid_file'], mode)
698 fp.write(str(pid) + '\n')
707 fp.write(str(pid) + '\n')
699 fp.close()
708 fp.close()
@@ -929,7 +938,11 b" def export(repo, revs, template='hg-%h.p"
929 branch = ctx.branch()
938 branch = ctx.branch()
930 if switch_parent:
939 if switch_parent:
931 parents.reverse()
940 parents.reverse()
932 prev = (parents and parents[0]) or nullid
941
942 if parents:
943 prev = parents[0]
944 else:
945 prev = nullid
933
946
934 shouldclose = False
947 shouldclose = False
935 if not fp and len(template) > 0:
948 if not fp and len(template) > 0:
@@ -1067,7 +1080,10 b' class changeset_printer(object):'
1067 log = self.repo.changelog
1080 log = self.repo.changelog
1068 date = util.datestr(ctx.date())
1081 date = util.datestr(ctx.date())
1069
1082
1070 hexfunc = self.ui.debugflag and hex or short
1083 if self.ui.debugflag:
1084 hexfunc = hex
1085 else:
1086 hexfunc = short
1071
1087
1072 parents = [(p, hexfunc(log.node(p)))
1088 parents = [(p, hexfunc(log.node(p)))
1073 for p in self._meaningful_parentrevs(log, rev)]
1089 for p in self._meaningful_parentrevs(log, rev)]
@@ -1866,7 +1882,10 b' def _makelogrevset(repo, pats, opts, rev'
1866 opts = dict(opts)
1882 opts = dict(opts)
1867 # follow or not follow?
1883 # follow or not follow?
1868 follow = opts.get('follow') or opts.get('follow_first')
1884 follow = opts.get('follow') or opts.get('follow_first')
1869 followfirst = opts.get('follow_first') and 1 or 0
1885 if opts.get('follow_first'):
1886 followfirst = 1
1887 else:
1888 followfirst = 0
1870 # --follow with FILE behaviour depends on revs...
1889 # --follow with FILE behaviour depends on revs...
1871 it = iter(revs)
1890 it = iter(revs)
1872 startrev = it.next()
1891 startrev = it.next()
@@ -277,7 +277,10 b' def annotate(ui, repo, *pats, **opts):'
277 opts['file'] = True
277 opts['file'] = True
278
278
279 fm = ui.formatter('annotate', opts)
279 fm = ui.formatter('annotate', opts)
280 datefunc = ui.quiet and util.shortdate or util.datestr
280 if ui.quiet:
281 datefunc = util.shortdate
282 else:
283 datefunc = util.datestr
281 hexfn = fm.hexfunc
284 hexfn = fm.hexfunc
282
285
283 opmap = [('user', ' ', lambda x: x[0].user(), ui.shortuser),
286 opmap = [('user', ' ', lambda x: x[0].user(), ui.shortuser),
@@ -664,7 +667,10 b' def bisect(ui, repo, rev=None, extra=Non'
664 # one of the parent was not checked.
667 # one of the parent was not checked.
665 parents = repo[nodes[0]].parents()
668 parents = repo[nodes[0]].parents()
666 if len(parents) > 1:
669 if len(parents) > 1:
667 side = good and state['bad'] or state['good']
670 if good:
671 side = state['bad']
672 else:
673 side = state['good']
668 num = len(set(i.node() for i in parents) & set(side))
674 num = len(set(i.node() for i in parents) & set(side))
669 if num == 1:
675 if num == 1:
670 return parents[0].ancestor(parents[1])
676 return parents[0].ancestor(parents[1])
@@ -3670,7 +3676,10 b' def grep(ui, repo, pattern, *pats, **opt'
3670
3676
3671 def display(fn, ctx, pstates, states):
3677 def display(fn, ctx, pstates, states):
3672 rev = ctx.rev()
3678 rev = ctx.rev()
3673 datefunc = ui.quiet and util.shortdate or util.datestr
3679 if ui.quiet:
3680 datefunc = util.shortdate
3681 else:
3682 datefunc = util.datestr
3674 found = False
3683 found = False
3675 @util.cachefunc
3684 @util.cachefunc
3676 def binary():
3685 def binary():
@@ -3946,7 +3955,10 b' def identify(ui, repo, source=None, rev='
3946 raise util.Abort(_("there is no Mercurial repository here "
3955 raise util.Abort(_("there is no Mercurial repository here "
3947 "(.hg not found)"))
3956 "(.hg not found)"))
3948
3957
3949 hexfunc = ui.debugflag and hex or short
3958 if ui.debugflag:
3959 hexfunc = hex
3960 else:
3961 hexfunc = short
3950 default = not (num or id or branch or tags or bookmarks)
3962 default = not (num or id or branch or tags or bookmarks)
3951 output = []
3963 output = []
3952 revs = []
3964 revs = []
@@ -4342,7 +4354,10 b' def locate(ui, repo, *pats, **opts):'
4342
4354
4343 Returns 0 if a match is found, 1 otherwise.
4355 Returns 0 if a match is found, 1 otherwise.
4344 """
4356 """
4345 end = opts.get('print0') and '\0' or '\n'
4357 if opts.get('print0'):
4358 end = '\0'
4359 else:
4360 end = '\n'
4346 rev = scmutil.revsingle(repo, opts.get('rev'), None).node()
4361 rev = scmutil.revsingle(repo, opts.get('rev'), None).node()
4347
4362
4348 ret = 1
4363 ret = 1
@@ -4506,7 +4521,10 b' def log(ui, repo, *pats, **opts):'
4506 rename = getrenamed(fn, rev)
4521 rename = getrenamed(fn, rev)
4507 if rename:
4522 if rename:
4508 copies.append((fn, rename[0]))
4523 copies.append((fn, rename[0]))
4509 revmatchfn = filematcher and filematcher(ctx.rev()) or None
4524 if filematcher:
4525 revmatchfn = filematcher(ctx.rev())
4526 else:
4527 revmatchfn = None
4510 displayer.show(ctx, copies=copies, matchfn=revmatchfn)
4528 displayer.show(ctx, copies=copies, matchfn=revmatchfn)
4511 if displayer.flush(rev):
4529 if displayer.flush(rev):
4512 count += 1
4530 count += 1
@@ -5550,7 +5568,10 b' def serve(ui, repo, **opts):'
5550 if opts.get('port'):
5568 if opts.get('port'):
5551 opts['port'] = util.getport(opts.get('port'))
5569 opts['port'] = util.getport(opts.get('port'))
5552
5570
5553 baseui = repo and repo.baseui or ui
5571 if repo:
5572 baseui = repo.baseui
5573 else:
5574 baseui = ui
5554 optlist = ("name templates style address port prefix ipv6"
5575 optlist = ("name templates style address port prefix ipv6"
5555 " accesslog errorlog certificate encoding")
5576 " accesslog errorlog certificate encoding")
5556 for o in optlist.split():
5577 for o in optlist.split():
@@ -5700,15 +5721,25 b' def status(ui, repo, *pats, **opts):'
5700 else:
5721 else:
5701 node1, node2 = scmutil.revpair(repo, revs)
5722 node1, node2 = scmutil.revpair(repo, revs)
5702
5723
5703 cwd = (pats and repo.getcwd()) or ''
5724 if pats:
5704 end = opts.get('print0') and '\0' or '\n'
5725 cwd = repo.getcwd()
5726 else:
5727 cwd = ''
5728
5729 if opts.get('print0'):
5730 end = '\0'
5731 else:
5732 end = '\n'
5705 copy = {}
5733 copy = {}
5706 states = 'modified added removed deleted unknown ignored clean'.split()
5734 states = 'modified added removed deleted unknown ignored clean'.split()
5707 show = [k for k in states if opts.get(k)]
5735 show = [k for k in states if opts.get(k)]
5708 if opts.get('all'):
5736 if opts.get('all'):
5709 show += ui.quiet and (states[:4] + ['clean']) or states
5737 show += ui.quiet and (states[:4] + ['clean']) or states
5710 if not show:
5738 if not show:
5711 show = ui.quiet and states[:4] or states[:5]
5739 if ui.quiet:
5740 show = states[:4]
5741 else:
5742 show = states[:5]
5712
5743
5713 stat = repo.status(node1, node2, scmutil.match(repo[node2], pats, opts),
5744 stat = repo.status(node1, node2, scmutil.match(repo[node2], pats, opts),
5714 'ignored' in show, 'clean' in show, 'unknown' in show,
5745 'ignored' in show, 'clean' in show, 'unknown' in show,
@@ -6029,7 +6060,11 b' def tag(ui, repo, name1, *names, **opts)'
6029 rev_ = opts['rev']
6060 rev_ = opts['rev']
6030 message = opts.get('message')
6061 message = opts.get('message')
6031 if opts.get('remove'):
6062 if opts.get('remove'):
6032 expectedtype = opts.get('local') and 'local' or 'global'
6063 if opts.get('local'):
6064 expectedtype = 'local'
6065 else:
6066 expectedtype = 'global'
6067
6033 for n in names:
6068 for n in names:
6034 if not repo.tagtype(n):
6069 if not repo.tagtype(n):
6035 raise util.Abort(_("tag '%s' does not exist") % n)
6070 raise util.Abort(_("tag '%s' does not exist") % n)
@@ -963,7 +963,11 b' class basefilectx(object):'
963 def ancestors(self, followfirst=False):
963 def ancestors(self, followfirst=False):
964 visit = {}
964 visit = {}
965 c = self
965 c = self
966 cut = followfirst and 1 or None
966 if followfirst:
967 cut = 1
968 else:
969 cut = None
970
967 while True:
971 while True:
968 for parent in c.parents()[:cut]:
972 for parent in c.parents()[:cut]:
969 visit[(parent.linkrev(), parent.filenode())] = parent
973 visit[(parent.linkrev(), parent.filenode())] = parent
@@ -1755,7 +1759,11 b' class memctx(committablectx):'
1755 # "filectxfn" for performance (e.g. converting from another VCS)
1759 # "filectxfn" for performance (e.g. converting from another VCS)
1756 self._filectxfn = util.cachefunc(filectxfn)
1760 self._filectxfn = util.cachefunc(filectxfn)
1757
1761
1758 self._extra = extra and extra.copy() or {}
1762 if extra:
1763 self._extra = extra.copy()
1764 else:
1765 self._extra = {}
1766
1759 if self._extra.get('branch', '') == '':
1767 if self._extra.get('branch', '') == '':
1760 self._extra['branch'] = 'default'
1768 self._extra['branch'] = 'default'
1761
1769
@@ -88,7 +88,10 b' class genericdag(basedag):'
88 '''generic implementations for DAGs'''
88 '''generic implementations for DAGs'''
89
89
90 def ancestorset(self, starts, stops=None):
90 def ancestorset(self, starts, stops=None):
91 stops = stops and set(stops) or set()
91 if stops:
92 stops = set(stops)
93 else:
94 stops = set()
92 seen = set()
95 seen = set()
93 pending = list(starts)
96 pending = list(starts)
94 while pending:
97 while pending:
@@ -179,7 +182,10 b' class revlogdag(revlogbaseddag):'
179 def ancestorset(self, starts, stops=None):
182 def ancestorset(self, starts, stops=None):
180 rlog = self._revlog
183 rlog = self._revlog
181 idx = rlog.index
184 idx = rlog.index
182 stops = stops and set(stops) or set()
185 if stops:
186 stops = set(stops)
187 else:
188 stops = set()
183 seen = set()
189 seen = set()
184 pending = list(starts)
190 pending = list(starts)
185 while pending:
191 while pending:
@@ -218,7 +218,10 b' def _oldheadssummary(repo, remoteheads, '
218 r = repo.set('heads(%ln + %ln)', oldheads, outgoing.missing)
218 r = repo.set('heads(%ln + %ln)', oldheads, outgoing.missing)
219 newheads = list(c.node() for c in r)
219 newheads = list(c.node() for c in r)
220 # set some unsynced head to issue the "unsynced changes" warning
220 # set some unsynced head to issue the "unsynced changes" warning
221 unsynced = inc and set([None]) or set()
221 if inc:
222 unsynced = set([None])
223 else:
224 unsynced = set()
222 return {None: (oldheads, newheads, unsynced)}
225 return {None: (oldheads, newheads, unsynced)}
223
226
224 def checkheads(repo, remote, outgoing, remoteheads, newbranch=False, inc=False,
227 def checkheads(repo, remote, outgoing, remoteheads, newbranch=False, inc=False,
@@ -34,7 +34,11 b' def addbranchrevs(lrepo, other, branches'
34 else:
34 else:
35 y = None
35 y = None
36 return x, y
36 return x, y
37 revs = revs and list(revs) or []
37 if revs:
38 revs = list(revs)
39 else:
40 revs = []
41
38 if not peer.capable('branchmap'):
42 if not peer.capable('branchmap'):
39 if branches:
43 if branches:
40 raise util.Abort(_("remote branch lookup not supported"))
44 raise util.Abort(_("remote branch lookup not supported"))
@@ -90,7 +90,10 b' def rawfile(web, req, tmpl):'
90 if guessmime:
90 if guessmime:
91 mt = mimetypes.guess_type(path)[0]
91 mt = mimetypes.guess_type(path)[0]
92 if mt is None:
92 if mt is None:
93 mt = util.binary(text) and 'application/binary' or 'text/plain'
93 if util.binary(text):
94 mt = 'application/binary'
95 else:
96 mt = 'text/plain'
94 if mt.startswith('text/'):
97 if mt.startswith('text/'):
95 mt += '; charset="%s"' % encoding.encoding
98 mt += '; charset="%s"' % encoding.encoding
96
99
@@ -365,7 +368,11 b' def changelog(web, req, tmpl, shortlog=F'
365 entry['parity'] = parity.next()
368 entry['parity'] = parity.next()
366 yield entry
369 yield entry
367
370
368 revcount = shortlog and web.maxshortchanges or web.maxchanges
371 if shortlog:
372 revcount = web.maxshortchanges
373 else:
374 revcount = web.maxchanges
375
369 if 'revcount' in req.form:
376 if 'revcount' in req.form:
370 try:
377 try:
371 revcount = int(req.form.get('revcount', [revcount])[0])
378 revcount = int(req.form.get('revcount', [revcount])[0])
@@ -783,8 +790,12 b' def filediff(web, req, tmpl):'
783 style = req.form['style'][0]
790 style = req.form['style'][0]
784
791
785 diffs = webutil.diffs(web.repo, tmpl, ctx, None, [path], parity, style)
792 diffs = webutil.diffs(web.repo, tmpl, ctx, None, [path], parity, style)
786 rename = fctx and webutil.renamelink(fctx) or []
793 if fctx:
787 ctx = fctx and fctx or ctx
794 rename = webutil.renamelink(fctx)
795 ctx = fctx
796 else:
797 rename = []
798 ctx = ctx
788 return tmpl("filediff",
799 return tmpl("filediff",
789 file=path,
800 file=path,
790 node=hex(n),
801 node=hex(n),
@@ -373,7 +373,10 b' def diffs(repo, tmpl, ctx, basectx, file'
373 diffopts = patch.diffopts(repo.ui, untrusted=True)
373 diffopts = patch.diffopts(repo.ui, untrusted=True)
374 if basectx is None:
374 if basectx is None:
375 parents = ctx.parents()
375 parents = ctx.parents()
376 node1 = parents and parents[0].node() or nullid
376 if parents:
377 node1 = parents[0].node()
378 else:
379 node1 = nullid
377 else:
380 else:
378 node1 = basectx.node()
381 node1 = basectx.node()
379 node2 = ctx.node()
382 node2 = ctx.node()
@@ -330,7 +330,10 b' class HTTPConnection(object):'
330 elif use_ssl is None:
330 elif use_ssl is None:
331 use_ssl = (port == 443)
331 use_ssl = (port == 443)
332 elif port is None:
332 elif port is None:
333 port = (use_ssl and 443 or 80)
333 if use_ssl:
334 port = 443
335 else:
336 port = 80
334 self.port = port
337 self.port = port
335 if use_ssl and not socketutil.have_ssl:
338 if use_ssl and not socketutil.have_ssl:
336 raise Exception('ssl requested but unavailable on this Python')
339 raise Exception('ssl requested but unavailable on this Python')
@@ -523,7 +523,11 b' class localrepository(object):'
523 if prevtags and prevtags[-1] != '\n':
523 if prevtags and prevtags[-1] != '\n':
524 fp.write('\n')
524 fp.write('\n')
525 for name in names:
525 for name in names:
526 m = munge and munge(name) or name
526 if munge:
527 m = munge(name)
528 else:
529 m = name
530
527 if (self._tagscache.tagtypes and
531 if (self._tagscache.tagtypes and
528 name in self._tagscache.tagtypes):
532 name in self._tagscache.tagtypes):
529 old = self.tags().get(name, nullid)
533 old = self.tags().get(name, nullid)
@@ -893,7 +897,11 b' class localrepository(object):'
893
897
894 def currenttransaction(self):
898 def currenttransaction(self):
895 """return the current transaction or None if non exists"""
899 """return the current transaction or None if non exists"""
896 tr = self._transref and self._transref() or None
900 if self._transref:
901 tr = self._transref()
902 else:
903 tr = None
904
897 if tr and tr.running():
905 if tr and tr.running():
898 return tr
906 return tr
899 return None
907 return None
@@ -913,7 +921,10 b' class localrepository(object):'
913
921
914 self._writejournal(desc)
922 self._writejournal(desc)
915 renames = [(vfs, x, undoname(x)) for vfs, x in self._journalfiles()]
923 renames = [(vfs, x, undoname(x)) for vfs, x in self._journalfiles()]
916 rp = report and report or self.ui.warn
924 if report:
925 rp = report
926 else:
927 rp = self.ui.warn
917 vfsmap = {'plain': self.vfs} # root of .hg/
928 vfsmap = {'plain': self.vfs} # root of .hg/
918 # we must avoid cyclic reference between repo and transaction.
929 # we must avoid cyclic reference between repo and transaction.
919 reporef = weakref.ref(self)
930 reporef = weakref.ref(self)
@@ -259,8 +259,17 b' def extract(ui, fileobj):'
259 if not diffs_seen:
259 if not diffs_seen:
260 os.unlink(tmpname)
260 os.unlink(tmpname)
261 return None, message, user, date, branch, None, None, None
261 return None, message, user, date, branch, None, None, None
262 p1 = parents and parents.pop(0) or None
262
263 p2 = parents and parents.pop(0) or None
263 if parents:
264 p1 = parents.pop(0)
265 else:
266 p1 = None
267
268 if parents:
269 p2 = parents.pop(0)
270 else:
271 p2 = None
272
264 return tmpname, message, user, date, branch, nodeid, p1, p2
273 return tmpname, message, user, date, branch, nodeid, p1, p2
265
274
266 class patchmeta(object):
275 class patchmeta(object):
@@ -1489,13 +1498,19 b' def makepatchmeta(backend, afile_orig, b'
1489 fname = None
1498 fname = None
1490 if not missing:
1499 if not missing:
1491 if gooda and goodb:
1500 if gooda and goodb:
1492 fname = isbackup and afile or bfile
1501 if isbackup:
1502 fname = afile
1503 else:
1504 fname = bfile
1493 elif gooda:
1505 elif gooda:
1494 fname = afile
1506 fname = afile
1495
1507
1496 if not fname:
1508 if not fname:
1497 if not nullb:
1509 if not nullb:
1498 fname = isbackup and afile or bfile
1510 if isbackup:
1511 fname = afile
1512 else:
1513 fname = bfile
1499 elif not nulla:
1514 elif not nulla:
1500 fname = afile
1515 fname = afile
1501 else:
1516 else:
@@ -2070,7 +2085,10 b' def diff(repo, node1=None, node2=None, m'
2070 if not modified and not added and not removed:
2085 if not modified and not added and not removed:
2071 return []
2086 return []
2072
2087
2073 hexfunc = repo.ui.debugflag and hex or short
2088 if repo.ui.debugflag:
2089 hexfunc = hex
2090 else:
2091 hexfunc = short
2074 revs = [hexfunc(node) for node in [ctx1.node(), ctx2.node()] if node]
2092 revs = [hexfunc(node) for node in [ctx1.node(), ctx2.node()] if node]
2075
2093
2076 copy = {}
2094 copy = {}
@@ -18,7 +18,10 b' import repoview'
18
18
19 def _revancestors(repo, revs, followfirst):
19 def _revancestors(repo, revs, followfirst):
20 """Like revlog.ancestors(), but supports followfirst."""
20 """Like revlog.ancestors(), but supports followfirst."""
21 cut = followfirst and 1 or None
21 if followfirst:
22 cut = 1
23 else:
24 cut = None
22 cl = repo.changelog
25 cl = repo.changelog
23
26
24 def iterate():
27 def iterate():
@@ -49,7 +52,10 b' def _revancestors(repo, revs, followfirs'
49
52
50 def _revdescendants(repo, revs, followfirst):
53 def _revdescendants(repo, revs, followfirst):
51 """Like revlog.descendants() but supports followfirst."""
54 """Like revlog.descendants() but supports followfirst."""
52 cut = followfirst and 1 or None
55 if followfirst:
56 cut = 1
57 else:
58 cut = None
53
59
54 def iterate():
60 def iterate():
55 cl = repo.changelog
61 cl = repo.changelog
@@ -656,7 +656,10 b' class templater(object):'
656 self.mapfile = mapfile or 'template'
656 self.mapfile = mapfile or 'template'
657 self.cache = cache.copy()
657 self.cache = cache.copy()
658 self.map = {}
658 self.map = {}
659 self.base = (mapfile and os.path.dirname(mapfile)) or ''
659 if mapfile:
660 self.base = os.path.dirname(mapfile)
661 else:
662 self.base = ''
660 self.filters = templatefilters.filters.copy()
663 self.filters = templatefilters.filters.copy()
661 self.filters.update(filters)
664 self.filters.update(filters)
662 self.defaults = defaults
665 self.defaults = defaults
@@ -1836,7 +1836,10 b' class TestRunner(object):'
1836 compiler = ''
1836 compiler = ''
1837 if self.options.compiler:
1837 if self.options.compiler:
1838 compiler = '--compiler ' + self.options.compiler
1838 compiler = '--compiler ' + self.options.compiler
1839 pure = self.options.pure and "--pure" or ""
1839 if self.options.pure:
1840 pure = "--pure"
1841 else:
1842 pure = ""
1840 py3 = ''
1843 py3 = ''
1841 if sys.version_info[0] == 3:
1844 if sys.version_info[0] == 3:
1842 py3 = '--c2to3'
1845 py3 = '--c2to3'
General Comments 0
You need to be logged in to leave comments. Login now