Commit Graph

625 Commits

Author SHA1 Message Date
Mads Kiilerich
2cc2b0c179 largefiles: remove silent handling of incorrect invocation of restorematchfn
It is better to get a crash than to continue without noticing errors.
2014-04-13 18:45:43 +02:00
Mads Kiilerich
4308622a72 largefiles: copy override, install matchfn outside the try/except restoring it 2014-04-13 18:45:43 +02:00
Mads Kiilerich
a14df815dc largefiles: clarify installmatchfn documentation 2014-04-13 18:45:43 +02:00
Mads Kiilerich
b4a84e042b largefiles: use more reasonable locking for update 2013-04-27 23:19:52 +02:00
Mads Kiilerich
368894e240 largefiles: full debugdirstate functionality for largefiles
- just reusing the original command with a mockup repo.

This makes it possible to see dates in the lfdirstate and gives less code
duplication.
2013-04-27 23:19:52 +02:00
Mads Kiilerich
4d1cd6d065 largefiles: make cat on standins do something
cat of a standin would silently fail.

The use of standins is mostly an implementation detail, but it is already a bit
leaking. Being able to see the content of standins might be convenient for
debugging.
2013-04-27 23:19:52 +02:00
Mads Kiilerich
6cef420525 largefiles: remove confusing handling of .bad return value - it is void 2014-04-13 18:45:43 +02:00
Mads Kiilerich
428d9fe9e0 largefiles: fix profile of unused largefilesdirstate._ignore 2013-10-03 18:01:21 +02:00
Mads Kiilerich
7cd32f165e largefiles: import whole modules instead of importing parts of them
Be more friendly to demandimport.
2014-04-08 00:48:36 +02:00
Mads Kiilerich
fc84595707 largefiles: update should only create a .orig backup of a largefile once
A .orig of a standin after the update do that a .orig of the actual largefile
is created. The .orig standin was however never removed again and the largefile
.orig was thus overwritten again and again.

The fix: remove the standin .orig when it is used.
2013-04-18 18:56:18 +02:00
Mads Kiilerich
5a86bd87e5 merge: pass merge ancestor to calculateupdates as a list
The list will so far always have one element.
2014-04-06 13:39:51 +02:00
Mads Kiilerich
41480e1b79 merge: move ancestor selection tweaking from manifestmerge to update function
- passing it through calculateupdates.

This will make sure manifestmerge actually use the ancestor it is given.
2014-04-06 13:39:51 +02:00
FUJIWARA Katsunori
039223a68b largefiles: remove no more referred "getoutgoinglfiles()" 2014-04-16 00:37:24 +09:00
FUJIWARA Katsunori
0c85153450 largefiles: use "outgoinghooks" to avoid redundant outgoing check
Before this patch, "hg outgoing" invokes "findcommonoutgoing()" not
only in "commands.outgoing()" but also in
"overrides.overrideoutgoing()" (via "getoutgoinglfiles()"), when
largefiles is enabled. The latter is redundant.

This patch uses "outgoinghooks" to avoid redundant outgoing check.

Newly introduced function "overrides.outgoinghook()" is registered
into "outgoinghooks" to get the result of outgoing check in
"commands.outgoing()".

It invokes "lfutil.getlfilestoupload()" directly with the result of
outgoing check to avoid redundant outgoing check in
"getoutgoinglfiles()": "sort()" is needed, because
"lfutil.getlfilestoupload()" doesn't sort the result of it.

This patch also omits "if toupload is None" ("No remote repo") case,
because failure of looking remote repository up should raise exception
in "commands.outgoing()" before invocation of "outgoinghooks".

Newly added "hg outgoing --large --graph" tests examine
"outgoinghooks" invocations in "hg outgoing --graph" code path.
2014-04-16 00:37:24 +09:00
FUJIWARA Katsunori
22be41c2e5 largefiles: use "summaryremotehooks" to avoid redundant outgoing check
Before this patch, "hg summary --remote --large" invokes
"findcommonoutgoing()" not only in "commands.summary()" but also in
"overrides.overridesummary()" (via "getoutgoinglfiles()"). The latter
is redundant.

This patch uses "summaryremotehooks" to avoid redundant outgoing check.

Newly introduced function "overrides.summaryremotehook()" is
registered into "summaryremotehooks" to get the result of outgoing
check in "commands.summary()".

It invokes "lfutil.getlfilestoupload()" directly with the result of
outgoing check to avoid redundant outgoing check in
"getoutgoinglfiles()".
2014-04-16 00:37:24 +09:00
FUJIWARA Katsunori
3da856bfcc largefiles: reuse "findcommonoutgoing()" result at "hg push"
Before this patch, "hg push" invokes "findcommonoutgoing()" not only
in "exchange.push()" but also in "lfilesrepo.push()", when largefiles
is enabled. The latter is redundant.

This patch registers own "prepushoutgoinghook" function into
"prepushoutgoinghooks" of "localrepository" to reuse
"findcommonoutgoing()" result.

"prepushoutgoinghook" omits "changelog.nodesbetween()" invocation,
because "findcommonoutgoing()" invocation in "exchange.push()" takes
"onlyheads" argument and it considers "nodesbetween()".
2014-04-16 00:37:24 +09:00
FUJIWARA Katsunori
a3f2ae29d0 largefiles: centralize the logic to get outgoing largefiles
Before this patch, "overrides.getoutgoinglfiles()" (called by
"overrideoutgoing()" and "overridesummary()") and "lfilesrepo.push()"
implement similar logic to get outgoing largefiles separately.

This patch centralizes the logic to get outgoing largefiles in
"lfutil.getlfilestoupload()".

"lfutil.getlfilestoupload()" takes "addfunc" argument, because each
callers need different information (and it is useful for enhancement
in the future).

  - "overrides.getoutgoinglfiles()" needs only filenames
  - "lfilesrepo.push()" needs only hashes of largefiles
2014-04-16 00:37:24 +09:00
Mads Kiilerich
a723522899 largefiles: don't prompt when one side of merge was changed but didn't change
This can happen after backout or grafts or criss cross merges. We already do
the same (but slightly different) thing in manifestmerge and filemerge.
2014-04-07 23:10:20 +02:00
Matt Mackall
c9eb4517fa merge with stable 2014-04-01 15:11:19 -05:00
FUJIWARA Katsunori
01d8b27701 i18n: fix "% inside _()" problems
Before this patch, "contrib/check-code.py" can't detect these
problems, because the regexp pattern to detect "% inside _()" doesn't
suppose the case that the format string and "%" aren't placed in the
same line.

This patch replaces "\s" in that regexp pattern with "[ \t\n]" to
detect "% inside _()" problems in such case.

"[\s\n]" can't be used in this purpose, because "\s" is automatically
replaced with "[ \t]" by "_preparepats()" and "\s" in "[]" causes
nested "[]" unexpectedly.
2014-04-01 02:46:03 +09:00
FUJIWARA Katsunori
920a8f861c hg: introduce "wirepeersetupfuncs" to setup wire peer by extensions (issue4109)
Since changeset a8955c4d9ef5, "reposetup()" of each extensions is
invoked only on repositories enabling corresponded extensions.

This causes that largefiles specific interactions between the
repository enabling largefiles locally and remote (wire) peer fail,
because there is no way to know whether largefiles is enabled on the
remote repository behind the wire peer, and largefiles specific
"wireproto functions" are not given to any wire peers.

To avoid this problem, largefiles should be enabled in wider scope
than each repositories (e.g. user-wide "${HOME}/.hgrc").

This patch introduces "wirepeersetupfuncs" to setup wire peer by
extensions already enabled. Functions registered into
"wirepeersetupfuncs" are invoked for all wire peers.

This patch uses plain list instead of "util.hooks" for
"wirepeersetupfuncs", because the former allows to control order of
function invocation by order of extension enabling: it may be useful
for workaround of problems with combination of enabled extensions
2014-03-29 01:20:07 +09:00
Kevin Bullock
c63d1fcf68 merge with stable
This should correct an earlier couple of bad merges (5433856b2558 and
596960a4ad0d, now pruned) that accidentally brought in a change that had
been marked obsolete (244ac996a821).
2014-03-31 10:12:07 -05:00
Mads Kiilerich
2629efac4f config: set a 'source' in most cases where config don't come from file but code
Some extensions set configuration settings that showed up in 'hg showconfig
--debug' with 'none' as source. That was confusing.

Instead, they will now tell which extension they come from.

This change tries to be consistent and specify a source everywhere - also where
it perhaps is less relevant.
2014-03-19 02:45:14 +01:00
Augie Fackler
ad0fddea79 check-code: disallow use of dict(key=value) construction
{} literals are faster and more consistent across Python 2 and 3.

Whitelisted the one use of dict() that is using a generator expresion.
2014-03-12 13:31:27 -04:00
Mads Kiilerich
7ee3d68332 largefiles: override calculateupdates instead of manifestmerge
That will give calculateupdates a purpose in life ... and be convenient later.
2014-03-02 18:30:41 +01:00
Lucas Moscovicz
e0f8aa1f35 hgext: updated extensions to return a baseset when adding symbols 2014-02-11 09:00:38 -08:00
Mads Kiilerich
5c02304224 largefiles: stylistic cleanup of filemerge 2013-11-16 15:54:41 -05:00
Mads Kiilerich
19967e8476 largefiles: show hashes before prompting for conflict resolution
The largefile hashes are mostly an implementation detail, but they are "leaked"
in several places anyway, and showing the hashes is better than not giving the
user any information about the options in the prompt.

The hashes are long, but it is largefile hashes and it would thus be confusing
to shorten them.
2013-11-16 15:46:29 -05:00
Mads Kiilerich
d6cfe18be7 largefiles: don't try to explain rename history before prompt for conflicts
Before it tried to explain the exact situation when merging moved largefiles.
That do not happen for normal merges and is not more relevant for largefiles
than for normal files. It is unneeded complexity - remove it.
2013-11-16 15:46:29 -05:00
Mads Kiilerich
af7f586373 largefiles: drop redundant special handling of merges of renames
It is unclear what cases this was supposed to cover but it do no longer seem
relevant.
2013-11-16 15:46:29 -05:00
Long Vu
718cfe2dd3 largefiles: call super class method with proper kwargs to respect API
Since the localrepositoyry.push() method in mercurial/localrepo.py is defined
this way:

  def push(self, remote, force=False, revs=None, newbranch=False):

it is better for largefiles to call push() on the super class with proper
kwargs to respect the API.

This will avoid breaking other extensions overriding the push method this way:

  def push(self, remote, force=False, **kwargs):
2013-12-03 13:28:04 -05:00
Matt Mackall
4223982ebe merge with stable 2013-12-01 14:10:53 -06:00
Mads Kiilerich
f2255e8146 largefiles: don't crash on 'local renamed directory' actions
a8386b4c47b1 introduced splitstandin on all action filenames. It would however
crash on 'd' actions where the filename is None.

Fix that and add test coverage for that case.
2013-11-26 15:38:33 +01:00
Mads Kiilerich
c73c847849 largefiles: update in two steps, handle interrupted updates better
An update would try to fetch any missing largefiles after having updated normal
files and standins. That could fail or be interrupted and would leave the
working directory in a state where the largefiles not only were missing but
also were scheduled for remove ... and where the old largefile was left in
place.

Instead we now remove old largefiles before starting to download and update
missing largefiles.
2013-11-07 01:56:40 +01:00
Mads Kiilerich
6b59065762 largefiles: inline _updatelfile, prepare for further refactorings 2013-11-07 01:49:48 +01:00
Mads Kiilerich
3f82a98b8e largefiles: cache largefiles for update, also without printmessage 2013-11-07 01:48:00 +01:00
Mads Kiilerich
90dc6e20e1 largefiles: cleanup of printmessage handling - the printed flag was redundant 2013-11-07 01:47:59 +01:00
Matt Mackall
6c7d99a18d merge with stable 2013-11-17 20:22:59 -05:00
Augie Fackler
213fff305a pathutil: tease out a new library to break an import cycle from canonpath use 2013-11-06 18:19:04 -05:00
Mads Kiilerich
3c628b9e09 largefiles: use 'remote'/'local' in merge prompts like in other merge prompts
Prompts like
  foo has been turned into a largefile
  use (l)argefile or keep as (n)ormal file?
