hgext/largefiles/overrides.py
changeset 22288 4e2559841d6c
parent 22287 f3ac9677fa2b
child 22289 e26df4e774f6
equal deleted inserted replaced
22287:f3ac9677fa2b 22288:4e2559841d6c
   711         lfcommands.updatelfiles(ui, repo, filelist, printmessage=False,
   711         lfcommands.updatelfiles(ui, repo, filelist, printmessage=False,
   712                                 normallookup=True)
   712                                 normallookup=True)
   713 
   713 
   714     finally:
   714     finally:
   715         wlock.release()
   715         wlock.release()
   716 
       
   717 def hgupdaterepo(orig, repo, node, overwrite):
       
   718     wlock = repo.wlock()
       
   719     try:
       
   720         return _hgupdaterepo(orig, repo, node, overwrite)
       
   721     finally:
       
   722         wlock.release()
       
   723 
       
   724 def _hgupdaterepo(orig, repo, node, overwrite):
       
   725     if not overwrite:
       
   726         # update standins for linear merge
       
   727         lfdirstate = lfutil.openlfdirstate(repo.ui, repo)
       
   728         s = lfdirstate.status(match_.always(repo.root, repo.getcwd()),
       
   729                               [], False, False, False)
       
   730         unsure, modified, added = s[:3]
       
   731         for lfile in unsure + modified + added:
       
   732             lfutil.updatestandin(repo, lfutil.standin(lfile))
       
   733 
       
   734         # Only call updatelfiles on the standins that have changed to save time
       
   735         oldstandins = lfutil.getstandinsstate(repo)
       
   736 
       
   737     result = orig(repo, node, overwrite)
       
   738 
       
   739     filelist = None
       
   740     if not overwrite:
       
   741         newstandins = lfutil.getstandinsstate(repo)
       
   742         filelist = lfutil.getlfilestoupdate(oldstandins, newstandins)
       
   743     lfcommands.updatelfiles(repo.ui, repo, filelist=filelist)
       
   744     return result
       
   745 
       
   746 def hgmerge(orig, repo, node, force=None, remind=True):
       
   747     wlock = repo.wlock()
       
   748     try:
       
   749         return _hgmerge(orig, repo, node, force, remind)
       
   750     finally:
       
   751         wlock.release()
       
   752 
       
   753 def _hgmerge(orig, repo, node, force, remind):
       
   754     result = orig(repo, node, force, remind)
       
   755     lfcommands.updatelfiles(repo.ui, repo)
       
   756     return result
       
   757 
   716 
   758 # When we rebase a repository with remotely changed largefiles, we need to
   717 # When we rebase a repository with remotely changed largefiles, we need to
   759 # take some extra care so that the largefiles are correctly updated in the
   718 # take some extra care so that the largefiles are correctly updated in the
   760 # working copy
   719 # working copy
   761 def overridepull(orig, ui, repo, source=None, **opts):
   720 def overridepull(orig, ui, repo, source=None, **opts):
  1303     orig(sink)
  1262     orig(sink)
  1304 
  1263 
  1305 def mercurialsinkafter(orig, sink):
  1264 def mercurialsinkafter(orig, sink):
  1306     sink.repo._isconverting = False
  1265     sink.repo._isconverting = False
  1307     orig(sink)
  1266     orig(sink)
       
  1267 
       
  1268 def mergeupdate(orig, repo, node, branchmerge, force, partial,
       
  1269                 *args, **kwargs):
       
  1270     wlock = repo.wlock()
       
  1271     try:
       
  1272         # branch |       |         |
       
  1273         #  merge | force | partial | action
       
  1274         # -------+-------+---------+--------------
       
  1275         #    x   |   x   |    x    | linear-merge
       
  1276         #    o   |   x   |    x    | branch-merge
       
  1277         #    x   |   o   |    x    | overwrite (as clean update)
       
  1278         #    o   |   o   |    x    | force-branch-merge (*1)
       
  1279         #    x   |   x   |    o    |   (*)
       
  1280         #    o   |   x   |    o    |   (*)
       
  1281         #    x   |   o   |    o    | overwrite (as revert)
       
  1282         #    o   |   o   |    o    |   (*)
       
  1283         #
       
  1284         # (*) don't care
       
  1285         # (*1) deprecated, but used internally (e.g: "rebase --collapse")
       
  1286 
       
  1287         linearmerge = not branchmerge and not force and not partial
       
  1288 
       
  1289         if linearmerge or (branchmerge and force and not partial):
       
  1290             # update standins for linear-merge or force-branch-merge,
       
  1291             # because largefiles in the working directory may be modified
       
  1292             lfdirstate = lfutil.openlfdirstate(repo.ui, repo)
       
  1293             s = lfdirstate.status(match_.always(repo.root, repo.getcwd()),
       
  1294                                   [], False, False, False)
       
  1295             unsure, modified, added = s[:3]
       
  1296             for lfile in unsure + modified + added:
       
  1297                 lfutil.updatestandin(repo, lfutil.standin(lfile))
       
  1298 
       
  1299         if linearmerge:
       
  1300             # Only call updatelfiles on the standins that have changed
       
  1301             # to save time
       
  1302             oldstandins = lfutil.getstandinsstate(repo)
       
  1303 
       
  1304         result = orig(repo, node, branchmerge, force, partial, *args, **kwargs)
       
  1305 
       
  1306         filelist = None
       
  1307         if linearmerge:
       
  1308             newstandins = lfutil.getstandinsstate(repo)
       
  1309             filelist = lfutil.getlfilestoupdate(oldstandins, newstandins)
       
  1310 
       
  1311         # suppress status message while automated committing
       
  1312         printmessage = not (getattr(repo, "_isrebasing", False) or
       
  1313                             getattr(repo, "_istransplanting", False))
       
  1314         lfcommands.updatelfiles(repo.ui, repo, filelist=filelist,
       
  1315                                 printmessage=printmessage,
       
  1316                                 normallookup=partial)
       
  1317 
       
  1318         return result
       
  1319     finally:
       
  1320         wlock.release()