--- a/hgext/largefiles/basestore.py Sat Feb 23 22:54:57 2013 +0100
+++ b/hgext/largefiles/basestore.py Thu Feb 28 14:51:59 2013 +0100
@@ -60,6 +60,8 @@
missing = []
ui = self.ui
+ util.makedirs(lfutil.storepath(self.repo, ''))
+
at = 0
for filename, hash in files:
ui.progress(_('getting largefiles'), at, unit='lfile',
--- a/hgext/largefiles/lfcommands.py Sat Feb 23 22:54:57 2013 +0100
+++ b/hgext/largefiles/lfcommands.py Thu Feb 28 14:51:59 2013 +0100
@@ -8,7 +8,7 @@
'''High-level command function for lfconvert, plus the cmdtable.'''
-import os
+import os, errno
import shutil
from mercurial import util, match as match_, hg, node, context, error, \
@@ -403,22 +403,13 @@
toget = []
for lfile in lfiles:
- # If we are mid-merge, then we have to trust the standin that is in the
- # working copy to have the correct hashvalue. This is because the
- # original hg.merge() already updated the standin as part of the normal
- # merge process -- we just have to update the largefile to match.
- if (getattr(repo, "_ismerging", False) and
- os.path.exists(repo.wjoin(lfutil.standin(lfile)))):
- expectedhash = lfutil.readstandin(repo, lfile)
- else:
+ try:
expectedhash = repo[node][lfutil.standin(lfile)].data().strip()
-
- # if it exists and its hash matches, it might have been locally
- # modified before updating and the user chose 'local'. in this case,
- # it will not be in any store, so don't look for it.
- if ((not os.path.exists(repo.wjoin(lfile)) or
- expectedhash != lfutil.hashfile(repo.wjoin(lfile))) and
- not lfutil.findfile(repo, expectedhash)):
+ except IOError, err:
+ if err.errno == errno.ENOENT:
+ continue # node must be None and standin wasn't found in wctx
+ raise
+ if not lfutil.findfile(repo, expectedhash):
toget.append((lfile, expectedhash))
if toget:
@@ -435,11 +426,12 @@
pass
totalsuccess = 0
totalmissing = 0
- for ctx in cmdutil.walkchangerevs(repo, matchfn, {'rev' : rev},
- prepare):
- success, missing = cachelfiles(ui, repo, ctx.node())
- totalsuccess += len(success)
- totalmissing += len(missing)
+ if rev != []: # walkchangerevs on empty list would return all revs
+ for ctx in cmdutil.walkchangerevs(repo, matchfn, {'rev' : rev},
+ prepare):
+ success, missing = cachelfiles(ui, repo, ctx.node())
+ totalsuccess += len(success)
+ totalmissing += len(missing)
ui.status(_("%d additional largefiles cached\n") % totalsuccess)
if totalmissing > 0:
ui.status(_("%d largefiles failed to download\n") % totalmissing)
@@ -458,7 +450,7 @@
if printmessage and lfiles:
ui.status(_('getting changed largefiles\n'))
printed = True
- cachelfiles(ui, repo, '.', lfiles)
+ cachelfiles(ui, repo, None, lfiles)
updated, removed = 0, 0
for f in lfiles:
@@ -500,6 +492,8 @@
# use normallookup() to allocate entry in largefiles dirstate,
# because lack of it misleads lfilesrepo.status() into
# recognition that such cache missing files are REMOVED.
+ if lfile not in repo[None]: # not switched to normal file
+ util.unlinkpath(abslfile, ignoremissing=True)
lfdirstate.normallookup(lfile)
return None # don't try to set the mode
else:
--- a/hgext/largefiles/lfutil.py Sat Feb 23 22:54:57 2013 +0100
+++ b/hgext/largefiles/lfutil.py Thu Feb 28 14:51:59 2013 +0100
@@ -225,13 +225,9 @@
standindir = repo.wjoin(shortname)
if pats:
pats = [os.path.join(standindir, pat) for pat in pats]
- elif os.path.isdir(standindir):
+ else:
# no patterns: relative to repo root
pats = [standindir]
- else:
- # no patterns and no standin dir: return matcher that matches nothing
- return match_.match(repo.root, None, [], exact=True)
-
# no warnings about missing files or directories
match = scmutil.match(repo[None], pats, opts)
match.bad = lambda f, msg: None
--- a/hgext/largefiles/overrides.py Sat Feb 23 22:54:57 2013 +0100
+++ b/hgext/largefiles/overrides.py Thu Feb 28 14:51:59 2013 +0100
@@ -686,15 +686,8 @@
return result
def hgmerge(orig, repo, node, force=None, remind=True):
- # Mark the repo as being in the middle of a merge, so that
- # updatelfiles() will know that it needs to trust the standins in
- # the working copy, not in the standins in the current node
- repo._ismerging = True
- try:
- result = orig(repo, node, force, remind)
- lfcommands.updatelfiles(repo.ui, repo)
- finally:
- repo._ismerging = False
+ result = orig(repo, node, force, remind)
+ lfcommands.updatelfiles(repo.ui, repo)
return result
# When we rebase a repository with remotely changed largefiles, we need to
@@ -751,7 +744,7 @@
if opts.get('all_largefiles'):
revspostpull = len(repo)
revs = []
- for rev in xrange(revsprepull + 1, revspostpull):
+ for rev in xrange(revsprepull, revspostpull):
revs.append(repo[rev].rev())
lfcommands.downloadlfiles(ui, repo, revs)
return result
--- a/hgext/largefiles/reposetup.py Sat Feb 23 22:54:57 2013 +0100
+++ b/hgext/largefiles/reposetup.py Thu Feb 28 14:51:59 2013 +0100
@@ -299,9 +299,9 @@
lfdirstate = lfutil.openlfdirstate(ui, self)
dirtymatch = match_.always(self.root, self.getcwd())
s = lfdirstate.status(dirtymatch, [], False, False, False)
- modifiedfiles = []
- for i in s:
- modifiedfiles.extend(i)
+ (unsure, modified, added, removed, _missing, _unknown,
+ _ignored, _clean) = s
+ modifiedfiles = unsure + modified + added + removed
lfiles = lfutil.listlfiles(self)
# this only loops through largefiles that exist (not
# removed/renamed)
--- a/mercurial/templatefilters.py Sat Feb 23 22:54:57 2013 +0100
+++ b/mercurial/templatefilters.py Thu Feb 28 14:51:59 2013 +0100
@@ -5,6 +5,7 @@
# This software may be used and distributed according to the terms of the
# GNU General Public License version 2 or any later version.
+from i18n import _
import cgi, re, os, time, urllib
import encoding, node, util, error
import hbisect
--- a/tests/test-issue3084.t Sat Feb 23 22:54:57 2013 +0100
+++ b/tests/test-issue3084.t Thu Feb 28 14:51:59 2013 +0100
@@ -31,6 +31,8 @@
foo has been turned into a largefile
use (l)argefile or keep as (n)ormal file? 0 files updated, 0 files merged, 1 files removed, 0 files unresolved
(branch merge, don't forget to commit)
+ getting changed largefiles
+ 0 largefiles updated, 0 removed
$ hg status
$ cat foo
--- a/tests/test-largefiles-cache.t Sat Feb 23 22:54:57 2013 +0100
+++ b/tests/test-largefiles-cache.t Thu Feb 28 14:51:59 2013 +0100
@@ -16,6 +16,9 @@
$ echo large > large
$ hg add --large large
$ hg commit -m 'add largefile'
+ $ hg rm large
+ $ hg commit -m 'branchhead without largefile'
+ $ hg up -qr 0
$ cd ..
Discard all cached largefiles in USERCACHE
@@ -35,14 +38,14 @@
adding changesets
adding manifests
adding file changes
- added 1 changesets with 1 changes to 1 files
+ added 2 changesets with 1 changes to 1 files
(run 'hg update' to get a working copy)
Update working directory to "tip", which requires largefile("large"),
but there is no cache file for it. So, hg must treat it as
"missing"(!) file.
- $ hg update
+ $ hg update -r0
getting changed largefiles
error getting id 7f7097b041ccf68cc5561e9600da4655d21c6d18 from url file:$TESTTMP/mirror for file large: can't get file locally (glob)
0 largefiles updated, 0 removed
@@ -59,7 +62,7 @@
Update working directory to tip, again.
- $ hg update
+ $ hg update -r0
getting changed largefiles
error getting id 7f7097b041ccf68cc5561e9600da4655d21c6d18 from url file:$TESTTMP/mirror for file large: can't get file locally (glob)
0 largefiles updated, 0 removed
@@ -68,6 +71,17 @@
! large
$ cd ..
+Verify that largefiles from pulled branchheads are fetched, also to an empty repo
+
+ $ hg init mirror2
+ $ hg -R mirror2 pull src -r0
+ pulling from src
+ adding changesets
+ adding manifests
+ adding file changes
+ added 1 changesets with 1 changes to 1 files
+ (run 'hg update' to get a working copy)
+
#if unix-permissions
Portable way to print file permissions:
@@ -88,6 +102,7 @@
$ chmod 660 large
$ echo change >> large
$ hg commit -m change
+ created new head
$ ../ls-l.py .hg/largefiles/e151b474069de4ca6898f67ce2f2a7263adf8fea
640
--- a/tests/test-largefiles.t Sat Feb 23 22:54:57 2013 +0100
+++ b/tests/test-largefiles.t Thu Feb 28 14:51:59 2013 +0100
@@ -917,8 +917,12 @@
$ cd d
More rebase testing, but also test that the largefiles are downloaded from
-'default' instead of 'default-push' when no source is specified (issue3584).
-The error messages go away if repo 'b' is created with --all-largefiles.
+'default-push' when no source is specified (issue3584). (The largefile from the
+pulled revision is however not downloaded but found in the local cache.)
+Largefiles are fetched for the new pulled revision, not for existing revisions,
+rebased or not.
+
+ $ [ ! -f .hg/largefiles/e166e74c7303192238d60af5a9c4ce9bef0b7928 ]
$ hg pull --rebase --all-largefiles --config paths.default-push=bogus/path --config paths.default=../b
pulling from $TESTTMP/b (glob)
searching for changes
@@ -930,18 +934,9 @@
M sub/normal4
M sub2/large6
saved backup bundle to $TESTTMP/d/.hg/strip-backup/f574fb32bb45-backup.hg (glob)
- error getting id eb7338044dc27f9bc59b8dd5a246b065ead7a9c4 from url file:$TESTTMP/b for file large3: can't get file locally (glob)
- error getting id eb7338044dc27f9bc59b8dd5a246b065ead7a9c4 from url file:$TESTTMP/b for file sub/large4: can't get file locally (glob)
- error getting id eb7338044dc27f9bc59b8dd5a246b065ead7a9c4 from url file:$TESTTMP/b for file large1: can't get file locally (glob)
- error getting id eb7338044dc27f9bc59b8dd5a246b065ead7a9c4 from url file:$TESTTMP/b for file sub/large2: can't get file locally (glob)
- error getting id eb7338044dc27f9bc59b8dd5a246b065ead7a9c4 from url file:$TESTTMP/b for file sub/large2: can't get file locally (glob)
- error getting id 5f78770c0e77ba4287ad6ef3071c9bf9c379742f from url file:$TESTTMP/b for file large1: can't get file locally (glob)
- error getting id eb7338044dc27f9bc59b8dd5a246b065ead7a9c4 from url file:$TESTTMP/b for file sub/large2: can't get file locally (glob)
- error getting id 4669e532d5b2c093a78eca010077e708a071bb64 from url file:$TESTTMP/b for file large1: can't get file locally (glob)
- error getting id 1deebade43c8c498a3c8daddac0244dc55d1331d from url file:$TESTTMP/b for file sub/large2: can't get file locally (glob)
0 additional largefiles cached
- 9 largefiles failed to download
nothing to rebase
+ $ [ -f .hg/largefiles/e166e74c7303192238d60af5a9c4ce9bef0b7928 ]
$ hg log --template '{rev}:{node|short} {desc|firstline}\n'
9:598410d3eb9a modify normal file largefile in repo d
8:a381d2c8c80e modify normal file and largefile in repo b
@@ -1229,10 +1224,76 @@
changeset 3:9e8fbc4bce62: large1 references corrupted $TESTTMP/d/.hg/largefiles/eb7338044dc27f9bc59b8dd5a246b065ead7a9c4 (glob)
changeset 4:74c02385b94c: large3 references corrupted $TESTTMP/d/.hg/largefiles/eb7338044dc27f9bc59b8dd5a246b065ead7a9c4 (glob)
changeset 4:74c02385b94c: sub/large4 references corrupted $TESTTMP/d/.hg/largefiles/eb7338044dc27f9bc59b8dd5a246b065ead7a9c4 (glob)
+ changeset 5:9d5af5072dbd: large3 references missing $TESTTMP/d/.hg/largefiles/baaf12afde9d8d67f25dab6dced0d2bf77dba47c
+ changeset 5:9d5af5072dbd: sub/large4 references missing $TESTTMP/d/.hg/largefiles/aeb2210d19f02886dde00dac279729a48471e2f9
+ changeset 6:4355d653f84f: large3 references missing $TESTTMP/d/.hg/largefiles/7838695e10da2bb75ac1156565f40a2595fa2fa0
[1]
- cleanup
$ rm $TESTTMP/d/.hg/largefiles/eb7338044dc27f9bc59b8dd5a246b065ead7a9c4
+ $ rm -f .hglf/sub/*.orig
+
+Update to revision with missing largefile - and make sure it really is missing
+
+ $ rm ${USERCACHE}/7838695e10da2bb75ac1156565f40a2595fa2fa0
+ $ hg up -r 6
+ getting changed largefiles
+ error getting id 7838695e10da2bb75ac1156565f40a2595fa2fa0 from url file:$TESTTMP/d for file large3: can't get file locally (glob)
+ 1 largefiles updated, 2 removed
+ 4 files updated, 0 files merged, 2 files removed, 0 files unresolved
+ $ rm normal3
+ $ echo >> sub/normal4
+ $ hg ci -m 'commit with missing files'
+ Invoking status precommit hook
+ M sub/normal4
+ ! large3
+ ! normal3
+ created new head
+ $ hg st
+ ! large3
+ ! normal3
+ $ hg up -r.
+ 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
+ $ hg st
+ ! large3
+ ! normal3
+ $ hg up -Cr.
+ getting changed largefiles
+ error getting id 7838695e10da2bb75ac1156565f40a2595fa2fa0 from url file:$TESTTMP/d for file large3: can't get file locally (glob)
+ 0 largefiles updated, 0 removed
+ 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
+ $ hg st
+ ! large3
+ $ hg rollback
+ repository tip rolled back to revision 9 (undo commit)
+ working directory now based on revision 6
+
+Merge with revision with missing largefile - and make sure it tries to fetch it.
+
+ $ hg up -Cqr null
+ $ echo f > f
+ $ hg ci -Am branch
+ adding f
+ Invoking status precommit hook
+ A f
+ created new head
+ $ hg merge -r 6
+ 4 files updated, 0 files merged, 0 files removed, 0 files unresolved
+ (branch merge, don't forget to commit)
+ getting changed largefiles
+ error getting id 7838695e10da2bb75ac1156565f40a2595fa2fa0 from url file:$TESTTMP/d for file large3: can't get file locally (glob)
+ 1 largefiles updated, 0 removed
+
+ $ hg rollback -q
+ $ hg up -Cq
+
+Pulling 0 revisions with --all-largefiles should not fetch for all revisions
+
+ $ hg pull --all-largefiles
+ pulling from $TESTTMP/d (glob)
+ searching for changes
+ no changes found
+ 0 additional largefiles cached
Merging does not revert to old versions of largefiles and also check
that merging after having pulled from a non-default remote works