Mercurial > hg
comparison hgext/largefiles/overrides.py @ 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 | 018608160299 |
comparison
equal
deleted
inserted
replaced
15254:dd03d3a9f888 | 15255:7ab05d752405 |
---|---|
90 if lfile: | 90 if lfile: |
91 ui.warn(_('%s already a largefile\n') % f) | 91 ui.warn(_('%s already a largefile\n') % f) |
92 continue | 92 continue |
93 | 93 |
94 if exact or not exists: | 94 if exact or not exists: |
95 if large or (lfsize and os.path.getsize(repo.wjoin(f)) >= \ | 95 abovemin = (lfsize and |
96 lfsize * 1024 * 1024) or (lfmatcher and lfmatcher(f)): | 96 os.path.getsize(repo.wjoin(f)) >= lfsize * 1024 * 1024) |
97 if large or abovemin or (lfmatcher and lfmatcher(f)): | |
97 lfnames.append(f) | 98 lfnames.append(f) |
98 if ui.verbose or not exact: | 99 if ui.verbose or not exact: |
99 ui.status(_('adding %s as a largefile\n') % m.rel(f)) | 100 ui.status(_('adding %s as a largefile\n') % m.rel(f)) |
100 | 101 |
101 bad = [] | 102 bad = [] |
115 if lfdirstate[f] == 'r': | 116 if lfdirstate[f] == 'r': |
116 lfdirstate.normallookup(f) | 117 lfdirstate.normallookup(f) |
117 else: | 118 else: |
118 lfdirstate.add(f) | 119 lfdirstate.add(f) |
119 lfdirstate.write() | 120 lfdirstate.write() |
120 bad += [lfutil.splitstandin(f) for f in lfutil.repo_add(repo, | 121 bad += [lfutil.splitstandin(f) |
121 standins) if f in m.files()] | 122 for f in lfutil.repo_add(repo, standins) |
123 if f in m.files()] | |
122 finally: | 124 finally: |
123 wlock.release() | 125 wlock.release() |
124 | 126 |
125 installnormalfilesmatchfn(repo[None].manifest()) | 127 installnormalfilesmatchfn(repo[None].manifest()) |
126 result = orig(ui, repo, *pats, **opts) | 128 result = orig(ui, repo, *pats, **opts) |
141 try: | 143 try: |
142 repo.lfstatus = True | 144 repo.lfstatus = True |
143 s = repo.status(match=m, clean=True) | 145 s = repo.status(match=m, clean=True) |
144 finally: | 146 finally: |
145 repo.lfstatus = False | 147 repo.lfstatus = False |
146 modified, added, deleted, clean = [[f for f in list if lfutil.standin(f) \ | 148 modified, added, deleted, clean = [[f for f in list |
147 in manifest] for list in [s[0], s[1], s[3], s[6]]] | 149 if lfutil.standin(f) in manifest] |
150 for list in [s[0], s[1], s[3], s[6]]] | |
148 | 151 |
149 def warn(files, reason): | 152 def warn(files, reason): |
150 for f in files: | 153 for f in files: |
151 ui.warn(_('not removing %s: file %s (use -f to force removal)\n') | 154 ui.warn(_('not removing %s: file %s (use -f to force removal)\n') |
152 % (m.rel(f), reason)) | 155 % (m.rel(f), reason)) |
356 m = copy.copy(match) | 359 m = copy.copy(match) |
357 lfile = lambda f: lfutil.standin(f) in manifest | 360 lfile = lambda f: lfutil.standin(f) in manifest |
358 m._files = [lfutil.standin(f) for f in m._files if lfile(f)] | 361 m._files = [lfutil.standin(f) for f in m._files if lfile(f)] |
359 m._fmap = set(m._files) | 362 m._fmap = set(m._files) |
360 orig_matchfn = m.matchfn | 363 orig_matchfn = m.matchfn |
361 m.matchfn = lambda f: lfutil.isstandin(f) and \ | 364 m.matchfn = lambda f: (lfutil.isstandin(f) and |
362 lfile(lfutil.splitstandin(f)) and \ | 365 lfile(lfutil.splitstandin(f)) and |
363 orig_matchfn(lfutil.splitstandin(f)) or None | 366 orig_matchfn(lfutil.splitstandin(f)) or |
367 None) | |
364 return m | 368 return m |
365 oldmatch = installmatchfn(override_match) | 369 oldmatch = installmatchfn(override_match) |
366 listpats = [] | 370 listpats = [] |
367 for pat in pats: | 371 for pat in pats: |
368 if match_.patkind(pat) is not None: | 372 if match_.patkind(pat) is not None: |
742 if f not in mc: | 746 if f not in mc: |
743 files.add(f) | 747 files.add(f) |
744 for f in mc: | 748 for f in mc: |
745 if mc[f] != mp1.get(f, None) or mc[f] != mp2.get(f, None): | 749 if mc[f] != mp1.get(f, None) or mc[f] != mp2.get(f, None): |
746 files.add(f) | 750 files.add(f) |
747 toupload = toupload.union(set([f for f in files if lfutil.isstandin(f)\ | 751 toupload = toupload.union( |
748 and f in ctx])) | 752 set([f for f in files if lfutil.isstandin(f) and f in ctx])) |
749 return toupload | 753 return toupload |
750 | 754 |
751 def override_outgoing(orig, ui, repo, dest=None, **opts): | 755 def override_outgoing(orig, ui, repo, dest=None, **opts): |
752 orig(ui, repo, dest, **opts) | 756 orig(ui, repo, dest, **opts) |
753 | 757 |