diff hgext/largefiles/overrides.py @ 15916:c96148346af8

largefiles: cache new largefiles for new heads when pulling When the user pulls from a remote repository that is not his default repo, it is quite likely that he will pull a new head. This means that if he tries to merge or rebase with the other head, he will run into a problem becuase largefiles has no way of tracking where the remote repository for this other head is, so it cannot download the largefiles from this other remote repository. It will attempt to download them from its default remote repository, which will not yet contain the largefiles. This patch solves this problem by caching any new largefiles for all heads directly into the system cache at the time of the pull, so they are available later. This behavior is actually more in line with Mercurial's distributed nature, because pulling already implies we have a connection to the remote server, but merging or rebasing does not.
author Na'Tosha Bard <natosha@unity3d.com>
date Wed, 18 Jan 2012 11:33:14 +0100
parents 264087940d5b
children 2dc599583ebe
line wrap: on
line diff
--- a/hgext/largefiles/overrides.py	Wed Jan 18 14:33:19 2012 +0100
+++ b/hgext/largefiles/overrides.py	Wed Jan 18 11:33:14 2012 +0100
@@ -658,6 +658,19 @@
         if not source:
             source = 'default'
         result = orig(ui, repo, source, **opts)
+        # If we do not have the new largefiles for any new heads we pulled, we
+        # will run into a problem later if we try to merge or rebase with one of
+        # these heads, so cache the largefiles now direclty into the system
+        # cache.
+        ui.status(_("caching new largefiles\n"))
+        numcached = 0
+        branches = repo.branchmap()
+        for branch in branches:
+            heads = repo.branchheads(branch)
+            for head in heads:
+                (cached, missing) = lfcommands.cachelfiles(ui, repo, head)
+                numcached += len(cached)
+        ui.status(_("%d largefiles cached\n" % numcached))
     return result
 
 def override_rebase(orig, ui, repo, **opts):