hgext/largefiles/overrides.py
changeset 45298 a3cd63d6005b
parent 45297 ab57793dec5b
child 45344 4c6004afd836
equal deleted inserted replaced
45297:ab57793dec5b 45298:a3cd63d6005b
    49 )
    49 )
    50 
    50 
    51 eh = exthelper.exthelper()
    51 eh = exthelper.exthelper()
    52 
    52 
    53 lfstatus = lfutil.lfstatus
    53 lfstatus = lfutil.lfstatus
       
    54 
       
    55 MERGE_ACTION_LARGEFILE_MARK_REMOVED = b'lfmr'
    54 
    56 
    55 # -- Utility functions: commonly/repeatedly needed functionality ---------------
    57 # -- Utility functions: commonly/repeatedly needed functionality ---------------
    56 
    58 
    57 
    59 
    58 def composelargefilematcher(match, manifest):
    60 def composelargefilematcher(match, manifest):
   493         orig(ui, fakerepo, *pats, **opts)
   495         orig(ui, fakerepo, *pats, **opts)
   494     else:
   496     else:
   495         orig(ui, repo, *pats, **opts)
   497         orig(ui, repo, *pats, **opts)
   496 
   498 
   497 
   499 
   498 # Register the `lfmr` merge action in emptyactions() return type
   500 # Register the MERGE_ACTION_LARGEFILE_MARK_REMOVED in emptyactions() return type
   499 @eh.wrapfunction(merge, b'emptyactions')
   501 @eh.wrapfunction(merge, b'emptyactions')
   500 def overrideemptyactions(origfn):
   502 def overrideemptyactions(origfn):
   501     ret = origfn()
   503     ret = origfn()
   502     ret[b'lfmr'] = []
   504     ret[MERGE_ACTION_LARGEFILE_MARK_REMOVED] = []
   503     return ret
   505     return ret
   504 
   506 
   505 
   507 
   506 # Before starting the manifest merge, merge.updates will call
   508 # Before starting the manifest merge, merge.updates will call
   507 # _checkunknownfile to check if there are any files in the merged-in
   509 # _checkunknownfile to check if there are any files in the merged-in
   621                     mresult.addfile(standin, b'k', None, b'replaces standin')
   623                     mresult.addfile(standin, b'k', None, b'replaces standin')
   622                 else:
   624                 else:
   623                     # "lfile" should be marked as "removed" without
   625                     # "lfile" should be marked as "removed" without
   624                     # removal of itself
   626                     # removal of itself
   625                     mresult.addfile(
   627                     mresult.addfile(
   626                         lfile, b'lfmr', None, b'forget non-standin largefile',
   628                         lfile,
       
   629                         MERGE_ACTION_LARGEFILE_MARK_REMOVED,
       
   630                         None,
       
   631                         b'forget non-standin largefile',
   627                     )
   632                     )
   628 
   633 
   629                     # linear-merge should treat this largefile as 're-added'
   634                     # linear-merge should treat this largefile as 're-added'
   630                     mresult.addfile(standin, b'a', None, b'keep standin')
   635                     mresult.addfile(standin, b'a', None, b'keep standin')
   631             else:  # pick remote normal file
   636             else:  # pick remote normal file
   637     return mresult
   642     return mresult
   638 
   643 
   639 
   644 
   640 @eh.wrapfunction(mergestatemod, b'recordupdates')
   645 @eh.wrapfunction(mergestatemod, b'recordupdates')
   641 def mergerecordupdates(orig, repo, actions, branchmerge, getfiledata):
   646 def mergerecordupdates(orig, repo, actions, branchmerge, getfiledata):
   642     if b'lfmr' in actions:
   647     if MERGE_ACTION_LARGEFILE_MARK_REMOVED in actions:
   643         lfdirstate = lfutil.openlfdirstate(repo.ui, repo)
   648         lfdirstate = lfutil.openlfdirstate(repo.ui, repo)
   644         for lfile, args, msg in actions[b'lfmr']:
   649         for lfile, args, msg in actions[MERGE_ACTION_LARGEFILE_MARK_REMOVED]:
   645             # this should be executed before 'orig', to execute 'remove'
   650             # this should be executed before 'orig', to execute 'remove'
   646             # before all other actions
   651             # before all other actions
   647             repo.dirstate.remove(lfile)
   652             repo.dirstate.remove(lfile)
   648             # make sure lfile doesn't get synclfdirstate'd as normal
   653             # make sure lfile doesn't get synclfdirstate'd as normal
   649             lfdirstate.add(lfile)
   654             lfdirstate.add(lfile)