##// 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 359 files.iterkeys(), filectxfn, ui.username(),
360 360 '%d %d' % util.makedate())
361 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 366 ui.status(_('added commit %s with %d files\n')
364 367 % (hexfn(initnode), len(files)))
365 368
@@ -475,7 +478,10 b' def renamedirs(dirs, words):'
475 478 if dirpath in replacements:
476 479 return replacements[dirpath]
477 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 485 renamed = os.path.join(head, wordgen.next())
480 486 replacements[dirpath] = renamed
481 487 return renamed
@@ -31,7 +31,10 b' class MissingTool(Exception):'
31 31 def checktool(exe, name=None, abort=True):
32 32 name = name or exe
33 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 38 raise exc(_('cannot find required "%s" tool') % name)
36 39
37 40 class NoRepo(Exception):
@@ -515,7 +515,11 b' def convert(ui, src, dest=None, revmapfi'
515 515 sortmode = [m for m in sortmodes if opts.get(m)]
516 516 if len(sortmode) > 1:
517 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 523 if sortmode == 'sourcesort' and not srcc.hasnativeorder():
520 524 raise util.Abort(_('--sourcesort is not supported by this data source'))
521 525 if sortmode == 'closesort' and not srcc.hasnativeclose():
@@ -209,7 +209,10 b' class gnuarch_source(converter_source, c'
209 209 mode = os.lstat(os.path.join(self.tmppath, name)).st_mode
210 210 if stat.S_ISLNK(mode):
211 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 216 else:
214 217 data = open(os.path.join(self.tmppath, name), 'rb').read()
215 218 mode = (mode & 0111) and 'x' or ''
@@ -87,7 +87,10 b' class mercurial_sink(converter_sink):'
87 87 if not branch:
88 88 branch = 'default'
89 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 95 branchpath = os.path.join(self.path, branch)
93 96 if setbranch:
@@ -871,8 +871,16 b' class svn_source(converter_source):'
871 871 if self.ui.configbool('convert', 'localtimezone'):
872 872 date = makedatetimestamp(date[0])
873 873
874 log = message and self.recode(message) or ''
875 author = author and self.recode(author) or ''
874 if message:
875 log = self.recode(message)
876 else:
877 log = ''
878
879 if author:
880 author = self.recode(author)
881 else:
882 author = ''
883
876 884 try:
877 885 branch = self.module.split("/")[-1]
878 886 if branch == self.trunkname:
@@ -1118,7 +1126,10 b' class svn_sink(converter_sink, commandli'
1118 1126 self.opener = scmutil.opener(self.wc)
1119 1127 self.wopener = scmutil.opener(self.wc)
1120 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 1134 if created:
1124 1135 hook = os.path.join(created, 'hooks', 'pre-revprop-change')
@@ -121,7 +121,10 b' class ciamsg(object):'
121 121 return patch.diffstat(pbuf.lines) or ''
122 122
123 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 128 self.cia.ui.pushbuffer()
126 129 self.cia.templater.show(self.ctx, changes=self.ctx.changeset(),
127 130 baseurl=self.cia.ui.config('web', 'baseurl'),
@@ -199,7 +202,10 b' class hgcia(object):'
199 202 style = self.ui.config('cia', 'style')
200 203 template = self.ui.config('cia', 'template')
201 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 209 template = templater.parsestring(template, quoted=False)
204 210 t = cmdutil.changeset_templater(self.ui, self.repo, False, None,
205 211 template, style, False)
@@ -506,7 +506,10 b' def files(ui, repo, *pats, **opts):'
506 506 kwt = kwtools['templater']
507 507 wctx = repo[None]
508 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 513 files = []
511 514 if not opts.get('unknown') or opts.get('all'):
512 515 files = sorted(status.modified + status.added + status.clean)
@@ -418,7 +418,10 b' class queue(object):'
418 418 gitmode = ui.configbool('mq', 'git', None)
419 419 if gitmode is None:
420 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 425 except error.ConfigError:
423 426 self.gitmode = ui.config('mq', 'git', 'auto').lower()
424 427 self.plainmode = ui.configbool('mq', 'plain', False)
@@ -610,7 +613,11 b' class queue(object):'
610 613 return True, ''
611 614
612 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 621 if all_patches or self.ui.verbose:
615 622 if isinstance(idx, str):
616 623 idx = self.series.index(idx)
@@ -1825,7 +1832,11 b' class queue(object):'
1825 1832 self.ui.write(pfx)
1826 1833 if summary:
1827 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 1840 if self.ui.formatted():
1830 1841 width = self.ui.termwidth() - len(pfx) - len(patchname) - 2
1831 1842 if width > 0:
@@ -2228,7 +2239,10 b' def unapplied(ui, repo, patch=None, **op'
2228 2239 ui.write(_("all patches applied\n"))
2229 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 2246 q.qseries(repo, start=start, length=length, status='U',
2233 2247 summary=opts.get('summary'))
2234 2248
@@ -2454,7 +2468,11 b' def top(ui, repo, **opts):'
2454 2468
2455 2469 Returns 0 on success."""
2456 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 2476 if t:
2459 2477 q.qseries(repo, start=t - 1, length=1, status='A',
2460 2478 summary=opts.get('summary'))
@@ -340,7 +340,10 b' class notifier(object):'
340 340
341 341 maxdiff = int(self.ui.config('notify', 'maxdiff', 300))
342 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 347 chunks = patch.diff(self.repo, prev, ref,
345 348 opts=patch.diffallopts(self.ui))
346 349 difflines = ''.join(chunks).splitlines()
@@ -489,7 +489,10 b' def patchbomb(ui, repo, *revs, **opts):'
489 489 if outgoing or bundle:
490 490 if len(revs) > 1:
491 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 496 revs = []
494 497
495 498 if rev:
@@ -437,8 +437,15 b' class _BaseFile(list):'
437 437 # the keys are sorted in the .mo file
438 438 def cmp(_self, other):
439 439 # msgfmt compares entries with msgctxt if it exists
440 self_msgid = _self.msgctxt and _self.msgctxt or _self.msgid
441 other_msgid = other.msgctxt and other.msgctxt or other.msgid
440 if _self.msgctxt:
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 449 if self_msgid > other_msgid:
443 450 return 1
444 451 elif self_msgid < other_msgid:
@@ -435,7 +435,10 b' def diff(ui, dst, src):'
435 435
436 436 diff = sorted(set(smarks) - set(dmarks))
437 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 442 ui.write(" %-25s %s\n" % (k, mark))
440 443
441 444 if len(diff) <= 0:
@@ -426,7 +426,10 b' def getremotechanges(ui, repo, other, on'
426 426 rheads = None
427 427 else:
428 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 433 fname = bundle = changegroup.writebundle(ui, cg, bundlename, bundletype)
431 434 # keep written bundle?
432 435 if bundlename:
@@ -274,7 +274,11 b' class FTPRangeHandler(urllib2.FTPHandler'
274 274 dirs = dirs[1:]
275 275 try:
276 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 282 for attr in attrs:
279 283 attr, value = splitattr(attr)
280 284 if attr.lower() == 'type' and \
@@ -398,7 +398,10 b' def makefileobj(repo, pat, node=None, de'
398 398 writable = mode not in ('r', 'rb')
399 399
400 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 405 if util.safehasattr(fp, 'fileno'):
403 406 return os.fdopen(os.dup(fp.fileno()), mode)
404 407 else:
@@ -474,7 +477,10 b' def copy(ui, repo, pats, opts, rename=Fa'
474 477
475 478 def walkpat(pat):
476 479 srcs = []
477 badstates = after and '?' or '?r'
480 if after:
481 badstates = '?'
482 else:
483 badstates = '?r'
478 484 m = scmutil.match(repo[None], [pat], opts, globbed=True)
479 485 for abs in repo.walk(m):
480 486 state = repo.dirstate[abs]
@@ -693,7 +699,10 b' def service(opts, parentfn=None, initfn='
693 699
694 700 def writepid(pid):
695 701 if opts['pid_file']:
696 mode = appendpid and 'a' or 'w'
702 if appendpid:
703 mode = 'a'
704 else:
705 mode = 'w'
697 706 fp = open(opts['pid_file'], mode)
698 707 fp.write(str(pid) + '\n')
699 708 fp.close()
@@ -929,7 +938,11 b" def export(repo, revs, template='hg-%h.p"
929 938 branch = ctx.branch()
930 939 if switch_parent:
931 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 947 shouldclose = False
935 948 if not fp and len(template) > 0:
@@ -1067,7 +1080,10 b' class changeset_printer(object):'
1067 1080 log = self.repo.changelog
1068 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 1088 parents = [(p, hexfunc(log.node(p)))
1073 1089 for p in self._meaningful_parentrevs(log, rev)]
@@ -1866,7 +1882,10 b' def _makelogrevset(repo, pats, opts, rev'
1866 1882 opts = dict(opts)
1867 1883 # follow or not follow?
1868 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 1889 # --follow with FILE behaviour depends on revs...
1871 1890 it = iter(revs)
1872 1891 startrev = it.next()
@@ -277,7 +277,10 b' def annotate(ui, repo, *pats, **opts):'
277 277 opts['file'] = True
278 278
279 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 284 hexfn = fm.hexfunc
282 285
283 286 opmap = [('user', ' ', lambda x: x[0].user(), ui.shortuser),
@@ -664,7 +667,10 b' def bisect(ui, repo, rev=None, extra=Non'
664 667 # one of the parent was not checked.
665 668 parents = repo[nodes[0]].parents()
666 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 674 num = len(set(i.node() for i in parents) & set(side))
669 675 if num == 1:
670 676 return parents[0].ancestor(parents[1])
@@ -3670,7 +3676,10 b' def grep(ui, repo, pattern, *pats, **opt'
3670 3676
3671 3677 def display(fn, ctx, pstates, states):
3672 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 3683 found = False
3675 3684 @util.cachefunc
3676 3685 def binary():
@@ -3946,7 +3955,10 b' def identify(ui, repo, source=None, rev='
3946 3955 raise util.Abort(_("there is no Mercurial repository here "
3947 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 3962 default = not (num or id or branch or tags or bookmarks)
3951 3963 output = []
3952 3964 revs = []
@@ -4342,7 +4354,10 b' def locate(ui, repo, *pats, **opts):'
4342 4354
4343 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 4361 rev = scmutil.revsingle(repo, opts.get('rev'), None).node()
4347 4362
4348 4363 ret = 1
@@ -4506,7 +4521,10 b' def log(ui, repo, *pats, **opts):'
4506 4521 rename = getrenamed(fn, rev)
4507 4522 if rename:
4508 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 4528 displayer.show(ctx, copies=copies, matchfn=revmatchfn)
4511 4529 if displayer.flush(rev):
4512 4530 count += 1
@@ -5550,7 +5568,10 b' def serve(ui, repo, **opts):'
5550 5568 if opts.get('port'):
5551 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 5575 optlist = ("name templates style address port prefix ipv6"
5555 5576 " accesslog errorlog certificate encoding")
5556 5577 for o in optlist.split():
@@ -5700,15 +5721,25 b' def status(ui, repo, *pats, **opts):'
5700 5721 else:
5701 5722 node1, node2 = scmutil.revpair(repo, revs)
5702 5723
5703 cwd = (pats and repo.getcwd()) or ''
5704 end = opts.get('print0') and '\0' or '\n'
5724 if pats:
5725 cwd = repo.getcwd()
5726 else:
5727 cwd = ''
5728
5729 if opts.get('print0'):
5730 end = '\0'
5731 else:
5732 end = '\n'
5705 5733 copy = {}
5706 5734 states = 'modified added removed deleted unknown ignored clean'.split()
5707 5735 show = [k for k in states if opts.get(k)]
5708 5736 if opts.get('all'):
5709 5737 show += ui.quiet and (states[:4] + ['clean']) or states
5710 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 5744 stat = repo.status(node1, node2, scmutil.match(repo[node2], pats, opts),
5714 5745 'ignored' in show, 'clean' in show, 'unknown' in show,
@@ -6029,7 +6060,11 b' def tag(ui, repo, name1, *names, **opts)'
6029 6060 rev_ = opts['rev']
6030 6061 message = opts.get('message')
6031 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 6068 for n in names:
6034 6069 if not repo.tagtype(n):
6035 6070 raise util.Abort(_("tag '%s' does not exist") % n)
@@ -963,7 +963,11 b' class basefilectx(object):'
963 963 def ancestors(self, followfirst=False):
964 964 visit = {}
965 965 c = self
966 cut = followfirst and 1 or None
966 if followfirst:
967 cut = 1
968 else:
969 cut = None
970
967 971 while True:
968 972 for parent in c.parents()[:cut]:
969 973 visit[(parent.linkrev(), parent.filenode())] = parent
@@ -1755,7 +1759,11 b' class memctx(committablectx):'
1755 1759 # "filectxfn" for performance (e.g. converting from another VCS)
1756 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 1767 if self._extra.get('branch', '') == '':
1760 1768 self._extra['branch'] = 'default'
1761 1769
@@ -88,7 +88,10 b' class genericdag(basedag):'
88 88 '''generic implementations for DAGs'''
89 89
90 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 95 seen = set()
93 96 pending = list(starts)
94 97 while pending:
@@ -179,7 +182,10 b' class revlogdag(revlogbaseddag):'
179 182 def ancestorset(self, starts, stops=None):
180 183 rlog = self._revlog
181 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 189 seen = set()
184 190 pending = list(starts)
185 191 while pending:
@@ -218,7 +218,10 b' def _oldheadssummary(repo, remoteheads, '
218 218 r = repo.set('heads(%ln + %ln)', oldheads, outgoing.missing)
219 219 newheads = list(c.node() for c in r)
220 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 225 return {None: (oldheads, newheads, unsynced)}
223 226
224 227 def checkheads(repo, remote, outgoing, remoteheads, newbranch=False, inc=False,
@@ -34,7 +34,11 b' def addbranchrevs(lrepo, other, branches'
34 34 else:
35 35 y = None
36 36 return x, y
37 revs = revs and list(revs) or []
37 if revs:
38 revs = list(revs)
39 else:
40 revs = []
41
38 42 if not peer.capable('branchmap'):
39 43 if branches:
40 44 raise util.Abort(_("remote branch lookup not supported"))
@@ -90,7 +90,10 b' def rawfile(web, req, tmpl):'
90 90 if guessmime:
91 91 mt = mimetypes.guess_type(path)[0]
92 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 97 if mt.startswith('text/'):
95 98 mt += '; charset="%s"' % encoding.encoding
96 99
@@ -365,7 +368,11 b' def changelog(web, req, tmpl, shortlog=F'
365 368 entry['parity'] = parity.next()
366 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 376 if 'revcount' in req.form:
370 377 try:
371 378 revcount = int(req.form.get('revcount', [revcount])[0])
@@ -783,8 +790,12 b' def filediff(web, req, tmpl):'
783 790 style = req.form['style'][0]
784 791
785 792 diffs = webutil.diffs(web.repo, tmpl, ctx, None, [path], parity, style)
786 rename = fctx and webutil.renamelink(fctx) or []
787 ctx = fctx and fctx or ctx
793 if fctx:
794 rename = webutil.renamelink(fctx)
795 ctx = fctx
796 else:
797 rename = []
798 ctx = ctx
788 799 return tmpl("filediff",
789 800 file=path,
790 801 node=hex(n),
@@ -373,7 +373,10 b' def diffs(repo, tmpl, ctx, basectx, file'
373 373 diffopts = patch.diffopts(repo.ui, untrusted=True)
374 374 if basectx is None:
375 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 380 else:
378 381 node1 = basectx.node()
379 382 node2 = ctx.node()
@@ -330,7 +330,10 b' class HTTPConnection(object):'
330 330 elif use_ssl is None:
331 331 use_ssl = (port == 443)
332 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 337 self.port = port
335 338 if use_ssl and not socketutil.have_ssl:
336 339 raise Exception('ssl requested but unavailable on this Python')
@@ -523,7 +523,11 b' class localrepository(object):'
523 523 if prevtags and prevtags[-1] != '\n':
524 524 fp.write('\n')
525 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 531 if (self._tagscache.tagtypes and
528 532 name in self._tagscache.tagtypes):
529 533 old = self.tags().get(name, nullid)
@@ -893,7 +897,11 b' class localrepository(object):'
893 897
894 898 def currenttransaction(self):
895 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 905 if tr and tr.running():
898 906 return tr
899 907 return None
@@ -913,7 +921,10 b' class localrepository(object):'
913 921
914 922 self._writejournal(desc)
915 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 928 vfsmap = {'plain': self.vfs} # root of .hg/
918 929 # we must avoid cyclic reference between repo and transaction.
919 930 reporef = weakref.ref(self)
@@ -259,8 +259,17 b' def extract(ui, fileobj):'
259 259 if not diffs_seen:
260 260 os.unlink(tmpname)
261 261 return None, message, user, date, branch, None, None, None
262 p1 = parents and parents.pop(0) or None
263 p2 = parents and parents.pop(0) or None
262
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 273 return tmpname, message, user, date, branch, nodeid, p1, p2
265 274
266 275 class patchmeta(object):
@@ -1489,13 +1498,19 b' def makepatchmeta(backend, afile_orig, b'
1489 1498 fname = None
1490 1499 if not missing:
1491 1500 if gooda and goodb:
1492 fname = isbackup and afile or bfile
1501 if isbackup:
1502 fname = afile
1503 else:
1504 fname = bfile
1493 1505 elif gooda:
1494 1506 fname = afile
1495 1507
1496 1508 if not fname:
1497 1509 if not nullb:
1498 fname = isbackup and afile or bfile
1510 if isbackup:
1511 fname = afile
1512 else:
1513 fname = bfile
1499 1514 elif not nulla:
1500 1515 fname = afile
1501 1516 else:
@@ -2070,7 +2085,10 b' def diff(repo, node1=None, node2=None, m'
2070 2085 if not modified and not added and not removed:
2071 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 2092 revs = [hexfunc(node) for node in [ctx1.node(), ctx2.node()] if node]
2075 2093
2076 2094 copy = {}
@@ -18,7 +18,10 b' import repoview'
18 18
19 19 def _revancestors(repo, revs, followfirst):
20 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 25 cl = repo.changelog
23 26
24 27 def iterate():
@@ -49,7 +52,10 b' def _revancestors(repo, revs, followfirs'
49 52
50 53 def _revdescendants(repo, revs, followfirst):
51 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 60 def iterate():
55 61 cl = repo.changelog
@@ -656,7 +656,10 b' class templater(object):'
656 656 self.mapfile = mapfile or 'template'
657 657 self.cache = cache.copy()
658 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 663 self.filters = templatefilters.filters.copy()
661 664 self.filters.update(filters)
662 665 self.defaults = defaults
@@ -1836,7 +1836,10 b' class TestRunner(object):'
1836 1836 compiler = ''
1837 1837 if self.options.compiler:
1838 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 1843 py3 = ''
1841 1844 if sys.version_info[0] == 3:
1842 1845 py3 = '--c2to3'
General Comments 0
You need to be logged in to leave comments. Login now