comparison hgext/largefiles/overrides.py @ 17658:a02c1ffddae9 stable

largefiles: handle commit -A properly, after a --large commit (issue3542) Previous to this, 'commit -A' would add as normal files, files that were already committed as largefiles, resulting in files being listed twice by 'status -A'. It also missed when (only) a largefile was deleted, even though status reported it as '!'. This also has the side effect of properly reporting the state of the affected largefiles in the post commit hook after a remove that also affected a normal file (the largefiles used to be 'R', now are properly absent). Since scmutil.addremove() is called both by the ui command (after some trivial argument validation) and during the commit process when -A is specified, it seems like a more appropriate method to wrap than the addremove command. Currently, a repo is only enabled to use largefiles after an add that explicitly identifies some file as large, and a subsequent commit. Therefore, this patch only changes behavior after such a largefile enabling commit. Note that in the test, if the final commit had a '-v', 'removing large8' would be printed twice. Both of these originate in removelargefiles(). The first print is in verbose mode after traversing remove + forget, the second is because the '_isaddremove' attr is set and 'after' is not.
author Matt Harbison <matt_harbison@yahoo.com>
date Mon, 30 Jul 2012 20:56:41 -0400
parents 6e2ab601be3f
children 67deea9c1c42 75f25bd4c7d4
comparison
equal deleted inserted replaced
17628:133d13e44544 17658:a02c1ffddae9
1016 if toupload is None: 1016 if toupload is None:
1017 ui.status(_('largefiles: No remote repo\n')) 1017 ui.status(_('largefiles: No remote repo\n'))
1018 else: 1018 else:
1019 ui.status(_('largefiles: %d to upload\n') % len(toupload)) 1019 ui.status(_('largefiles: %d to upload\n') % len(toupload))
1020 1020
1021 def overrideaddremove(orig, ui, repo, *pats, **opts): 1021 def scmutiladdremove(orig, repo, pats=[], opts={}, dry_run=None,
1022 similarity=None):
1022 if not lfutil.islfilesrepo(repo): 1023 if not lfutil.islfilesrepo(repo):
1023 return orig(ui, repo, *pats, **opts) 1024 return orig(repo, pats, opts, dry_run, similarity)
1024 # Get the list of missing largefiles so we can remove them 1025 # Get the list of missing largefiles so we can remove them
1025 lfdirstate = lfutil.openlfdirstate(ui, repo) 1026 lfdirstate = lfutil.openlfdirstate(repo.ui, repo)
1026 s = lfdirstate.status(match_.always(repo.root, repo.getcwd()), [], False, 1027 s = lfdirstate.status(match_.always(repo.root, repo.getcwd()), [], False,
1027 False, False) 1028 False, False)
1028 (unsure, modified, added, removed, missing, unknown, ignored, clean) = s 1029 (unsure, modified, added, removed, missing, unknown, ignored, clean) = s
1029 1030
1030 # Call into the normal remove code, but the removing of the standin, we want 1031 # Call into the normal remove code, but the removing of the standin, we want
1032 # we don't remove the standin in the largefiles code, preventing a very 1033 # we don't remove the standin in the largefiles code, preventing a very
1033 # confused state later. 1034 # confused state later.
1034 if missing: 1035 if missing:
1035 m = [repo.wjoin(f) for f in missing] 1036 m = [repo.wjoin(f) for f in missing]
1036 repo._isaddremove = True 1037 repo._isaddremove = True
1037 removelargefiles(ui, repo, *m, **opts) 1038 removelargefiles(repo.ui, repo, *m, **opts)
1038 repo._isaddremove = False 1039 repo._isaddremove = False
1039 # Call into the normal add code, and any files that *should* be added as 1040 # Call into the normal add code, and any files that *should* be added as
1040 # largefiles will be 1041 # largefiles will be
1041 addlargefiles(ui, repo, *pats, **opts) 1042 addlargefiles(repo.ui, repo, *pats, **opts)
1042 # Now that we've handled largefiles, hand off to the original addremove 1043 # Now that we've handled largefiles, hand off to the original addremove
1043 # function to take care of the rest. Make sure it doesn't do anything with 1044 # function to take care of the rest. Make sure it doesn't do anything with
1044 # largefiles by installing a matcher that will ignore them. 1045 # largefiles by installing a matcher that will ignore them.
1045 installnormalfilesmatchfn(repo[None].manifest()) 1046 installnormalfilesmatchfn(repo[None].manifest())
1046 result = orig(ui, repo, *pats, **opts) 1047 result = orig(repo, pats, opts, dry_run, similarity)
1047 restorematchfn() 1048 restorematchfn()
1048 return result 1049 return result
1049 1050
1050 # Calling purge with --all will cause the largefiles to be deleted. 1051 # Calling purge with --all will cause the largefiles to be deleted.
1051 # Override repo.status to prevent this from happening. 1052 # Override repo.status to prevent this from happening.