was not as clear as the usual prompts that use 'remote' or 'local' to explain
what happened on which side ... especially not when used to the normal prompts.

"as" could also indicate that it would be possible to take the content of the
largefile and somehow put it into the normal file. It could make it more clear
that it was a choice between one side or the other.

For consistency we will now phrase it like:
  remote turned local normal file f into a largefile
  use (l)argefile or keep (n)ormal file?
2013-10-28 22:34:07 +01:00
Mads Kiilerich
bcec8229ea largefiles: don't prompt for normal/largefile changes when doing plain updates
We used to get like:

  $ hg up -r 2
  foo has been turned into a normal file
  keep as (l)argefile or use (n)ormal file? l
  getting changed largefiles
  0 largefiles updated, 0 removed
  0 files updated, 0 files merged, 2 files removed, 0 files unresolved
  $ cat foo
  cat: foo: No such file or directory
  [1]

- which both asked the wrong question and did the wrong thing.

Instead, skip this conflict resolution when the local conflicting file has been
scheduled for removal and there thus is no conflict.
2013-10-25 02:33:59 +08:00
Mads Kiilerich
d2031cc679 largefiles: remove extra check for file to get - it _is_ by definition in p2 2013-10-25 02:25:10 +08:00
Mads Kiilerich
db98125811 largefiles: don't process merge actions at all when overwriting 2013-10-25 01:24:10 +08:00
Mads Kiilerich
63e01aeb0a largefiles: hide passwords in URLs in ui messages 2013-10-17 16:13:15 +08:00
Mads Kiilerich
59f7203fee largefiles: don't add extra \n when displaying remote messages in putlfile 2013-10-24 01:49:56 +08:00
Mads Kiilerich
46512da6c4 largefiles: add missing \n in ui.warn messages 2013-10-21 11:22:54 +08:00
Mads Kiilerich
ee0298712d largefiles: fix 'unexpected response' warning newlines
Warnings should always end with \n. The warning message might contain or end
with \n, so better show it with repr encoding.
2013-10-24 01:49:56 +08:00
FUJIWARA Katsunori
fb1d8fd59b localrepo: invoke only feature setup functions for enabled extensions
Before this patch, each feature setup functions for localrepository
class should examine whether corresponding extension is enabled or not
by themselves.

This patch invokes only feature setup functions defined in module of
enabled extensions, and it makes implementation of feature setup
functions easier and simpler.
2013-10-17 21:45:17 +09:00
Mads Kiilerich
72342dd16e largefiles: refactor basestore, extract _gethash method 2013-10-10 04:28:44 +02:00
Mads Kiilerich
aff7af83da largefiles: make the protocol hack for replacing heads with lheads more precise
Before the hack would replace 'heads' with 'lheads' no matter where it occured
in a batch command string.

Instead we will use a regexp to more carefully only match the 'heads' commands.
2013-10-10 04:28:39 +02:00
Siddharth Agarwal
99a29f5838 largefiles: standardize error message for dirty working dir 2013-09-23 21:41:01 -07:00
FUJIWARA Katsunori
0b216b06c5 largefiles: setup "largefiles" feature in each repositories individually
Before this patch, if largefiles extension is enabled once in any of
target repositories, commands handling multiple repositories at a time
like below misunderstand that "largefiles" feature is supported also
in all other local repositories:

  - clone/pull from or push to localhost
  - recursive execution in subrepo tree

This patch registers "featuresetup()" into "featuresetupfuncs" of
"localrepository" to support "largefiles" features only in
repositories enabling largefiles extension, instead of adding
"largefiles" feature to class variable "_basesupported" of
"localrepository".

This patch also adds checking below to the largefiles specific class
derived from "localrepository":

  - push to localhost: whether features supported in the local(= dst)
    repository satisfies ones required in the remote(= src)

This can prevent useless looking up in the remote repository, when
supported and required features are mismatched: "push()" of
"localrepository" also checks it, but it is executed after looking up
in the remote.
2013-09-21 21:33:29 +09:00
FUJIWARA Katsunori
c1e7da5d4f localrepo: make supported features manageable in each repositories individually
Before this patch, all localrepositories support same features,
because supported features are managed by the class variable
"supported" of "localrepository".

For example, "largefiles" feature provided by largefiles extension is
recognized as supported, by adding the feature name to "supported" of
"localrepository".

So, commands handling multiple repositories at a time like below
misunderstand that such features are supported also in repositories
not enabling corresponded extensions:

  - clone/pull from or push to localhost
  - recursive execution in subrepo tree

"reposetup()" can't be used to fix this problem, because it is invoked
after checking whether supported features satisfy ones required in the
target repository.

So, this patch adds the set object named as "featuresetupfuncs" to
"localrepository" to manage hook functions to setup supported features
of each repositories.

If any functions are added to "featuresetupfuncs", they are invoked,
and information about supported features is managed in each
repositories individually.

This patch also adds checking below:

  - pull from localhost: whether features supported in the local(= dst)
    repository satisfies ones required in the remote(= src)

  - push to localhost: whether features supported in the remote(= dst)
    repository satisfies ones required in the local(= src)

Managing supported features by the class variable means that there is
no difference of supported features between each instances of
"localrepository" in the same Python process, so such checking is not
needed before this patch.

Even with this patch, if intermediate bundlefile is used as pulling
source, pulling indirectly from the remote repository, which requires
features more than ones supported in the local, can't be prevented,
because bundlefile has no information about "required features" in it.
2013-09-21 21:33:29 +09:00
Siddharth Agarwal
3f3eb7081b largefiles: remove bailifchanged check from overridepull (BC)
This brings pull --rebase with largefiles in line with pull --rebase without.
2013-09-20 15:26:30 -07:00
Sean Farley
fbb07e88d9 largefiles: remove unnecessary check of instance
The refactoring of all the context objects allows us to simply pass a basectx
to the __new__ constructor and have it return the same object without
allocating new memory.

This also removes the need to import the context module.
2013-08-06 15:10:09 -05:00
Wei, Elson
8a3265a449 largefiles: overridematch() should replace the file path instead of extending (issue3934) 2013-07-24 13:20:44 +08:00
Matt Mackall
13d2a13ea6 ui: merge prompt text components into a singe string
This will help avoid problems with partial or mismatched translation
of the components.
2013-05-22 17:31:43 -05:00
FUJIWARA Katsunori
72d4082125 largefiles: check unknown files with case awareness of the filesystem
Before this patch, largefiles extension checks unknown files in the
working directory always case sensitively.

This causes failure in updating from the revision X consisting of
'.hglf/A' (and "A" implicitly) to the revision Y consisting of 'a'
(not ".hglf/A") on case insensitive filesystem, because "A" in the
working directory is treated as colliding against and different from
'a' on the revision Y.

This patch uses "repo.dirstate.normalize()" to check unknown files
with case awareness of the filesystem.
2013-05-07 05:04:11 +09:00
FUJIWARA Katsunori
1d7c1875df largefiles: check existence of the file with case awareness of the filesystem
Before this patch, largefiles extension always unlinks largefiles
untracked on the target context in merging/updating after updating
working directory.

For example, it is assumed that the revision X consists of ".hglf/A"
(and "A" implicitly) and revision Y consists of "a" (not ".hglf/A").

In the case of updating from X to Y, largefiles extension tries to
unlink "A" after updating "a" in working directory. This causes
unexpected unlinking "a" on the case insensitive filesystem.

This patch checks existence of the file in the working context with
case awareness of the filesystem to prevent from such unexpected
unlinking.

"lfcommands._updatelfile()" also unlinks target file in the case
"largefile is tracked in the target context, but fails to be fetched".

This patch doesn't apply "repo.dirstate.normalize()" in this case,
because it should be already ensured in the manifest merging that
there is no normal file colliding against any largefiles.
2013-05-07 05:04:11 +09:00
Mads Kiilerich
69da8bff75 largefiles: use repo.wwrite for writing standins (issue3909) 2013-04-27 00:41:42 +02:00
Mads Kiilerich
2f9545c92c largefiles: drop repo wrapping detection
After 08202d1ef738 I see:

  $ hg id -q
  largefiles: repo method 'commit' appears to have already been wrapped by another extension: largefiles may behave incorrectly
  largefiles: repo method 'push' appears to have already been wrapped by another extension: largefiles may behave incorrectly
  3bd0c95ec1bf

The warning is bad:

* The message gives no hint what the problem is and how it can be resolved.
  The message is useless.

* Largefiles do have its share of problems, but I don't think I ever have seen
  a problem where this warning would have helped. The 'may' in the warning
  seems like an exaggeration of the risk. Having largefiles enabled in
  combination with for instance mq, hggit and hgsubversion causes a warning
  (depending on the configuration order) but do not cause problems. Extensions
  might of course be incompatible, but they can be that in many other ways.
  The check and the message are incorrect.

It would thus be better to remove the check and the warning completely.

Before 08202d1ef738 the check always failed. That change made the check work
more like intended ... but the intention was wrong. This change will thus also
back that change out.
2013-04-26 19:04:01 +02:00
Wagner Bruna
bf79f90e32 largefiles: fix typos in documentation 2013-04-19 18:26:35 -03:00
Mads Kiilerich
ec228a65b1 largefiles: wlock in status before lfdirstate.write() 2013-04-17 03:41:11 +02:00
Mads Kiilerich
9c2c68a468 largefiles: don't hash all largefiles when initializing a lfdirstate
The largefiles will be hashed on demand if necessary ... and sometimes it isn't
necessary.
2013-04-15 23:31:56 +02:00
Mads Kiilerich
9a6bd8ef12 largefiles: use filechunkiter for iterating largefile when serving getlfile
The default file iterator is line based and will give odd chunk sizes - often
very short and relatively expensive.
2013-04-16 00:40:21 +02:00
Mads Kiilerich
208aa05eca largefiles: stat all largefiles in one batch before downloading
This avoids a lot of expensive roundtrips to remote repositories ... but might
be slightly slower for local operations.

This will also change some aborts on missing files to warnings. That will in
some situations make it possible to continue working on a repository with
missing largefiles.
2013-04-15 23:37:43 +02:00
Mads Kiilerich
f099974674 largefiles: 'put' should store 'source' file in under 'hash', also in localstore 2013-04-15 23:34:36 +02:00
Mads Kiilerich
bfe49038e9 largefiles: getlfile must hit end of HTTP chunked streams to reuse connections
We did read the exactly the right number of bytes from the response body. But
if the response came in chunked encoding then that meant that the HTTP layer
still hadn't read the last 0-sized chunk and expected the app layer to read
more data from the stream. The app layer was however happy and sent another
request which had to be sent on another HTTP connection while the old one was
lingering until some other event closed the connection.

Adding an extra read where we expect to hit the end of file makes the HTTP
connection ready for reuse. This thus plugs a real socket leak.

