Mercurial > hg
changeset 15255:7ab05d752405
largefiles: cosmetics, whitespace, code style
This is mainly about keeping code under the 80-column limit with as
few backslashes as possible. I am deliberately not making any logic or
behaviour changes here and have restrained myself to a few "peephole"
refactorings.
author | Greg Ward <greg@gerg.ca> |
---|---|
date | Thu, 13 Oct 2011 21:42:54 -0400 |
parents | dd03d3a9f888 |
children | 8caf7a757afa |
files | hgext/largefiles/basestore.py hgext/largefiles/lfcommands.py hgext/largefiles/lfutil.py hgext/largefiles/overrides.py hgext/largefiles/proto.py hgext/largefiles/reposetup.py |
diffstat | 6 files changed, 53 insertions(+), 44 deletions(-) [+] |
line wrap: on
line diff
--- a/hgext/largefiles/basestore.py Thu Oct 13 20:45:49 2011 -0400 +++ b/hgext/largefiles/basestore.py Thu Oct 13 21:42:54 2011 -0400 @@ -166,8 +166,8 @@ ui = repo.ui if not remote: - path = getattr(repo, 'lfpullsource', None) or \ - ui.expandpath('default-push', 'default') + path = (getattr(repo, 'lfpullsource', None) or + ui.expandpath('default-push', 'default')) # ui.expandpath() leaves 'default-push' and 'default' alone if # they cannot be expanded: fallback to the empty string,
--- a/hgext/largefiles/lfcommands.py Thu Oct 13 20:45:49 2011 -0400 +++ b/hgext/largefiles/lfcommands.py Thu Oct 13 21:42:54 2011 -0400 @@ -383,9 +383,9 @@ # if it exists and its hash matches, it might have been locally # modified before updating and the user chose 'local'. in this case, # it will not be in any store, so don't look for it. - if (not os.path.exists(repo.wjoin(lfile)) \ - or expectedhash != lfutil.hashfile(repo.wjoin(lfile))) and \ - not lfutil.findfile(repo, expectedhash): + if ((not os.path.exists(repo.wjoin(lfile)) or + expectedhash != lfutil.hashfile(repo.wjoin(lfile))) and + not lfutil.findfile(repo, expectedhash)): toget.append((lfile, expectedhash)) if toget: @@ -441,9 +441,9 @@ if os.path.exists(absstandin+'.orig'): shutil.copyfile(abslfile, abslfile+'.orig') expecthash = lfutil.readstandin(repo, lfile) - if expecthash != '' and \ - (not os.path.exists(abslfile) or \ - expecthash != lfutil.hashfile(abslfile)): + if (expecthash != '' and + (not os.path.exists(abslfile) or + expecthash != lfutil.hashfile(abslfile))): if not lfutil.copyfromcache(repo, expecthash, lfile): return None # don't try to set the mode or update the dirstate ret = 1 @@ -468,7 +468,6 @@ # -- hg commands declarations ------------------------------------------------ - cmdtable = { 'lfconvert': (lfconvert, [('s', 'size', '',
--- a/hgext/largefiles/lfutil.py Thu Oct 13 20:45:49 2011 -0400 +++ b/hgext/largefiles/lfutil.py Thu Oct 13 21:42:54 2011 -0400 @@ -86,8 +86,8 @@ path = os.path.join(path, hash) else: if os.name == 'nt': - path = os.path.join(os.getenv('LOCALAPPDATA') or \ - os.getenv('APPDATA'), longname, hash) + appdata = os.getenv('LOCALAPPDATA', os.getenv('APPDATA')) + path = os.path.join(appdata, longname, hash) elif os.name == 'posix': path = os.path.join(os.getenv('HOME'), '.' + longname, hash) else: @@ -184,7 +184,8 @@ matcher = getstandinmatcher(repo) # ignore unknown files in working directory - return [splitstandin(f) for f in repo[rev].walk(matcher) \ + return [splitstandin(f) + for f in repo[rev].walk(matcher) if rev is not None or repo.dirstate[f] != '?'] def incache(repo, hash): @@ -394,8 +395,9 @@ def getexecutable(filename): mode = os.stat(filename).st_mode - return (mode & stat.S_IXUSR) and (mode & stat.S_IXGRP) and (mode & \ - stat.S_IXOTH) + return ((mode & stat.S_IXUSR) and + (mode & stat.S_IXGRP) and + (mode & stat.S_IXOTH)) def getmode(executable): if executable:
--- a/hgext/largefiles/overrides.py Thu Oct 13 20:45:49 2011 -0400 +++ b/hgext/largefiles/overrides.py Thu Oct 13 21:42:54 2011 -0400 @@ -92,8 +92,9 @@ continue if exact or not exists: - if large or (lfsize and os.path.getsize(repo.wjoin(f)) >= \ - lfsize * 1024 * 1024) or (lfmatcher and lfmatcher(f)): + abovemin = (lfsize and + os.path.getsize(repo.wjoin(f)) >= lfsize * 1024 * 1024) + if large or abovemin or (lfmatcher and lfmatcher(f)): lfnames.append(f) if ui.verbose or not exact: ui.status(_('adding %s as a largefile\n') % m.rel(f)) @@ -117,8 +118,9 @@ else: lfdirstate.add(f) lfdirstate.write() - bad += [lfutil.splitstandin(f) for f in lfutil.repo_add(repo, - standins) if f in m.files()] + bad += [lfutil.splitstandin(f) + for f in lfutil.repo_add(repo, standins) + if f in m.files()] finally: wlock.release() @@ -143,8 +145,9 @@ s = repo.status(match=m, clean=True) finally: repo.lfstatus = False - modified, added, deleted, clean = [[f for f in list if lfutil.standin(f) \ - in manifest] for list in [s[0], s[1], s[3], s[6]]] + modified, added, deleted, clean = [[f for f in list + if lfutil.standin(f) in manifest] + for list in [s[0], s[1], s[3], s[6]]] def warn(files, reason): for f in files: @@ -358,9 +361,10 @@ m._files = [lfutil.standin(f) for f in m._files if lfile(f)] m._fmap = set(m._files) orig_matchfn = m.matchfn - m.matchfn = lambda f: lfutil.isstandin(f) and \ - lfile(lfutil.splitstandin(f)) and \ - orig_matchfn(lfutil.splitstandin(f)) or None + m.matchfn = lambda f: (lfutil.isstandin(f) and + lfile(lfutil.splitstandin(f)) and + orig_matchfn(lfutil.splitstandin(f)) or + None) return m oldmatch = installmatchfn(override_match) listpats = [] @@ -744,8 +748,8 @@ for f in mc: if mc[f] != mp1.get(f, None) or mc[f] != mp2.get(f, None): files.add(f) - toupload = toupload.union(set([f for f in files if lfutil.isstandin(f)\ - and f in ctx])) + toupload = toupload.union( + set([f for f in files if lfutil.isstandin(f) and f in ctx])) return toupload def override_outgoing(orig, ui, repo, dest=None, **opts):
--- a/hgext/largefiles/proto.py Thu Oct 13 20:45:49 2011 -0400 +++ b/hgext/largefiles/proto.py Thu Oct 13 21:42:54 2011 -0400 @@ -12,9 +12,9 @@ import lfutil -LARGEFILES_REQUIRED_MSG = '\nThis repository uses the largefiles extension.' \ - '\n\nPlease enable it in your Mercurial config ' \ - 'file.\n' +LARGEFILES_REQUIRED_MSG = ('\nThis repository uses the largefiles extension.' + '\n\nPlease enable it in your Mercurial config ' + 'file.\n') def putlfile(repo, proto, sha): '''Put a largefile into a repository's local cache and into the
--- a/hgext/largefiles/reposetup.py Thu Oct 13 20:45:49 2011 -0400 +++ b/hgext/largefiles/reposetup.py Thu Oct 13 21:42:54 2011 -0400 @@ -30,8 +30,8 @@ method = getattr(repo, name) #if not (isinstance(method, types.MethodType) and # method.im_func is repo.__class__.commitctx.im_func): - if isinstance(method, types.FunctionType) and method.func_name == \ - 'wrap': + if (isinstance(method, types.FunctionType) and + method.func_name == 'wrap'): ui.warn(_('largefiles: repo method %r appears to have already been' ' wrapped by another extension: ' 'largefiles may behave incorrectly\n') @@ -193,16 +193,18 @@ lfiles = (modified, added, removed, missing, [], [], clean) result = list(result) # Unknown files - result[4] = [f for f in unknown if repo.dirstate[f] == '?'\ - and not lfutil.isstandin(f)] + result[4] = [f for f in unknown + if (repo.dirstate[f] == '?' and + not lfutil.isstandin(f))] # Ignored files must be ignored by both the dirstate and # lfdirstate result[5] = set(ignored).intersection(set(result[5])) # combine normal files and largefiles - normals = [[fn for fn in filelist if not \ - lfutil.isstandin(fn)] for filelist in result] - result = [sorted(list1 + list2) for (list1, list2) in \ - zip(normals, lfiles)] + normals = [[fn for fn in filelist + if not lfutil.isstandin(fn)] + for filelist in result] + result = [sorted(list1 + list2) + for (list1, list2) in zip(normals, lfiles)] else: def toname(f): if lfutil.isstandin(f): @@ -251,8 +253,8 @@ # Case 1: user calls commit with no specific files or # include/exclude patterns: refresh and commit all files that # are "dirty". - if (match is None) or (not match.anypats() and not \ - match.files()): + if ((match is None) or + (not match.anypats() and not match.files())): # Spend a bit of time here to get a list of files we know # are modified so we can compare only against those. # It can cost a lot of time (several seconds) @@ -345,8 +347,8 @@ fstandin += os.sep # prevalidate matching standin directories - if lfutil.any_(st for st in match._files if \ - st.startswith(fstandin)): + if lfutil.any_(st for st in match._files + if st.startswith(fstandin)): continue actualfiles.append(f) match._files = actualfiles @@ -369,8 +371,8 @@ toupload = set() o = repo.changelog.nodesbetween(o, revs)[0] for n in o: - parents = [p for p in repo.changelog.parents(n) if p != \ - node.nullid] + parents = [p for p in repo.changelog.parents(n) + if p != node.nullid] ctx = repo[n] files = set(ctx.files()) if len(parents) == 2: @@ -388,8 +390,10 @@ None): files.add(f) - toupload = toupload.union(set([ctx[f].data().strip() for f\ - in files if lfutil.isstandin(f) and f in ctx])) + toupload = toupload.union( + set([ctx[f].data().strip() + for f in files + if lfutil.isstandin(f) and f in ctx])) lfcommands.uploadlfiles(ui, self, remote, toupload) return super(lfiles_repo, self).push(remote, force, revs, newbranch)