sapling/eden/scm/tests/test-fb-hgext-lfs-pushrebase.t
Jun Wu e41d5cd495 changegroup: drop "added x changesets with y changes to z files" message
Summary:
Our current `hg pull` in production typically shows:

  % hg pull
  pulling from mononoke://...
  connected to ... session ...
  imported commit graph for ... commits (1 segment)

There is no "added x changesets ..." message. Drop it from tests.

This also makes it easier to migrate tests to remotefilelog repos, since
with remotefilelog it will show "0 changes to 0 files".

Differential Revision: D32570597

fbshipit-source-id: aa660e2cbd9bc07caa74f0126e152589b08e5c57
2021-12-14 22:16:15 -08:00

356 lines
9.2 KiB
Perl

#chg-compatible
$ setconfig experimental.allowfilepeer=True
$ disable treemanifest
$ configure mutation-norecord
$ . "$TESTDIR/library.sh"
$ enable lfs pushrebase
$ setconfig diff.git=1 pushrebase.rewritedates=false
$ readconfig <<EOF
> [lfs]
> threshold=10B
> url=file:$TESTTMP/dummy-remote/
> verify=existance
> EOF
# prepare a full repo with lfs metadata
$ hg init master
$ hg init lfs-upload-trigger
$ cd master
$ echo THIS-IS-LFS-FILE > x
$ hg commit -qAm x-lfs
$ hg mv x y
$ hg commit -m y-lfs
$ echo NOTLFS > y
$ hg commit -m y-nonlfs
$ hg mv y x
$ hg commit -m x-nonlfs
$ echo BECOME-LFS-AGAIN >> x
$ hg commit -m x-lfs-again
$ hg book master
$ hg push -q ../lfs-upload-trigger
$ cd ..
# clone a client
$ hg clone --no-shallow ssh://user@dummy/master client --noupdate
streaming all changes
5 files to transfer, * of data (glob)
transferred 2.01 KB in 0.0 seconds (1.97 MB/sec)
searching for changes
no changes found
$ cd client
$ hg update
1 files updated, 0 files merged, 0 files removed, 0 files unresolved
$ hg log -p -r ::tip -T '{node} {desc}\n' -G
@ 042535657086a5b08463b9210a8f46dc270e51f9 x-lfs-again
diff --git a/x b/x
--- a/x
+++ b/x
@@ -1,1 +1,2 @@
NOTLFS
+BECOME-LFS-AGAIN
o c6cc0cd58884b847de39aa817ded71e6051caa9f x-nonlfs
diff --git a/y b/x
rename from y
rename to x
o f3dec7f3610207dbf222ec2d7b68df16a5fde0f2 y-nonlfs
diff --git a/y b/y
--- a/y
+++ b/y
@@ -1,1 +1,1 @@
-THIS-IS-LFS-FILE
+NOTLFS
o 799bebfa53189a3db8424680f1a8f9806540e541 y-lfs
diff --git a/x b/y
rename from x
rename to y
o 0d2948821b2b3b6e58505696145f2215cea2b2cd x-lfs
diff --git a/x b/x
new file mode 100644
--- /dev/null
+++ b/x
@@ -0,0 +1,1 @@
+THIS-IS-LFS-FILE
# Clone a second client
$ cp -R . ../client2
# Edit the working copy
$ echo ADD-A-LINE >> x
$ hg mv x y
$ hg diff
diff --git a/x b/y
rename from x
rename to y
--- a/x
+++ b/y
@@ -1,2 +1,3 @@
NOTLFS
BECOME-LFS-AGAIN
+ADD-A-LINE
$ hg status -C
A y
x
R x
$ hg commit -m shallow.lfs.commit
# Introduce conflict in x in master
$ cd ../master
$ hg log -r master -T '{node}\n'
042535657086a5b08463b9210a8f46dc270e51f9
$ echo INTRODUCE-CONFLICT >> x
$ hg commit -qm introduce-conflict
$ hg log -r master -T '{node}\n'
949778ec92dd45fafbcc6ab7b8c843fdceb66e24
$ hg book conflict_master -r 949778ec92dd45fafbcc6ab7b8c843fdceb66e24
$ hg update -q 042535657086a5b08463b9210a8f46dc270e51f9
$ echo NEW-FILE >> z
$ hg commit -qAm add-new-file
$ hg log -r tip -T '{node}\n'
a5bcdd7fe9f0d300a2dbed2bd81d140547638856
$ hg book -f -r a5bcdd7fe9f0d300a2dbed2bd81d140547638856 master
$ hg log -T '{node} {bookmarks} {desc}\n' -G
@ a5bcdd7fe9f0d300a2dbed2bd81d140547638856 master add-new-file
o 949778ec92dd45fafbcc6ab7b8c843fdceb66e24 conflict_master introduce-conflict
o 042535657086a5b08463b9210a8f46dc270e51f9 x-lfs-again
o c6cc0cd58884b847de39aa817ded71e6051caa9f x-nonlfs
o f3dec7f3610207dbf222ec2d7b68df16a5fde0f2 y-nonlfs
o 799bebfa53189a3db8424680f1a8f9806540e541 y-lfs
o 0d2948821b2b3b6e58505696145f2215cea2b2cd x-lfs
# Push lfs content to server: conflict in x expected
$ cd ../client
$ hg push --to conflict_master ../master
pushing to ../master
searching for changes
abort: conflicting changes in:
x
(pull and rebase your changes locally, then try again)
[255]
# Push lfs content to server: succeed
$ mv $TESTTMP/master/.hg/store/lfs{,.bak}
$ hg push --to master ../master
pushing to ../master
searching for changes
pushing 1 changeset:
515a4dfd2e0c shallow.lfs.commit
2 new changesets from the server will be downloaded
adding changesets
adding manifests
adding file changes
1 files updated, 0 files merged, 0 files removed, 0 files unresolved
# This should work even if the HG server does not have access to LFS server
$ test -d $TESTTMP/master/.hg/store/lfs
[1]
# Check content
$ cd ../master
$ hg log -T '{node} {bookmarks} {desc}\n' -G
o b13138389e22bc6af15868704e6e7bcf502d2b3b shallow.lfs.commit
@ a5bcdd7fe9f0d300a2dbed2bd81d140547638856 master add-new-file
o 949778ec92dd45fafbcc6ab7b8c843fdceb66e24 conflict_master introduce-conflict
o 042535657086a5b08463b9210a8f46dc270e51f9 x-lfs-again
o c6cc0cd58884b847de39aa817ded71e6051caa9f x-nonlfs
o f3dec7f3610207dbf222ec2d7b68df16a5fde0f2 y-nonlfs
o 799bebfa53189a3db8424680f1a8f9806540e541 y-lfs
o 0d2948821b2b3b6e58505696145f2215cea2b2cd x-lfs
$ hg log -p -r tip -T '{node} {desc}\n'
b13138389e22bc6af15868704e6e7bcf502d2b3b shallow.lfs.commit
diff --git a/x b/y
rename from x
rename to y
--- a/x
+++ b/y
@@ -1,2 +1,3 @@
NOTLFS
BECOME-LFS-AGAIN
+ADD-A-LINE
$ hg book -f -r tip master
# Verify the server has lfs content after the pushrebase
$ hg debugindex y
rev offset length delta linkrev nodeid p1 p2
0 0 * -1 1 4ce3392f9979 000000000000 000000000000 (glob)
1 * * -1 2 139f72f7ca98 4ce3392f9979 000000000000 (glob)
2 * * -1 7 f3e0509ec098 000000000000 000000000000 (glob)
$ hg debugdata y 0
version https://git-lfs.github.com/spec/v1
oid sha256:802935f5411aa569948cd326115b3521107250019b5dbadf0f6ab2aa2d1e4639
size 17
x-hg-copy x
x-hg-copyrev 1ff4e6c9b2764057ea0c52f7b4a5a9be2e79c8e0
x-is-binary 0
$ hg debugdata y 1
NOTLFS
$ hg debugdata y 2
version https://git-lfs.github.com/spec/v1
oid sha256:a2fcdb080e9838f6e1476a494c1d553e6ffefb68b0d146a06f34b535b5198442
size 35
x-hg-copy x
x-hg-copyrev d33b2f7888d4f6f9112256d0f1c625af6d188fde
x-is-binary 0
$ hg cat -r 799bebfa53189a3db8424680f1a8f9806540e541 y
THIS-IS-LFS-FILE
$ hg cat -r f3dec7f3610207dbf222ec2d7b68df16a5fde0f2 y
NOTLFS
$ hg cat -r 'desc(shallow.lfs.commit)' y
NOTLFS
BECOME-LFS-AGAIN
ADD-A-LINE
$ hg debugindex x
rev offset length delta linkrev nodeid p1 p2
0 0 * -1 0 1ff4e6c9b276 000000000000 000000000000 (glob)
1 * * -1 3 68b9378cf5a1 000000000000 000000000000 (glob)
2 * * -1 4 d33b2f7888d4 68b9378cf5a1 000000000000 (glob)
3 * * -1 5 d587d4396479 d33b2f7888d4 000000000000 (glob)
# pull lfs content from server and update
$ cd ../client2
$ hg pull --bookmark master
pulling from ssh://user@dummy/master
searching for changes
adding changesets
adding manifests
adding file changes
updating bookmark master
$ hg update tip
2 files updated, 0 files merged, 1 files removed, 0 files unresolved
$ hg log -T '{node} {bookmarks} {desc}\n' -G
@ b13138389e22bc6af15868704e6e7bcf502d2b3b master shallow.lfs.commit
o a5bcdd7fe9f0d300a2dbed2bd81d140547638856 add-new-file
o 042535657086a5b08463b9210a8f46dc270e51f9 x-lfs-again
o c6cc0cd58884b847de39aa817ded71e6051caa9f x-nonlfs
o f3dec7f3610207dbf222ec2d7b68df16a5fde0f2 y-nonlfs
o 799bebfa53189a3db8424680f1a8f9806540e541 y-lfs
o 0d2948821b2b3b6e58505696145f2215cea2b2cd x-lfs
$ hg log -p -r tip -T '{node} {desc}\n'
b13138389e22bc6af15868704e6e7bcf502d2b3b shallow.lfs.commit
diff --git a/x b/y
rename from x
rename to y
--- a/x
+++ b/y
@@ -1,2 +1,3 @@
NOTLFS
BECOME-LFS-AGAIN
+ADD-A-LINE
$ cd ..
# Test pushing a file that shrunk from lfs to non-lfs
$ cat >> $HGRCPATH << EOF
> [extensions]
> remotenames=
> [lfs]
> url=
> verify=none
> [pushrebase]
> rewritedates = False
> EOF
$ hg init master2
$ hg clone -q ssh://user@dummy/master2 client3
$ cd client3
$ cat >> .hg/hgrc <<EOF
> [lfs]
> url=file:$TESTTMP/dummy-remote/
> EOF
$ echo THIS-IS-LFS-FILE > x
$ hg commit -qAm x-lfs
$ hg push -q --create --to master -r .
$ hg pull -f -q
$ hg up master
0 files updated, 0 files merged, 0 files removed, 0 files unresolved
$ hg mv x y
$ hg commit -m y-lfs
$ hg push -q --to master -r .
$ hg up master
0 files updated, 0 files merged, 0 files removed, 0 files unresolved
# Cannot push a change that goes from lfs to not-lfs where the previous file
# revision is a rename. This is because internally the server needs to compare
# contents since the rename prevents it from comparing hashes.
$ echo NOT-LFS > y
$ hg commit -m y-not-lfs
$ hg push --to master -r .
pushing rev 026f7366f3d2 to destination ssh://user@dummy/master2 bookmark master
searching for changes
remote: lfs.url needs to be configured
remote: pushing 1 changeset:
remote: 026f7366f3d2 y-not-lfs
abort: push failed on remote
[255]
# Can push once server has lfs.url set
$ cat >> ../master2/.hg/hgrc <<EOF
> [lfs]
> url=file:$TESTTMP/dummy-remote/
> EOF
$ hg push --to master -r .
pushing rev 026f7366f3d2 to destination ssh://user@dummy/master2 bookmark master
searching for changes
updating bookmark master
remote: pushing 1 changeset:
remote: 026f7366f3d2 y-not-lfs