To distinguish HTTP from SSH we look at self's class, just like it is done in
putlfile.
2013-04-16 04:35:10 +02:00
Mads Kiilerich
70924c1c48 largefiles: drop limitreader, use filechunkiter limit
filechunkiter.close was a noop.
2013-04-16 01:55:57 +02:00
Mads Kiilerich
c479eff330 largefiles: move protocol conversion into getlfile and make it an iterable
Avoid the intermediate limitreader and filechunkiter between getlfile and
copyandhash - return the right protocol and put the complexity where it better
can be managed.
2013-04-16 01:46:39 +02:00
Mads Kiilerich
eef7ef8e25 largefiles: don't close the fd passed to store._getfile 2013-04-15 23:47:04 +02:00
Mads Kiilerich
76454d8f22 largefiles: remove blecch from lfutil.copyandhash - don't close the passed fd 2013-04-15 23:43:50 +02:00
Mads Kiilerich
d9e36e98f8 largefiles: drop lfutil.blockstream - use filechunkiter like everybody else
The old chunk size is kept - just to avoid changing it.
2013-04-15 23:43:44 +02:00
Mads Kiilerich
cb8479f469 largefiles: refactoring - use findfile in localstore._getfile 2013-04-15 23:35:43 +02:00
Mads Kiilerich
9fb2d6a4da largefiles: refactoring - return hex from _getfile and copyandhash 2013-04-15 23:35:18 +02:00
Mads Kiilerich
092b44d44d largefiles: refactoring - create destination dir in lfutil.link 2013-04-15 23:32:33 +02:00
Mads Kiilerich
a83579d8b9 largefiles: deprecate --all-largefiles for pull
The same can be achieved with --lfrev pulled() and we shouldn't advertise
unnecessary command line options.
2013-04-15 01:59:11 +02:00
Mads Kiilerich
f03134c0a8 largefiles: implement pull --all-largefiles as a special case of --lfrev 2013-04-15 01:59:11 +02:00
Mads Kiilerich
fa7d021ee4 largefiles: drop --cache-largefiles again
This goes a step further than 974959d637b7 and backs out the unreleased
--cache-largefiles option. The same can be achieved with --lfrev heads(pulled()) and
we shouldn't introduce unnecessary command line options.
2013-04-15 01:59:11 +02:00
Mads Kiilerich
7e0e7a8927 largefiles: introduce pulled() revset expression for use in --lfrev
This provides a general way to do what already can be done with
--all-largefiles and --cache-largefiles.
2013-04-15 01:59:04 +02:00
Mads Kiilerich
a81c3f8371 largefiles: introduce pull --lfrev option
The revset will be evaluated after the changesets has been pulled, and missing
largefiles from matching revisions will be pulled to the local caches.

This in combination with revsets will make it possible to specify different
strategies for pulling largefiles.

The revset expressions used for this option might be quite complex and will
probably be most useful from scripts or an alias ... but less complicated than
configuring hooks.
2013-04-15 01:57:16 +02:00
Mads Kiilerich
0ae0b2850d largefiles: refactor overridepull internals 2013-04-15 01:54:43 +02:00
Mads Kiilerich
8db31ff332 largefiles: introduce lfpull command for pulling missing largefiles 2013-04-15 01:53:37 +02:00
Mads Kiilerich
704d1b4d79 largefiles: update help
Some clarifications, and some clean-up after --cache-largefiles was introduced.
2013-04-15 01:46:10 +02:00
Mads Kiilerich
2e2ad4f35e largefiles: fix cat of non-largefiles from subdirectory
We were calling back to the original commands.cat from inside the walk loop
that handled and filtered out largefiles. That did however happen with file
paths relative to repo root and the original cat would fail when it applied its
own walk and match on top of that.

Instead we now duplicate and modify the code from commands.cat and patch it to
handle both normal and largefiles.

A change in test output shows that this also makes the exit code with
largefiles consistent with the normal one in the case where one of several
specified files are missing.

This also fixes the combination of --output and largefiles.
2013-04-15 01:43:31 +02:00
Mads Kiilerich
f8ce95d4b0 largefiles: don't store whole file in memory for 'cat' 2013-04-15 01:41:49 +02:00
FUJIWARA Katsunori
b8042ee37a largefiles: improve repo wrapping detection
Before this patch, repo wrapping detection in "reposetup()" of
largefiles can detect only limited repo wrapping: replacing target
functions by another one named as "wrap".

So, it can't detect repo wrapping even in recommended style: replacing
"__class__" of repo by derived class.

This patch can detect repo wrapping in both styles below:

  - replacing "__class__" of repo by derived class (recommended style):

        class derived(repo.__class__):
            def push(self, *args, **kwargs):
                return super(derived, self).push(*args, **kwargs)
        repo.__class__ = derived

  - replacing function of repo by another one (not recommended style):

        orgpush = repo.push
        def push(*args, **kwargs):
            return orgpush(*args, **kwargs)
        repo.push = push
2013-04-10 02:27:35 +09:00
Bryan O'Sullivan
af3ab5c0be largefiles: quiet (and document) undefined name errors (issue3886)
These names were found using Cython; I was completely puzzled until
I searched the rest of the tree. It's icky to mess with another
module's namespace, but ickier yet to do so without a comment :-)
2013-04-12 17:33:24 -07:00
Siddharth Agarwal
a91711a512 largefiles: fix _always for match overrides
Upcoming patches will speed dirstate.walk up by not filtering based on the
match function when match.always() is True. For that to work, match.always()
needs to be accurate. Previously it wasn't so for largefiles.
2013-03-25 14:22:34 -07:00
Siddharth Agarwal
b2140786db largefiles: don't query the dirstate for key None
lfutil.splitstandin(f) can be None, and we query the dirstate for that without
checking if it is. This will cause problems with the upcoming move to critbit-
based dicts, since they only support strings as keys.
2013-03-19 13:49:34 -07:00
Durham Goode
474ac2b31e rebase: fix --collapse when a file was added then removed
When a series of commits first adds a file and then removes it,
hg rebase --collapse prompts whether to keep the file or delete it. This is
due to it reusing the branch merge code. In a noninteractive terminal it
defaults to keeping the file, which results in a collapsed commit that is
has a file that should be deleted. This bug resulted in developers accidentally
commiting unintentional changes to our repo twice today, so it's fairly
important to get fixed.

This change allows rebase --collapse to tell the merge code to accept the
latest version every time without prompting.

Adds a test as well.
2013-03-15 11:23:29 -07:00
Mads Kiilerich
265b736027 largefiles: remove wrong comment on standin matcher and code for creating dirs
The existence of these directories could not be relied on anyway and all
dependencies on them should have been removed.
2013-02-28 14:05:15 +01:00
Mads Kiilerich
00a100f5a5 merge with stable 2013-02-28 14:51:59 +01:00
Mads Kiilerich
335985feed largefiles: updatelfiles should use working dir standins, not standins from p1
This makes a difference when working directory is dirty, especially when
merging with a revision for which we don't have largefiles.
2013-02-28 13:45:18 +01:00
Mads Kiilerich
090ace70e1 largefiles: simplify cachelfiles - don't spend a lot of time checking hashes
cachelfiles jumped through loops to handle merges and modified files ... but it
did apparently no longer have a valid reason to do so. It should just always
make sure that the largefiles referenced from the standins are present - no
matter which actual largefile is stored in the working directory. If there is
no standin then there is nothing to fetch.

The old code usually verified the hash of all largefiles every time this
function was invoked - for examply by 'update'.

This change makes a trivial noop update 5-10 seconds faster on our repo (with
the other 50% spent doing another unnecessary hashing of all largefiles).
2013-02-28 13:45:18 +01:00
Mads Kiilerich
1d9aca9cb3 largefiles: don't let update leave wrong largefiles in wd if fetch fails
Situations where a largefile for some reason wasn't available sometimes caused
wrong largefile content and state. It has mostly been seen when interrupting
download of largefiles ... and when introducing programming errors.

Instead we now make sure to delete the old and wrong largefile. A missing file
is a well-known error condition and much more reasonable way to handle the
situation.
2013-02-28 13:45:18 +01:00
Mads Kiilerich
68d046f103 largefiles: missing largefiles should not be committed as removed
Largefiles can easily become missing - for example if it simply isn't available
or the download fail. It might even be convenient to be able to work that way
in some cases.

But commiting missing largefiles as if they had been 'hg remove'd is plain wrong.
2013-02-28 13:45:18 +01:00
Mads Kiilerich
8c5a6710d0 largefiles: don't assume that .hg/largefiles/ still exists
It might not have been created and it might have been removed.
2013-02-28 13:45:18 +01:00
Mads Kiilerich
34d52d8c6e largefiles: getstandinmatcher should not depend on existence of directories
Looking for a (potentially empty) directory was not reliable - both because it
is a reasonable assumption that empty directories can be removed and because it
wasn't created in all cases ... such as when pulling to an existing repository.
2013-02-28 13:45:18 +01:00
Mads Kiilerich
d00a3f9b96 largefiles: fix download of largefiles from an empty list of changesets
The empty list was interpreted as all revisions - just like None is.

The empty list is now handled explicitly.
2013-02-28 13:44:24 +01:00
Mads Kiilerich
6e16465965 largefiles: fix off-by-one error on pull --all-largefiles
Test output is changed in a case where one revision was pulled, but because of
the off-by-one error it thought that 0 revisions were pulled ... and because of
another bug it thus (tried to) fetch largefiles for all revisions.

After this change it no longer reports failure when it failed while trying to
fetch largefiles it shouldn't fetch.  Largefiles that it shouldn't fetch but
managed to fetch anyway will now correctly be missing later on.

This change thus resolves some of unexplained test output introduced in
8664d9900884.
2013-02-28 13:44:22 +01:00
Na'Tosha Bard
f1bd9d017e largefiles: don't cache largefiles for pulled heads by default
After discussion, we've agreed that largefiles for newly pulled heads should
not be cached by default.  The use case for this is using largefiles repos
with multiple remote servers (and therefore multiple remote largefiles caches),
where users will be pulling from non-default locations on a regular basis.  We
think this use case will be significantly less common than the use case where
all largefiles are stored on the same central server, so the default should be
no caching.

The old behavior can be obtained by passing the --cache-largefiles flag to
pull.
2013-02-09 21:07:42 +00:00
Mads Kiilerich
f66f2bb471 largefiles: fix cat when using relative paths from subdirectory 2013-01-25 18:20:13 +01:00
Mads Kiilerich
c066baf66c largefiles: fix commit when using relative paths from subdirectory
Remove cwd handling from getstandinmatcher - it did not belong there, as proven
by the tests.
2013-01-25 16:59:34 +01:00
Mads Kiilerich
2ec95abd3b largefiles: allow use of urls with #revision
largefiles tried to create a peer directly with the specified url. That caused
  abort: unsupported URL component: "..."
if a revision was specified in the url.

The branch name do not matter for largefiles' use of remote peers. Largefiles
will be shared among all branches anyway.
2013-01-28 15:19:44 +01:00
Mads Kiilerich
4b17e20f7c largefiles: don't verify largefile hashes on servers when processing statlfile
When changesets referencing largefiles are pushed then the corresponding
largefiles will be pushed too - unless the target already has them. The client
will use statlfile to make sure it only sends largefiles that the target
doesn't have. The server would however on every statlfile check that the
content of the largefile had the expected hash. What should be cheap thus
became an expensive operation that trashed the disk and the cache.

Largefile hashes are already checked by putlfile before being stored on the
server. A server should thus be able to keep its largefile store free of
errors - even more than it can keep revlogs free of errors. Verification should
happen when running 'hg verify' locally on the server. Rehashing every
largefile on every remote stat is too expensive.

Clients will also stat lfiles before downloading them. When the server verified
the hash in stat it meant that it had to read the file twice to serve it.

With this change the server will assume its own hashes are ok without checking
them on every statlfile.

Some consequences of this change:
- in case of server side corruption the problem will be detected by the
  existing check on the client side - not on server side
- clients that could upload an uncorrupted largefile when pushing will no
  longer magically heal the server (and break hardlinks) - a client will now
  only upload its uncorrupted files after the corrupted file has been removed
  on the server side
- client side verify will no longer report corruption in files it doesn't have

(Issue3123 discussed related problems - and how they have been fixed.)
2013-01-28 15:19:44 +01:00
Mads Kiilerich
46ab1da155 largefiles: verify all files in each revision and report errors in any revision
Verify used 'any' and would stop verifying after the first failure in each
changeset.

The exit code only reported the result from the last changeset.
2013-01-28 15:19:44 +01:00
Mads Kiilerich
6608184763 largefiles: adapt remotestore._getfile to batched statlfile
6fb54510b150 introduced batching of statlfile, but not all codepaths got
converted.

_getfile gave _stat garbage and got garbage back. The garbage didn't match the
expected error codes and was thus interpreted as success. It could thus end up
trying to fetch a largefile that didn't exist.

Instead we now pass _stat valid input and handle both correct and invalid
output correctly.

