##// END OF EJS Templates
largefiles: simplify revert - use getstandinsstate like other commands do
Mads Kiilerich -
r21094:4643bfec default
parent child Browse files
Show More
@@ -579,8 +579,7 def overridecopy(orig, ui, repo, pats, o
579 # Standins are only updated (to match the hash of largefiles) before
579 # Standins are only updated (to match the hash of largefiles) before
580 # commits. Update the standins then run the original revert, changing
580 # commits. Update the standins then run the original revert, changing
581 # the matcher to hit standins instead of largefiles. Based on the
581 # the matcher to hit standins instead of largefiles. Based on the
582 # resulting standins update the largefiles. Then return the standins
582 # resulting standins update the largefiles.
583 # to their proper state
584 def overriderevert(orig, ui, repo, *pats, **opts):
583 def overriderevert(orig, ui, repo, *pats, **opts):
585 # Because we put the standins in a bad state (by updating them)
584 # Because we put the standins in a bad state (by updating them)
586 # and then return them to a correct state we need to lock to
585 # and then return them to a correct state we need to lock to
@@ -597,8 +596,9 def overriderevert(orig, ui, repo, *pats
597 if (os.path.exists(repo.wjoin(lfutil.standin(lfile)))):
596 if (os.path.exists(repo.wjoin(lfutil.standin(lfile)))):
598 os.unlink(repo.wjoin(lfutil.standin(lfile)))
597 os.unlink(repo.wjoin(lfutil.standin(lfile)))
599
598
599 oldstandins = lfutil.getstandinsstate(repo)
600
600 try:
601 try:
601 ctx = scmutil.revsingle(repo, opts.get('rev'))
602 def overridematch(ctx, pats=[], opts={}, globbed=False,
602 def overridematch(ctx, pats=[], opts={}, globbed=False,
603 default='relpath'):
603 default='relpath'):
604 match = oldmatch(ctx, pats, opts, globbed, default)
604 match = oldmatch(ctx, pats, opts, globbed, default)
@@ -616,50 +616,21 def overriderevert(orig, ui, repo, *pats
616 origmatchfn = m.matchfn
616 origmatchfn = m.matchfn
617 def matchfn(f):
617 def matchfn(f):
618 if lfutil.isstandin(f):
618 if lfutil.isstandin(f):
619 # We need to keep track of what largefiles are being
619 return (origmatchfn(lfutil.splitstandin(f)) and
620 # matched so we know which ones to update later --
620 (f in repo[None] or f in ctx))
621 # otherwise we accidentally revert changes to other
622 # largefiles. This is repo-specific, so duckpunch the
623 # repo object to keep the list of largefiles for us
624 # later.
625 if origmatchfn(lfutil.splitstandin(f)) and \
626 (f in repo[None] or f in ctx):
627 lfileslist = getattr(repo, '_lfilestoupdate', [])
628 lfileslist.append(lfutil.splitstandin(f))
629 repo._lfilestoupdate = lfileslist
630 return True
631 else:
632 return False
633 return origmatchfn(f)
621 return origmatchfn(f)
634 m.matchfn = matchfn
622 m.matchfn = matchfn
635 return m
623 return m
636 oldmatch = installmatchfn(overridematch)
624 oldmatch = installmatchfn(overridematch)
637 scmutil.match
625 overridematch(repo[None], pats, opts)
638 matches = overridematch(repo[None], pats, opts)
639 orig(ui, repo, *pats, **opts)
626 orig(ui, repo, *pats, **opts)
640 finally:
627 finally:
641 restorematchfn()
628 restorematchfn()
642 lfileslist = getattr(repo, '_lfilestoupdate', [])
643 lfcommands.updatelfiles(ui, repo, filelist=lfileslist,
644 printmessage=False)
645
629
646 # empty out the largefiles list so we start fresh next time
630 newstandins = lfutil.getstandinsstate(repo)
647 repo._lfilestoupdate = []
631 filelist = lfutil.getlfilestoupdate(oldstandins, newstandins)
648 for lfile in modified:
632 lfcommands.updatelfiles(ui, repo, filelist, printmessage=False)
649 if lfile in lfileslist:
633
650 if os.path.exists(repo.wjoin(lfutil.standin(lfile))) and lfile\
651 in repo['.']:
652 lfutil.writestandin(repo, lfutil.standin(lfile),
653 repo['.'][lfile].data().strip(),
654 'x' in repo['.'][lfile].flags())
655 lfdirstate = lfutil.openlfdirstate(ui, repo)
656 for lfile in added:
657 standin = lfutil.standin(lfile)
658 if standin not in ctx and (standin in matches or opts.get('all')):
659 if lfile in lfdirstate:
660 lfdirstate.drop(lfile)
661 util.unlinkpath(repo.wjoin(standin))
662 lfdirstate.write()
663 finally:
634 finally:
664 wlock.release()
635 wlock.release()
665
636
General Comments 0
You need to be logged in to leave comments. Login now