##// END OF EJS Templates
largefiles: cosmetics, whitespace, code style...
Greg Ward -
r15255:7ab05d75 default
parent child Browse files
Show More
@@ -166,8 +166,8 b' def _openstore(repo, remote=None, put=Fa'
166 ui = repo.ui
166 ui = repo.ui
167
167
168 if not remote:
168 if not remote:
169 path = getattr(repo, 'lfpullsource', None) or \
169 path = (getattr(repo, 'lfpullsource', None) or
170 ui.expandpath('default-push', 'default')
170 ui.expandpath('default-push', 'default'))
171
171
172 # ui.expandpath() leaves 'default-push' and 'default' alone if
172 # ui.expandpath() leaves 'default-push' and 'default' alone if
173 # they cannot be expanded: fallback to the empty string,
173 # they cannot be expanded: fallback to the empty string,
@@ -383,9 +383,9 b' def cachelfiles(ui, repo, node):'
383 # if it exists and its hash matches, it might have been locally
383 # if it exists and its hash matches, it might have been locally
384 # modified before updating and the user chose 'local'. in this case,
384 # modified before updating and the user chose 'local'. in this case,
385 # it will not be in any store, so don't look for it.
385 # it will not be in any store, so don't look for it.
386 if (not os.path.exists(repo.wjoin(lfile)) \
386 if ((not os.path.exists(repo.wjoin(lfile)) or
387 or expectedhash != lfutil.hashfile(repo.wjoin(lfile))) and \
387 expectedhash != lfutil.hashfile(repo.wjoin(lfile))) and
388 not lfutil.findfile(repo, expectedhash):
388 not lfutil.findfile(repo, expectedhash)):
389 toget.append((lfile, expectedhash))
389 toget.append((lfile, expectedhash))
390
390
391 if toget:
391 if toget:
@@ -441,9 +441,9 b' def _updatelfile(repo, lfdirstate, lfile'
441 if os.path.exists(absstandin+'.orig'):
441 if os.path.exists(absstandin+'.orig'):
442 shutil.copyfile(abslfile, abslfile+'.orig')
442 shutil.copyfile(abslfile, abslfile+'.orig')
443 expecthash = lfutil.readstandin(repo, lfile)
443 expecthash = lfutil.readstandin(repo, lfile)
444 if expecthash != '' and \
444 if (expecthash != '' and
445 (not os.path.exists(abslfile) or \
445 (not os.path.exists(abslfile) or
446 expecthash != lfutil.hashfile(abslfile)):
446 expecthash != lfutil.hashfile(abslfile))):
447 if not lfutil.copyfromcache(repo, expecthash, lfile):
447 if not lfutil.copyfromcache(repo, expecthash, lfile):
448 return None # don't try to set the mode or update the dirstate
448 return None # don't try to set the mode or update the dirstate
449 ret = 1
449 ret = 1
@@ -468,7 +468,6 b' def _updatelfile(repo, lfdirstate, lfile'
468
468
469 # -- hg commands declarations ------------------------------------------------
469 # -- hg commands declarations ------------------------------------------------
470
470
471
472 cmdtable = {
471 cmdtable = {
473 'lfconvert': (lfconvert,
472 'lfconvert': (lfconvert,
474 [('s', 'size', '',
473 [('s', 'size', '',
@@ -86,8 +86,8 b' def systemcachepath(ui, hash):'
86 path = os.path.join(path, hash)
86 path = os.path.join(path, hash)
87 else:
87 else:
88 if os.name == 'nt':
88 if os.name == 'nt':
89 path = os.path.join(os.getenv('LOCALAPPDATA') or \
89 appdata = os.getenv('LOCALAPPDATA', os.getenv('APPDATA'))
90 os.getenv('APPDATA'), longname, hash)
90 path = os.path.join(appdata, longname, hash)
91 elif os.name == 'posix':
91 elif os.name == 'posix':
92 path = os.path.join(os.getenv('HOME'), '.' + longname, hash)
92 path = os.path.join(os.getenv('HOME'), '.' + longname, hash)
93 else:
93 else:
@@ -184,7 +184,8 b' def listlfiles(repo, rev=None, matcher=N'
184 matcher = getstandinmatcher(repo)
184 matcher = getstandinmatcher(repo)
185
185
186 # ignore unknown files in working directory
186 # ignore unknown files in working directory
187 return [splitstandin(f) for f in repo[rev].walk(matcher) \
187 return [splitstandin(f)
188 for f in repo[rev].walk(matcher)
188 if rev is not None or repo.dirstate[f] != '?']
189 if rev is not None or repo.dirstate[f] != '?']
189
190
190 def incache(repo, hash):
191 def incache(repo, hash):
@@ -394,8 +395,9 b' def writehash(hash, filename, executable'
394
395
395 def getexecutable(filename):
396 def getexecutable(filename):
396 mode = os.stat(filename).st_mode
397 mode = os.stat(filename).st_mode
397 return (mode & stat.S_IXUSR) and (mode & stat.S_IXGRP) and (mode & \
398 return ((mode & stat.S_IXUSR) and
398 stat.S_IXOTH)
399 (mode & stat.S_IXGRP) and
400 (mode & stat.S_IXOTH))
399
401
400 def getmode(executable):
402 def getmode(executable):
401 if executable:
403 if executable:
@@ -92,8 +92,9 b' def override_add(orig, ui, repo, *pats, '
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))
@@ -117,8 +118,9 b' def override_add(orig, ui, repo, *pats, '
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
@@ -143,8 +145,9 b' def override_remove(orig, ui, repo, *pat'
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:
@@ -358,9 +361,10 b' def override_copy(orig, ui, repo, pats, '
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 = []
@@ -744,8 +748,8 b' def getoutgoinglfiles(ui, repo, dest=Non'
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):
@@ -12,9 +12,9 b' from mercurial.i18n import _'
12
12
13 import lfutil
13 import lfutil
14
14
15 LARGEFILES_REQUIRED_MSG = '\nThis repository uses the largefiles extension.' \
15 LARGEFILES_REQUIRED_MSG = ('\nThis repository uses the largefiles extension.'
16 '\n\nPlease enable it in your Mercurial config ' \
16 '\n\nPlease enable it in your Mercurial config '
17 'file.\n'
17 'file.\n')
18
18
19 def putlfile(repo, proto, sha):
19 def putlfile(repo, proto, sha):
20 '''Put a largefile into a repository's local cache and into the
20 '''Put a largefile into a repository's local cache and into the
@@ -30,8 +30,8 b' def reposetup(ui, repo):'
30 method = getattr(repo, name)
30 method = getattr(repo, name)
31 #if not (isinstance(method, types.MethodType) and
31 #if not (isinstance(method, types.MethodType) and
32 # method.im_func is repo.__class__.commitctx.im_func):
32 # method.im_func is repo.__class__.commitctx.im_func):
33 if isinstance(method, types.FunctionType) and method.func_name == \
33 if (isinstance(method, types.FunctionType) and
34 'wrap':
34 method.func_name == 'wrap'):
35 ui.warn(_('largefiles: repo method %r appears to have already been'
35 ui.warn(_('largefiles: repo method %r appears to have already been'
36 ' wrapped by another extension: '
36 ' wrapped by another extension: '
37 'largefiles may behave incorrectly\n')
37 'largefiles may behave incorrectly\n')
@@ -193,16 +193,18 b' def reposetup(ui, repo):'
193 lfiles = (modified, added, removed, missing, [], [], clean)
193 lfiles = (modified, added, removed, missing, [], [], clean)
194 result = list(result)
194 result = list(result)
195 # Unknown files
195 # Unknown files
196 result[4] = [f for f in unknown if repo.dirstate[f] == '?'\
196 result[4] = [f for f in unknown
197 and not lfutil.isstandin(f)]
197 if (repo.dirstate[f] == '?' and
198 not lfutil.isstandin(f))]
198 # Ignored files must be ignored by both the dirstate and
199 # Ignored files must be ignored by both the dirstate and
199 # lfdirstate
200 # lfdirstate
200 result[5] = set(ignored).intersection(set(result[5]))
201 result[5] = set(ignored).intersection(set(result[5]))
201 # combine normal files and largefiles
202 # combine normal files and largefiles
202 normals = [[fn for fn in filelist if not \
203 normals = [[fn for fn in filelist
203 lfutil.isstandin(fn)] for filelist in result]
204 if not lfutil.isstandin(fn)]
204 result = [sorted(list1 + list2) for (list1, list2) in \
205 for filelist in result]
205 zip(normals, lfiles)]
206 result = [sorted(list1 + list2)
207 for (list1, list2) in zip(normals, lfiles)]
206 else:
208 else:
207 def toname(f):
209 def toname(f):
208 if lfutil.isstandin(f):
210 if lfutil.isstandin(f):
@@ -251,8 +253,8 b' def reposetup(ui, repo):'
251 # Case 1: user calls commit with no specific files or
253 # Case 1: user calls commit with no specific files or
252 # include/exclude patterns: refresh and commit all files that
254 # include/exclude patterns: refresh and commit all files that
253 # are "dirty".
255 # are "dirty".
254 if (match is None) or (not match.anypats() and not \
256 if ((match is None) or
255 match.files()):
257 (not match.anypats() and not match.files())):
256 # Spend a bit of time here to get a list of files we know
258 # Spend a bit of time here to get a list of files we know
257 # are modified so we can compare only against those.
259 # are modified so we can compare only against those.
258 # It can cost a lot of time (several seconds)
260 # It can cost a lot of time (several seconds)
@@ -345,8 +347,8 b' def reposetup(ui, repo):'
345 fstandin += os.sep
347 fstandin += os.sep
346
348
347 # prevalidate matching standin directories
349 # prevalidate matching standin directories
348 if lfutil.any_(st for st in match._files if \
350 if lfutil.any_(st for st in match._files
349 st.startswith(fstandin)):
351 if st.startswith(fstandin)):
350 continue
352 continue
351 actualfiles.append(f)
353 actualfiles.append(f)
352 match._files = actualfiles
354 match._files = actualfiles
@@ -369,8 +371,8 b' def reposetup(ui, repo):'
369 toupload = set()
371 toupload = set()
370 o = repo.changelog.nodesbetween(o, revs)[0]
372 o = repo.changelog.nodesbetween(o, revs)[0]
371 for n in o:
373 for n in o:
372 parents = [p for p in repo.changelog.parents(n) if p != \
374 parents = [p for p in repo.changelog.parents(n)
373 node.nullid]
375 if p != node.nullid]
374 ctx = repo[n]
376 ctx = repo[n]
375 files = set(ctx.files())
377 files = set(ctx.files())
376 if len(parents) == 2:
378 if len(parents) == 2:
@@ -388,8 +390,10 b' def reposetup(ui, repo):'
388 None):
390 None):
389 files.add(f)
391 files.add(f)
390
392
391 toupload = toupload.union(set([ctx[f].data().strip() for f\
393 toupload = toupload.union(
392 in files if lfutil.isstandin(f) and f in ctx]))
394 set([ctx[f].data().strip()
395 for f in files
396 if lfutil.isstandin(f) and f in ctx]))
393 lfcommands.uploadlfiles(ui, self, remote, toupload)
397 lfcommands.uploadlfiles(ui, self, remote, toupload)
394 return super(lfiles_repo, self).push(remote, force, revs,
398 return super(lfiles_repo, self).push(remote, force, revs,
395 newbranch)
399 newbranch)
General Comments 0
You need to be logged in to leave comments. Login now