This makes the code work as intended ... but it would probably be better if it
didn't abort on missing largefiles, just like it happened to do before.
2013-01-28 15:19:44 +01:00
Mads Kiilerich
30af46c496 largefiles: don't allow corruption to propagate after detection
basestore.get uses util.atomictempfile when checking and receiving a new
largefile ... but the close/discard logic was too clever for largefiles.
Largefiles relied on being able to discard the file and thus prevent it from
being written to the store. That was however too brittle. lfutil.copyandhash
closes the infile after writing to it ... with a 'blecch' comment. The discard
was thus a silent noop, and as a result of that corruption would be detected
... and then the corrupted files would be used anyway.

Instead we now use a tmp file and rename or unlink it after validating it.

A better solution should be implemented ... but not now.
2013-01-28 15:19:44 +01:00
Mads Kiilerich
896f340423 largefiles: adapt verify to batched remote statlfile (issue3780)
6fb54510b150 introduced batching of statlfile, but not all codepaths got
converted.

'hg verify' with a remotestore could thus crash with
  TypeError: 'builtin_function_or_method' object is not iterable

Also, the 'hash' variable was used without assigning to it. Don't use variable
names that collide with Python built-in functions. Instead we use 'expecthash'
as in localstore.

The tests for this issue covers an untested area. The tests happens to also
reveal incorrect attempts at getting non-existing largefiles, bad server side
handling of that, and corruption issues - all to be fixed later.
2013-01-28 15:19:44 +01:00
Mads Kiilerich
0abb17e594 largefiles: let wirestore._stat return stats as expected by remotestore verify
- preparing for fixing verify crash.
2013-01-28 15:19:44 +01:00
Wagner Bruna
30efeaefbe largefiles: enhance error message to make it more i18n-friendly 2013-01-21 13:42:04 -02:00
Benoit Boissinot
8f1400147f largefiles: fix largefiles+subrepo update (issue3752)
Override updaterepo() instead of individual methods that may not be called for
each subrepo. Add test.
Based on patch from Matt Harbison.

Changes the order of update-related messages (now largefiles comes before the
global status).
2013-01-23 00:51:53 +01:00
Mads Kiilerich
5787baee50 spelling: fix some minor issues found by spell checker 2013-02-10 18:24:29 +01:00
Na'Tosha Bard
7b4ce40b7d largefiles: fix test and check code 2013-02-09 16:02:01 +00:00
Siddharth Agarwal
ace5cac25b manifestmerge: pass in branchmerge and force separately
This will be used in an upcoming patch.
2013-02-08 15:23:23 +00:00
Na'Tosha Bard
3d65ebe9c1 largefiles: make caching largefiles message more explicit
In some cases, caching largefiles may take a long time (if the user has
pulled a lot of new heads).  This patch makes it more clear what is happening,
by showing the number of heads we are caching largefiles for.
2013-02-09 15:08:21 +00:00
Na'Tosha Bard
5cbae337c9 largefiles: document behavior of caching largefiles for new heads 2013-02-09 15:25:46 +00:00
Mads Kiilerich
1f565a1b35 largefiles: docstrings for verify methods 2013-02-08 13:08:25 +01:00
Mads Kiilerich
e9a72ba5f1 largefiles: fold oddly named _verify into remotestore.exists 2013-02-08 13:00:08 +01:00
Mads Kiilerich
52235c623d largefiles: make verify --lfa and --lfc work without --large
The slightly obscure --lfa and --lfc only worked as modifiers to --large and
could be combined. The documentation was however not clear what they did.

Instead they now imply --large and the description is updated.
2013-01-24 23:57:44 +01:00
Mads Kiilerich
7251dc2f89 largefiles: verify status should be written as status, not as write
Make 'hg verify --large -q' quiet when no errors.
2013-02-04 02:46:53 +01:00
Mads Kiilerich
293a08a6ab largefiles: report localstore errors with single line warnings messages
The actual hash is also not relevant to report.

This makes verify output with multiple failures easier to process.
2013-02-04 02:46:53 +01:00
Mads Kiilerich
ee476759ff merge: delay debug messages for merge actions
Show messages at a point where the actions have been sorted, thus preparing for
backout of 14f4258e3526.

This makes manifestmerge more of a silent operation, just like 'copies' is.

Indent 'preserving' messages to make them subordinate to the action logging so
they fit in the new context. (The 'preserving' messages are quite redundant and
could also be removed completely.)
2013-01-24 23:57:44 +01:00
Mads Kiilerich
3da557a087 merge: make all action tuples have the same length - keep args as tuple 2013-01-24 23:57:44 +01:00
Mads Kiilerich
dd30593de7 refactoring: use unlinkpath with ignoremissing 2013-01-15 23:30:10 +01:00
Mads Kiilerich
99450fc446 largefiles: upload files in sorted order 2012-12-12 02:38:14 +01:00
Mads Kiilerich
2d6545f8b6 subrepos: process subrepos in sorted order
Add sorted() in places found by testing with PYTHONHASHSEED=random and code
inspection.

An alternative to sprinkling sorted() all over would be to change substate to a
custom dict with sorted iterators...
2012-12-12 02:38:14 +01:00
Mads Kiilerich
9692d4642d largefiles: make log match largefiles in the non-standin location too
Yet another match hack.
2013-01-15 01:05:12 +01:00
Mads Kiilerich
dfd7d10cbf largefiles: fix update from a merge with removed files
A situation with this case could happen after interrupting an update. Update
would fail with:
  abort: No such file or directory: $TESTTMP/f/.hglf/sub2/large6

Update from a merge without using clean is not possible anyway, so this patch
takes a step in the right direction so it gets as far as reporting the right
error.
2013-01-11 16:30:29 +01:00
Mads Kiilerich
19813fa421 largefiles: fix revert removing a largefile from a merge
Before revert could fail with:
  abort: .hglf/large@33fdd332ec: not found in manifest!

The LookupError will now be caught and handled correctly.
2013-01-11 16:30:29 +01:00
Mads Kiilerich
5096819efc largefiles: remove unused proto.refuseclient code
Should have been removed with other pre-1.9 code in 416c0b8e6104.
2013-01-11 16:30:29 +01:00
Augie Fackler
2986e3abf8 Merge with stable. 2013-01-10 09:43:28 -05:00
Mads Kiilerich
79e0196dc6 largefiles: make update with backup files in .hglf slightly less broken
Largefiles update would try to copy f to f.orig if there was a .hglf/f.orig .
That is in many many ways very very wrong, but it also caused an abort if f
didn't exist.

Now it only tries to copy f if it exists.
2013-01-10 15:33:14 +01:00
Mads Kiilerich
82c7e260df largefiles: don't walk through all ignored files
Problem: 'hg status' with largefiles enabled would walk through all the files
that .hgignore said should be ignored. That made it slow if a lot of files were
.hgignored or the cache was cold.

It seems like there was a reason to this, but other improvements has rendered
this unnecessary.

Solution: .hgignore is now only ignored when that is requested (--ignore).

This is a minimal 'stable' change. There is room for other improvement.
2012-12-13 19:19:06 +01:00
Mads Kiilerich
96d2cbf93b largefiles revert: update lfdirstate with result from first cleanliness check
Largefiles revert do for some reason have two lfdirstates and lfdirstatestatus
invocations in one function. The result from the first lfdirstate check was
however not written back to the lfdirstate, and some files was thus checked
twice.
2012-12-13 19:19:06 +01:00
Mads Kiilerich
f9eedbbdd4 largefiles status: update lfdirstate with result from cleanliness check
Problem: 'hg status' kept checking largefiles with an unknown state until some
other command wrote the updated dirstate.

Solution: Add missing lfdirstate.write().
2012-12-13 19:19:06 +01:00
Levi Bard
5ac6c21477 largefiles: commit directories that only contain largefiles (issue3548)
If we pass a directory to commit whose only commitable files
are largefiles, the core commit code aborts before finding
the largefiles.
So we do the following:
For directories that only have largefiles as matches,
we explicitly add the largefiles to the matchlist and remove
the directory.
In other cases, we leave the match list unmodified.
2012-12-10 14:58:42 +01:00
Augie Fackler
2316255c71 largefiles: stop using <> operator in favor of !=
<> has been deprecated for a while, and != is futureproof
2013-01-01 13:04:40 -06:00
Mads Kiilerich
9302004c43 largefiles: cleanup of warnings on errors getting largefiles
Especially the "no default or default-push path set in hgrc" was often very
misleading and didn't give any hint where it actually was looking.

A long error messages is better than several multi-line messages.
2012-12-13 19:19:06 +01:00
Mads Kiilerich
f356c36feb largefiles: remove trivial portability wrappers 2012-12-13 19:19:06 +01:00
Mads Kiilerich
8c4d272590 largefiles: remove reporemove portability wrapper 2012-12-13 19:19:06 +01:00
Mads Kiilerich
59edc6b723 largefiles: remove findoutgoing portability wrapper 2012-12-13 19:19:06 +01:00
Mads Kiilerich
b9392de5ec largefiles: use constant for '.hglf/'
Problem: '.hglf' + '/' was computed in some tight loops. There is no need for
that.
2012-12-13 19:19:06 +01:00
Mads Kiilerich
6b50b212dd largefiles: use plain wjoin instead of the complex pathto 2012-12-13 19:19:06 +01:00
Mads Kiilerich
c4f44002f9 largefiles: unindent code 2012-12-28 11:55:57 +01:00
Mads Kiilerich
38f4eda033 largefiles: simplify lfdirstate ignore handling - it is only for tracking .hglf 2012-12-13 19:19:06 +01:00
Mads Kiilerich
ba25df8826 largefiles: rename 'admin' to more descriptive 'lfstoredir' 2012-12-13 19:19:06 +01:00
Mads Kiilerich
8c0ce2a8b9 largefiles: simplify lfutil.getstandinmatcher by inlining getmatcher 2012-12-13 19:19:06 +01:00
Mads Kiilerich
e973341bd0 largefiles: remove overly complex handling of ignored and unknown files 2012-12-13 19:19:06 +01:00
Mads Kiilerich
20020a39e4 largefiles: introduce basic debugstate --large functionality
Very useful for debugging largefiles "performance" issues.

This is used for testing 45d039e26849.
2012-12-28 11:55:57 +01:00
Mads Kiilerich
275333d6c9 util: fold ENOENT check into unlinkpath, controlled by new ignoremissing flag
Refactor a common pattern.
2012-12-28 11:55:57 +01:00
Mads Kiilerich
056fcbf2bc merge with stable 2012-12-28 11:55:45 +01:00
Mads Kiilerich
53f5b626ae largefiles: align rm warnings with warnings used in core 2012-12-13 19:19:06 +01:00
Mads Kiilerich
2d06a8beab merge with stable 2012-12-13 21:34:55 +01:00
Pierre-Yves David
5ccc6bfa9a clfilter: rename unfilteredmeth to unfilteredmethod
As originally intended.
2012-11-30 22:34:21 +01:00
FUJIWARA Katsunori
5434449902 i18n: change output of largefiles for summary to distinguish from one for outgoing
Before this patch, largefiles extension uses "largefiles: No remote
repo" message not only for "outgoing" as status report, but also for
"summary" as summarized information.

This sharing prevents message translators from inserting white spaces
between "largefiles:" and "No remote repo" in translated message to
align column position of summarized information.

This patch changes output of largefiles for summary to distinguish
from one for outgoing.

This patch puts "no remote repo" into parentheses, because this is not
summarized information.
2012-10-31 03:59:28 +09:00
FUJIWARA Katsunori
f05ff4243c i18n: add "i18n" comment to column positioning messages of "hg summary"
This comment makes it easier to distinguish such messages from others
for message translators.
2012-10-31 03:59:28 +09:00
Matt Harbison
eb56660b19 largefiles: don't copy largefiles from working dir to the store while converting
Previously, if one or more largefiles for a repo being converted were not in the
usercache, the convert would abort with a reference to the largefile being
missing (as opposed to the previous patch, where the standin was referenced as
missing).  This is because commitctx() tries to copy all largefiles to the
local store, first from the user cache, and if the file isn't found there, from
the working directory.  No files will exist in the working directory during a
convert, however.  It is not sufficient to force the source repo to be local
before proceeding, because clone and pull do not download largefiles by default.

