Skip to content
Snippets Groups Projects
Commit 6e84171a authored by Matt Harbison's avatar Matt Harbison
Browse files

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
parent 483aa765
No related branches found
No related tags found
No related merge requests found
......@@ -515,10 +515,10 @@
dest.startswith(repo.wjoin(lfutil.shortname))):
srclfile = src.replace(repo.wjoin(lfutil.standin('')), '')
destlfile = dest.replace(repo.wjoin(lfutil.standin('')), '')
destlfiledir = os.path.dirname(destlfile) or '.'
destlfiledir = os.path.dirname(repo.wjoin(destlfile)) or '.'
if not os.path.isdir(destlfiledir):
os.makedirs(destlfiledir)
if rename:
os.rename(repo.wjoin(srclfile), repo.wjoin(destlfile))
lfdirstate.remove(srclfile)
else:
......@@ -519,10 +519,12 @@
if not os.path.isdir(destlfiledir):
os.makedirs(destlfiledir)
if rename:
os.rename(repo.wjoin(srclfile), repo.wjoin(destlfile))
lfdirstate.remove(srclfile)
else:
util.copyfile(srclfile, destlfile)
util.copyfile(repo.wjoin(srclfile),
repo.wjoin(destlfile))
lfdirstate.add(destlfile)
lfdirstate.write()
except util.Abort, e:
......
......@@ -141,6 +141,43 @@
$ cat sub/large4
large22
Test copies and moves from a directory other than root (issue3516)
$ cd ..
$ hg init lf_cpmv
$ cd lf_cpmv
$ mkdir dira
$ mkdir dira/dirb
$ touch dira/dirb/largefile
$ hg add --large dira/dirb/largefile
$ hg commit -m "added"
Invoking status precommit hook
A dira/dirb/largefile
$ cd dira
$ hg cp dirb/largefile foo/largefile
$ hg ci -m "deep copy"
Invoking status precommit hook
A dira/foo/largefile
$ find . | sort
.
./dirb
./dirb/largefile
./foo
./foo/largefile
$ hg mv foo/largefile baz/largefile
$ hg ci -m "moved"
Invoking status precommit hook
A dira/baz/largefile
R dira/foo/largefile
$ find . | sort
.
./baz
./baz/largefile
./dirb
./dirb/largefile
./foo
$ cd ../../a
#if hgweb
Test display of largefiles in hgweb
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment