hgext/largefiles/overrides.py
changeset 22196 23fe278bde43
parent 22194 216942807308
child 22283 cb556ea76dcd
equal deleted inserted replaced
22195:1dad76c0afb7 22196:23fe278bde43
   428         return actions
   428         return actions
   429 
   429 
   430     removes = set(a[0] for a in actions['r'])
   430     removes = set(a[0] for a in actions['r'])
   431 
   431 
   432     newglist = []
   432     newglist = []
       
   433     lfmr = [] # LargeFiles: Mark as Removed
   433     for action in actions['g']:
   434     for action in actions['g']:
   434         f, args, msg = action
   435         f, args, msg = action
   435         splitstandin = f and lfutil.splitstandin(f)
   436         splitstandin = f and lfutil.splitstandin(f)
   436         if (splitstandin is not None and
   437         if (splitstandin is not None and
   437             splitstandin in p1 and splitstandin not in removes):
   438             splitstandin in p1 and splitstandin not in removes):
   454             lfile = f
   455             lfile = f
   455             msg = _('remote turned local largefile %s into a normal file\n'
   456             msg = _('remote turned local largefile %s into a normal file\n'
   456                     'keep (l)argefile or use (n)ormal file?'
   457                     'keep (l)argefile or use (n)ormal file?'
   457                     '$$ &Largefile $$ &Normal file') % lfile
   458                     '$$ &Largefile $$ &Normal file') % lfile
   458             if repo.ui.promptchoice(msg, 0) == 0:
   459             if repo.ui.promptchoice(msg, 0) == 0:
   459                 actions['r'].append((lfile, None, msg))
   460                 if branchmerge:
       
   461                     # largefile can be restored from standin safely
       
   462                     actions['r'].append((lfile, None, msg))
       
   463                 else:
       
   464                     # "lfile" should be marked as "removed" without
       
   465                     # removal of itself
       
   466                     lfmr.append((lfile, None, msg))
       
   467 
       
   468                     # linear-merge should treat this largefile as 're-added'
       
   469                     actions['a'].append((standin, None, msg))
   460             else:
   470             else:
   461                 actions['r'].append((standin, None, msg))
   471                 actions['r'].append((standin, None, msg))
   462                 newglist.append((lfile, (p2.flags(lfile),), msg))
   472                 newglist.append((lfile, (p2.flags(lfile),), msg))
   463         else:
   473         else:
   464             newglist.append(action)
   474             newglist.append(action)
   465 
   475 
   466     newglist.sort()
   476     newglist.sort()
   467     actions['g'] = newglist
   477     actions['g'] = newglist
       
   478     if lfmr:
       
   479         lfmr.sort()
       
   480         actions['lfmr'] = lfmr
   468 
   481 
   469     return actions
   482     return actions
       
   483 
       
   484 def mergerecordupdates(orig, repo, actions, branchmerge):
       
   485     if 'lfmr' in actions:
       
   486         # this should be executed before 'orig', to execute 'remove'
       
   487         # before all other actions
       
   488         for lfile, args, msg in actions['lfmr']:
       
   489             repo.dirstate.remove(lfile)
       
   490 
       
   491     return orig(repo, actions, branchmerge)
       
   492 
   470 
   493 
   471 # Override filemerge to prompt the user about how they wish to merge
   494 # Override filemerge to prompt the user about how they wish to merge
   472 # largefiles. This will handle identical edits without prompting the user.
   495 # largefiles. This will handle identical edits without prompting the user.
   473 def overridefilemerge(origfn, repo, mynode, orig, fcd, fco, fca, labels=None):
   496 def overridefilemerge(origfn, repo, mynode, orig, fcd, fco, fca, labels=None):
   474     if not lfutil.isstandin(orig):
   497     if not lfutil.isstandin(orig):