This is slightly less than ideal because while the conversion will now complete,
it won't be possible to update to revs with missing largefiles unless the user
intervenes manually, because there is no default path pointing back to the
source repo.  Ideally these files would be cached during the conversion.

This check could have been done in reposetup.commitctx() instead, but this
ensures the local store directory is created, which is necessary to enable the
standin matcher.

The rm -> 'rm -f' change in the test is to temporarily suppress an error
clearing the cache- as noted, the cache is is not repopulated during convert.
When that is fixed, this can be changed back and the verification errors will
disappear too.
2012-10-23 21:32:19 -04:00
Matt Harbison
8973167c73 largefiles: respect the rev when reading standins in copytostore() (issue3630)
When the rev isn't specified, the standin for the working copy gets read.  But
convert doesn't update the working copy for each cset it processes, so there is
no standin and the 'hg convert' would abort complaining about the standin being
missing.

Note that if the largefile is not in the user cache, 'hg convert' complains
about the largefile itself missing from the destination repo.
2012-10-23 21:07:14 -04:00
Pierre-Yves David
afde19de6d largefile: status is buggy on repoproxy, so run unfiltered
For some yet-unkown reason, largefile status does not work on
repoproxy. As status is not affected by filtering, we run it unfiltered.

Na'Tosha Bard's view on this issue:

    "but, well, largefiles status is kind of an unholy piece of code"
2012-10-08 18:11:56 +02:00
Matt Harbison
ff98bafc79 largefiles: use 'default' instead of 'default-push' when pulling (issue3584)
This only applies to downloading largefiles, and only when no source for the
pull is explicitly provided.  The repository itself was properly being pulled
via 'default' previously.

Using --all-largefiles is not necessary on a bare pull to test this (this
existing test is merely a convenience), but it is required to test pulling on
the rebase path.

Note that the errors generated in the --rebase case are because the repo
specified doesn't have the largefiles in its cache (though they are in the user
cache), so the errors are misleading.  Specifying --all-largefiles when cloning
to 'b' fixes this, but instead of errors, it reports caching only 5 largefiles
instead of the 9 that come up missing.  Likely this is because the largefile
download procedure tries to download missing files for each rev, and some of the
files have standins in more than one rev that gets pulled.
2012-10-20 21:43:46 -04:00
FUJIWARA Katsunori
d06e5a0fa2 largefiles: distinguish "no remote repo" from "no files to upload" (issue3651)
Before this patch, when no files to upload, "hg outgoing --large" and
"hg summary --large" show "no remote repo", even though valid remote
repository is specified.

It is because that "getoutgoinglfiles()" returns None, not only if no
valid remote repository is specified, but also if no files to upload.

This patch makes "getoutgoinglfiles()" return empty list when no files
to upload, and makes largefiles show "no files to upload" message at
that time.

This patch doesn't test "if toupload is None" route in
"overrideoutgoing()", because this route is not executed unless remote
repository becomes inaccessible just before largefiles specific
processing: successful execution of "orig()" means that at least one
of "default", "default-push" or dest is valid one, and that
"getoutgoinglfiles()" never returns None in such cases.

At "hg summary --large" invocation, this patch shows message below:

    largefiles: (no files to upload)

This follows the message shown by "hg summary" with MQ:

    mq:     (empty queue)
2012-10-08 23:49:36 +09:00
Matt Harbison
7640adfa45 largefiles: always create the cache and standin directories when cloning
The standin matcher only works if the .hglf directory exists (and it won't exist
if 'clone -U' is used, unless --all-largefiles is also specified).  Since not
even 'update -r null' will get rid of the standin directory, this ensures that
the standin directory always exists if the repo has the 'largefiles'
requirement.  This requirement is only set after a largefile is committed, so
these directories will not be created for repos that have the extension enabled
but have not committed a largefile.

With the standin directory in place, 'lfconvert --to-normal' will now be able to
download the required largefiles when converting a repo that was created with
'clone -U', and whose files are not in the usercache.

The downloadlfiles command could probably be put inside the 'largefiles'
requirement conditional too, but given that the user specified --all-largefiles,
there is likely an expectation to print out the number of largefiles downloaded,
even if it is 0.
2012-10-14 15:10:13 -04:00
Matt Harbison
6217120715 largefiles: fix a traceback in lfconvert if a largefile is missing (issue3519)
The largefile may be missing for various reasons, including that a remote
repository was cloned without the --all-largefiles option.  Therefore, it seems
reasonable to attempt to download the missing files and failing that, abort and
indicate the affected file and revision so the user can manually fix the
problem.
2012-10-14 14:44:08 -04:00
Pierre-Yves David
dc4260df80 largefile: use self in repo method instead of repo
Most method added (or overwritten) to repo by largefile works on `repo`
instead of `self`. This currently works without trouble because `self` and
`repo` are likely the same. However this is semantically dubious and this may
cause issue for filtering. `self` may be proxy object different from the `repo`
one.

This changeset fix that and use `self` when applicable.
2012-10-08 15:41:58 +02:00
Matt Harbison
8c0a3d405b largefiles: update lfutil.findoutgoing() discovery method
It looks like this method missed the updates in 7a899bd0f9c0 (which changed the
preferred discovery method from findcommonincoming() to findcommonoutgoing()),
and 8b2938386599 (which rolls up the outgoing lists into a single object).
2012-10-08 22:43:54 -04:00
Siddharth Agarwal
a5e71891bd commands: don't infer repo for commands like update (issue2748)
Maintain a whitelist of commands to infer the repo for instead. The whitelist
contains those commands that take file(s) in the working dir as arguments.
2012-10-16 11:43:15 -07:00
Bryan O'Sullivan
3048607d30 Merge with crew-stable 2012-10-02 14:31:25 -07:00
Matt Harbison
ca1372542e largefiles: download missing subrepo revs when archiving
This is something plain hgsubrepos already do.  Previously, an abort message
complained about an unknown revision.
2012-09-23 00:08:13 -04:00
Matt Mackall
8c86a57e7c merge with stable 2012-09-27 15:51:14 -05:00
Matt Mackall
77a75fbd07 merge with stable 2012-09-18 16:19:56 -05:00
Matt Mackall
b0dd832e65 merge with stable 2012-09-17 15:13:17 -05:00
Matt Harbison
fa8ea6e5a3 largefiles: delegate to the wrapped clone command
This allows the wrapped command's validation code to run (which is currently
only to ensure 'noupdate' and 'updaterev' aren't both specified), the
copy/pasted unpacking of hg.clone() args to be removed, and any future changes
to the base command (however unlikely) to be inherited by largefiles.

Unfortunately, the command override can't be swapped entirely for an hg.clone()
override because the extra --all-largefiles arg needs to be injected.  It also
isn't enough to call the wrapped clone command and leave the caching code after
it, because the file caching code needs access to the destination repo, which is
only available from hg.clone().  An alternative would be to use the dest path in
the clone command override to re-obtain a reference to the repo.

A slight deviation from the regular hg.clone() function is that the repo is NOT
deleted if the caching fails, but that was also the previous behavior.  Maybe it
should for consistency?
2012-09-09 12:43:24 -04:00
Matt Harbison
b14b475d95 largefiles: don't convert dest=None to dest=hg.defaultdest() in clone command
A status message is output if hg.clone() determines the default destination
because None was provided.  The previous code never passed None to hg.clone().
2012-09-09 12:09:53 -04:00
Matt Harbison
93f873fbd2 largefiles: restore caching of largefiles with 'clone -U --all-largefiles'
This was broken when restoring normal -u and -U functionality.
2012-09-09 03:37:38 -04:00
Matt Harbison
3eb1617064 largefiles: restore normal 'clone -u' and 'clone -U' functionality
Previously, tip would be checked out regardless of the -u or -U parameter.  I'm
not sure what the 'required for successful walkchangerevs' comment meant, but it
appears to reference code which has since moved to downloadlfiles() in
5c06bddf85b8.  Perhaps it was to force caching when the -U parameter is given?
The price of this change is that -U --all-largefiles won't cache anything.  That
will be fixed next.

Note that X + Y in the 'X largefiles updated, n removed' and 'Y additional
largefiles cached' lines do not add up to the same values in these tests, but
all of the largefiles have been downloaded.  The reason being that several
largefiles have the same content (eb7338044 is pointed to by sub/large2, large3
and sub/large4).  In the 'clone -u 1' operation, this largefile is cached to
populate the working directory, even without --all-largefiles.  That means the
file isn't downloaded again and cached in the rev where large3 and sub/large4
both point to this file.  Downloading that one file in that one rev seems to be
counted twice with 'clone -u 0'.  (Maybe it is also being downloaded twice?)
2012-09-08 13:31:06 -04:00
Matt Harbison
d3a4f5a08b largefiles: preserve the exit status of the forget command
This maintains the exit codes documented in commands.py.
2012-09-05 22:42:23 -04:00
Matt Harbison
0931dc58e6 largefiles: preserve the exit status of the rebase command 2012-09-05 22:31:03 -04:00
Matt Harbison
ac0da61364 largefiles: preserve the exit status of the log command 2012-09-05 22:12:40 -04:00
Matt Harbison
4cda36b611 largefiles: exit from remove with 1 on warnings
This maintains the exit codes documented in commands.py.
2012-09-09 20:18:08 -04:00
Matt Harbison
096f56ab20 largefiles: preserve exit code from outgoing command (issue3611)
This maintains the exit codes documented in commands.py.
2012-09-05 21:26:08 -04:00
Matt Harbison
2128536df5 largefiles: adjust localstore to handle batch statlfile requests (issue3583)
This fixes a traceback when pushing to a local repo which started with
6fb54510b150.
2012-08-14 22:38:25 -04:00
Bryan O'Sullivan
68bb78ae36 Merge with crew-stable 2012-09-04 13:50:50 -07:00
Mads Kiilerich
7af1f60b20 largefiles: minor code cleanup
Fix:
* unnecessary use of map and lambda
* comment instead of readable code
* comparing None with 0
* and...or anti-pattern for 'ternary if' with very clever handling of i=None
2012-08-27 23:17:21 +02:00
Mads Kiilerich
2372d51b68 fix wording and not-completely-trivial spelling errors and bad docstrings 2012-08-15 22:39:18 +02:00
Mads Kiilerich
2f4504e446 fix trivial spelling errors 2012-08-15 22:38:42 +02:00
Matt Harbison
fd44bab84b largefiles: enable islfilesrepo() prior to a commit (issue3541)
Previously, even if a file was added with --large, 'hg addremove' or 'hg ci -A'
would add all files (including the previously added large files) as normal
files.  Only after a commit where a file was added with --large would subsequent
adds or 'ci -A' take into account the minsize or the pattern configuration.
This change more closely follows the help for largefiles, which mentions that
'add --large' is required to enable the configuration, but doesn't mention the
previously required commit.

Also, if 'hg add --large' was performed and then 'hg forget <file>' (both before
a largefile enabling commit), the forget command would error out saying
'.hglf/<file> not tracked'.  This is also fixed.

This reports that a repo is largefiles enabled as soon as a file is added with
--large, which enables 'add', 'addremove' and 'ci -A' to honor the config
settings before the first commit.  Note that prior to the next commit, if all
largefiles are forgotten, the repository goes back to reporting the repo as not
largefiles enabled.

It makes no sense to handle this by adding a --large option to 'addremove',
because then it would also be needed for 'commit', but only when '-A' is
specified.  While this gets around the awkwardness of having to add a largefile,
then commit it, and then addremove the other files when importing an existing
codebase (and preserving that extra commit in permanent history), it does still
require finding and manually adding one of the files as --large.  Therefore it
is probably desirable to have a --large option for init as well.
2012-07-30 20:56:41 -04:00
Matt Harbison
2aaabbf1cc largefiles: handle commit -A properly, after a --large commit (issue3542)
Previous to this, 'commit -A' would add as normal files, files that were already
committed as largefiles, resulting in files being listed twice by 'status -A'.
It also missed when (only) a largefile was deleted, even though status reported
it as '!'.  This also has the side effect of properly reporting the state of the
affected largefiles in the post commit hook after a remove that also affected a
normal file (the largefiles used to be 'R', now are properly absent).

Since scmutil.addremove() is called both by the ui command (after some trivial
argument validation) and during the commit process when -A is specified, it
seems like a more appropriate method to wrap than the addremove command.

Currently, a repo is only enabled to use largefiles after an add that explicitly
identifies some file as large, and a subsequent commit.  Therefore, this patch
only changes behavior after such a largefile enabling commit.

Note that in the test, if the final commit had a '-v', 'removing large8' would
be printed twice.  Both of these originate in removelargefiles().  The first
print is in verbose mode after traversing remove + forget, the second is because
the '_isaddremove' attr is set and 'after' is not.
2012-07-30 20:56:41 -04:00
Mads Kiilerich
688b9e2048 check-code: indent 4 spaces in py files 2012-07-31 03:30:42 +02:00
Simon Heimberg
74b66f52f4 largefiles: use hg.peer instead of hg.remoteui 2012-07-28 22:55:01 +02:00
Matt Harbison
2331fa9fcd largefiles: support revsets for outgoing --large
Previous to this, outgoing with a revset succeeded unless --large was also
specified.
2012-07-20 19:08:26 -04:00
Matt Harbison
1c93565f66 largefiles: fix a traceback introduced with recent peer changes
Changeset 9467184ce7e7 broke 'outgoing --large'

    ...
    File "hgext\largefiles\lfutil.py", line 56, in findoutgoing
      remote.local(), force=force)
    File "mercurial\discovery.py", line 31, in findcommonincoming
      if not remote.capable('getbundle'):
  AttributeError: 'lfilesrepo' object has no attribute 'capable'

This restores the previous functionality, though I'm not sure if there's a
better way to do this- that changeset introduces a hunk in debugdiscovery that
does this:

            if not util.safehasattr(remote, 'branches'):
                # enable in-client legacy support
                remote = localrepo.locallegacypeer(remote.local())

Is there a legacy support issue here too?
2012-07-20 23:50:52 -04:00
Matt Harbison
944ad7f58e largefiles: support revsets for cat
Previous to this, cat only accepted revsets if the largefiles extension was
disabled.
2012-07-20 19:14:41 -04:00
Matt Harbison
a7de7f0ce5 largefiles: support revsets for revert
Previous to this, revert only accepted revsets if the largefiles extension was
disabled.
2012-07-20 18:13:19 -04:00
Matt Mackall
387f7efad8 largefiles: fix exception hack for i18n (issue3197)
Properly fixing this is quite a bit trickier.
2012-07-27 12:33:48 -05:00
Matt Harbison
8e588880da largefiles: fix path handling for cp/mv (issue3516)
Previously, a copy or a move of a largefile only worked if the cwd was the root
of the repository.  The first issue was that the destination path passed to
os.mkdirs() chopped the absolute path to the standin after '.hglf/', which
essentially created a path relative to the repository root.  Similarly, the
second issue was that the source and dest paths for copyfile() were relative to
the repo root.  This converts these three paths to absolute paths.

Some notable issues, regardless of the directory in which the cp/mv is executed:

1) The copy is not being recorded in lfdirstate, but it is in dirstate for the
standins.  I'm not sure if this is by design (i.e. minimal info in lfdirstate).

2) status -C doesn't behave as expected.  Using the testcase as an example:

  # after mv + ci
  $ hg status -C -v --rev '.^'     # expected to see 'A' and ' ' lines too
  R dira\dirb\largefile

  $ hg status -C -v --rev '.^' foo/largefile
  # no output                      # expected to see 'A' and ' ' lines only

  $ hg status -C -v --rev '.^' foo/
  # no output                      # expected to see 'A', ' ' and 'R' lines

  $ hg status -C -v --rev '.^' ./  # expected to see 'A' and ' ' lines too
  R dirb\largefile

  $ hg status -C -v --rev '.^' ../.hglf/dira/foo/largefile
  A ..\.hglf\dira\foo\largefile
    ..\.hglf\dira\dirb\largefile  # no 'R' expected when new file is specified

  $ hg status -C -v --rev '.^' ../.hglf   # OK
  A ..\.hglf\dira\foo\largefile
    ..\.hglf\dira\dirb\largefile
  R ..\.hglf\dira\dirb\largefile
2012-07-22 23:37:53 -04:00
Matt Harbison
a6f5e08a5d largefiles: mark as a first party extension 2012-07-20 22:10:52 -04:00
Matt Harbison
a3f198c97e largefiles: ensure addlargefiles() doesn't add a standin as a largefile
An easy way to force this (and cause a traceback) prior to the fix for 3507 was

  $ touch large
  $ hg add --large large
  $ hg ci -m "add"
  $ hg remove large
  $ touch large
  $ hg addremove --config largefiles.patterns=**large

This patch also detected (and corrected) a previous test where a standin got
added as a largefile (without a traceback).
2012-07-19 23:35:13 -04:00
Matt Harbison
b617460d47 largefiles: fix a traceback when addremove follows a remove (issue3507)
The problem only occurred if a file was removed with 'hg rm' (as opposed to the
OS utilities), and then addremove was run before a commit.  Both normal and
large files were affected.

Ensuring that the file exists prior to an lstat() for size seems like the Right
Thing.  But oddly enough, the missing file that was causing lstat() to blow up
was a standin when a largefile was removed, which seems fishy, because a standin
should never be added as a largefile.  I was then able to get a standin added as
a largefile (whose name is 'large') with

   hg addremove --config largefiles.patterns=**large

which also causes a backtrace.  That will be fixed next.
2012-07-19 11:12:05 -04:00
Matt Harbison
f0d41a8692 largefiles: defer lfdirstate.drop() until after commit (issue3364)
The example in comment #9 of the bug writeup must be run exactly- it was the
commit after the rm and prior to the addremove that screwed things up, because
that commit noticed that the largefile was missing, called drop(), and then the
original commit function did nothing (due to the file in the '!' state).  The
addremove command properly put it into the 'R' state, but it remained stuck in
that state (because commit insisted 'nothing changed').  Without the commit
prior to addremove, the problem didn't occur.

Maybe this is an indication that lfdirstate needs to take a few more hints from
the regular dirstate, regardless of what _it_ thinks the state is- similar
inconsistency is probably still possible with this patch if the original commit
succeeds but the lfdirstate write fails.
2012-07-19 10:00:15 -04:00
Matt Harbison
91452ea7b9 largefiles: fix addremove with -R option
If a file was missing, the missing list contained a path relative to the repo.
When building the matcher from that list, the file name ended up concatenated to
cwd, causing the command to abort with '<file> not under root'.  This rebuilds
the missing list with paths relative to cwd.
2012-07-19 06:30:59 -04:00
Peter Arrenbrecht
ef7b77046e peer: introduce real peer classes
This change separates peer implementations from the repository implementation.
localpeer currently is a simple pass-through to localrepository, except for
legacy calls, which have already been removed from localpeer. This ensures that
the local client code only uses the most modern peer API when talking to local
repos.

Peers have a .local() method which returns either None or the underlying
localrepository (or descendant thereof). Repos have a .peer() method to return
a freshly constructed localpeer. The latter is used by hg.peer(), and also to
allow folks to pass either a peer or a repo to some generic helper methods.
We might want to get rid of .peer() eventually.

The only user of locallegacypeer is debugdiscovery, which uses it to pose as a
pre-setdiscovery client. But we decided to leave the old API defined in
locallegacypeer for clarity and maybe for other uses in the future.

It might be nice to actually define the peer API directly in peer.py as stub
methods. One problem there is, however, that localpeer implements
lock/addchangegroup, whereas the true remote peers implement unbundle.
It might be desireable to get rid of this distinction eventually.
2012-07-13 21:47:06 +02:00
Sune Foldager
ffe56435bf peer: introduce peer methods to prepare for peer classes
This introduces a peer method into all repository classes, which currently
simply returns self. It also changes hg.repository so it now raises an
exception if the supplied paths does not resolve to a localrepo or descendant.

