##// END OF EJS Templates
largefiles: more work on cleaning up comments...
Greg Ward -
r15254:dd03d3a9 default
parent child Browse files
Show More
@@ -243,13 +243,13 b' def _lfconvert_addchangeset(rsrc, rdst, '
243
243
244 if f in lfiles:
244 if f in lfiles:
245 dstfiles.append(lfutil.standin(f))
245 dstfiles.append(lfutil.standin(f))
246 # lfile in manifest if it has not been removed/renamed
246 # largefile in manifest if it has not been removed/renamed
247 if f in ctx.manifest():
247 if f in ctx.manifest():
248 if 'l' in ctx.filectx(f).flags():
248 if 'l' in ctx.filectx(f).flags():
249 if renamed and renamed[0] in lfiles:
249 if renamed and renamed[0] in lfiles:
250 raise util.Abort(_('largefile %s becomes symlink') % f)
250 raise util.Abort(_('largefile %s becomes symlink') % f)
251
251
252 # lfile was modified, update standins
252 # largefile was modified, update standins
253 fullpath = rdst.wjoin(f)
253 fullpath = rdst.wjoin(f)
254 lfutil.createdir(os.path.dirname(fullpath))
254 lfutil.createdir(os.path.dirname(fullpath))
255 m = util.sha1('')
255 m = util.sha1('')
@@ -282,7 +282,7 b' def _lfconvert_addchangeset(rsrc, rdst, '
282 raise IOError()
282 raise IOError()
283 renamed = fctx.renamed()
283 renamed = fctx.renamed()
284 if renamed:
284 if renamed:
285 # standin is always a lfile because lfileness
285 # standin is always a largefile because largefile-ness
286 # doesn't change after rename or copy
286 # doesn't change after rename or copy
287 renamed = lfutil.standin(renamed[0])
287 renamed = lfutil.standin(renamed[0])
288
288
@@ -310,10 +310,10 b' def override_copy(orig, ui, repo, pats, '
310 if os.path.isdir(dest):
310 if os.path.isdir(dest):
311 if not os.path.isdir(makestandin(dest)):
311 if not os.path.isdir(makestandin(dest)):
312 os.makedirs(makestandin(dest))
312 os.makedirs(makestandin(dest))
313 # This could copy both largefiles and normal files in one command,
313 # This could copy both lfiles and normal files in one command,
314 # but we don't want to do that first replace their matcher to only
314 # but we don't want to do that. First replace their matcher to
315 # match normal files and run it then replace it to just match
315 # only match normal files and run it, then replace it to just
316 # lfiles and run it again
316 # match largefiles and run it again.
317 nonormalfiles = False
317 nonormalfiles = False
318 nolfiles = False
318 nolfiles = False
319 try:
319 try:
@@ -418,18 +418,20 b' def override_copy(orig, ui, repo, pats, '
418
418
419 return result
419 return result
420
420
421 # When the user calls revert, we have to be careful to not revert any changes
421 # When the user calls revert, we have to be careful to not revert any
422 # to other lfiles accidentally. This means we have to keep track of the lfiles
422 # changes to other largefiles accidentally. This means we have to keep
423 # that are being reverted so we only pull down the necessary lfiles.
423 # track of the largefiles that are being reverted so we only pull down
424 # the necessary largefiles.
424 #
425 #
425 # Standins are only updated (to match the hash of lfiles) before commits.
426 # Standins are only updated (to match the hash of largefiles) before
426 # Update the standins then run the original revert (changing the matcher to hit
427 # commits. Update the standins then run the original revert, changing
427 # standins instead of lfiles). Based on the resulting standins update the
428 # the matcher to hit standins instead of largefiles. Based on the
428 # lfiles. Then return the standins to their proper state
429 # resulting standins update the largefiles. Then return the standins
430 # to their proper state
429 def override_revert(orig, ui, repo, *pats, **opts):
431 def override_revert(orig, ui, repo, *pats, **opts):
430 # Because we put the standins in a bad state (by updating them) and then
432 # Because we put the standins in a bad state (by updating them)
431 # return them to a correct state we need to lock to prevent others from
433 # and then return them to a correct state we need to lock to
432 # changing them in their incorrect state.
434 # prevent others from changing them in their incorrect state.
433 wlock = repo.wlock()
435 wlock = repo.wlock()
434 try:
436 try:
435 lfdirstate = lfutil.openlfdirstate(ui, repo)
437 lfdirstate = lfutil.openlfdirstate(ui, repo)
@@ -461,11 +463,11 b' def override_revert(orig, ui, repo, *pat'
461 orig_matchfn = m.matchfn
463 orig_matchfn = m.matchfn
462 def matchfn(f):
464 def matchfn(f):
463 if lfutil.isstandin(f):
465 if lfutil.isstandin(f):
464 # We need to keep track of what lfiles are being
466 # We need to keep track of what largefiles are being
465 # matched so we know which ones to update later
467 # matched so we know which ones to update later --
466 # (otherwise we revert changes to other lfiles
468 # otherwise we accidentally revert changes to other
467 # accidentally). This is repo specific, so duckpunch
469 # largefiles. This is repo-specific, so duckpunch the
468 # the repo object to keep the list of lfiles for us
470 # repo object to keep the list of largefiles for us
469 # later.
471 # later.
470 if orig_matchfn(lfutil.splitstandin(f)) and \
472 if orig_matchfn(lfutil.splitstandin(f)) and \
471 (f in repo[None] or f in ctx):
473 (f in repo[None] or f in ctx):
@@ -487,7 +489,8 b' def override_revert(orig, ui, repo, *pat'
487 lfileslist = getattr(repo, '_lfilestoupdate', [])
489 lfileslist = getattr(repo, '_lfilestoupdate', [])
488 lfcommands.updatelfiles(ui, repo, filelist=lfileslist,
490 lfcommands.updatelfiles(ui, repo, filelist=lfileslist,
489 printmessage=False)
491 printmessage=False)
490 # Empty out the lfiles list so we start fresh next time
492
493 # empty out the largefiles list so we start fresh next time
491 repo._lfilestoupdate = []
494 repo._lfilestoupdate = []
492 for lfile in modified:
495 for lfile in modified:
493 if lfile in lfileslist:
496 if lfile in lfileslist:
@@ -523,9 +526,9 b' def hg_merge(orig, repo, node, force=Non'
523 lfcommands.updatelfiles(repo.ui, repo)
526 lfcommands.updatelfiles(repo.ui, repo)
524 return result
527 return result
525
528
526 # When we rebase a repository with remotely changed lfiles, we need
529 # When we rebase a repository with remotely changed largefiles, we need to
527 # to take some extra care so that the lfiles are correctly updated
530 # take some extra care so that the largefiles are correctly updated in the
528 # in the working copy
531 # working copy
529 def override_pull(orig, ui, repo, source=None, **opts):
532 def override_pull(orig, ui, repo, source=None, **opts):
530 if opts.get('rebase', False):
533 if opts.get('rebase', False):
531 repo._isrebasing = True
534 repo._isrebasing = True
@@ -569,9 +572,8 b' def override_rebase(orig, ui, repo, **op'
569
572
570 def override_archive(orig, repo, dest, node, kind, decode=True, matchfn=None,
573 def override_archive(orig, repo, dest, node, kind, decode=True, matchfn=None,
571 prefix=None, mtime=None, subrepos=None):
574 prefix=None, mtime=None, subrepos=None):
572 # No need to lock because we are only reading history and lfile caches
575 # No need to lock because we are only reading history and
573 # neither of which are modified
576 # largefile caches, neither of which are modified.
574
575 lfcommands.cachelfiles(repo.ui, repo, node)
577 lfcommands.cachelfiles(repo.ui, repo, node)
576
578
577 if kind not in archival.archivers:
579 if kind not in archival.archivers:
@@ -643,10 +645,10 b' def override_archive(orig, repo, dest, n'
643
645
644 archiver.done()
646 archiver.done()
645
647
646 # If a lfile is modified the change is not reflected in its standin until a
648 # If a largefile is modified, the change is not reflected in its
647 # commit. cmdutil.bailifchanged raises an exception if the repo has
649 # standin until a commit. cmdutil.bailifchanged() raises an exception
648 # uncommitted changes. Wrap it to also check if lfiles were changed. This is
650 # if the repo has uncommitted changes. Wrap it to also check if
649 # used by bisect and backout.
651 # largefiles were changed. This is used by bisect and backout.
650 def override_bailifchanged(orig, repo):
652 def override_bailifchanged(orig, repo):
651 orig(repo)
653 orig(repo)
652 repo.lfstatus = True
654 repo.lfstatus = True
@@ -770,10 +772,10 b' def override_summary(orig, ui, repo, *pa'
770 ui.status(_('largefiles: %d to upload\n') % len(toupload))
772 ui.status(_('largefiles: %d to upload\n') % len(toupload))
771
773
772 def override_addremove(orig, ui, repo, *pats, **opts):
774 def override_addremove(orig, ui, repo, *pats, **opts):
773 # Check if the parent or child has lfiles if they do don't allow it. If
775 # Check if the parent or child has largefiles; if so, disallow
774 # there is a symlink in the manifest then getting the manifest throws an
776 # addremove. If there is a symlink in the manifest then getting
775 # exception catch it and let addremove deal with it. This happens in
777 # the manifest throws an exception: catch it and let addremove
776 # Mercurial's test test-addremove-symlink
778 # deal with it.
777 try:
779 try:
778 manifesttip = set(repo['tip'].manifest())
780 manifesttip = set(repo['tip'].manifest())
779 except util.Abort:
781 except util.Abort:
@@ -791,7 +793,7 b' def override_addremove(orig, ui, repo, *'
791
793
792 return orig(ui, repo, *pats, **opts)
794 return orig(ui, repo, *pats, **opts)
793
795
794 # Calling purge with --all will cause the lfiles to be deleted.
796 # Calling purge with --all will cause the largefiles to be deleted.
795 # Override repo.status to prevent this from happening.
797 # Override repo.status to prevent this from happening.
796 def override_purge(orig, ui, repo, *dirs, **opts):
798 def override_purge(orig, ui, repo, *dirs, **opts):
797 oldstatus = repo.status
799 oldstatus = repo.status
@@ -118,12 +118,11 b' def reposetup(ui, repo):'
118 except KeyError:
118 except KeyError:
119 return False
119 return False
120
120
121 # create a copy of match that matches standins instead of
122 # lfiles if matcher not set then it is the always matcher so
123 # overwrite that
124 if match is None:
121 if match is None:
125 match = match_.always(self.root, self.getcwd())
122 match = match_.always(self.root, self.getcwd())
126
123
124 # Create a copy of match that matches standins instead
125 # of largefiles.
127 def tostandin(file):
126 def tostandin(file):
128 if inctx(lfutil.standin(file), ctx2):
127 if inctx(lfutil.standin(file), ctx2):
129 return lfutil.standin(file)
128 return lfutil.standin(file)
@@ -199,7 +198,7 b' def reposetup(ui, repo):'
199 # Ignored files must be ignored by both the dirstate and
198 # Ignored files must be ignored by both the dirstate and
200 # lfdirstate
199 # lfdirstate
201 result[5] = set(ignored).intersection(set(result[5]))
200 result[5] = set(ignored).intersection(set(result[5]))
202 # combine normal files and lfiles
201 # combine normal files and largefiles
203 normals = [[fn for fn in filelist if not \
202 normals = [[fn for fn in filelist if not \
204 lfutil.isstandin(fn)] for filelist in result]
203 lfutil.isstandin(fn)] for filelist in result]
205 result = [sorted(list1 + list2) for (list1, list2) in \
204 result = [sorted(list1 + list2) for (list1, list2) in \
@@ -220,8 +219,8 b' def reposetup(ui, repo):'
220 self.lfstatus = True
219 self.lfstatus = True
221 return result
220 return result
222
221
223 # This call happens after a commit has occurred. Copy all of the lfiles
222 # As part of committing, copy all of the largefiles into the
224 # into the cache
223 # cache.
225 def commitctx(self, *args, **kwargs):
224 def commitctx(self, *args, **kwargs):
226 node = super(lfiles_repo, self).commitctx(*args, **kwargs)
225 node = super(lfiles_repo, self).commitctx(*args, **kwargs)
227 ctx = self[node]
226 ctx = self[node]
@@ -232,9 +231,9 b' def reposetup(ui, repo):'
232
231
233 return node
232 return node
234
233
235 # This call happens before a commit has occurred. The lfile standins
234 # Before commit, largefile standins have not had their
236 # have not had their contents updated (to reflect the hash of their
235 # contents updated to reflect the hash of their largefile.
237 # lfile). Do that here.
236 # Do that here.
238 def commit(self, text="", user=None, date=None, match=None,
237 def commit(self, text="", user=None, date=None, match=None,
239 force=False, editor=False, extra={}):
238 force=False, editor=False, extra={}):
240 orig = super(lfiles_repo, self).commit
239 orig = super(lfiles_repo, self).commit
@@ -242,11 +241,12 b' def reposetup(ui, repo):'
242 wlock = repo.wlock()
241 wlock = repo.wlock()
243 try:
242 try:
244 if getattr(repo, "_isrebasing", False):
243 if getattr(repo, "_isrebasing", False):
245 # We have to take the time to pull down the new lfiles now.
244 # We have to take the time to pull down the new
246 # Otherwise if we are rebasing, any lfiles that were
245 # largefiles now. Otherwise if we are rebasing,
247 # modified in the changesets we are rebasing on top of get
246 # any largefiles that were modified in the
248 # overwritten either by the rebase or in the first commit
247 # destination changesets get overwritten, either
249 # after the rebase.
248 # by the rebase or in the first commit after the
249 # rebase.
250 lfcommands.updatelfiles(repo.ui, repo)
250 lfcommands.updatelfiles(repo.ui, repo)
251 # Case 1: user calls commit with no specific files or
251 # Case 1: user calls commit with no specific files or
252 # include/exclude patterns: refresh and commit all files that
252 # include/exclude patterns: refresh and commit all files that
@@ -265,7 +265,7 b' def reposetup(ui, repo):'
265 for i in s:
265 for i in s:
266 modifiedfiles.extend(i)
266 modifiedfiles.extend(i)
267 lfiles = lfutil.listlfiles(self)
267 lfiles = lfutil.listlfiles(self)
268 # this only loops through lfiles that exist (not
268 # this only loops through largefiles that exist (not
269 # removed/renamed)
269 # removed/renamed)
270 for lfile in lfiles:
270 for lfile in lfiles:
271 if lfile in modifiedfiles:
271 if lfile in modifiedfiles:
@@ -327,9 +327,9 b' def reposetup(ui, repo):'
327 match = copy.copy(match)
327 match = copy.copy(match)
328 orig_matchfn = match.matchfn
328 orig_matchfn = match.matchfn
329
329
330 # Check both the list of lfiles and the list of standins
330 # Check both the list of largefiles and the list of
331 # because if a lfile was removed, it won't be in the list of
331 # standins because if a largefile was removed, it
332 # lfiles at this point
332 # won't be in the list of largefiles at this point
333 match._files += sorted(standins)
333 match._files += sorted(standins)
334
334
335 actualfiles = []
335 actualfiles = []
@@ -99,8 +99,8 b' def uisetup(ui):'
99 wireproto.commands['heads'] = (proto.heads, '')
99 wireproto.commands['heads'] = (proto.heads, '')
100 wireproto.commands['lheads'] = (wireproto.heads, '')
100 wireproto.commands['lheads'] = (wireproto.heads, '')
101
101
102 # make putlfile behave the same as push and {get,stat}lfile behave the same
102 # make putlfile behave the same as push and {get,stat}lfile behave
103 # as pull w.r.t. permissions checks
103 # the same as pull w.r.t. permissions checks
104 hgweb_mod.perms['putlfile'] = 'push'
104 hgweb_mod.perms['putlfile'] = 'push'
105 hgweb_mod.perms['getlfile'] = 'pull'
105 hgweb_mod.perms['getlfile'] = 'pull'
106 hgweb_mod.perms['statlfile'] = 'pull'
106 hgweb_mod.perms['statlfile'] = 'pull'
General Comments 0
You need to be logged in to leave comments. Login now