Finally, all call sites are changed to use the peer and local methods as
appropriate, where peer is used whenever the code is dealing with a remote
repository (even if it's on local disk).
2012-07-13 21:46:53 +02:00
Na'Tosha Bard
7bf5bfedef largefiles: optimize status by synchronizing lfdirstate with the largefile on update
This speeds up status on a largefiles repo by synchronizing the largefiles dirstate to the
largefile's mtime upon update, preventing the files from coming back as "unsure" later,
requiring a check of the SHA1 sum.
2012-07-13 14:49:16 +02:00
Na'Tosha Bard
1ffeefa9fa largefiles: batch statlfile requests when pushing a largefiles repo (issue3386)
This implements a part of issue 3386.  It batches the request for the status of
all largefiles in the revisions that are about to be pushed into a single
request, instead of doing N separate requests.

In a real world test case, this change was verified to save 1,116 round-trips to
the server.  It only requires a client-side change; it is backwards-compatible
with an older version of the server.
2012-06-24 20:36:22 +02:00
Matt Harbison
63a46b018b subrepo: propagate matcher to subrepos when archiving
Add a match object to subrepo.archive(). This will allow the -X and -I
options to be honored inside subrepos when archiving. They formerly
only affect the top level repo.
2012-06-16 22:34:06 -04:00
Matt Harbison
218655984d largefiles: remove a standin check that could never be true 2012-06-18 22:45:21 -04:00
Matt Harbison
c16332f051 largefiles: fix the directory structure when archiving a subrepo in a subrepo
Previously, a repo consisting of main/sub/subsub archived sub and subsub as
siblings under main.
2012-06-18 23:02:51 -04:00
Matt Harbison
bf6dae387d largefiles: fix a traceback when archiving a subrepo in a subrepo
This regression was introduced in 310edb24b71f.
2012-06-17 21:57:48 -04:00
Martin Geisler
643b04fbb7 largefiles: lowercase messages 2012-06-12 14:18:18 +02:00
Na'Tosha Bard
b035ee4c71 largefiles: fix addremove when largefile is missing (issue3227) 2012-05-13 12:11:50 +02:00
Matt Mackall
082c081b22 largefiles: fix default clone destination regression 2012-05-16 11:40:33 -05:00
Matt Mackall
264c1fb976 merge with stable 2012-05-15 07:00:55 +02:00
Levi Bard
c5f81ed918 largefiles: don't attempt to clone all largefiles to non-local destinations 2012-05-13 22:59:22 +02:00
Mads Kiilerich
b315fbc5ab largefiles: use wlock for lfconvert (issue3444)
largefiles and lfconvert do dirty hacks with dirstate, so to avoid writing that
as a side effect of the wlock release we clear dirstate first.

To avoid confusing lock validation algorithms in error situations we unlock
_before_ removing the target directory.
2012-05-13 17:34:55 +02:00
Na'Tosha Bard
0af9bc5a7f largefiles: optimize performance when updating (issue3440)
Previously, when updating, cachelfiles was called blindly on all largefiles
in the repository at the revision being updated to, despite the fact that
a list of which largefiles needs to be updated has already been collected.  This
optimization constrains the cachelfiles call to only the largefiles that need
to be updated.

On a repository with about 80 largefiles, updating between two revisions that
only change one largefile goes from approximately 6.7 seconds to 3.3 seconds.
2012-05-12 15:41:27 +02:00
Na'Tosha Bard
18869bf5f2 largefiles: add --all-largefiles flag to pull 2012-05-12 11:45:22 +02:00
Na'Tosha Bard
faa9f04319 largefiles: refactor downloading of all largefiles to generic function 2012-05-12 09:59:01 +02:00
Brodie Rao
92158e04de cleanup: "raise SomeException()" -> "raise SomeException" 2012-05-12 16:00:58 +02:00
Brodie Rao
a7ef0a0cc5 cleanup: "not x in y" -> "x not in y" 2012-05-12 16:00:57 +02:00
Na'Tosha Bard
0f2fb0db6a largefiles: add --all-largefiles flag to clone (issue3188) 2012-05-11 23:11:43 +02:00
Matt Mackall
48471fd098 merge with stable 2012-05-12 00:06:11 +02:00
Na'Tosha Bard
7899056542 largefiles: fix deletion of multiple missing largefiles (issue3329) 2012-05-11 15:32:22 +02:00
Na'Tosha Bard
d4432c172d largefiles: follow normal codepath for addremove if non-largefiles repo (issue3249) 2012-05-11 14:42:26 +02:00
Matt Mackall
d7cd292c1a merge with stable 2012-05-08 12:05:45 -05:00
Martin Geisler
4640718d42 merge with stable 2012-05-06 14:36:42 +02:00
Patrick Mezard
9b4af94333 largefiles: fix "hg status dir" missing regular files (issue3421)
largefiles status implementation attemps to rewrite the input match objects to
match the "standins" as well as the regular files. When fixing the directories
listed in match.files(), if there was related standin entry, it was kept and
the original path discarded. But directories can appear both as regular and
standin entries.
2012-05-06 13:14:58 +02:00
hlian
992a6313f9 largefiles: in putlfile, ensure tempfile's directory exists prior to creation
Let R be a repo served by an hg daemon on a machine with an empty largefiles
cache. Pushing a largefiles repo to R will result in a no-such-file-or-directory
OSError because putlfile will attempt to create a temporary file in
R/.hg/largefiles, which does not yet exist.

This patch also adds a regression test for this scenario.
2012-05-04 14:36:40 -04:00
Matt Harbison
2a3bf0a137 largefiles: make archive -S store largefiles instead of standins
This is essentially a copy of largefile's override of archive() in the
archival class, adapted for overriding hgsubrepo's archive().  That
means decoding isn't taken into consideration, nor is .hg_archival.txt
generated (the same goes for regular subrepos).  Unlike subrepos, but
consistent with largefile's handling of the top repo, ui.progress() is
*not* called.  This should probably be refactored at some point, but
at least this generates the archives properly for now.  Previously,
the standins were ignored and the largefiles were archived only for
the top level repo.

Long term, it would probably be most desirable to figure out how to
tweak archival's archive() if necessary such that largefiles doesn't
need to override it completely just to special case the translating of
standins to the real files.  Largefiles will already return a context
with the true largefiles instead of the standins if lfilesrepo's
lfstatus is True- perhaps this can be leveraged?
2012-05-03 21:32:57 -04:00
Na'Tosha Bard
da576e6ebb largefiles: fix commit of both largefiles and non-largefiles (issue3354)
This bug was caused by some old code that should have been removed long ago.
2012-05-03 15:24:45 +02:00
Patrick Mezard
2c65c226cf localrepo: add setparents() to adjust dirstate copies (issue3407)
The fix introduced in 3509b9cf8f86 was only partially successful. It is correct
to turn dirstate 'm' merge records into normal/dirty ones but copy records are
lost in the process. To adjust them as well, we need to look in the first
parent manifest to know which files were added and preserve only related
records. But the dirstate does not have access to changesets, the logic has to
moved at another level, in localrepo.
2012-04-29 22:25:55 +02:00
Matt Harbison
165acc96be largefiles: notice dirty large files in a subrepo
Summary and commit use dirty() to check the status of a subrepository,
so this overrides dirty() in the subrepo in the same manner as
status() to check the large files instead of their standins.

Previously, if only a large file was changed in a subrepo, summary in
the top level repo would not report the subrepo was dirty and commit
-S would report nothing changed.  If any type of file was changed in
the top repo and only a large file in the subrepo, commit -S would not
commit the changes to the subrepo.
2012-04-22 13:19:22 -04:00
Matt Harbison
677d4b2efc largefiles: fix status -S reporting of subrepos (issue3231)
Wrapping the status command will only invoke overridestatus() and set
the lfstatus field for the top level repository.  Wrapping the status
function is required to set the field on child repositories.

Previously, status -S would report large files in a subrepo as '?'
regardless of their actual states, and was inconsistent with what
status would report from within that subrepo.
2012-04-22 03:47:34 -04:00
Martin Geisler
004ba88f28 largefiles: hide .hglf/ prefix for largefiles in hgweb
This makes the manifest view in hgweb match what you see in the
working copy and what you get when you download an archive in hgweb.
2012-04-15 16:05:57 +02:00
Na'Tosha Bard
26cdea9a9e largefiles: fix cat for largefiles (issue3352)
This is a fix to largefiles so that 'hg cat' will work correctly when a
largefile is specified.

As per discussion on Issue 3352:

1) The file will be printed regardless if it is binary or large.
2) The file is downloaded if it is not readily available (not found in
   the system cache), so that it can be printed.  If the download fails,
   then we abort.
2012-04-16 17:03:39 +02:00
Matt Mackall
9b533bc599 merge with stable 2012-03-26 16:42:53 -05:00
FUJIWARA Katsunori
a3e4d70aa4 largefiles: use 'dirstate.dirs()' for 'directory pattern' relation check
original implementation queries whether specified pattern is related
or not to largefiles in target context by 'dirstate.__contains__()'.

but this can't recognize 'directory pattern' correctly, so this patch
uses 'dirstate.dirs()' for it.

this patch uses dirstate instead of lfdirstate in 'working' route
(second patch hunk for 'hgext/largefiles/reposetup.py'), because
'dirs()' information may be already built for dirstate but not yet for
lfdirstate at this point. this prevents lfdirstate from building up
and having 'dirs()' information.
2012-03-22 23:58:47 +09:00
FUJIWARA Katsunori
74e7c5bd04 largefiles: suppress unexpected warning of 'hg status' for removed files
original implementation queries whether specified pattern is related
or not to largefiles, to target context.

but changectx/workingctx returns False about relationship with files
marked as removed.

So, 'hg status' with 'file pattern' for removed file shows unexpected
warning message in below process:

    1. 'tostandin()' returns non-STANDIN filename for removed file,
       because changectx/workingctx returns False about relationship
       with it

    2. 'match.files()' contains non-STANDIN filename, which is already
       removed from working directory

    3. 'dirstate.walk()' invoked via 'localrepository.status()' treats
       non-STANDIN filename as bad filename, because there is no entry
       for it in dirstate: only STANDIN is managed in dirstate

    4. 'dirstate.walk()' invokes 'match.bad()', which is defined in
       'localrepository.status()' as 'bad()'

    5. 'bad()' shows warning message for non-STANDIN, because it is
       not related to source context: only STANDIN is related to it

this patch queries to dirstate instead of changectxt/workingctx,
because dirstate returns expected result for removed files.

'match.files()' is used by 'localrepository.status()' only in
'working' case, so this patched code also works correctly in
non-'working' case.
2012-03-22 23:58:47 +09:00
Matt Mackall
f2a652218a i18n: fix all remaining uses of % inside _() 2012-03-08 13:35:27 -06:00
Na'Tosha Bard
c51d8441de largefiles: fix check-code errors. 2012-03-09 17:11:07 +01:00
Na'Tosha Bard
65205ee295 largefiles: remove use of underscores that breaks coding convention 2012-03-09 16:11:52 +01:00
Na'Tosha Bard
a5ba0413ef largefiles: only update changed largefiles when transplanting 2012-03-09 15:26:13 +01:00
Na'Tosha Bard
064a3d8577 largefiles: move calculation of largefiles for updating to utility function 2012-03-09 16:45:49 +01:00
Martin Geisler
b8759cea3b largefiles: respect store.createmode and avoid extra file copy
Before, a tempfile was used to create a temp file was created with 600
permissions and the uploaded data was written into it. This file was
then *copied* to .hg/largefiles/<hash>.

We now simply use atomictempfile to write the data to a temp file with
the right permissions and then rename that into place.
2012-02-23 13:37:10 +01:00
Martin Geisler
61a444869a largefiles: respect store.createmode in basestore.get
This replaces another use of tempfile with atomictempfile. The problem
with tempfile is that it creates files with 600 permissions instead of
respecting repo.store.createmode.
2012-02-23 13:37:10 +01:00
Martin Geisler
c3f611d55c largefiles: use repo.store.createmode for new files in .hg/largefiles
Before, the mode was copied from the file in the working copy. This is
inconsistent with how Mercurial normally creates files inside the .hg
folder. This can lead to a situation where you can read the files
under .hg/store but not under .hg/largefiles and so a clone will fail
if it needs to access a largefile.
2012-02-23 13:22:55 +01:00
Dan Villiom Podlaski Christiansen
83af46e848 largefiles: don't break filesets 2012-02-20 17:59:48 +01:00
Matt Mackall
7f2d6a6af7 merge with stable 2012-03-08 15:59:33 -06:00
Matt Mackall
ee77ef5137 merge with stable 2012-02-24 16:16:48 -06:00
Matt Mackall
72210502d5 merge with stable 2012-02-22 17:36:33 -06:00
FUJIWARA Katsunori
c3838f8d3f largefiles: check whether specified patterns are related to largefiles strictly
current 'lfiles_repo.status()' implementation examines whether
specified patterns are related to largefiles in working directory (not
to STANDIN) or not by NOT-EMPTY-NESS of below list:

    [f for f in match.files() if f in lfdirstate]

but it can not be assumed that all in 'match.files()' are file itself
exactly, because user may only specify part of path to match whole
under subdirectories recursively.

above examination will mis-recognize such pattern as 'not related to
largefiles', and executes normal 'status()' procedure. so, 'hg status'
shows '?'(unknown) status for largefiles in working directory unexpectedly.

this patch examines relation of pattern to largefiles by applying
'match()' on each entries in lfdirstate and checking wheter there is
no matched entry.

it may increase cost of examination, because it causes of full scan of
entries in lfdirstate.

so this patch uses normal for-loop instead of list comprehensions, to
decrease cost when matching is found.
2012-02-15 23:01:09 +09:00
Na'Tosha Bard
8564a2aba3 largefiles: only cache largefiles in new heads
This fixes a serious performance regression in largefiles introduced in
Mercurial 2.1.  Caching new largefiles on pull is necessary, because
otherwise largefiles will be missing (and unable to be downloaded) when
the user tries to merge or rebase a new head with an old one.  But this
is an expensive operation and should only be done for heads that are new
from the pull, rather than on all heads in the repository.
2012-02-10 14:46:09 +01:00
FUJIWARA Katsunori
b1ab26d815 i18n: use util.pconvert() instead of 'str.replace()' for problematic encoding
some problematic encodings use backslash as part of multi-byte characters.

util.pconvert() can treat strings in such encodings correctly, if
win32mbcs is enabled, but str.replace() can not.
2012-02-05 22:58:31 +09:00
Na'Tosha Bard
979dbb4473 largefiles: fix revert on missing largefile (issue3217) 2012-01-25 16:52:16 +01:00
Na'Tosha Bard
e63a87cfd7 largefiles: fix transplant for all cases (issue3192) 2012-01-25 14:10:01 +01:00
Matt Mackall
ee1d294b90 merge with stable 2012-02-16 16:40:29 -06:00
Na'Tosha Bard
8640514f70 largefiles: optimize update speed by only updating changed largefiles
Historically, during 'hg update', every largefile in the working copy was
hashed (which is a very expensive operation on big files) and any
largefiles that did not have a hash that matched their standin were
updated.

This patch optimizes 'hg update' by keeping track of what standins have
changed between the old and new revisions, and only updating the largefiles
that have changed.  This saves a lot of time by avoiding the unecessary
calculation of a list of sha1 hashes for big files.

With this patch, the time 'hg update' takes to complete is a function of
how many largefiles need to be updated and what their size is.

Performance tests on a repository with about 80 largefiles ranging from
a few MB to about 97 MB are shown below.  The tests show how long it takes
to run 'hg update' with no changes actually being updated.

Mercurial 2.1 release:

$ time hg update
0 files updated, 0 files merged, 0 files removed, 0 files unresolved
getting changed largefiles
0 largefiles updated, 0 removed

real    0m10.045s
user    0m9.367s
sys    0m0.674s

With this patch:

$ time hg update
0 files updated, 0 files merged, 0 files removed, 0 files unresolved

real    0m0.965s
user    0m0.845s
sys    0m0.115s

The same repsoitory, without the largefiles extension enabled:

$ time hg update
0 files updated, 0 files merged, 0 files removed, 0 files unresolved

real    0m0.799s
user    0m0.684s
sys    0m0.111s

So before the patch, 'hg update' with no changes was approximately 9.25s
slower with largefiles enabled.  With this patch, it is approximately 0.165s
slower.
2012-02-13 18:37:07 +01:00
Matt Mackall
bd7d3adcb4 merge with stable 2012-02-10 17:09:23 -06:00
Matt Mackall
e3a172f2f0 merge: don't use unknown()
This removes use of unknown files for building the synthetic working
directory manifest used by manifestmerge. Instead, we adopt the
strategy used by _checkunknown.

Side-effect: unknown files are no longer moved by remote directory
renames, and now are left alone like ignored files.
2012-02-09 17:04:17 -06:00
Matt Mackall
f454042775 merge: refactor unknown file conflict checking
Previously, we would do a full working directory walk including
unknown files to perform a merge. In many cases, this was painful
because unknown files greatly outnumbered tracked files and generally
had no useful effect on the merge.

Here we instead wait until we find a file in the destination that's
not tracked locally and detect if it exists and is not ignored. This
is usually cheaper but can be -more- expensive in the case where we're
adding a huge number of files. On the other hand, the cost of statting
the new files should be dwarfed by the cost of eventually writing
them.

In this version, case collisions are detected implicitly by
os.path.exists and wctx[f] lookup.
2012-02-09 16:50:19 -06:00
Matt Mackall
6715adc25e merge with stable 2012-02-06 15:22:43 -06:00
FUJIWARA Katsunori
1343f41ef6 largefiles: reduce redundant splitstandin/standin combination
assumptions:

    - 'lfutil.splitstandin(f)' strips 'f' of '.hglf/', if it can
    - 'lfile(f)' examines 'lfutil.standin(f) in manifest'
    - 'lfutil.standin(f)' adds '.hglf/' to 'f'

and

    - 'f' should start with '.hglf/' there, because it is already
      examined by 'lfutil.isstandin(f)'

then:

    lfile(lfutil.splitstandin(f))
      => lfile(<f without '.hglf/'>)
      => lfutil.standin(<f without '.hglf/'>) in manifest
      => <<f without '.hglf/'> with '.hglf/'> in manifest
      => f in manifest
2012-02-06 12:16:29 +09:00
FUJIWARA Katsunori
7600c7feb1 largefiles: reduce OR-ing of same conditions 2012-02-06 12:16:29 +09:00
Na'Tosha Bard
a93a493b94 largefiles: fix addremove when no largefiles are specified 2012-01-23 13:24:32 +01:00
Na'Tosha Bard
ccfa519703 largefiles: add --normal option to hg add (issue3061) 2011-12-02 18:20:32 +01:00
Na'Tosha Bard
77c6b2a6a2 largefiles: fix caching largefiles from an aliased repo (issue3212) 2012-01-20 11:56:12 +01:00
Patrick Mezard
7768e63bf5 largefiles: test and simplify empty directory removal in remove 2012-01-19 10:07:13 +01:00
Na'Tosha Bard
1e5b58f8a8 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.
2012-01-18 11:33:14 +01:00
Patrick Mezard
b21e9758d9 largefiles: remove unused lfutil.readhash() 2012-01-18 14:33:19 +01:00
Na'Tosha Bard
69b4cf9fd4 largefiles: check if largefile could be found when archiving (issue3193) 2012-01-18 14:19:43 +01:00
Na'Tosha Bard
be9c0ca800 largefiles: refactor lfutil.findfiles to be more logical 2012-01-18 13:41:03 +01:00
Matt Mackall
35e56c3616 merge with stable 2012-01-18 15:07:15 -06:00
Patrick Mezard
2c7c26d633 largefiles: remove empty directories upon update (issue3202) 2012-01-17 11:29:32 +01:00
Na'Tosha Bard
922ddbc57a largefiles: correctly handle newly added largefile on other side of merge 2012-01-16 19:45:35 +01:00
Na'Tosha Bard
d2bd6a2acb largefiles: fix output of hg summary (issue3060) 2012-01-08 12:35:47 +01:00
Na'Tosha Bard
0bd0abc6e9 largefiles: fix confusion upon removal of added largefile (issue3176)
This patch makes "hg remove" work the same way on largefiles as it does on
regular Mercurial files.  If you try to remove an added largefile, the removal
fails and you are instead prompted to use "hg forget" to undo the add.
2012-01-08 11:19:51 +01:00
Michal Sznajder
1dd342b724 largefiles: clarify help when options are ignored until first add is done 2011-12-28 00:01:48 +01:00
Matt Mackall
c0c746bcbd largefiles: copy files in binary mode (issue3164) 2011-12-20 11:43:38 -06:00
Martin Geisler
19be7012dc largefiles: handle merges between normal files and largefiles (issue3084)
The largefiles extension prevents users from adding a normal file
named 'foo' if there is already a largefile with the same name.
However, there was a loop-hole: when merging, it was possible to bring
in a normal file named 'foo' while also having a '.hglf/foo' file.

This patch fixes this by extending the manifest merge to deal with
these kinds of conflicts. If there is a normal file 'foo' in the
working copy, and the other parent brings in a '.hglf/foo' file, then
the user will be prompted to keep the normal file or the largefile.
Likewise for the symmetric case where a normal file is brought in via
the second parent. The prompt looks like this:

  $ hg merge
  foo has been turned into a largefile
  use (l)argefile or keep as (n)ormal file?

After the merge, either the '.hglf/foo' file or the 'foo' file will
have been deleted. This would cause status to return output like:

  $ hg status
  M foo
  R foo

To fix this, the lfiles_repo.status method is changed so that a
removed normal file isn't shown if there is largefile with the same
name, and vice versa for largefiles.
2011-12-09 17:35:00 +01:00
Kevin Gessner
edef96f084 largefiles: don't require a user cache (issue3088) (issue3155)
If the user cache path isn't specified in .hgrc, and it can't be constructed
from the environment, don't try to use that cache.
2011-12-15 13:19:43 -05:00
Martin Geisler
3a9a310829 largefiles: fix 'hg status' abort after merge
If a largefile is introduced on the branch that is merged into the
working copy, then 'hg status' would abort with an error like:

   $ hg status
   abort: .hglf/foo@33fdd332ec: not found in manifest!

The problem was that the largefiles status code only looked in the
first parent for the largefile. Largefiles are now always reported as
modified if they don't exist in the first parent -- this matches the
behavior of localrepo.status for normal files.
2011-12-09 17:34:58 +01:00
Na'Tosha Bard
5fa005e186 largefiles: correctly download new largefiles when merging
There is a bug in the merge process where, if a new largefile is introduced
in a merge and the user does not have that largefile in his repo's local store
nor in his system cache, the working copy will retain the old largefile.  Upon
the commit of the merge, the standin is re-written to contain the hash of the
old largefile, and the lfdirstate retains a "Modified" status for the file.
The end result is that the largefile can show up in the merge commit as
"Modified", but the standin has no diff.  This is wrong in two ways:

  1) Such a "wedged" history with a nonsense change in a commit should not be
      possible
  2) It effectively reverts a largefile to an old version when doing a merge

This is caused by the fact that the updatelfiles() command always checks the
current largefile's hash against the hash stored in the current node's standin.
This is correct behavior in every case except for a merge.  When merging, we
must assume that the standin in the working copy contains the correct hash,
because the original hg.merge() has already updated it for us.

This patch fixes the issue by patching the repo object to carry a "_ismerging"
attribute, that the updatelfiles() command checks for.  When this attribute is
found, it checks against the working copy's standin, rather than the standin
in the current node.
2012-01-11 16:53:51 +01:00
Levi Bard
d1dde129fb largefiles: remove pasted code
Refactor and remove pasted code from lfcommands.py
2012-01-08 17:46:27 +01:00
Levi Bard
cd1e9ae0e5 largefiles: add error checking to tags conversion (issue3092)
Check for errors when parsing .hgtags during lfconvert,
and skip lines that don't parse or refer to invalid changesets.
2012-01-08 17:06:34 +01:00
Levi Bard
11d6177f07 largefiles: don't reference uninitialized variable (issue3092) 2012-01-08 17:03:39 +01:00
Dan Villiom Podlaski Christiansen
b83792b911 largefiles: factor out a copyalltostore() function 2012-01-08 14:33:10 +01:00
Levi Bard
745707ea8a largefiles: fix inappropriate locking (issue3182)
Don't lock/write on operations that should be readonly (status).
Always lock when writing the lfdirstate (rollback).
Don't write lfdirstate until after committing; state isn't actually changed
until the commit is complete.
2012-01-07 19:05:59 +01:00
Na'Tosha Bard
0bbf2e33ad largefiles: correctly handle dirstate status when rebasing
When rebasing, we need to trust that the standins are always correct. The
rebase operation updates the standins according to the changeset it is
rebasing. We need to make the largefiles in the working copy match.  If we
don't make them match, then they get accidentally reverted, either during
the rebase or during the next commit after the rebase.

This worked previously only becuase we were relying on the behavior that
largefiles with a changed standin, but unchanged contents, never showed up in
the list of modified largefiles.  Unfortunately, pre-commit hooks can get
an incorrect status this way, and it also results in extra execution of code.

The solution is to simply trust the standins when we are about to commit a
rebased changeset, and politely ask updatelfiles() to pull the new contents
down.  In this case, updatelfiles() will also mark any files it has pulled
down as dirty in the lfdirstate so that pre-commit hooks will get correct
status output.
2012-01-07 18:43:34 +01:00
Na'Tosha Bard
05ebae9a13 largefiles: implement addremove (issue3064)
Implementing addremove correctly in largefiles is tricky, becuase the original
addremove function does not call into any of the add or remove function we've
already overridden in the extension.  So the trick is to implement addremove
without duplicating any code.

This patch implements addremove by pulling out the interesting parts of
override_add() and override_remove() into generic utility functions, and
using those to handle the largefiles in addremove.  Then a matcher is
installed that will ignore all largefiles, and the original addremove
function is called to take care of the regular files in addremove.

A small bit of monkey patching is used to make sure that remove_largefiles()
notifies the user when a file is removed by addremove and also makes sure
the removal of largefiles doesn't interfer with the original addremove's
operation of removing the standin.
2012-01-07 12:42:54 +01:00
Levi Bard
68127050e4 largefiles: Fix parser warning: redefinition of unused 'node' from line 14 2012-01-08 11:23:21 +01:00
Martin Geisler
a6341e1149 merge with stable 2012-01-08 14:50:20 +01:00
Na'Tosha Bard
2695ae39d0 largefiles: remove invalid comment (issue3065)
This comment is invalid.  The hg.update() function will abort in the case of
any genuine error, so there is nothing to check.  If we have gotten to this
point in execution, nothing critical has gone wrong, and if any standins
have been updated, we must pull new largefiles.
2012-01-07 23:37:19 +01:00
Dan Villiom Podlaski Christiansen
175ef36b21 largefiles: remove a chunk of commented out code 2012-01-07 15:27:34 +01:00
Kevin Gessner
c57b4c7195 largefiles: display remote errors from putlfile (issue3123) (issue3149) 2012-01-05 07:26:22 -08:00
Matt Mackall
c9f57cde0f merge with stable 2011-12-29 14:45:18 -06:00
Michal Sznajder
09c755f459 largefiles: tiny code clean up
lfutil.islfilesrepo is a preffered way for testing if repo is largefiles enabled
2011-12-27 23:56:20 +01:00
Na'Tosha Bard
60040a8402 largefiles: fix rename (issue3093) 2011-11-30 15:11:00 +01:00
Matt Mackall
6e77a4d58a merge with i18n 2011-11-30 17:16:43 -06:00
Mads Kiilerich
2af29b7753 largefiles: avoid use of uinitialized variable in case of errors 2011-11-25 02:09:48 +01:00