tests: migrate test-[ef]*-t.py back to .t tests

Summary:
See the previous diff for context. Those tests are migrated back via the script
with some manual edits.

Reviewed By: sggutier

Differential Revision: D35102167

fbshipit-source-id: 68227b8950c2f41ce8e0dfc7bb6cc257613b7b61
This commit is contained in:
Jun Wu 2022-05-26 18:13:23 -07:00 committed by Facebook GitHub Bot
parent a51037fe66
commit 6e4837bd3e
61 changed files with 2441 additions and 2596 deletions

View File

@ -158,20 +158,20 @@ segmentedchangelogcompatiblelist = """
test-encoding-textwrap.t
test-eolfilename.t
test-execute-bit.t
test-exitcodemask-t.py
test-exitcodemask.t
test-extension-hgext-prefix.t
test-extension-inline.t
test-extensions-afterloaded.t
test-extensions-default.t
test-extensions-wrapfunction.py
test-fb-hgext-absorb-filefixupstate.py
test-fb-hgext-arcconfig-t.py
test-fb-hgext-arcconfig.t
test-fb-hgext-catnotate.t
test-fb-hgext-checkmessagehook-t.py
test-fb-hgext-checkmessagehook.t
test-fb-hgext-copytrace-amend.t
test-fb-hgext-copytrace-mergedriver-t.py
test-fb-hgext-debugcommitmessage-t.py
test-fb-hgext-diff-since-last-submit-t.py
test-fb-hgext-copytrace-mergedriver.t
test-fb-hgext-debugcommitmessage.t
test-fb-hgext-diff-since-last-submit.t
test-fb-hgext-errorredirect.t
test-fb-hgext-extorder.t
test-fb-hgext-extutil.py
@ -193,8 +193,8 @@ segmentedchangelogcompatiblelist = """
test-fb-hgext-phabdiff.t
test-fb-hgext-phabstatus.t
test-fb-hgext-rage.t
test-fb-hgext-remotefilelog-bundleloop-t.py
test-fb-hgext-remotefilelog-commit-repack-t.py
test-fb-hgext-remotefilelog-bundleloop.t
test-fb-hgext-remotefilelog-commit-repack.t
test-fb-hgext-remotefilelog-datapack.py
test-fb-hgext-remotefilelog-histpack.py
test-fb-hgext-remotefilelog-localdatarepack-full.t
@ -210,17 +210,17 @@ segmentedchangelogcompatiblelist = """
test-fb-hgext-smartlog-smallcommitmetadata.t
test-fb-hgext-smartlog.t
test-fb-hgext-sshaskpass.py
test-fb-hgext-syncstatus-t.py
test-fb-hgext-syncstatus.t
test-fb-hgext-template-stat.t
test-fb-hgext-treemanifest-bad-tree.t
test-fb-hgext-treemanifest-convertflat.t
test-fb-hgext-treemanifest-sendtrees.t
test-fb-hgext-treemanifest-sparse-prefetch.t
test-fb-hgext-treemanifest-sparse-t.py
test-fb-hgext-tweakdefaults-bookmarks-t.py
test-fb-hgext-treemanifest-sparse.t
test-fb-hgext-tweakdefaults-bookmarks.t
test-fb-hgext-tweakdefaults-grep.t
test-fb-hgext-tweakdefaults-opawarecommands.t
test-fb-hgext-tweakdefaults-ordering-t.py
test-fb-hgext-tweakdefaults-ordering.t
test-fb-hgext-tweakdefaults-revsets.t
test-filecache.py
test-filelog.py
@ -427,7 +427,7 @@ segmentedchangelogcompatiblelist = """
test-fb-hgext-copytrace.t
test-fb-hgext-crdump.t
test-fb-hgext-debugdetectissues.t
test-fb-hgext-dirsync-amend-t.py
test-fb-hgext-dirsync-amend.t
test-fb-hgext-dirsync.t
test-fb-hgext-git-getmeta.t
test-fb-hgext-merge-conflictinfo.t
@ -448,10 +448,10 @@ segmentedchangelogcompatiblelist = """
test-fb-hgext-remotefilelog-ruststores-rotatelog-size.t
test-fb-hgext-remotefilelog-treemanifest-corrupt.t
test-fb-hgext-remotefilelog-worker.t
test-fb-hgext-reset-remotenames-t.py
test-fb-hgext-reset-remotenames.t
test-fb-hgext-treemanifest-blame.t
test-fb-hgext-treemanifest-comparetrees.t
test-fb-hgext-treemanifest-disabled-t.py
test-fb-hgext-treemanifest-disabled.t
test-fb-hgext-treemanifest-infinitepush.t
test-fb-hgext-treemanifest-peertopeer.t
test-fb-hgext-treemanifest-pushrebase.t
@ -596,36 +596,36 @@ ignorerevnumincompatiblelist = """
test-eol-clone.t
test-eol-hook.t
test-eol-update.t
test-export-t.py
test-export.t
test-extdata.t
test-fb-hgext-copytrace-errormsg-t.py
test-fb-hgext-copytrace-errormsg.t
test-fb-hgext-drop.t
test-fb-hgext-fastannotate-corrupt.t
test-fb-hgext-fastannotate-perfhack.t
test-fb-hgext-fastannotate-protocol.t
test-fb-hgext-fastannotate-renames-t.py
test-fb-hgext-fastannotate-renames.t
test-fb-hgext-fastannotate.t
test-fb-hgext-fastlog.t
test-fb-hgext-fbhistedit-rebase-interactive.t
test-fb-hgext-morestatus.t
test-fb-hgext-phrevset-t.py
test-fb-hgext-phrevset.t
test-fb-hgext-pushrebase-remotenames.t
test-fb-hgext-remotefilelog-prefetch.t
test-fb-hgext-remotefilelog-sparse.t
test-fb-hgext-remotefilelog-wireproto-t.py
test-fb-hgext-reset-remotenames-t.py
test-fb-hgext-reset-t.py
test-fb-hgext-smartlog-inhibit-t.py
test-fb-hgext-smartlog-remotenames-t.py
test-fb-hgext-remotefilelog-wireproto.t
test-fb-hgext-reset-remotenames.t
test-fb-hgext-reset.t
test-fb-hgext-smartlog-inhibit.t
test-fb-hgext-smartlog-remotenames.t
test-fb-hgext-treemanifest-noflat.t
test-fb-hgext-treemanifest-prefetch.t
test-fb-hgext-treemanifest.t
test-fb-hgext-tweakdefaults-ordering-t.py
test-fb-hgext-tweakdefaults-pullrebaseremotenames-t.py
test-fb-hgext-tweakdefaults-ordering.t
test-fb-hgext-tweakdefaults-pullrebaseremotenames.t
test-fb-hgext-tweakdefaults-remotenames.t
test-fb-hgext-tweakdefaults.t
test-fb-hgext-tweakdefaults-update-t.py
test-fb-hgext-whereami-t.py
test-fb-hgext-tweakdefaults-update.t
test-fb-hgext-whereami.t
test-fileset.t
test-git-export.t
test-glog-topological-t.py

View File

@ -1,28 +0,0 @@
# Copyright (c) Meta Platforms, Inc. and affiliates.
# Copyright (c) Mercurial Contributors.
#
# This software may be used and distributed according to the terms of the
# GNU General Public License version 2 or any later version.
from __future__ import absolute_import
from testutil.dott import feature, sh, testtmp # noqa: F401
sh % "configure modernclient"
# Create an empty repo:
sh % "newclientrepo a"
# Try some commands:
sh % "hg log"
sh % "hg histgrep wah" == "[1]"
sh % "hg manifest"
# Poke at a clone:
sh % "hg push -r . -q --to book --create"
sh % "cd .."
sh % "newclientrepo b test:a_server" == ""
sh % "hg log" == ""

View File

@ -0,0 +1,27 @@
#debugruntest-compatible
# Copyright (c) Meta Platforms, Inc. and affiliates.
# Copyright (c) Mercurial Contributors.
#
# This software may be used and distributed according to the terms of the
# GNU General Public License version 2 or any later version.
$ configure modernclient
# Create an empty repo:
$ newclientrepo a
# Try some commands:
$ hg log
$ hg histgrep wah
[1]
$ hg manifest
# Poke at a clone:
$ hg push -r . -q --to book --create
$ cd ..
$ newclientrepo b test:a_server
$ hg log

View File

@ -1,41 +0,0 @@
# Copyright (c) Meta Platforms, Inc. and affiliates.
#
# This software may be used and distributed according to the terms of the
# GNU General Public License version 2.
from __future__ import absolute_import
from testutil.dott import feature, sh, testtmp # noqa: F401
# Command line flag is effective:
sh % "hg add a --config 'ui.exitcodemask=63'" == r"""
abort: '$TESTTMP' is not inside a repository, but this command requires a repository!
(use 'cd' to go to a directory inside a repository and try again)
[63]"""
sh % "'HGPLAIN=1' hg add a --config 'ui.exitcodemask=63'" == r"""
abort: '$TESTTMP' is not inside a repository, but this command requires a repository!
(use 'cd' to go to a directory inside a repository and try again)
[63]"""
# Config files are ignored if HGPLAIN is set:
sh % "setconfig 'ui.exitcodemask=31'"
sh % "hg add a" == r"""
abort: '$TESTTMP' is not inside a repository, but this command requires a repository!
(use 'cd' to go to a directory inside a repository and try again)
[31]"""
sh % "'HGPLAIN=1' hg add a" == r"""
abort: '$TESTTMP' is not inside a repository, but this command requires a repository!
(use 'cd' to go to a directory inside a repository and try again)
[255]"""
# But HGPLAINEXCEPT can override the behavior:
sh % "'HGPLAIN=1' 'HGPLAINEXCEPT=exitcode' hg add a" == r"""
abort: '$TESTTMP' is not inside a repository, but this command requires a repository!
(use 'cd' to go to a directory inside a repository and try again)
[31]"""

View File

@ -0,0 +1,37 @@
#debugruntest-compatible
# Copyright (c) Meta Platforms, Inc. and affiliates.
#
# This software may be used and distributed according to the terms of the
# GNU General Public License version 2.
# Command line flag is effective:
$ hg add a --config 'ui.exitcodemask=63'
abort: '$TESTTMP' is not inside a repository, but this command requires a repository!
(use 'cd' to go to a directory inside a repository and try again)
[63]
$ HGPLAIN=1 hg add a --config 'ui.exitcodemask=63'
abort: '$TESTTMP' is not inside a repository, but this command requires a repository!
(use 'cd' to go to a directory inside a repository and try again)
[63]
# Config files are ignored if HGPLAIN is set:
$ setconfig 'ui.exitcodemask=31'
$ hg add a
abort: '$TESTTMP' is not inside a repository, but this command requires a repository!
(use 'cd' to go to a directory inside a repository and try again)
[31]
$ HGPLAIN=1 hg add a
abort: '$TESTTMP' is not inside a repository, but this command requires a repository!
(use 'cd' to go to a directory inside a repository and try again)
[255]
# But HGPLAINEXCEPT can override the behavior:
$ HGPLAIN=1 HGPLAINEXCEPT=exitcode hg add a
abort: '$TESTTMP' is not inside a repository, but this command requires a repository!
(use 'cd' to go to a directory inside a repository and try again)
[31]

View File

@ -1,356 +0,0 @@
# Copyright (c) Meta Platforms, Inc. and affiliates.
# Copyright (c) Mercurial Contributors.
#
# This software may be used and distributed according to the terms of the
# GNU General Public License version 2 or any later version.
from __future__ import absolute_import
from edenscm.mercurial import pycompat
from testutil.dott import feature, sh, testtmp # noqa: F401
sh % "hg init repo"
sh % "cd repo"
sh % "touch foo"
sh % "hg add foo"
for i in range(12):
open("foo", "ab").write(b"foo-%s\n" % pycompat.encodeutf8(str(i)))
sh.hg("ci", "-m", "foo-%s" % i)
sh % "hg export -v -o 'foo-%nof%N.patch' 2:tip" == r"""
exporting patches:
foo-01of10.patch
foo-02of10.patch
foo-03of10.patch
foo-04of10.patch
foo-05of10.patch
foo-06of10.patch
foo-07of10.patch
foo-08of10.patch
foo-09of10.patch
foo-10of10.patch"""
sh % "hg export -v -o 'foo-%%%H.patch' 2:tip" == r"""
exporting patches:
foo-%617188a1c80f869a7b66c85134da88a6fb145f67.patch
foo-%dd41a5ff707a5225204105611ba49cc5c229d55f.patch
foo-%f95a5410f8664b6e1490a4af654e4b7d41a7b321.patch
foo-%4346bcfde53b4d9042489078bcfa9c3e28201db2.patch
foo-%afda8c3a009cc99449a05ad8aa4655648c4ecd34.patch
foo-%35284ce2b6b99c9d2ac66268fe99e68e1974e1aa.patch
foo-%9688c41894e6931305fa7165a37f6568050b4e9b.patch
foo-%747d3c68f8ec44bb35816bfcd59aeb50b9654c2f.patch
foo-%5f17a83f5fbd9414006a5e563eab4c8a00729efd.patch
foo-%f3acbafac161ec68f1598af38f794f28847ca5d3.patch"""
sh % "hg export -v -o 'foo-%b-%R.patch' 2:tip" == r"""
exporting patches:
foo-repo-2.patch
foo-repo-3.patch
foo-repo-4.patch
foo-repo-5.patch
foo-repo-6.patch
foo-repo-7.patch
foo-repo-8.patch
foo-repo-9.patch
foo-repo-10.patch
foo-repo-11.patch"""
sh % "hg export -v -o 'foo-%h.patch' 2:tip" == r"""
exporting patches:
foo-617188a1c80f.patch
foo-dd41a5ff707a.patch
foo-f95a5410f866.patch
foo-4346bcfde53b.patch
foo-afda8c3a009c.patch
foo-35284ce2b6b9.patch
foo-9688c41894e6.patch
foo-747d3c68f8ec.patch
foo-5f17a83f5fbd.patch
foo-f3acbafac161.patch"""
sh % "hg export -v -o 'foo-%r.patch' 2:tip" == r"""
exporting patches:
foo-02.patch
foo-03.patch
foo-04.patch
foo-05.patch
foo-06.patch
foo-07.patch
foo-08.patch
foo-09.patch
foo-10.patch
foo-11.patch"""
sh % "hg export -v -o 'foo-%m.patch' 2:tip" == r"""
exporting patches:
foo-foo_2.patch
foo-foo_3.patch
foo-foo_4.patch
foo-foo_5.patch
foo-foo_6.patch
foo-foo_7.patch
foo-foo_8.patch
foo-foo_9.patch
foo-foo_10.patch
foo-foo_11.patch"""
# Doing it again clobbers the files rather than appending:
sh % "hg export -v -o foo-%m.patch 2:3" == r"""
exporting patches:
foo-foo_2.patch
foo-foo_3.patch"""
sh % "grep HG foo-foo_2.patch" | "wc -l" == "1"
sh % "grep HG foo-foo_3.patch" | "wc -l" == "1"
# Exporting 4 changesets to a file:
sh % "hg export -o export_internal 1 2 3 4"
sh % "grep HG export_internal" | "wc -l" == "4"
# Doing it again clobbers the file rather than appending:
sh % "hg export -o export_internal 1 2 3 4"
sh % "grep HG export_internal" | "wc -l" == "4"
# Exporting 4 changesets to stdout:
sh % "hg export 1 2 3 4" | "grep HG" | "wc -l" == "4"
# Exporting revision -2 to a file:
sh % "hg export -- -2" == r"""
# HG changeset patch
# User test
# Date 0 0
# Thu Jan 01 00:00:00 1970 +0000
# Node ID 5f17a83f5fbd9414006a5e563eab4c8a00729efd
# Parent 747d3c68f8ec44bb35816bfcd59aeb50b9654c2f
foo-10
diff -r 747d3c68f8ec -r 5f17a83f5fbd foo
--- a/foo Thu Jan 01 00:00:00 1970 +0000
+++ b/foo Thu Jan 01 00:00:00 1970 +0000
@@ -8,3 +8,4 @@
foo-7
foo-8
foo-9
+foo-10"""
# Exporting wdir revision:
sh % "echo foo-wdir" >> "foo"
sh % 'hg export "wdir()"' == r"""
# HG changeset patch
# User test
# Date 0 0
# Thu Jan 01 00:00:00 1970 +0000
# Node ID ffffffffffffffffffffffffffffffffffffffff
# Parent f3acbafac161ec68f1598af38f794f28847ca5d3
diff -r f3acbafac161 foo
--- a/foo Thu Jan 01 00:00:00 1970 +0000
+++ b/foo Thu Jan 01 00:00:00 1970 +0000
@@ -10,3 +10,4 @@
foo-9
foo-10
foo-11
+foo-wdir"""
sh % "hg revert -q foo"
# No filename should be printed if stdout is specified explicitly:
sh % "hg export -v 1 -o -" == r"""
exporting patch:
# HG changeset patch
# User test
# Date 0 0
# Thu Jan 01 00:00:00 1970 +0000
# Node ID d1c9656e973cfb5aebd5499bbd2cb350e3b12266
# Parent 871558de6af2e8c244222f8eea69b782c94ce3df
foo-1
diff -r 871558de6af2 -r d1c9656e973c foo
--- a/foo Thu Jan 01 00:00:00 1970 +0000
+++ b/foo Thu Jan 01 00:00:00 1970 +0000
@@ -1,1 +1,2 @@
foo-0
+foo-1"""
# Checking if only alphanumeric characters are used in the file name (%m option):
sh % "echo line" >> "foo"
sh % 'hg commit -m " !\\"#$%&(,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~"'
sh % "hg export -v -o %m.patch tip" == r"""
exporting patch:
____________0123456789_______ABCDEFGHIJKLMNOPQRSTUVWXYZ______abcdefghijklmnopqrstuvwxyz____.patch"""
# Catch exporting unknown revisions (especially empty revsets, see issue3353)
sh % "hg export" == r"""
# HG changeset patch
# User test
# Date 0 0
# Thu Jan 01 00:00:00 1970 +0000
# Node ID 197ecd81a57f760b54f34a58817ad5b04991fa47
# Parent f3acbafac161ec68f1598af38f794f28847ca5d3
!"#$%&(,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~
diff -r f3acbafac161 -r 197ecd81a57f foo
--- a/foo Thu Jan 01 00:00:00 1970 +0000
+++ b/foo Thu Jan 01 00:00:00 1970 +0000
@@ -10,3 +10,4 @@
foo-9
foo-10
foo-11
+line"""
sh % "hg export ''" == r"""
hg: parse error: empty query
[255]"""
sh % "hg export 999" == r"""
abort: unknown revision '999'!
[255]"""
sh % 'hg export "not all()"' == r"""
abort: export requires at least one changeset
[255]"""
# Check for color output
(
sh % "cat"
<< r"""
[color]
mode = ansi
[extensions]
color =
"""
>> "$HGRCPATH"
)
sh % "hg export --color always --nodates tip" == rb"""
# HG changeset patch
# User test
# Date 0 0
# Thu Jan 01 00:00:00 1970 +0000
# Node ID * (glob)
# Parent * (glob)
!"#$%&(,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~
\x1b[0;1mdiff -r f3acbafac161 -r 197ecd81a57f foo\x1b[0m (esc)
\x1b[0;31;1m--- a/foo\x1b[0m (esc)
\x1b[0;32;1m+++ b/foo\x1b[0m (esc)
\x1b[0;35m@@ -10,3 +10,4 @@\x1b[0m (esc)
foo-9
foo-10
foo-11
\x1b[0;92m+line\x1b[0m (esc)"""
# Test exporting a subset of files
sh % "newrepo"
sh % "setconfig diff.git=1"
(
sh % "drawdag"
<< r"""
# B/foo/3=3\n (copied from bar/1)
# B/foo/1=1\n (copied from bar/1)
# B/bar/2=2\n
B # B/foo/2=2\n (copied from foo/1)
| # A/bar/1=0\n
A # A/foo/1=0\n
"""
)
sh % "hg export -r 'all()' --pattern 'path:foo'" == r"""
# HG changeset patch
# User test
# Date 0 0
# Thu Jan 01 00:00:00 1970 +0000
# Node ID * (glob)
# Parent 0000000000000000000000000000000000000000
A
diff --git a/foo/1 b/foo/1
new file mode 100644
--- /dev/null
+++ b/foo/1
@@ -0,0 +1,1 @@
+0
# HG changeset patch
# User test
# Date 0 0
# Thu Jan 01 00:00:00 1970 +0000
# Node ID * (glob)
# Parent * (glob)
B
diff --git a/foo/1 b/foo/1
--- a/foo/1
+++ b/foo/1
@@ -1,1 +1,1 @@
-0
+1
diff --git a/foo/1 b/foo/2
copy from foo/1
copy to foo/2
--- a/foo/1
+++ b/foo/2
@@ -1,1 +1,1 @@
-0
+2
diff --git a/bar/1 b/foo/3
copy from bar/1
copy to foo/3
--- a/bar/1
+++ b/foo/3
@@ -1,1 +1,1 @@
-0
+3"""
# Export with diff.filtercopysource=1 - note bar/1 -> foo/3 copy is ignored
sh % "hg export -r 'all()' --pattern 'path:foo/3' --config diff.filtercopysource=0" == r"""
# HG changeset patch
# User test
# Date 0 0
# Thu Jan 01 00:00:00 1970 +0000
# Node ID * (glob)
# Parent 0000000000000000000000000000000000000000
A
# HG changeset patch
# User test
# Date 0 0
# Thu Jan 01 00:00:00 1970 +0000
# Node ID * (glob)
# Parent * (glob)
B
diff --git a/bar/1 b/foo/3
copy from bar/1
copy to foo/3
--- a/bar/1
+++ b/foo/3
@@ -1,1 +1,1 @@
-0
+3"""
sh % "hg export -r 'all()' --pattern 'path:foo/3' --config diff.filtercopysource=1" == r"""
# HG changeset patch
# User test
# Date 0 0
# Thu Jan 01 00:00:00 1970 +0000
# Node ID * (glob)
# Parent 0000000000000000000000000000000000000000
A
# HG changeset patch
# User test
# Date 0 0
# Thu Jan 01 00:00:00 1970 +0000
# Node ID * (glob)
# Parent * (glob)
B
diff --git a/foo/3 b/foo/3
new file mode 100644
--- /dev/null
+++ b/foo/3
@@ -0,0 +1,1 @@
+3"""

View File

@ -0,0 +1,352 @@
#debugruntest-compatible
# Copyright (c) Meta Platforms, Inc. and affiliates.
# Copyright (c) Mercurial Contributors.
#
# This software may be used and distributed according to the terms of the
# GNU General Public License version 2 or any later version.
$ hg init repo
$ cd repo
$ touch foo
$ hg add foo
$ for i in `seq 0 11`; do
> echo foo-$i >> foo
> hg ci -m foo-$i
> done
$ hg export -v -o 'foo-%nof%N.patch' 2:tip
exporting patches:
foo-01of10.patch
foo-02of10.patch
foo-03of10.patch
foo-04of10.patch
foo-05of10.patch
foo-06of10.patch
foo-07of10.patch
foo-08of10.patch
foo-09of10.patch
foo-10of10.patch
$ hg export -v -o 'foo-%%%H.patch' 2:tip
exporting patches:
foo-%617188a1c80f869a7b66c85134da88a6fb145f67.patch
foo-%dd41a5ff707a5225204105611ba49cc5c229d55f.patch
foo-%f95a5410f8664b6e1490a4af654e4b7d41a7b321.patch
foo-%4346bcfde53b4d9042489078bcfa9c3e28201db2.patch
foo-%afda8c3a009cc99449a05ad8aa4655648c4ecd34.patch
foo-%35284ce2b6b99c9d2ac66268fe99e68e1974e1aa.patch
foo-%9688c41894e6931305fa7165a37f6568050b4e9b.patch
foo-%747d3c68f8ec44bb35816bfcd59aeb50b9654c2f.patch
foo-%5f17a83f5fbd9414006a5e563eab4c8a00729efd.patch
foo-%f3acbafac161ec68f1598af38f794f28847ca5d3.patch
$ hg export -v -o 'foo-%b-%R.patch' 2:tip
exporting patches:
foo-repo-2.patch
foo-repo-3.patch
foo-repo-4.patch
foo-repo-5.patch
foo-repo-6.patch
foo-repo-7.patch
foo-repo-8.patch
foo-repo-9.patch
foo-repo-10.patch
foo-repo-11.patch
$ hg export -v -o 'foo-%h.patch' 2:tip
exporting patches:
foo-617188a1c80f.patch
foo-dd41a5ff707a.patch
foo-f95a5410f866.patch
foo-4346bcfde53b.patch
foo-afda8c3a009c.patch
foo-35284ce2b6b9.patch
foo-9688c41894e6.patch
foo-747d3c68f8ec.patch
foo-5f17a83f5fbd.patch
foo-f3acbafac161.patch
$ hg export -v -o 'foo-%r.patch' 2:tip
exporting patches:
foo-02.patch
foo-03.patch
foo-04.patch
foo-05.patch
foo-06.patch
foo-07.patch
foo-08.patch
foo-09.patch
foo-10.patch
foo-11.patch
$ hg export -v -o 'foo-%m.patch' 2:tip
exporting patches:
foo-foo_2.patch
foo-foo_3.patch
foo-foo_4.patch
foo-foo_5.patch
foo-foo_6.patch
foo-foo_7.patch
foo-foo_8.patch
foo-foo_9.patch
foo-foo_10.patch
foo-foo_11.patch
# Doing it again clobbers the files rather than appending:
$ hg export -v -o foo-%m.patch 2:3
exporting patches:
foo-foo_2.patch
foo-foo_3.patch
$ grep HG foo-foo_2.patch | wc -l
1
$ grep HG foo-foo_3.patch | wc -l
1
# Exporting 4 changesets to a file:
$ hg export -o export_internal 1 2 3 4
$ grep HG export_internal | wc -l
4
# Doing it again clobbers the file rather than appending:
$ hg export -o export_internal 1 2 3 4
$ grep HG export_internal | wc -l
4
$ hg export 1 2 3 4 | grep HG | wc -l
4
# Exporting revision -2 to a file:
$ hg export -- -2
# HG changeset patch
# User test
# Date 0 0
# Thu Jan 01 00:00:00 1970 +0000
# Node ID 5f17a83f5fbd9414006a5e563eab4c8a00729efd
# Parent 747d3c68f8ec44bb35816bfcd59aeb50b9654c2f
foo-10
diff -r 747d3c68f8ec -r 5f17a83f5fbd foo
--- a/foo Thu Jan 01 00:00:00 1970 +0000
+++ b/foo Thu Jan 01 00:00:00 1970 +0000
@@ -8,3 +8,4 @@
foo-7
foo-8
foo-9
+foo-10
# Exporting wdir revision:
$ echo foo-wdir >> foo
$ hg export "wdir()"
# HG changeset patch
# User test
# Date 0 0
# Thu Jan 01 00:00:00 1970 +0000
# Node ID ffffffffffffffffffffffffffffffffffffffff
# Parent f3acbafac161ec68f1598af38f794f28847ca5d3
diff -r f3acbafac161 foo
--- a/foo Thu Jan 01 00:00:00 1970 +0000
+++ b/foo Thu Jan 01 00:00:00 1970 +0000
@@ -10,3 +10,4 @@
foo-9
foo-10
foo-11
+foo-wdir
$ hg revert -q foo
# No filename should be printed if stdout is specified explicitly:
$ hg export -v 1 -o -
exporting patch:
# HG changeset patch
# User test
# Date 0 0
# Thu Jan 01 00:00:00 1970 +0000
# Node ID d1c9656e973cfb5aebd5499bbd2cb350e3b12266
# Parent 871558de6af2e8c244222f8eea69b782c94ce3df
foo-1
diff -r 871558de6af2 -r d1c9656e973c foo
--- a/foo Thu Jan 01 00:00:00 1970 +0000
+++ b/foo Thu Jan 01 00:00:00 1970 +0000
@@ -1,1 +1,2 @@
foo-0
+foo-1
# Checking if only alphanumeric characters are used in the file name (%m option):
$ echo line >> foo
$ hg commit -m " !\"#$%&(,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]"'^'"_\`abcdefghijklmnopqrstuvwxyz{|}~"
$ hg export -v -o %m.patch tip
exporting patch:
____________0123456789_______ABCDEFGHIJKLMNOPQRSTUVWXYZ______abcdefghijklmnopqrstuvwxyz____.patch
# Catch exporting unknown revisions (especially empty revsets, see issue3353)
$ hg export
# HG changeset patch
# User test
# Date 0 0
# Thu Jan 01 00:00:00 1970 +0000
# Node ID 197ecd81a57f760b54f34a58817ad5b04991fa47
# Parent f3acbafac161ec68f1598af38f794f28847ca5d3
!"#$%&(,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~
diff -r f3acbafac161 -r 197ecd81a57f foo
--- a/foo Thu Jan 01 00:00:00 1970 +0000
+++ b/foo Thu Jan 01 00:00:00 1970 +0000
@@ -10,3 +10,4 @@
foo-9
foo-10
foo-11
+line
$ hg export ''
hg: parse error: empty query
[255]
$ hg export 999
abort: unknown revision '999'!
[255]
$ hg export "not all()"
abort: export requires at least one changeset
[255]
# Check for color output
$ cat >> $HGRCPATH << 'EOF'
> [color]
> mode = ansi
> [extensions]
> color =
> EOF
$ hg export --color always --nodates tip
# HG changeset patch
# User test
# Date 0 0
# Thu Jan 01 00:00:00 1970 +0000
# Node ID 197ecd81a57f760b54f34a58817ad5b04991fa47
# Parent f3acbafac161ec68f1598af38f794f28847ca5d3
!"#$%&(,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~
diff -r f3acbafac161 -r 197ecd81a57f foo
--- a/foo
+++ b/foo
@@ -10,3 +10,4 @@
foo-9
foo-10
foo-11
+line
# Test exporting a subset of files
$ newrepo
$ setconfig diff.git=1
$ drawdag << 'EOS'
> # B/foo/3=3\n (copied from bar/1)
> # B/foo/1=1\n (copied from bar/1)
> # B/bar/2=2\n
> B # B/foo/2=2\n (copied from foo/1)
> | # A/bar/1=0\n
> A # A/foo/1=0\n
> EOS
$ hg export -r 'all()' --pattern 'path:foo'
# HG changeset patch
# User test
# Date 0 0
# Thu Jan 01 00:00:00 1970 +0000
# Node ID * (glob)
# Parent 0000000000000000000000000000000000000000
A
diff --git a/foo/1 b/foo/1
new file mode 100644
--- /dev/null
+++ b/foo/1
@@ -0,0 +1,1 @@
+0
# HG changeset patch
# User test
# Date 0 0
# Thu Jan 01 00:00:00 1970 +0000
# Node ID * (glob)
# Parent * (glob)
B
diff --git a/foo/1 b/foo/1
--- a/foo/1
+++ b/foo/1
@@ -1,1 +1,1 @@
-0
+1
diff --git a/foo/1 b/foo/2
copy from foo/1
copy to foo/2
--- a/foo/1
+++ b/foo/2
@@ -1,1 +1,1 @@
-0
+2
diff --git a/bar/1 b/foo/3
copy from bar/1
copy to foo/3
--- a/bar/1
+++ b/foo/3
@@ -1,1 +1,1 @@
-0
+3
# Export with diff.filtercopysource=1 - note bar/1 -> foo/3 copy is ignored
$ hg export -r 'all()' --pattern 'path:foo/3' --config diff.filtercopysource=0
# HG changeset patch
# User test
# Date 0 0
# Thu Jan 01 00:00:00 1970 +0000
# Node ID * (glob)
# Parent 0000000000000000000000000000000000000000
A
# HG changeset patch
# User test
# Date 0 0
# Thu Jan 01 00:00:00 1970 +0000
# Node ID * (glob)
# Parent * (glob)
B
diff --git a/bar/1 b/foo/3
copy from bar/1
copy to foo/3
--- a/bar/1
+++ b/foo/3
@@ -1,1 +1,1 @@
-0
+3
$ hg export -r 'all()' --pattern 'path:foo/3' --config diff.filtercopysource=1
# HG changeset patch
# User test
# Date 0 0
# Thu Jan 01 00:00:00 1970 +0000
# Node ID * (glob)
# Parent 0000000000000000000000000000000000000000
A
# HG changeset patch
# User test
# Date 0 0
# Thu Jan 01 00:00:00 1970 +0000
# Node ID * (glob)
# Parent * (glob)
B
diff --git a/foo/3 b/foo/3
new file mode 100644
--- /dev/null
+++ b/foo/3
@@ -0,0 +1,1 @@
+3

View File

@ -1,37 +0,0 @@
# Copyright (c) Meta Platforms, Inc. and affiliates.
#
# This software may be used and distributed according to the terms of the
# GNU General Public License version 2.
from __future__ import absolute_import
from testutil.dott import feature, sh, testtmp # noqa: F401
(
sh % "cat"
<< r"""
[extensions]
arcconfig=$TESTDIR/../edenscm/hgext/extlib/phabricator/arcconfig.py
"""
>> "$HGRCPATH"
)
# Sanity check expectations when there is no arcconfig
sh % "hg init repo"
sh % "cd repo"
sh % "hg debugarcconfig" == r"""
abort: no .arcconfig found
[255]"""
# Show that we can locate and reflect the contents of the .arcconfig from
# the repo dir
sh % 'echo \'{"hello": "world"}\'' > ".arcconfig"
sh % "hg debugarcconfig" == '{"_arcconfig_path": "$TESTTMP/repo", "hello": "world"}'
# We expect to see the combination of the user arcrc and the repo rc
sh % "echo '{\"user\": true}'" > "$HOME/.arcrc"
sh % "hg debugarcconfig" == '{"_arcconfig_path": "$TESTTMP/repo", "hello": "world", "user": true}'

View File

@ -0,0 +1,31 @@
#debugruntest-compatible
# Copyright (c) Meta Platforms, Inc. and affiliates.
#
# This software may be used and distributed according to the terms of the
# GNU General Public License version 2.
$ cat >> $HGRCPATH << 'EOF'
> [extensions]
> arcconfig=$TESTDIR/../edenscm/hgext/extlib/phabricator/arcconfig.py
> EOF
# Sanity check expectations when there is no arcconfig
$ hg init repo
$ cd repo
$ hg debugarcconfig
abort: no .arcconfig found
[255]
# Show that we can locate and reflect the contents of the .arcconfig from
# the repo dir
$ echo '{"hello": "world"}' > .arcconfig
$ hg debugarcconfig
{"_arcconfig_path": "$TESTTMP/repo", "hello": "world"}
# We expect to see the combination of the user arcrc and the repo rc
$ echo '{"user": true}' > $HOME/.arcrc
$ hg debugarcconfig
{"_arcconfig_path": "$TESTTMP/repo", "hello": "world", "user": true}

View File

@ -1,45 +0,0 @@
# Copyright (c) Meta Platforms, Inc. and affiliates.
#
# This software may be used and distributed according to the terms of the
# GNU General Public License version 2.
from __future__ import absolute_import
from testutil.dott import sh, testtmp # noqa: F401
(
sh % "cat"
<< r"""
[extensions]
checkmessagehook=
"""
>> "$HGRCPATH"
)
# Build up a repo
sh % "hg init repo" == ""
sh % "cd repo"
sh % "touch a"
sh % 'hg commit -A -l "$TESTDIR/ctrlchar-msg.txt"' == r"""
adding a
+-------------------------------------------------------------
| Non-printable characters in commit message are not allowed.
| Edit your commit message to fix this issue.
| The problematic commit message can be found at:
| Line 5: 'This has a sneaky ctrl-A: \x01'
| Line 6: 'And this has esc: \x1b'
+-------------------------------------------------------------
abort: pretxncommit.checkmessage hook failed
[255]"""
sh % 'hg commit -A -l "$TESTDIR/perfectlyok-msg.txt"' == "adding a"
sh % "hg log -r ." == r"""
commit: d9cf9881be7b
user: test
date: Thu Jan 01 00:00:00 1970 +0000
summary: This commit message is perfectly OK, and has no sneaky control characters."""
# Try force adding a non-printable character
sh % "touch b"
sh % 'hg commit -A -l "$TESTDIR/ctrlchar-msg.txt" --config checkmessage.allownonprintable=True' == "adding b"

View File

@ -0,0 +1,40 @@
#debugruntest-compatible
# Copyright (c) Meta Platforms, Inc. and affiliates.
#
# This software may be used and distributed according to the terms of the
# GNU General Public License version 2.
$ cat >> $HGRCPATH << 'EOF'
> [extensions]
> checkmessagehook=
> EOF
# Build up a repo
$ hg init repo
$ cd repo
$ touch a
$ hg commit -A -l "$TESTDIR/ctrlchar-msg.txt"
adding a
+-------------------------------------------------------------
| Non-printable characters in commit message are not allowed.
| Edit your commit message to fix this issue.
| The problematic commit message can be found at:
| Line 5: 'This has a sneaky ctrl-A: \x01'
| Line 6: 'And this has esc: \x1b'
+-------------------------------------------------------------
abort: pretxncommit.checkmessage hook failed
[255]
$ hg commit -A -l "$TESTDIR/perfectlyok-msg.txt"
adding a
$ hg log -r .
commit: d9cf9881be7b
user: test
date: Thu Jan 01 00:00:00 1970 +0000
summary: This commit message is perfectly OK, and has no sneaky control characters.
# Try force adding a non-printable character
$ touch b
$ hg commit -A -l "$TESTDIR/ctrlchar-msg.txt" --config checkmessage.allownonprintable=True
adding b

View File

@ -1,46 +0,0 @@
# Copyright (c) Meta Platforms, Inc. and affiliates.
#
# This software may be used and distributed according to the terms of the
# GNU General Public License version 2.
from __future__ import absolute_import
from testutil.dott import feature, sh, testtmp # noqa: F401
# TODO: Make this test compatibile with obsstore enabled.
sh % "setconfig 'experimental.evolution='"
(
sh % "cat"
<< r"""
[extensions]
rebase=
copytrace=
[experimental]
copytrace=off
"""
>> "$HGRCPATH"
)
sh % "hg init repo"
sh % "cd repo"
sh % "echo 1" > "1"
sh % "hg add 1"
sh % "hg ci -m 1"
sh % "echo 2" > "1"
sh % "hg ci -m 2"
sh % "hg up 0" == "1 files updated, 0 files merged, 0 files removed, 0 files unresolved"
sh % "hg mv 1 2"
sh % "hg ci -m dest"
sh % "hg rebase -s 1 -d ." == r"""
rebasing 812796267395 "2"
other [source] changed 1 which local [dest] deleted
hint: if this is due to a renamed file, you can manually input the renamed path, or re-run the command using --config=experimental.copytrace=on to make hg figure out renamed path automatically (which is very slow, and you will need to be patient)
use (c)hanged version, leave (d)eleted, or leave (u)nresolved, or input (r)enamed path? u
unresolved conflicts (see hg resolve, then hg rebase --continue)
[1]"""
sh % "hg rebase --abort" == "rebase aborted"
sh % "hg rebase -s 1 -d . --config=experimental.copytrace=on" == r"""
rebasing 812796267395 "2"
merging 2 and 1 to 2"""

View File

@ -0,0 +1,41 @@
#debugruntest-compatible
# Copyright (c) Meta Platforms, Inc. and affiliates.
#
# This software may be used and distributed according to the terms of the
# GNU General Public License version 2.
# TODO: Make this test compatibile with obsstore enabled.
$ setconfig 'experimental.evolution='
$ cat >> $HGRCPATH << 'EOF'
> [extensions]
> rebase=
> copytrace=
> [experimental]
> copytrace=off
> EOF
$ hg init repo
$ cd repo
$ echo 1 > 1
$ hg add 1
$ hg ci -m 1
$ echo 2 > 1
$ hg ci -m 2
$ hg up 0
1 files updated, 0 files merged, 0 files removed, 0 files unresolved
$ hg mv 1 2
$ hg ci -m dest
$ hg rebase -s 1 -d .
rebasing 812796267395 "2"
other [source] changed 1 which local [dest] deleted
hint: if this is due to a renamed file, you can manually input the renamed path, or re-run the command using --config=experimental.copytrace=on to make hg figure out renamed path automatically (which is very slow, and you will need to be patient)
use (c)hanged version, leave (d)eleted, or leave (u)nresolved, or input (r)enamed path? u
unresolved conflicts (see hg resolve, then hg rebase --continue)
[1]
$ hg rebase --abort
rebase aborted
$ hg rebase -s 1 -d . --config=experimental.copytrace=on
rebasing 812796267395 "2"
merging 2 and 1 to 2

View File

@ -1,62 +0,0 @@
# Copyright (c) Meta Platforms, Inc. and affiliates.
#
# This software may be used and distributed according to the terms of the
# GNU General Public License version 2.
from __future__ import absolute_import
from testutil.dott import feature, sh, testtmp # noqa: F401
# With copied file using the heuristics copytracing:
sh % "enable mergedriver"
sh % "newrepo"
sh % "enable copytrace amend"
sh % "setconfig 'copytrace.draftusefullcopytrace=0' 'experimental.copytrace=off' 'copytrace.fastcopytrace=1' 'experimental.mergedriver=python:$TESTTMP/m.py'"
(
sh % "drawdag"
<< r"""
B C
|/
A
|
Z
"""
)
sh % "cat" << r"""
def preprocess(ui, repo, hooktype, mergestate, wctx, labels):
ui.write("unresolved: %r\n" % (sorted(mergestate.unresolved())))
def conclude(ui, repo, hooktype, mergestate, wctx, labels):
pass
""" > "$TESTTMP/m.py"
sh % "hg up -q $B"
# (trigger amend copytrace code path)
sh % "hg cp A D"
sh % "hg cp A E"
sh % "hg amend -m B2 -d '0 0'"
sh % "hg bookmark -i book-B"
# Do the merge:
sh % "hg up -q $C"
sh % "hg graft book-B" == 'grafting b55db8435dc2 "B2" (book-B)'
sh % "hg status"
sh % "hg log -r . -T '{desc}\\n' --stat" == r"""
B2
B | 1 +
D | 1 +
E | 1 +
3 files changed, 3 insertions(+), 0 deletions(-)"""
# Run again with heuristics copytrace disabled:
sh % "setconfig 'extensions.copytrace=!' 'experimental.copytrace=on' 'copytrace.fastcopytrace=0'"
sh % "hg up -q $C"
sh % "hg graft book-B" == 'grafting b55db8435dc2 "B2" (book-B)'

View File

@ -0,0 +1,59 @@
#debugruntest-compatible
# Copyright (c) Meta Platforms, Inc. and affiliates.
#
# This software may be used and distributed according to the terms of the
# GNU General Public License version 2.
# With copied file using the heuristics copytracing:
$ enable mergedriver
$ newrepo
$ enable copytrace amend
$ setconfig 'copytrace.draftusefullcopytrace=0' 'experimental.copytrace=off' 'copytrace.fastcopytrace=1' 'experimental.mergedriver=python:$TESTTMP/m.py'
$ drawdag << 'EOS'
> B C
> |/
> A
> |
> Z
> EOS
$ cat > $TESTTMP/m.py << 'EOF'
> def preprocess(ui, repo, hooktype, mergestate, wctx, labels):
> ui.write("unresolved: %r\n" % (sorted(mergestate.unresolved())))
> def conclude(ui, repo, hooktype, mergestate, wctx, labels):
> pass
> EOF
$ hg up -q $B
# (trigger amend copytrace code path)
$ hg cp A D
$ hg cp A E
$ hg amend -m B2 -d '0 0'
$ hg bookmark -i book-B
# Do the merge:
$ hg up -q $C
$ hg graft book-B
grafting b55db8435dc2 "B2" (book-B)
$ hg status
$ hg log -r . -T '{desc}\n' --stat
B2
B | 1 +
D | 1 +
E | 1 +
3 files changed, 3 insertions(+), 0 deletions(-)
# Run again with heuristics copytrace disabled:
$ setconfig 'extensions.copytrace=!' 'experimental.copytrace=on' 'copytrace.fastcopytrace=0'
$ hg up -q $C
$ hg graft book-B
grafting b55db8435dc2 "B2" (book-B)

View File

@ -1,46 +0,0 @@
# Copyright (c) Meta Platforms, Inc. and affiliates.
#
# This software may be used and distributed according to the terms of the
# GNU General Public License version 2.
from __future__ import absolute_import
from testutil.dott import feature, sh, testtmp # noqa: F401
# Set up extension
(
sh % "cat"
<< r"""
[extensions]
debugcommitmessage=
"""
>> "$HGRCPATH"
)
# Set up repo
sh % "hg init repo"
sh % "cd repo"
# Test extension
sh % "hg debugcommitmessage" == r"""
HG: Enter commit message. Lines beginning with 'HG:' are removed.
HG: Leave message empty to abort commit.
HG: --
HG: user: test
HG: branch 'default'
HG: no files changed"""
sh % "hg debugcommitmessage --config 'committemplate.changeset.commit.normal.normal=Test Specific Message\\n'" == "Test Specific Message"
sh % "hg debugcommitmessage --config 'committemplate.changeset.commit=Test Generic Message\\n'" == "Test Generic Message"
sh % "hg debugcommitmessage commit.amend.normal --config 'committemplate.changeset.commit=Test Generic Message\\n'" == "Test Generic Message"
sh % "hg debugcommitmessage randomform --config 'committemplate.changeset.commit=Test Generic Message\\n'" == r"""
HG: Enter commit message. Lines beginning with 'HG:' are removed.
HG: Leave message empty to abort commit.
HG: --
HG: user: test
HG: branch 'default'
HG: no files changed"""

View File

@ -0,0 +1,44 @@
#debugruntest-compatible
# Copyright (c) Meta Platforms, Inc. and affiliates.
#
# This software may be used and distributed according to the terms of the
# GNU General Public License version 2.
# Set up extension
$ cat >> $HGRCPATH << 'EOF'
> [extensions]
> debugcommitmessage=
> EOF
# Set up repo
$ hg init repo
$ cd repo
# Test extension
$ hg debugcommitmessage
HG: Enter commit message. Lines beginning with 'HG:' are removed.
HG: Leave message empty to abort commit.
HG: --
HG: user: test
HG: branch 'default'
HG: no files changed
$ hg debugcommitmessage --config 'committemplate.changeset.commit.normal.normal=Test Specific Message\n'
Test Specific Message
$ hg debugcommitmessage --config 'committemplate.changeset.commit=Test Generic Message\n'
Test Generic Message
$ hg debugcommitmessage commit.amend.normal --config 'committemplate.changeset.commit=Test Generic Message\n'
Test Generic Message
$ hg debugcommitmessage randomform --config 'committemplate.changeset.commit=Test Generic Message\n'
HG: Enter commit message. Lines beginning with 'HG:' are removed.
HG: Leave message empty to abort commit.
HG: --
HG: user: test
HG: branch 'default'
HG: no files changed

View File

@ -1,185 +0,0 @@
# Copyright (c) Meta Platforms, Inc. and affiliates.
#
# This software may be used and distributed according to the terms of the
# GNU General Public License version 2.
from __future__ import absolute_import
from testutil.dott import feature, sh, testtmp # noqa: F401
# Load extensions
(
sh % "cat"
<< r"""
[extensions]
arcconfig=$TESTDIR/../edenscm/hgext/extlib/phabricator/arcconfig.py
arcdiff=
"""
>> "$HGRCPATH"
)
# Diff with no revision
sh % "hg init repo"
sh % "cd repo"
sh % "touch foo"
sh % "hg add foo"
sh % "hg ci -qm 'No rev'"
sh % "hg diff --since-last-submit" == r"""
abort: local changeset is not associated with a differential revision
[255]"""
sh % "hg log -r 'lastsubmitted(.)' -T '{node} {desc}\\n'" == r"""
abort: local changeset is not associated with a differential revision
[255]"""
# Fake a diff
sh % "echo bleet" > "foo"
sh % "hg ci -qm 'Differential Revision: https://phabricator.fb.com/D1'"
sh % "hg diff --since-last-submit" == r"""
abort: no .arcconfig found
[255]"""
sh % "hg log -r 'lastsubmitted(.)' -T '{node} {desc}\\n'" == r"""
abort: no .arcconfig found
[255]"""
# Prep configuration
sh % "echo '{}'" > ".arcrc"
sh % 'echo \'{"config" : {"default" : "https://a.com/api"}, "hosts" : {"https://a.com/api/" : { "user" : "testuser", "oauth" : "garbage_cert"}}}\'' > ".arcconfig"
# Now progressively test the response handling for variations of missing data
sh % "cat" << r"""
[{}]
""" > "$TESTTMP/mockduit"
sh % "'HG_ARC_CONDUIT_MOCK=$TESTTMP/mockduit' hg diff --since-last-submit" == r"""
Error calling graphql: Unexpected graphql response format
abort: unable to determine previous changeset hash
[255]"""
sh % "'HG_ARC_CONDUIT_MOCK=$TESTTMP/mockduit' hg log -r 'lastsubmitted(.)' -T '{node} {desc}\\n'" == r"""
Error calling graphql: Unexpected graphql response format
abort: unable to determine previous changeset hash
[255]"""
sh % "cat" << r"""
[{"data": {"query": [{"results": {"nodes": [{
"number": 1,
"diff_status_name": "Needs Review",
"differential_diffs": {"count": 3},
"is_landing": false,
"land_job_status": "NO_LAND_RUNNING",
"needs_final_review_status": "NOT_NEEDED",
"created_time": 123,
"updated_time": 222
}]}}]}}]
""" > "$TESTTMP/mockduit"
sh % "'HG_ARC_CONDUIT_MOCK=$TESTTMP/mockduit' hg diff --since-last-submit" == r"""
abort: unable to determine previous changeset hash
[255]"""
sh % "'HG_ARC_CONDUIT_MOCK=$TESTTMP/mockduit' hg log -r 'lastsubmitted(.)' -T '{node} {desc}\\n'" == r"""
abort: unable to determine previous changeset hash
[255]"""
sh % "cat" << r"""
[{"data": {"query": [{"results": {"nodes": [{
"number": 1,
"diff_status_name": "Needs Review",
"is_landing": false,
"land_job_status": "NO_LAND_RUNNING",
"needs_final_review_status": "NOT_NEEDED",
"created_time": 123,
"updated_time": 222
}]}}]}}]
""" > "$TESTTMP/mockduit"
sh % "'HG_ARC_CONDUIT_MOCK=$TESTTMP/mockduit' hg diff --since-last-submit" == r"""
abort: unable to determine previous changeset hash
[255]"""
sh % "'HG_ARC_CONDUIT_MOCK=$TESTTMP/mockduit' hg log -r 'lastsubmitted(.)' -T '{node} {desc}\\n'" == r"""
abort: unable to determine previous changeset hash
[255]"""
# This is the case when the diff is up to date with the current commit;
# there is no diff since what was landed.
sh % "cat" << r"""
[{"data": {"query": [{"results": {"nodes": [{
"number": 1,
"diff_status_name": "Needs Review",
"latest_active_diff": {
"local_commit_info": {
"nodes": [
{"property_value": "{\"lolwut\": {\"time\": 0, \"commit\": \"2e6531b7dada2a3e5638e136de05f51e94a427f4\"}}"}
]
}
},
"differential_diffs": {"count": 1},
"is_landing": false,
"land_job_status": "NO_LAND_RUNNING",
"needs_final_review_status": "NOT_NEEDED",
"created_time": 123,
"updated_time": 222
}]}}]}}]
""" > "$TESTTMP/mockduit"
sh % "'HG_ARC_CONDUIT_MOCK=$TESTTMP/mockduit' hg diff --since-last-submit"
sh % "'HG_ARC_CONDUIT_MOCK=$TESTTMP/mockduit' hg log -r 'lastsubmitted(.)' -T '{node} {desc}\\n'" == "2e6531b7dada2a3e5638e136de05f51e94a427f4 Differential Revision: https://phabricator.fb.com/D1"
# This is the case when the diff points at our parent commit, we expect to
# see the bleet text show up. There's a fake hash that I've injected into
# the commit list returned from our mocked phabricator; it is present to
# assert that we order the commits consistently based on the time field.
sh % "cat" << r"""
[{"data": {"query": [{"results": {"nodes": [{
"number": 1,
"diff_status_name": "Needs Review",
"latest_active_diff": {
"local_commit_info": {
"nodes": [
{"property_value": "{\"lolwut\": {\"time\": 0, \"commit\": \"88dd5a13bf28b99853a24bddfc93d4c44e07c6bd\"}}"}
]
}
},
"differential_diffs": {"count": 1},
"is_landing": false,
"land_job_status": "NO_LAND_RUNNING",
"needs_final_review_status": "NOT_NEEDED",
"created_time": 123,
"updated_time": 222
}]}}]}}]
""" > "$TESTTMP/mockduit"
sh % "'HG_ARC_CONDUIT_MOCK=$TESTTMP/mockduit' hg diff --since-last-submit --nodates" == r"""
diff -r 88dd5a13bf28 -r 2e6531b7dada foo
--- a/foo
+++ b/foo
@@ -0,0 +1,1 @@
+bleet"""
sh % "'HG_ARC_CONDUIT_MOCK=$TESTTMP/mockduit' hg log -r 'lastsubmitted(.)' -T '{node} {desc}\\n'" == "88dd5a13bf28b99853a24bddfc93d4c44e07c6bd No rev"
sh % "'HG_ARC_CONDUIT_MOCK=$TESTTMP/mockduit' hg diff --since-last-submit-2o" == r"""
Phabricator rev: 88dd5a13bf28b99853a24bddfc93d4c44e07c6bd
Local rev: 2e6531b7dada2a3e5638e136de05f51e94a427f4 (.)
Changed: foo
| ...
| +bleet"""
# Make a new commit on top, and then use -r to look at the previous commit
sh % "echo other" > "foo"
sh % "hg commit -m 'Other commmit'"
sh % "'HG_ARC_CONDUIT_MOCK=$TESTTMP/mockduit' hg diff --since-last-submit --nodates -r 2e6531b" == r"""
diff -r 88dd5a13bf28 -r 2e6531b7dada foo
--- a/foo
+++ b/foo
@@ -0,0 +1,1 @@
+bleet"""
sh % "'HG_ARC_CONDUIT_MOCK=$TESTTMP/mockduit' hg log -r 'lastsubmitted(2e6531b)' -T '{node} {desc}\\n'" == "88dd5a13bf28b99853a24bddfc93d4c44e07c6bd No rev"

View File

@ -0,0 +1,181 @@
#debugruntest-compatible
# Copyright (c) Meta Platforms, Inc. and affiliates.
#
# This software may be used and distributed according to the terms of the
# GNU General Public License version 2.
# Load extensions
$ cat >> $HGRCPATH << 'EOF'
> [extensions]
> arcconfig=$TESTDIR/../edenscm/hgext/extlib/phabricator/arcconfig.py
> arcdiff=
> EOF
# Diff with no revision
$ hg init repo
$ cd repo
$ touch foo
$ hg add foo
$ hg ci -qm 'No rev'
$ hg diff --since-last-submit
abort: local changeset is not associated with a differential revision
[255]
$ hg log -r 'lastsubmitted(.)' -T '{node} {desc}\n'
abort: local changeset is not associated with a differential revision
[255]
# Fake a diff
$ echo bleet > foo
$ hg ci -qm 'Differential Revision: https://phabricator.fb.com/D1'
$ hg diff --since-last-submit
abort: no .arcconfig found
[255]
$ hg log -r 'lastsubmitted(.)' -T '{node} {desc}\n'
abort: no .arcconfig found
[255]
# Prep configuration
$ echo '{}' > .arcrc
$ echo '{"config" : {"default" : "https://a.com/api"}, "hosts" : {"https://a.com/api/" : { "user" : "testuser", "oauth" : "garbage_cert"}}}' > .arcconfig
# Now progressively test the response handling for variations of missing data
$ cat > $TESTTMP/mockduit << 'EOF'
> [{}]
> EOF
$ HG_ARC_CONDUIT_MOCK=$TESTTMP/mockduit hg diff --since-last-submit
Error calling graphql: Unexpected graphql response format
abort: unable to determine previous changeset hash
[255]
$ HG_ARC_CONDUIT_MOCK=$TESTTMP/mockduit hg log -r 'lastsubmitted(.)' -T '{node} {desc}\n'
Error calling graphql: Unexpected graphql response format
abort: unable to determine previous changeset hash
[255]
$ cat > $TESTTMP/mockduit << 'EOF'
> [{"data": {"query": [{"results": {"nodes": [{
> "number": 1,
> "diff_status_name": "Needs Review",
> "differential_diffs": {"count": 3},
> "is_landing": false,
> "land_job_status": "NO_LAND_RUNNING",
> "needs_final_review_status": "NOT_NEEDED",
> "created_time": 123,
> "updated_time": 222
> }]}}]}}]
> EOF
$ HG_ARC_CONDUIT_MOCK=$TESTTMP/mockduit hg diff --since-last-submit
abort: unable to determine previous changeset hash
[255]
$ HG_ARC_CONDUIT_MOCK=$TESTTMP/mockduit hg log -r 'lastsubmitted(.)' -T '{node} {desc}\n'
abort: unable to determine previous changeset hash
[255]
$ cat > $TESTTMP/mockduit << 'EOF'
> [{"data": {"query": [{"results": {"nodes": [{
> "number": 1,
> "diff_status_name": "Needs Review",
> "is_landing": false,
> "land_job_status": "NO_LAND_RUNNING",
> "needs_final_review_status": "NOT_NEEDED",
> "created_time": 123,
> "updated_time": 222
> }]}}]}}]
> EOF
$ HG_ARC_CONDUIT_MOCK=$TESTTMP/mockduit hg diff --since-last-submit
abort: unable to determine previous changeset hash
[255]
$ HG_ARC_CONDUIT_MOCK=$TESTTMP/mockduit hg log -r 'lastsubmitted(.)' -T '{node} {desc}\n'
abort: unable to determine previous changeset hash
[255]
# This is the case when the diff is up to date with the current commit;
# there is no diff since what was landed.
$ cat > $TESTTMP/mockduit << 'EOF'
> [{"data": {"query": [{"results": {"nodes": [{
> "number": 1,
> "diff_status_name": "Needs Review",
> "latest_active_diff": {
> "local_commit_info": {
> "nodes": [
> {"property_value": "{\"lolwut\": {\"time\": 0, \"commit\": \"2e6531b7dada2a3e5638e136de05f51e94a427f4\"}}"}
> ]
> }
> },
> "differential_diffs": {"count": 1},
> "is_landing": false,
> "land_job_status": "NO_LAND_RUNNING",
> "needs_final_review_status": "NOT_NEEDED",
> "created_time": 123,
> "updated_time": 222
> }]}}]}}]
> EOF
$ HG_ARC_CONDUIT_MOCK=$TESTTMP/mockduit hg diff --since-last-submit
$ HG_ARC_CONDUIT_MOCK=$TESTTMP/mockduit hg log -r 'lastsubmitted(.)' -T '{node} {desc}\n'
2e6531b7dada2a3e5638e136de05f51e94a427f4 Differential Revision: https://phabricator.fb.com/D1
# This is the case when the diff points at our parent commit, we expect to
# see the bleet text show up. There's a fake hash that I've injected into
# the commit list returned from our mocked phabricator; it is present to
# assert that we order the commits consistently based on the time field.
$ cat > $TESTTMP/mockduit << 'EOF'
> [{"data": {"query": [{"results": {"nodes": [{
> "number": 1,
> "diff_status_name": "Needs Review",
> "latest_active_diff": {
> "local_commit_info": {
> "nodes": [
> {"property_value": "{\"lolwut\": {\"time\": 0, \"commit\": \"88dd5a13bf28b99853a24bddfc93d4c44e07c6bd\"}}"}
> ]
> }
> },
> "differential_diffs": {"count": 1},
> "is_landing": false,
> "land_job_status": "NO_LAND_RUNNING",
> "needs_final_review_status": "NOT_NEEDED",
> "created_time": 123,
> "updated_time": 222
> }]}}]}}]
> EOF
$ HG_ARC_CONDUIT_MOCK=$TESTTMP/mockduit hg diff --since-last-submit --nodates
diff -r 88dd5a13bf28 -r 2e6531b7dada foo
--- a/foo
+++ b/foo
@@ -0,0 +1,1 @@
+bleet
$ HG_ARC_CONDUIT_MOCK=$TESTTMP/mockduit hg log -r 'lastsubmitted(.)' -T '{node} {desc}\n'
88dd5a13bf28b99853a24bddfc93d4c44e07c6bd No rev
$ HG_ARC_CONDUIT_MOCK=$TESTTMP/mockduit hg diff --since-last-submit-2o
Phabricator rev: 88dd5a13bf28b99853a24bddfc93d4c44e07c6bd
Local rev: 2e6531b7dada2a3e5638e136de05f51e94a427f4 (.)
Changed: foo
| ...
| +bleet
# Make a new commit on top, and then use -r to look at the previous commit
$ echo other > foo
$ hg commit -m 'Other commmit'
$ HG_ARC_CONDUIT_MOCK=$TESTTMP/mockduit hg diff --since-last-submit --nodates -r 2e6531b
diff -r 88dd5a13bf28 -r 2e6531b7dada foo
--- a/foo
+++ b/foo
@@ -0,0 +1,1 @@
+bleet
$ HG_ARC_CONDUIT_MOCK=$TESTTMP/mockduit hg log -r 'lastsubmitted(2e6531b)' -T '{node} {desc}\n'
88dd5a13bf28b99853a24bddfc93d4c44e07c6bd No rev

View File

@ -1,254 +0,0 @@
# Copyright (c) Meta Platforms, Inc. and affiliates.
#
# This software may be used and distributed according to the terms of the
# GNU General Public License version 2.
from __future__ import absolute_import
from testutil.dott import feature, sh, testtmp # noqa: F401
(
sh % "cat"
<< r"""
[extensions]
dirsync=
"""
>> "$HGRCPATH"
)
sh % "hg init repo"
sh % "cd repo"
(
sh % "cat"
<< r"""
[ui]
verbose=true
[dirsync]
sync1.1=dir1/
sync1.2=dir2/subdir/
"""
>> ".hg/hgrc"
)
# Add multiple files
sh % "mkdir dir1"
sh % "echo a" > "dir1/a"
sh % "echo b" > "dir1/b"
sh % "hg commit -Am 'Adding a and b'" == r"""
adding dir1/a
adding dir1/b
mirrored adding 'dir1/a' to 'dir2/subdir/a'
mirrored adding 'dir1/b' to 'dir2/subdir/b'
committing files:
dir1/a
dir1/b
dir2/subdir/a
dir2/subdir/b
committing manifest
committing changelog
committed * (glob)"""
sh % "hg diff --git -r null -r ." == r"""
diff --git a/dir1/a b/dir1/a
new file mode 100644
--- /dev/null
+++ b/dir1/a
@@ -0,0 +1,1 @@
+a
diff --git a/dir1/b b/dir1/b
new file mode 100644
--- /dev/null
+++ b/dir1/b
@@ -0,0 +1,1 @@
+b
diff --git a/dir2/subdir/a b/dir2/subdir/a
new file mode 100644
--- /dev/null
+++ b/dir2/subdir/a
@@ -0,0 +1,1 @@
+a
diff --git a/dir2/subdir/b b/dir2/subdir/b
new file mode 100644
--- /dev/null
+++ b/dir2/subdir/b
@@ -0,0 +1,1 @@
+b"""
# Include only changes to particular file
sh % "echo a" >> "dir1/a"
sh % "echo b" >> "dir1/b"
sh % "hg commit --amend -I dir1/a" == r"""
amending changeset * (glob)
mirrored changes in 'dir1/a' to 'dir2/subdir/a'
committing files:
dir1/a
dir1/b
dir2/subdir/a
dir2/subdir/b
committing manifest
committing changelog
committed * (glob)"""
sh % "hg diff --git -r null -r ." == r"""
diff --git a/dir1/a b/dir1/a
new file mode 100644
--- /dev/null
+++ b/dir1/a
@@ -0,0 +1,2 @@
+a
+a
diff --git a/dir1/b b/dir1/b
new file mode 100644
--- /dev/null
+++ b/dir1/b
@@ -0,0 +1,1 @@
+b
diff --git a/dir2/subdir/a b/dir2/subdir/a
new file mode 100644
--- /dev/null
+++ b/dir2/subdir/a
@@ -0,0 +1,2 @@
+a
+a
diff --git a/dir2/subdir/b b/dir2/subdir/b
new file mode 100644
--- /dev/null
+++ b/dir2/subdir/b
@@ -0,0 +1,1 @@
+b"""
sh % "echo a" >> "dir1/a"
sh % "hg commit --amend dir1/b" == r"""
amending changeset * (glob)
mirrored changes in 'dir1/b' to 'dir2/subdir/b'
committing files:
dir1/a
dir1/b
dir2/subdir/a
dir2/subdir/b
committing manifest
committing changelog
committed * (glob)"""
sh % "hg diff --git -r null -r ." == r"""
diff --git a/dir1/a b/dir1/a
new file mode 100644
--- /dev/null
+++ b/dir1/a
@@ -0,0 +1,2 @@
+a
+a
diff --git a/dir1/b b/dir1/b
new file mode 100644
--- /dev/null
+++ b/dir1/b
@@ -0,0 +1,2 @@
+b
+b
diff --git a/dir2/subdir/a b/dir2/subdir/a
new file mode 100644
--- /dev/null
+++ b/dir2/subdir/a
@@ -0,0 +1,2 @@
+a
+a
diff --git a/dir2/subdir/b b/dir2/subdir/b
new file mode 100644
--- /dev/null
+++ b/dir2/subdir/b
@@ -0,0 +1,2 @@
+b
+b"""
# Exclude changes to particular file
sh % "echo b" >> "dir1/b"
sh % "hg commit --amend -X dir1/a" == r"""
amending changeset * (glob)
mirrored changes in 'dir1/b' to 'dir2/subdir/b'
committing files:
dir1/a
dir1/b
dir2/subdir/a
dir2/subdir/b
committing manifest
committing changelog
committed * (glob)"""
sh % "hg diff --git -r null -r ." == r"""
diff --git a/dir1/a b/dir1/a
new file mode 100644
--- /dev/null
+++ b/dir1/a
@@ -0,0 +1,2 @@
+a
+a
diff --git a/dir1/b b/dir1/b
new file mode 100644
--- /dev/null
+++ b/dir1/b
@@ -0,0 +1,3 @@
+b
+b
+b
diff --git a/dir2/subdir/a b/dir2/subdir/a
new file mode 100644
--- /dev/null
+++ b/dir2/subdir/a
@@ -0,0 +1,2 @@
+a
+a
diff --git a/dir2/subdir/b b/dir2/subdir/b
new file mode 100644
--- /dev/null
+++ b/dir2/subdir/b
@@ -0,0 +1,3 @@
+b
+b
+b"""
# Check the addremove flag
sh % "echo c" > "dir1/c"
sh % "rm dir1/a"
sh % "hg commit --amend -A" == r"""
amending changeset * (glob)
removing dir1/a
adding dir1/c
mirrored adding 'dir1/c' to 'dir2/subdir/c'
mirrored remove of 'dir1/a' to 'dir2/subdir/a'
committing files:
dir1/b
dir1/c
dir2/subdir/b
dir2/subdir/c
committing manifest
committing changelog
committed * (glob)"""
sh % "hg diff --git -r null -r ." == r"""
diff --git a/dir1/b b/dir1/b
new file mode 100644
--- /dev/null
+++ b/dir1/b
@@ -0,0 +1,3 @@
+b
+b
+b
diff --git a/dir1/c b/dir1/c
new file mode 100644
--- /dev/null
+++ b/dir1/c
@@ -0,0 +1,1 @@
+c
diff --git a/dir2/subdir/b b/dir2/subdir/b
new file mode 100644
--- /dev/null
+++ b/dir2/subdir/b
@@ -0,0 +1,3 @@
+b
+b
+b
diff --git a/dir2/subdir/c b/dir2/subdir/c
new file mode 100644
--- /dev/null
+++ b/dir2/subdir/c
@@ -0,0 +1,1 @@
+c"""

View File

@ -0,0 +1,246 @@
#debugruntest-compatible
# Copyright (c) Meta Platforms, Inc. and affiliates.
#
# This software may be used and distributed according to the terms of the
# GNU General Public License version 2.
$ cat >> $HGRCPATH << 'EOF'
> [extensions]
> dirsync=
> EOF
$ hg init repo
$ cd repo
$ cat >> .hg/hgrc << 'EOF'
> [ui]
> verbose=true
> [dirsync]
> sync1.1=dir1/
> sync1.2=dir2/subdir/
> EOF
# Add multiple files
$ mkdir dir1
$ echo a > dir1/a
$ echo b > dir1/b
$ hg commit -Am 'Adding a and b'
adding dir1/a
adding dir1/b
mirrored adding 'dir1/a' to 'dir2/subdir/a'
mirrored adding 'dir1/b' to 'dir2/subdir/b'
committing files:
dir1/a
dir1/b
dir2/subdir/a
dir2/subdir/b
committing manifest
committing changelog
committed * (glob)
$ hg diff --git -r null -r .
diff --git a/dir1/a b/dir1/a
new file mode 100644
--- /dev/null
+++ b/dir1/a
@@ -0,0 +1,1 @@
+a
diff --git a/dir1/b b/dir1/b
new file mode 100644
--- /dev/null
+++ b/dir1/b
@@ -0,0 +1,1 @@
+b
diff --git a/dir2/subdir/a b/dir2/subdir/a
new file mode 100644
--- /dev/null
+++ b/dir2/subdir/a
@@ -0,0 +1,1 @@
+a
diff --git a/dir2/subdir/b b/dir2/subdir/b
new file mode 100644
--- /dev/null
+++ b/dir2/subdir/b
@@ -0,0 +1,1 @@
+b
# Include only changes to particular file
$ echo a >> dir1/a
$ echo b >> dir1/b
$ hg commit --amend -I dir1/a
amending changeset * (glob)
mirrored changes in 'dir1/a' to 'dir2/subdir/a'
committing files:
dir1/a
dir1/b
dir2/subdir/a
dir2/subdir/b
committing manifest
committing changelog
committed * (glob)
$ hg diff --git -r null -r .
diff --git a/dir1/a b/dir1/a
new file mode 100644
--- /dev/null
+++ b/dir1/a
@@ -0,0 +1,2 @@
+a
+a
diff --git a/dir1/b b/dir1/b
new file mode 100644
--- /dev/null
+++ b/dir1/b
@@ -0,0 +1,1 @@
+b
diff --git a/dir2/subdir/a b/dir2/subdir/a
new file mode 100644
--- /dev/null
+++ b/dir2/subdir/a
@@ -0,0 +1,2 @@
+a
+a
diff --git a/dir2/subdir/b b/dir2/subdir/b
new file mode 100644
--- /dev/null
+++ b/dir2/subdir/b
@@ -0,0 +1,1 @@
+b
$ echo a >> dir1/a
$ hg commit --amend dir1/b
amending changeset * (glob)
mirrored changes in 'dir1/b' to 'dir2/subdir/b'
committing files:
dir1/a
dir1/b
dir2/subdir/a
dir2/subdir/b
committing manifest
committing changelog
committed * (glob)
$ hg diff --git -r null -r .
diff --git a/dir1/a b/dir1/a
new file mode 100644
--- /dev/null
+++ b/dir1/a
@@ -0,0 +1,2 @@
+a
+a
diff --git a/dir1/b b/dir1/b
new file mode 100644
--- /dev/null
+++ b/dir1/b
@@ -0,0 +1,2 @@
+b
+b
diff --git a/dir2/subdir/a b/dir2/subdir/a
new file mode 100644
--- /dev/null
+++ b/dir2/subdir/a
@@ -0,0 +1,2 @@
+a
+a
diff --git a/dir2/subdir/b b/dir2/subdir/b
new file mode 100644
--- /dev/null
+++ b/dir2/subdir/b
@@ -0,0 +1,2 @@
+b
+b
# Exclude changes to particular file
$ echo b >> dir1/b
$ hg commit --amend -X dir1/a
amending changeset * (glob)
mirrored changes in 'dir1/b' to 'dir2/subdir/b'
committing files:
dir1/a
dir1/b
dir2/subdir/a
dir2/subdir/b
committing manifest
committing changelog
committed * (glob)
$ hg diff --git -r null -r .
diff --git a/dir1/a b/dir1/a
new file mode 100644
--- /dev/null
+++ b/dir1/a
@@ -0,0 +1,2 @@
+a
+a
diff --git a/dir1/b b/dir1/b
new file mode 100644
--- /dev/null
+++ b/dir1/b
@@ -0,0 +1,3 @@
+b
+b
+b
diff --git a/dir2/subdir/a b/dir2/subdir/a
new file mode 100644
--- /dev/null
+++ b/dir2/subdir/a
@@ -0,0 +1,2 @@
+a
+a
diff --git a/dir2/subdir/b b/dir2/subdir/b
new file mode 100644
--- /dev/null
+++ b/dir2/subdir/b
@@ -0,0 +1,3 @@
+b
+b
+b
# Check the addremove flag
$ echo c > dir1/c
$ rm dir1/a
$ hg commit --amend -A
amending changeset * (glob)
removing dir1/a
adding dir1/c
mirrored adding 'dir1/c' to 'dir2/subdir/c'
mirrored remove of 'dir1/a' to 'dir2/subdir/a'
committing files:
dir1/b
dir1/c
dir2/subdir/b
dir2/subdir/c
committing manifest
committing changelog
committed * (glob)
$ hg diff --git -r null -r .
diff --git a/dir1/b b/dir1/b
new file mode 100644
--- /dev/null
+++ b/dir1/b
@@ -0,0 +1,3 @@
+b
+b
+b
diff --git a/dir1/c b/dir1/c
new file mode 100644
--- /dev/null
+++ b/dir1/c
@@ -0,0 +1,1 @@
+c
diff --git a/dir2/subdir/b b/dir2/subdir/b
new file mode 100644
--- /dev/null
+++ b/dir2/subdir/b
@@ -0,0 +1,3 @@
+b
+b
+b
diff --git a/dir2/subdir/c b/dir2/subdir/c
new file mode 100644
--- /dev/null
+++ b/dir2/subdir/c
@@ -0,0 +1,1 @@
+c

View File

@ -1,189 +0,0 @@
# Copyright (c) Meta Platforms, Inc. and affiliates.
#
# This software may be used and distributed according to the terms of the
# GNU General Public License version 2.
from __future__ import absolute_import
from testutil.dott import feature, sh, testtmp # noqa: F401
feature.require(["py2"])
(
sh % "cat"
<< r"""
[extensions]
fastannotate=
[fastannotate]
mainbranch=main
"""
>> "$HGRCPATH"
)
sh % "hg init repo"
sh % "cd repo"
# add or rename files on top of the master branch
sh % "echo a1" > "a"
sh % "echo b1" > "b"
sh % "hg commit -qAm 1"
sh % "hg bookmark -i main"
sh % "hg fastannotate --debug -nf b" == r"""
fastannotate: b: 1 new changesets in the main branch
0 b: b1"""
sh % "hg fastannotate --debug -nf a" == r"""
fastannotate: a: 1 new changesets in the main branch
0 a: a1"""
sh % "echo a2" >> "a"
sh % "cat" << r"""
b0
b1
""" > "b"
sh % "hg mv a t"
sh % "hg mv b a"
sh % "hg mv t b"
sh % "hg commit -m 'swap names'"
# existing linelogs are not helpful with such renames in side branches
sh % "hg fastannotate --debug -nf a" == r"""
fastannotate: a: linelog cannot help in annotating this revision
1 a: b0
0 b: b1"""
sh % "hg fastannotate --debug -nf b" == r"""
fastannotate: b: linelog cannot help in annotating this revision
0 a: a1
1 b: a2"""
# move main branch forward, rebuild should happen
sh % "hg bookmark -i main -r . -q"
sh % "hg fastannotate --debug -nf b" == r"""
fastannotate: b: cache broken and deleted
fastannotate: b: 2 new changesets in the main branch
0 a: a1
1 b: a2"""
sh % "hg fastannotate --debug -nf b" == r"""
fastannotate: b: using fast path (resolved fctx: True)
0 a: a1
1 b: a2"""
# for rev 0, the existing linelog is still useful for a, but not for b
sh % "hg fastannotate --debug -nf a -r 0" == r"""
fastannotate: a: using fast path (resolved fctx: True)
0 a: a1"""
sh % "hg fastannotate --debug -nf b -r 0" == r"""
fastannotate: b: linelog cannot help in annotating this revision
0 b: b1"""
# a rebuild can also be triggered if "the main branch last time" mismatches
sh % "echo a3" >> "a"
sh % "hg commit -m a3"
(
sh % "cat"
<< r"""
b3
b4
"""
>> "b"
)
sh % "hg commit -m b4"
sh % "hg bookmark -i main -q"
sh % "hg fastannotate --debug -nf a" == r"""
fastannotate: a: cache broken and deleted
fastannotate: a: 3 new changesets in the main branch
1 a: b0
0 b: b1
2 a: a3"""
sh % "hg fastannotate --debug -nf a" == r"""
fastannotate: a: using fast path (resolved fctx: True)
1 a: b0
0 b: b1
2 a: a3"""
# linelog can be updated without being helpful
sh % "hg mv a t"
sh % "hg mv b a"
sh % "hg mv t b"
sh % "hg commit -m 'swap names again'"
sh % "hg fastannotate --debug -nf b" == r"""
fastannotate: b: 1 new changesets in the main branch
1 a: b0
0 b: b1
2 a: a3"""
sh % "hg fastannotate --debug -nf b" == r"""
fastannotate: b: linelog cannot help in annotating this revision
1 a: b0
0 b: b1
2 a: a3"""
# move main branch forward again, rebuilds are one-time
sh % "hg bookmark -i main -q"
sh % "hg fastannotate --debug -nf a" == r"""
fastannotate: a: cache broken and deleted
fastannotate: a: 4 new changesets in the main branch
0 a: a1
1 b: a2
3 b: b3
3 b: b4"""
sh % "hg fastannotate --debug -nf b" == r"""
fastannotate: b: cache broken and deleted
fastannotate: b: 4 new changesets in the main branch
1 a: b0
0 b: b1
2 a: a3"""
sh % "hg fastannotate --debug -nf a" == r"""
fastannotate: a: using fast path (resolved fctx: True)
0 a: a1
1 b: a2
3 b: b3
3 b: b4"""
sh % "hg fastannotate --debug -nf b" == r"""
fastannotate: b: using fast path (resolved fctx: True)
1 a: b0
0 b: b1
2 a: a3"""
# list changeset hashes to improve readability
sh % "hg log -T '{rev}:{node}\\n'" == r"""
4:980e1ab8c516350172928fba95b49ede3b643dca
3:14e123fedad9f491f5dde0beca2a767625a0a93a
2:96495c41e4c12218766f78cdf244e768d7718b0f
1:35c2b781234c994896aba36bd3245d3104e023df
0:653e95416ebb5dbcc25bbc7f75568c9e01f7bd2f"""
# annotate a revision not in the linelog. linelog cannot be used, but does not get rebuilt either
sh % "hg fastannotate --debug -nf a -r 96495c41e4c12218766f78cdf244e768d7718b0f" == r"""
fastannotate: a: linelog cannot help in annotating this revision
1 a: b0
0 b: b1
2 a: a3"""
sh % "hg fastannotate --debug -nf a -r 2" == r"""
fastannotate: a: linelog cannot help in annotating this revision
1 a: b0
0 b: b1
2 a: a3"""
sh % "hg fastannotate --debug -nf a -r ." == r"""
fastannotate: a: using fast path (resolved fctx: True)
0 a: a1
1 b: a2
3 b: b3
3 b: b4"""
# annotate an ancient revision where the path matches. linelog can be used
sh % "hg fastannotate --debug -nf a -r 0" == r"""
fastannotate: a: using fast path (resolved fctx: True)
0 a: a1"""
sh % "hg fastannotate --debug -nf a -r 653e95416ebb5dbcc25bbc7f75568c9e01f7bd2f" == r"""
fastannotate: a: using fast path (resolved fctx: False)
0 a: a1"""

View File

@ -0,0 +1,176 @@
#debugruntest-compatible
# Copyright (c) Meta Platforms, Inc. and affiliates.
#
# This software may be used and distributed according to the terms of the
# GNU General Public License version 2.
#require py2
$ cat >> $HGRCPATH << 'EOF'
> [extensions]
> fastannotate=
> [fastannotate]
> mainbranch=main
> EOF
$ hg init repo
$ cd repo
# add or rename files on top of the master branch
$ echo a1 > a
$ echo b1 > b
$ hg commit -qAm 1
$ hg bookmark -i main
$ hg fastannotate --debug -nf b
fastannotate: b: 1 new changesets in the main branch
0 b: b1
$ hg fastannotate --debug -nf a
fastannotate: a: 1 new changesets in the main branch
0 a: a1
$ echo a2 >> a
$ cat > b << 'EOF'
> b0
> b1
> EOF
$ hg mv a t
$ hg mv b a
$ hg mv t b
$ hg commit -m 'swap names'
# existing linelogs are not helpful with such renames in side branches
$ hg fastannotate --debug -nf a
fastannotate: a: linelog cannot help in annotating this revision
1 a: b0
0 b: b1
$ hg fastannotate --debug -nf b
fastannotate: b: linelog cannot help in annotating this revision
0 a: a1
1 b: a2
# move main branch forward, rebuild should happen
$ hg bookmark -i main -r . -q
$ hg fastannotate --debug -nf b
fastannotate: b: cache broken and deleted
fastannotate: b: 2 new changesets in the main branch
0 a: a1
1 b: a2
$ hg fastannotate --debug -nf b
fastannotate: b: using fast path (resolved fctx: True)
0 a: a1
1 b: a2
# for rev 0, the existing linelog is still useful for a, but not for b
$ hg fastannotate --debug -nf a -r 0
fastannotate: a: using fast path (resolved fctx: True)
0 a: a1
$ hg fastannotate --debug -nf b -r 0
fastannotate: b: linelog cannot help in annotating this revision
0 b: b1
# a rebuild can also be triggered if "the main branch last time" mismatches
$ echo a3 >> a
$ hg commit -m a3
$ cat >> b << 'EOF'
> b3
> b4
> EOF
$ hg commit -m b4
$ hg bookmark -i main -q
$ hg fastannotate --debug -nf a
fastannotate: a: cache broken and deleted
fastannotate: a: 3 new changesets in the main branch
1 a: b0
0 b: b1
2 a: a3
$ hg fastannotate --debug -nf a
fastannotate: a: using fast path (resolved fctx: True)
1 a: b0
0 b: b1
2 a: a3
# linelog can be updated without being helpful
$ hg mv a t
$ hg mv b a
$ hg mv t b
$ hg commit -m 'swap names again'
$ hg fastannotate --debug -nf b
fastannotate: b: 1 new changesets in the main branch
1 a: b0
0 b: b1
2 a: a3
$ hg fastannotate --debug -nf b
fastannotate: b: linelog cannot help in annotating this revision
1 a: b0
0 b: b1
2 a: a3
# move main branch forward again, rebuilds are one-time
$ hg bookmark -i main -q
$ hg fastannotate --debug -nf a
fastannotate: a: cache broken and deleted
fastannotate: a: 4 new changesets in the main branch
0 a: a1
1 b: a2
3 b: b3
3 b: b4
$ hg fastannotate --debug -nf b
fastannotate: b: cache broken and deleted
fastannotate: b: 4 new changesets in the main branch
1 a: b0
0 b: b1
2 a: a3
$ hg fastannotate --debug -nf a
fastannotate: a: using fast path (resolved fctx: True)
0 a: a1
1 b: a2
3 b: b3
3 b: b4
$ hg fastannotate --debug -nf b
fastannotate: b: using fast path (resolved fctx: True)
1 a: b0
0 b: b1
2 a: a3
# list changeset hashes to improve readability
$ hg log -T '{rev}:{node}\n'
4:980e1ab8c516350172928fba95b49ede3b643dca
3:14e123fedad9f491f5dde0beca2a767625a0a93a
2:96495c41e4c12218766f78cdf244e768d7718b0f
1:35c2b781234c994896aba36bd3245d3104e023df
0:653e95416ebb5dbcc25bbc7f75568c9e01f7bd2f
# annotate a revision not in the linelog. linelog cannot be used, but does not get rebuilt either
$ hg fastannotate --debug -nf a -r 96495c41e4c12218766f78cdf244e768d7718b0f
fastannotate: a: linelog cannot help in annotating this revision
1 a: b0
0 b: b1
2 a: a3
$ hg fastannotate --debug -nf a -r 2
fastannotate: a: linelog cannot help in annotating this revision
1 a: b0
0 b: b1
2 a: a3
$ hg fastannotate --debug -nf a -r .
fastannotate: a: using fast path (resolved fctx: True)
0 a: a1
1 b: a2
3 b: b3
3 b: b4
# annotate an ancient revision where the path matches. linelog can be used
$ hg fastannotate --debug -nf a -r 0
fastannotate: a: using fast path (resolved fctx: True)
0 a: a1
$ hg fastannotate --debug -nf a -r 653e95416ebb5dbcc25bbc7f75568c9e01f7bd2f
fastannotate: a: using fast path (resolved fctx: False)
0 a: a1

View File

@ -1,59 +0,0 @@
# Copyright (c) Meta Platforms, Inc. and affiliates.
#
# This software may be used and distributed according to the terms of the
# GNU General Public License version 2.
from __future__ import absolute_import
from testutil.dott import feature, sh, testtmp # noqa: F401
(
sh % "cat"
<< r"""
[extensions]
phrevset=
[paths]
default=dummy://dummy
"""
>> "$HGRCPATH"
)
sh % "hg init repo"
sh % "cd repo"
sh % "echo 1" > "1"
sh % "hg add 1"
sh % "hg commit -m 'Differential Revision: http.ololo.com/D1234'"
sh % "hg up -q 0"
sh % "hg up D1234" == r"""
phrevset.callsign is not set - doing a linear search
This will be slow if the diff was not committed recently
abort: phrevset.graphqlonly is set and Phabricator cannot resolve D1234
[255]"""
sh % "drawdag" << "A"
sh % "setconfig phrevset.mock-D1234=$A phrevset.callsign=CALLSIGN"
sh % "hg log -r D1234 -T '{desc}\n'" == "A"
# Callsign is invalid
sh % "hg log -r D1234 --config phrevset.callsign=C -T '{desc}\n'" == r"""
abort: Diff callsign 'CALLSIGN' is different from repo callsigns '['C']'
[255]"""
# Now we have two callsigns, and one of them is correct. Make sure it works
sh % "hg log -r D1234 --config phrevset.callsign=C,CALLSIGN -T '{desc}\n'" == "A"
# Phabricator provides an unknown commit hash.
sh % "setconfig phrevset.mock-D1234=6008bb23d775556ff6c3528541ca5a2177b4bb92"
sh % "hg log -r D1234 -T '{desc}\n'" == r"""
pulling D1234 (6008bb23d775556ff6c3528541ca5a2177b4bb92) from 'dummy://dummy/'
pull failed: repository dummy://dummy/ not found
abort: unknown revision 'D1234'!
[255]"""
# 'pull -r Dxxx' will be rewritten to 'pull -r HASH'
sh % "hg pull -r D1234 --config paths.default=test:fake_server" == r"""
pulling from test:fake_server
rewriting pull rev 'D1234' into '6008bb23d775556ff6c3528541ca5a2177b4bb92'
abort: unknown revision '6008bb23d775556ff6c3528541ca5a2177b4bb92'!
[255]"""

View File

@ -0,0 +1,56 @@
#debugruntest-compatible
# Copyright (c) Meta Platforms, Inc. and affiliates.
#
# This software may be used and distributed according to the terms of the
# GNU General Public License version 2.
$ cat >> $HGRCPATH << 'EOF'
> [extensions]
> phrevset=
> [paths]
> default=dummy://dummy
> EOF
$ hg init repo
$ cd repo
$ echo 1 > 1
$ hg add 1
$ hg commit -m 'Differential Revision: http.ololo.com/D1234'
$ hg up -q 0
$ hg up D1234
phrevset.callsign is not set - doing a linear search
This will be slow if the diff was not committed recently
abort: phrevset.graphqlonly is set and Phabricator cannot resolve D1234
[255]
$ drawdag << 'EOS'
> A > EOS
$ setconfig phrevset.mock-D1234=$A phrevset.callsign=CALLSIGN
$ hg log -r D1234 -T '{desc}\n'
A
# Callsign is invalid
$ hg log -r D1234 --config phrevset.callsign=C -T '{desc}\n'
abort: Diff callsign 'CALLSIGN' is different from repo callsigns '['C']'
[255]
# Now we have two callsigns, and one of them is correct. Make sure it works
$ hg log -r D1234 --config phrevset.callsign=C,CALLSIGN -T '{desc}\n'
A
# Phabricator provides an unknown commit hash.
$ setconfig phrevset.mock-D1234=6008bb23d775556ff6c3528541ca5a2177b4bb92
$ hg log -r D1234 -T '{desc}\n'
abort: unknown revision 'D1234'!
[255]
# 'pull -r Dxxx' will be rewritten to 'pull -r HASH'
$ hg pull -r D1234 --config paths.default=test:fake_server
pulling from test:fake_server
rewriting pull rev 'D1234' into '6008bb23d775556ff6c3528541ca5a2177b4bb92'
abort: unknown revision '6008bb23d775556ff6c3528541ca5a2177b4bb92'!
[255]

View File

@ -1,44 +0,0 @@
# Copyright (c) Meta Platforms, Inc. and affiliates.
#
# This software may be used and distributed according to the terms of the
# GNU General Public License version 2.
from __future__ import absolute_import
from testutil.dott import sh, testtmp # noqa: F401
(
sh % "cat"
<< r"""
[extensions]
preventpremegarepoupdateshook=
"""
>> "$HGRCPATH"
)
sh % "hg init repo" == ""
sh % "cd repo" == ""
sh % "touch a" == ""
sh % "hg commit -A -m pre_megarepo_commit" == "adding a"
sh % "mkdir .megarepo" == ""
sh % "touch .megarepo/remapping_state" == ""
sh % "hg commit -A -m megarepo_merge" == "adding .megarepo/remapping_state"
sh % "touch b" == ""
sh % "hg commit -A -m another_commit" == "adding b"
sh % "hg update .^" == "0 files updated, 0 files merged, 1 files removed, 0 files unresolved"
sh % "hg update --config ui.interactive=true .^" << r"""n
""" == r"""
Checking out commits from before megarepo merge is discouraged. The resulting checkout will contain just the contents of one git subrepo. Many tools might not work as expected. Do you want to continue (Yn)? n
abort: preupdate.preventpremegarepoupdates hook failed
[255]"""
sh % "hg update --config ui.interactive=false .^" == r"""
Checking out commits from before megarepo merge is discouraged. The resulting checkout will contain just the contents of one git subrepo. Many tools might not work as expected. Do you want to continue (Yn)? y
0 files updated, 0 files merged, 1 files removed, 0 files unresolved"""
sh % "hg update tip^" == "1 files updated, 0 files merged, 0 files removed, 0 files unresolved"
sh % "HGPLAIN=1 hg update --config ui.interactive=true .^" == "0 files updated, 0 files merged, 1 files removed, 0 files unresolved"

View File

@ -0,0 +1,40 @@
#debugruntest-compatible
# Copyright (c) Meta Platforms, Inc. and affiliates.
#
# This software may be used and distributed according to the terms of the
# GNU General Public License version 2.
$ cat >> $HGRCPATH << 'EOF'
> [extensions]
> preventpremegarepoupdateshook=
> EOF
$ hg init repo
$ cd repo
$ touch a
$ hg commit -A -m pre_megarepo_commit
adding a
$ mkdir .megarepo
$ touch .megarepo/remapping_state
$ hg commit -A -m megarepo_merge
adding .megarepo/remapping_state
$ touch b
$ hg commit -A -m another_commit
adding b
$ hg update .^
0 files updated, 0 files merged, 1 files removed, 0 files unresolved
$ echo n | hg update --config ui.interactive=true .^
Checking out commits from before megarepo merge is discouraged. The resulting checkout will contain just the contents of one git subrepo. Many tools might not work as expected. Do you want to continue (Yn)? n
abort: preupdate.preventpremegarepoupdates hook failed
[255]
$ hg update --config ui.interactive=false .^
Checking out commits from before megarepo merge is discouraged. The resulting checkout will contain just the contents of one git subrepo. Many tools might not work as expected. Do you want to continue (Yn)? y
0 files updated, 0 files merged, 1 files removed, 0 files unresolved
$ hg update tip^
1 files updated, 0 files merged, 0 files removed, 0 files unresolved
$ HGPLAIN=1 hg update --config ui.interactive=true .^
0 files updated, 0 files merged, 1 files removed, 0 files unresolved

View File

@ -1,35 +0,0 @@
# Copyright (c) Meta Platforms, Inc. and affiliates.
#
# This software may be used and distributed according to the terms of the
# GNU General Public License version 2.
from __future__ import absolute_import
from testutil.dott import feature, sh, testtmp # noqa: F401
sh % "setconfig \"remotefilelog.cachepath=$TESTTMP/cache\" 'extensions.remotefilelog='"
sh % "newrepo"
sh % "echo remotefilelog" >> ".hg/requires"
(
sh % "drawdag"
<< r"""
E # E/X=1 (renamed from Y)
|
D # D/Y=3 (renamed from X)
|
B # B/X=2
|
A # A/X=1
"""
)
sh % 'hg bundle --all "$TESTTMP/bundle" --traceback -q'
sh % "newrepo"
sh % "echo remotefilelog" >> ".hg/requires"
sh % 'hg unbundle "$TESTTMP/bundle"' == r"""
adding changesets
adding manifests
adding file changes"""

View File

@ -0,0 +1,28 @@
#debugruntest-compatible
# Copyright (c) Meta Platforms, Inc. and affiliates.
#
# This software may be used and distributed according to the terms of the
# GNU General Public License version 2.
$ setconfig "remotefilelog.cachepath=$TESTTMP/cache" 'extensions.remotefilelog='
$ newrepo
$ echo remotefilelog >> .hg/requires
$ drawdag << 'EOS'
> E # E/X=1 (renamed from Y)
> |
> D # D/Y=3 (renamed from X)
> |
> B # B/X=2
> |
> A # A/X=1
> EOS
$ hg bundle --all "$TESTTMP/bundle" --traceback -q
$ newrepo
$ echo remotefilelog >> .hg/requires
$ hg unbundle "$TESTTMP/bundle"
adding changesets
adding manifests
adding file changes

View File

@ -1,35 +0,0 @@
# Copyright (c) Meta Platforms, Inc. and affiliates.
#
# This software may be used and distributed according to the terms of the
# GNU General Public License version 2.
from __future__ import absolute_import
from testutil.dott import feature, sh, testtmp # noqa: F401
sh % ". $TESTDIR/library.sh"
sh % "setconfig experimental.allowfilepeer=True"
sh % "hginit master"
sh % "cd master"
sh % "setconfig 'remotefilelog.server=True'"
sh % "cd .."
sh % "hgcloneshallow ssh://user@dummy/master client" == r"""
streaming all changes
0 files to transfer, 0 bytes of data
transferred 0 bytes in 0.0 seconds (0 bytes/sec)
no changes found
updating to branch default
0 files updated, 0 files merged, 0 files removed, 0 files unresolved"""
sh % "cd client"
sh % "setconfig 'remotefilelog.commitsperrepack=1'"
sh % "echo x" > "x"
sh % "hg commit -Am x" == r"""
adding x
(running background incremental repack)
(running background incremental repack)
(running background incremental repack)"""

View File

@ -0,0 +1,31 @@
#debugruntest-compatible
# Copyright (c) Meta Platforms, Inc. and affiliates.
#
# This software may be used and distributed according to the terms of the
# GNU General Public License version 2.
$ . $TESTDIR/library.sh
$ setconfig experimental.allowfilepeer=True
$ hginit master
$ cd master
$ setconfig 'remotefilelog.server=True'
$ cd ..
$ hgcloneshallow ssh://user@dummy/master client
streaming all changes
0 files to transfer, 0 bytes of data
transferred 0 bytes in 0.0 seconds (0 bytes/sec)
no changes found
updating to branch default
0 files updated, 0 files merged, 0 files removed, 0 files unresolved
$ cd client
$ setconfig 'remotefilelog.commitsperrepack=1'
$ echo x > x
$ hg commit -Am x
adding x
(running background incremental repack)
(running background incremental repack)
(running background incremental repack)

View File

@ -1,65 +0,0 @@
# Copyright (c) Meta Platforms, Inc. and affiliates.
#
# This software may be used and distributed according to the terms of the
# GNU General Public License version 2.
from __future__ import absolute_import
from testutil.dott import feature, sh, testtmp # noqa: F401
sh % "setconfig extensions.treemanifest=! treemanifest.sendtrees=False treemanifest.treeonly=False"
sh % "setconfig experimental.allowfilepeer=True"
sh % '. "$TESTDIR/library.sh"'
sh % "hginit master"
sh % "cd master"
(
sh % "cat"
<< r"""
[remotefilelog]
server=True
"""
>> ".hg/hgrc"
)
sh % "echo x" > "x"
sh % "hg commit -qAm x"
sh % "echo y" >> "x"
sh % "hg commit -qAm y"
sh % "echo z" >> "x"
sh % "hg commit -qAm z"
sh % "hg update 1" == "1 files updated, 0 files merged, 0 files removed, 0 files unresolved"
sh % "echo w" >> "x"
sh % "hg commit -qAm w"
sh % "cd .."
# Shallow clone and activate getflogheads testing extension
sh % "hgcloneshallow 'ssh://user@dummy/master' shallow --noupdate" == r"""
streaming all changes
3 files to transfer, 908 bytes of data
transferred 908 bytes in 0.0 seconds (887 KB/sec)
searching for changes
no changes found"""
sh % "cd shallow"
(
sh % "cat"
<< r"""
[extensions]
getflogheads=$TESTDIR/getflogheads.py
"""
>> ".hg/hgrc"
)
# Get heads of a remotefilelog
sh % "hg getflogheads x" == r"""
2797809ca5e9c2f307d82b1345e832f655fb99a2
ca758b402ddc91e37e3113e1a97791b537e1b7bb"""
# Get heads of a non-existing remotefilelog
sh % "hg getflogheads y" == "EMPTY"

View File

@ -0,0 +1,50 @@
#debugruntest-compatible
# Copyright (c) Meta Platforms, Inc. and affiliates.
#
# This software may be used and distributed according to the terms of the
# GNU General Public License version 2.
$ setconfig extensions.treemanifest=! treemanifest.sendtrees=False treemanifest.treeonly=False
$ setconfig experimental.allowfilepeer=True
$ . "$TESTDIR/library.sh"
$ hginit master
$ cd master
$ cat >> .hg/hgrc << 'EOF'
> [remotefilelog]
> server=True
> EOF
$ echo x > x
$ hg commit -qAm x
$ echo y >> x
$ hg commit -qAm y
$ echo z >> x
$ hg commit -qAm z
$ hg update 1
1 files updated, 0 files merged, 0 files removed, 0 files unresolved
$ echo w >> x
$ hg commit -qAm w
$ cd ..
# Shallow clone and activate getflogheads testing extension
$ hgcloneshallow 'ssh://user@dummy/master' shallow --noupdate -q
$ cd shallow
$ cat >> .hg/hgrc << 'EOF'
> [extensions]
> getflogheads=$TESTDIR/getflogheads.py
> EOF
# Get heads of a remotefilelog
$ hg getflogheads x
2797809ca5e9c2f307d82b1345e832f655fb99a2
ca758b402ddc91e37e3113e1a97791b537e1b7bb
# Get heads of a non-existing remotefilelog
$ hg getflogheads y
EMPTY

View File

@ -1,41 +0,0 @@
# coding=utf-8
# Copyright (c) Meta Platforms, Inc. and affiliates.
#
# This software may be used and distributed according to the terms of the
# GNU General Public License version 2.
from __future__ import absolute_import
from testutil.dott import feature, sh, testtmp # noqa: F401
sh % "configure modernclient"
(
sh % "cat"
<< r"""
[extensions]
reset=
remotenames=
"""
>> "$HGRCPATH"
)
sh % "newclientrepo repo"
sh % "echo x" > "x"
sh % "hg commit -qAm x"
sh % "hg book foo"
sh % "echo x" >> "x"
sh % "hg commit -qAm x2"
sh % "hg push -q -r . --to foo --create"
# Resetting past a remote bookmark should not delete the remote bookmark
sh % "newclientrepo client test:repo_server foo"
sh % "hg book --list-remote *"
sh % "hg book bar"
sh % "hg reset --clean 'remote/foo^'"
sh % "hg log -G -T '{node|short} {bookmarks} {remotebookmarks}\\n'" == r"""
o a89d614e2364 remote/foo
@ b292c1e3311f bar"""

View File

@ -0,0 +1,33 @@
#debugruntest-compatible
# coding=utf-8
# Copyright (c) Meta Platforms, Inc. and affiliates.
#
# This software may be used and distributed according to the terms of the
# GNU General Public License version 2.
$ configure modernclient
$ cat >> $HGRCPATH << 'EOF'
> [extensions]
> reset=
> remotenames=
> EOF
$ newclientrepo repo
$ echo x > x
$ hg commit -qAm x
$ hg book foo
$ echo x >> x
$ hg commit -qAm x2
$ hg push -q -r . --to foo --create
# Resetting past a remote bookmark should not delete the remote bookmark
$ newclientrepo client test:repo_server foo
$ hg book --list-remote *
$ hg book bar
$ hg reset --clean 'remote/foo^'
$ hg log -G -T '{node|short} {bookmarks} {remotebookmarks}\n'
o a89d614e2364 remote/foo
@ b292c1e3311f bar

View File

@ -1,181 +0,0 @@
# coding=utf-8
# Copyright (c) Meta Platforms, Inc. and affiliates.
#
# This software may be used and distributed according to the terms of the
# GNU General Public License version 2.
from __future__ import absolute_import
from testutil.dott import feature, sh, testtmp # noqa: F401
(
sh % "cat"
<< r"""
[extensions]
reset=
[experimental]
evolution=
"""
>> "$HGRCPATH"
)
sh % "hg init repo"
sh % "cd repo"
sh % "echo x" > "x"
sh % "hg commit -qAm x"
sh % "hg book foo"
# Soft reset should leave pending changes
sh % "echo y" >> "x"
sh % "hg commit -qAm y"
sh % "hg log -G -T '{node|short} {bookmarks}\\n'" == r"""
@ 66ee28d0328c foo
o b292c1e3311f"""
sh % "hg reset '.^'" == "1 changeset hidden"
sh % "hg log -G -T '{node|short} {bookmarks}\\n'" == "@ b292c1e3311f foo"
sh % "hg diff" == r"""
diff -r b292c1e3311f x
--- a/x Thu Jan 01 00:00:00 1970 +0000
+++ b/x * (glob)
@@ -1,1 +1,2 @@
x
+y"""
# Clean reset should overwrite all changes
sh % "hg commit -qAm y"
sh % "hg reset --clean '.^'" == "1 changeset hidden"
sh % "hg diff"
# Reset should recover from backup bundles (with correct phase)
sh % "hg log -G -T '{node|short} {bookmarks}\\n'" == "@ b292c1e3311f foo"
sh % "hg debugmakepublic b292c1e3311f"
sh % "hg reset --clean 66ee28d0328c" == ""
sh % "hg log -G -T '{node|short} {bookmarks} {phase}\\n'" == r"""
@ 66ee28d0328c foo draft
o b292c1e3311f public"""
# Reset should not strip reachable commits
sh % "hg book bar"
sh % "hg reset --clean '.^'"
sh % "hg log -G -T '{node|short} {bookmarks}\\n'" == r"""
o 66ee28d0328c foo
@ b292c1e3311f bar"""
sh % "hg book -d bar"
sh % "hg up foo" == r"""
1 files updated, 0 files merged, 0 files removed, 0 files unresolved
(activating bookmark foo)"""
# Reset to '.' by default
sh % "echo z" >> "x"
sh % "echo z" >> "y"
sh % "hg add y"
sh % "hg st" == r"""
M x
A y"""
sh % "hg reset"
sh % "hg st" == r"""
M x
? y"""
sh % "hg reset -C"
sh % "hg st" == "? y"
sh % "rm y"
# Keep old commits
sh % "hg reset --keep '.^'"
sh % "hg log -G -T '{node|short} {bookmarks}\\n'" == r"""
o 66ee28d0328c
@ b292c1e3311f foo"""
# Reset without a bookmark
sh % "hg up tip" == r"""
1 files updated, 0 files merged, 0 files removed, 0 files unresolved
(leaving bookmark foo)"""
sh % "hg book -d foo"
sh % "hg reset '.^'" == "1 changeset hidden"
sh % "hg book foo"
# Reset to bookmark with - in the name
sh % "hg reset 66ee28d0328c" == ""
sh % "hg book foo-bar -r '.^'"
sh % "hg reset foo-bar" == "1 changeset hidden"
sh % "hg book -d foo-bar"
# Verify file status after reset
sh % "hg reset -C 66ee28d0328c" == ""
sh % "touch toberemoved"
sh % "hg commit -qAm 'add file for removal'"
sh % "echo z" >> "x"
sh % "touch tobeadded"
sh % "hg add tobeadded"
sh % "hg rm toberemoved"
sh % "hg commit -m 'to be reset'"
sh % "hg reset '.^'" == "1 changeset hidden"
sh % "hg status" == r"""
M x
! toberemoved
? tobeadded"""
sh % "hg reset -C 66ee28d0328c" == "1 changeset hidden"
# Reset + Obsolete tests
(
sh % "cat"
<< r"""
[extensions]
amend=
rebase=
[experimental]
evolution=all
"""
>> ".hg/hgrc"
)
sh % "touch a"
sh % "hg commit -Aqm a"
sh % "hg log -G -T '{node|short} {bookmarks}\\n'" == r"""
@ 7f3a02b3e388 foo
o 66ee28d0328c
o b292c1e3311f"""
# Reset prunes commits
sh % "hg reset -C '66ee28d0328c^'" == "2 changesets hidden"
sh % "hg log -r 66ee28d0328c" == r"""
commit: 66ee28d0328c
user: test
date: Thu Jan 01 00:00:00 1970 +0000
summary: y"""
sh % "hg log -G -T '{node|short} {bookmarks}\\n'" == "@ b292c1e3311f foo"
sh % "hg reset -C 7f3a02b3e388"
sh % "hg log -G -T '{node|short} {bookmarks}\\n'" == r"""
@ 7f3a02b3e388 foo
o 66ee28d0328c
o b292c1e3311f"""
# Reset to the commit your on is a no-op
sh % "hg status"
sh % "hg log -r . -T '{rev}\\n'" == "4"
sh % "hg reset ."
sh % "hg log -r . -T '{rev}\\n'" == "4"
sh % "hg debugdirstate" == r"""
n 644 0 * a (glob)
n 644 0 * tobeadded (glob)
n 644 4 * x (glob)"""

View File

@ -0,0 +1,185 @@
#debugruntest-compatible
# coding=utf-8
# Copyright (c) Meta Platforms, Inc. and affiliates.
#
# This software may be used and distributed according to the terms of the
# GNU General Public License version 2.
$ cat >> $HGRCPATH << 'EOF'
> [extensions]
> reset=
> [experimental]
> evolution=
> EOF
$ hg init repo
$ cd repo
$ echo x > x
$ hg commit -qAm x
$ hg book foo
# Soft reset should leave pending changes
$ echo y >> x
$ hg commit -qAm y
$ hg log -G -T '{node|short} {bookmarks}\n'
@ 66ee28d0328c foo
o b292c1e3311f
$ hg reset '.^'
1 changeset hidden
$ hg log -G -T '{node|short} {bookmarks}\n'
@ b292c1e3311f foo
$ hg diff
diff -r b292c1e3311f x
--- a/x Thu Jan 01 00:00:00 1970 +0000
+++ b/x * (glob)
@@ -1,1 +1,2 @@
x
+y
# Clean reset should overwrite all changes
$ hg commit -qAm y
$ hg reset --clean '.^'
1 changeset hidden
$ hg diff
# Reset should recover from backup bundles (with correct phase)
$ hg log -G -T '{node|short} {bookmarks}\n'
@ b292c1e3311f foo
$ hg debugmakepublic b292c1e3311f
$ hg reset --clean 66ee28d0328c
$ hg log -G -T '{node|short} {bookmarks} {phase}\n'
@ 66ee28d0328c foo draft
o b292c1e3311f public
# Reset should not strip reachable commits
$ hg book bar
$ hg reset --clean '.^'
$ hg log -G -T '{node|short} {bookmarks}\n'
o 66ee28d0328c foo
@ b292c1e3311f bar
$ hg book -d bar
$ hg up foo
1 files updated, 0 files merged, 0 files removed, 0 files unresolved
(activating bookmark foo)
# Reset to '.' by default
$ echo z >> x
$ echo z >> y
$ hg add y
$ hg st
M x
A y
$ hg reset
$ hg st
M x
? y
$ hg reset -C
$ hg st
? y
$ rm y
# Keep old commits
$ hg reset --keep '.^'
$ hg log -G -T '{node|short} {bookmarks}\n'
o 66ee28d0328c
@ b292c1e3311f foo
# Reset without a bookmark
$ hg up tip
1 files updated, 0 files merged, 0 files removed, 0 files unresolved
(leaving bookmark foo)
$ hg book -d foo
$ hg reset '.^'
1 changeset hidden
$ hg book foo
# Reset to bookmark with - in the name
$ hg reset 66ee28d0328c
$ hg book foo-bar -r '.^'
$ hg reset foo-bar
1 changeset hidden
$ hg book -d foo-bar
# Verify file status after reset
$ hg reset -C 66ee28d0328c
$ touch toberemoved
$ hg commit -qAm 'add file for removal'
$ echo z >> x
$ touch tobeadded
$ hg add tobeadded
$ hg rm toberemoved
$ hg commit -m 'to be reset'
$ hg reset '.^'
1 changeset hidden
$ hg status
M x
! toberemoved
? tobeadded
$ hg reset -C 66ee28d0328c
1 changeset hidden
# Reset + Obsolete tests
$ cat >> .hg/hgrc << 'EOF'
> [extensions]
> amend=
> rebase=
> [experimental]
> evolution=all
> EOF
$ touch a
$ hg commit -Aqm a
$ hg log -G -T '{node|short} {bookmarks}\n'
@ 7f3a02b3e388 foo
o 66ee28d0328c
o b292c1e3311f
# Reset prunes commits
$ hg reset -C '66ee28d0328c^'
2 changesets hidden
$ hg log -r 66ee28d0328c
commit: 66ee28d0328c
user: test
date: Thu Jan 01 00:00:00 1970 +0000
summary: y
$ hg log -G -T '{node|short} {bookmarks}\n'
@ b292c1e3311f foo
$ hg reset -C 7f3a02b3e388
$ hg log -G -T '{node|short} {bookmarks}\n'
@ 7f3a02b3e388 foo
o 66ee28d0328c
o b292c1e3311f
# Reset to the commit your on is a no-op
$ hg status
$ hg log -r . -T '{rev}\n'
4
$ hg reset .
$ hg log -r . -T '{rev}\n'
4
$ hg debugdirstate
n 644 0 * a (glob)
n 644 0 * tobeadded (glob)
n 644 4 * x (glob)

View File

@ -1,51 +0,0 @@
# coding=utf-8
# Copyright (c) Meta Platforms, Inc. and affiliates.
#
# This software may be used and distributed according to the terms of the
# GNU General Public License version 2.
from __future__ import absolute_import
from testutil.dott import feature, sh, testtmp # noqa: F401
(
sh % "cat"
<< r"""
[extensions]
amend=
smartlog=
[experimental]
evolution = createmarkers
"""
>> "$HGRCPATH"
)
# Test that changesets with visible precursors are rendered as x's
sh % "hg init repo"
sh % "cd repo"
sh % "hg debugbuilddag +4"
sh % "hg book -r 3 test"
sh % "hg up 1" == "0 files updated, 0 files merged, 0 files removed, 0 files unresolved"
sh % "hg amend -m amended --no-rebase" == r"""
hint[amend-restack]: descendants of 66f7d451a68b are left behind - use 'hg restack' to rebase them
hint[hint-ack]: use 'hg hint --ack amend-restack' to silence these hints"""
sh % "hg smartlog -T '{rev} {bookmarks}'" == r"""
@ 4
o 3 test
o 2
x 1
o 0"""
sh % "hg unamend"
sh % "hg up 2" == "0 files updated, 0 files merged, 0 files removed, 0 files unresolved"
sh % "hg debugmakepublic -r ."
sh % "hg smartlog -T '{rev} {bookmarks}'" == r"""
o 3 test
@ 2
~"""

View File

@ -0,0 +1,46 @@
#debugruntest-compatible
# coding=utf-8
# Copyright (c) Meta Platforms, Inc. and affiliates.
#
# This software may be used and distributed according to the terms of the
# GNU General Public License version 2.
$ cat >> $HGRCPATH << 'EOF'
> [extensions]
> amend=
> smartlog=
> [experimental]
> evolution = createmarkers
> EOF
# Test that changesets with visible precursors are rendered as x's
$ hg init repo
$ cd repo
$ hg debugbuilddag +4
$ hg book -r 3 test
$ hg up 1
0 files updated, 0 files merged, 0 files removed, 0 files unresolved
$ hg amend -m amended --no-rebase
hint[amend-restack]: descendants of 66f7d451a68b are left behind - use 'hg restack' to rebase them
hint[hint-ack]: use 'hg hint --ack amend-restack' to silence these hints
$ hg smartlog -T '{rev} {bookmarks}'
@ 4
o 3 test
o 2
x 1
o 0
$ hg unamend
$ hg up 2
0 files updated, 0 files merged, 0 files removed, 0 files unresolved
$ hg debugmakepublic -r .
$ hg smartlog -T '{rev} {bookmarks}'
o 3 test
@ 2
~

View File

@ -1,101 +0,0 @@
# coding=utf-8
# Copyright (c) Meta Platforms, Inc. and affiliates.
#
# This software may be used and distributed according to the terms of the
# GNU General Public License version 2.
from __future__ import absolute_import
from testutil.dott import feature, sh, testtmp # noqa: F401
sh % "configure modernclient"
(
sh % "cat"
<< r"""
[extensions]
smartlog=
remotenames=
"""
>> "$HGRCPATH"
)
sh % "newclientrepo repo"
sh % "echo x" > "x"
sh % "hg commit -qAm x1"
sh % "hg book master1"
sh % "echo x" >> "x"
sh % "hg commit -qAm x2"
sh % "hg push -r . -q --to master1 --create"
# Non-bookmarked public heads should not be visible in smartlog
sh % "newclientrepo client test:repo_server master1" == ""
sh % "hg book mybook -r 'desc(x1)'"
sh % "hg up 'desc(x1)'" == "1 files updated, 0 files merged, 0 files removed, 0 files unresolved"
sh % "hg smartlog -T '{desc} {bookmarks} {remotebookmarks}'" == r"""
o x2 remote/master1
@ x1 mybook"""
# Old head (rev 1) is still visible
sh % "echo z" >> "x"
sh % "hg commit -qAm x3"
sh % "hg push --non-forward-move -q --to master1"
sh % "hg smartlog -T '{desc} {bookmarks} {remotebookmarks}'" == r"""
@ x3 remote/master1
o x1 mybook"""
# Test configuration of "interesting" bookmarks
sh % "hg up -q '.^'"
sh % "echo x" >> "x"
sh % "hg commit -qAm x4"
sh % "hg push -q --to project/bookmark --create"
sh % "hg smartlog -T '{desc} {bookmarks} {remotebookmarks}'" == r"""
o x3 remote/master1
@ x4
o x1 mybook"""
sh % "hg up '.^'" == "1 files updated, 0 files merged, 0 files removed, 0 files unresolved"
sh % "hg smartlog -T '{desc} {bookmarks} {remotebookmarks}'" == r"""
o x3 remote/master1
o x4
@ x1 mybook"""
(
sh % "cat"
<< r"""
[smartlog]
repos=default/
names=project/bookmark
"""
>> "$HGRCPATH"
)
sh % "hg smartlog -T '{desc} {bookmarks} {remotebookmarks}'" == r"""
o x3 remote/master1
o x4
@ x1 mybook"""
(
sh % "cat"
<< r"""
[smartlog]
names=master project/bookmark
"""
>> "$HGRCPATH"
)
sh % "hg smartlog -T '{desc} {bookmarks} {remotebookmarks}'" == r"""
o x3 remote/master1
o x4
@ x1 mybook"""

View File

@ -0,0 +1,89 @@
#debugruntest-compatible
# coding=utf-8
# Copyright (c) Meta Platforms, Inc. and affiliates.
#
# This software may be used and distributed according to the terms of the
# GNU General Public License version 2.
$ configure modernclient
$ cat >> $HGRCPATH << 'EOF'
> [extensions]
> smartlog=
> remotenames=
> [commitcloud]
> enablestatus=false
> EOF
$ newclientrepo repo
$ echo x > x
$ hg commit -qAm x1
$ hg book master1
$ echo x >> x
$ hg commit -qAm x2
$ hg push -r . -q --to master1 --create
# Non-bookmarked public heads should not be visible in smartlog
$ newclientrepo client test:repo_server master1
$ hg book mybook -r 'desc(x1)'
$ hg up 'desc(x1)'
1 files updated, 0 files merged, 0 files removed, 0 files unresolved
$ hg smartlog -T '{desc} {bookmarks} {remotebookmarks}'
o x2 remote/master1
@ x1 mybook
# Old head (rev 1) is still visible
$ echo z >> x
$ hg commit -qAm x3
$ hg push --non-forward-move -q --to master1
$ hg smartlog -T '{desc} {bookmarks} {remotebookmarks}'
@ x3 remote/master1
o x1 mybook
# Test configuration of "interesting" bookmarks
$ hg up -q '.^'
$ echo x >> x
$ hg commit -qAm x4
$ hg push -q --to project/bookmark --create
$ hg smartlog -T '{desc} {bookmarks} {remotebookmarks}'
o x3 remote/master1
@ x4
o x1 mybook
$ hg up '.^'
1 files updated, 0 files merged, 0 files removed, 0 files unresolved
$ hg smartlog -T '{desc} {bookmarks} {remotebookmarks}'
o x3 remote/master1
o x4
@ x1 mybook
$ cat >> $HGRCPATH << 'EOF'
> [smartlog]
> repos=default/
> names=project/bookmark
> EOF
$ hg smartlog -T '{desc} {bookmarks} {remotebookmarks}'
o x3 remote/master1
o x4
@ x1 mybook
$ cat >> $HGRCPATH << 'EOF'
> [smartlog]
> names=master project/bookmark
> EOF
$ hg smartlog -T '{desc} {bookmarks} {remotebookmarks}'
o x3 remote/master1
o x4
@ x1 mybook

View File

@ -1,36 +0,0 @@
# Copyright (c) Meta Platforms, Inc. and affiliates.
#
# This software may be used and distributed according to the terms of the
# GNU General Public License version 2.
from __future__ import absolute_import
from testutil.dott import feature, sh, testtmp # noqa: F401
sh % "newrepo"
sh % "enable smartlog"
(
sh % "drawdag"
<< r"""
B C # B has date 100000 0
|/ # C has date 200000 0
A
"""
)
sh % 'hg bookmark -ir "$A" master'
sh % "hg log -r 'smartlog()' -T '{desc}\\n'" == r"""
A
B
C"""
sh % "hg log -r \"smartlog($B)\" -T '{desc}\\n'" == r"""
A
B"""
sh % "hg log -r \"smartlog(heads=$C, master=$B)\" -T '{desc}\\n'" == r"""
A
B
C"""
sh % "hg log -r \"smartlog(master=($A::)-$B-$C)\" -T '{desc}\\n'" == r"""
A
B
C"""

View File

@ -0,0 +1,29 @@
#debugruntest-compatible
# Copyright (c) Meta Platforms, Inc. and affiliates.
#
# This software may be used and distributed according to the terms of the
# GNU General Public License version 2.
$ newrepo
$ enable smartlog
$ drawdag << 'EOS'
> B C # B has date 100000 0
> |/ # C has date 200000 0
> A
> EOS
$ hg bookmark -ir "$A" master
$ hg log -r 'smartlog()' -T '{desc}\n'
A
B
C
$ hg log -r "smartlog($B)" -T '{desc}\n'
A
B
$ hg log -r "smartlog(heads=$C, master=$B)" -T '{desc}\n'
A
B
C
$ hg log -r "smartlog(master=($A::)-$B-$C)" -T '{desc}\n'
A
B
C

View File

@ -1,192 +0,0 @@
# Copyright (c) Meta Platforms, Inc. and affiliates.
#
# This software may be used and distributed according to the terms of the
# GNU General Public License version 2.
from __future__ import absolute_import
from testutil.dott import feature, sh, testtmp # noqa: F401
# Setup
(
sh % "cat"
<< r"""
[extensions]
arcconfig=$TESTDIR/../edenscm/hgext/extlib/phabricator/arcconfig.py
phabstatus=
smartlog=
"""
>> "$HGRCPATH"
)
sh % "hg init repo"
sh % "cd repo"
sh % "touch foo"
sh % "hg ci -qAm 'Differential Revision: https://phabricator.fb.com/D1'"
# With an invalid arc configuration
sh % "hg log -T '{syncstatus}\\n' -r ." == r"""
arcconfig configuration problem. No diff information can be provided.
Error info: no .arcconfig found
Error"""
# Configure arc...
sh % "echo '{}'" > ".arcrc"
sh % 'echo \'{"config" : {"default" : "https://a.com/api"}, "hosts" : {"https://a.com/api/" : { "user" : "testuser", "oauth" : "garbage_cert"}}}\'' > ".arcconfig"
# And now with bad responses:
sh % "cat" << r"""
[{}]
""" > "$TESTTMP/mockduit"
sh % "'HG_ARC_CONDUIT_MOCK=$TESTTMP/mockduit' hg log -T '{syncstatus}\\n' -r ." == r"""
Error talking to phabricator. No diff information can be provided.
Error info: Unexpected graphql response format
Error"""
sh % "cat" << r"""
[{"errors": [{"message": "failed, yo"}]}]
""" > "$TESTTMP/mockduit"
sh % "'HG_ARC_CONDUIT_MOCK=$TESTTMP/mockduit' hg log -T '{syncstatus}\\n' -r ." == r"""
Error talking to phabricator. No diff information can be provided.
Error info: failed, yo
Error"""
# Missing status field is treated as an error
sh % "cat" << r"""
[{"data": {"query": [{"results": {"nodes": [{
"number": 1,
"latest_active_diff": {
"local_commit_info": {
"nodes": [
{"property_value": "{\"lolwut\": {\"time\": 0, \"commit\": \"lolwut\"}}"}
]
}
},
"differential_diffs": {"count": 3},
"created_time": 123,
"updated_time": 222
}]}}]}}]
""" > "$TESTTMP/mockduit"
sh % "'HG_ARC_CONDUIT_MOCK=$TESTTMP/mockduit' hg log -T '{syncstatus}\\n' -r ." == r"""
Error talking to phabricator. No diff information can be provided.
Error info: Unexpected graphql response format
Error"""
# Missing count field is treated as an error
sh % "cat" << r"""
[{"data": {"query": [{"results": {"nodes": [{
"number": 1,
"diff_status_name": "Approved",
"latest_active_diff": {
"local_commit_info": {
"nodes": [
{"property_value": "{\"lolwut\": {\"time\": 0, \"commit\": \"lolwut\"}}"}
]
}
},
"created_time": 123,
"updated_time": 222
}]}}]}}]
""" > "$TESTTMP/mockduit"
sh % "'HG_ARC_CONDUIT_MOCK=$TESTTMP/mockduit' hg log -T '{syncstatus}\\n' -r ." == r"""
Error talking to phabricator. No diff information can be provided.
Error info: Unexpected graphql response format
Error"""
# Missing hash doesn't make us explode
sh % "cat" << r"""
[{"data": {"query": [{"results": {"nodes": [{
"number": 1,
"diff_status_name": "Approved",
"latest_active_diff": {
"local_commit_info": {
"nodes": [
{"property_value": "{\"lolwut\": {\"time\": 0}}"}
]
}
},
"differential_diffs": {"count": 3},
"is_landing": false,
"land_job_status": "NO_LAND_RUNNING",
"needs_final_review_status": "NOT_NEEDED",
"created_time": 123,
"updated_time": 222
}]}}]}}]
""" > "$TESTTMP/mockduit"
sh % "'HG_ARC_CONDUIT_MOCK=$TESTTMP/mockduit' hg log -T '{phabcommit}\\n' -r ." == ""
# Hash field displayed
sh % "cat" << r"""
[{"data": {"query": [{"results": {"nodes": [{
"number": 1,
"diff_status_name": "Approved",
"latest_active_diff": {
"local_commit_info": {
"nodes": [
{"property_value": "{\"lolwut\": {\"commit\": \"ffffff\", \"time\": 0}}"}
]
}
},
"differential_diffs": {"count": 3},
"is_landing": false,
"land_job_status": "NO_LAND_RUNNING",
"needs_final_review_status": "NOT_NEEDED",
"created_time": 123,
"updated_time": 222
}]}}]}}]
""" > "$TESTTMP/mockduit"
sh % "'HG_ARC_CONDUIT_MOCK=$TESTTMP/mockduit' hg log -T '{phabcommit}\\n' -r ." == "ffffff"
# Missing hash field is treated as unsync
sh % "cat" << r"""
[{"data": {"query": [{"results": {"nodes": [{
"number": 1,
"diff_status_name": "Approved",
"latest_active_diff": {
"local_commit_info": {
"nodes": [
{"property_value": "{\"lolwut\": {\"time\": 0}}"}
]
}
},
"differential_diffs": {"count": 3},
"is_landing": false,
"land_job_status": "NO_LAND_RUNNING",
"needs_final_review_status": "NOT_NEEDED",
"created_time": 123,
"updated_time": 222
}]}}]}}]
""" > "$TESTTMP/mockduit"
sh % "'HG_ARC_CONDUIT_MOCK=$TESTTMP/mockduit' hg log -T '{syncstatus}\\n' -r ." == "unsync"
# And finally, the success case
sh % "cat" << r"""
[{"data": {"query": [{"results": {"nodes": [{
"number": 1,
"diff_status_name": "Committed",
"latest_active_diff": {
"local_commit_info": {
"nodes": [
{"property_value": "{\"lolwut\": {\"time\": 0, \"commit\": \"lolwut\"}}"}
]
}
},
"differential_diffs": {"count": 3},
"is_landing": false,
"land_job_status": "NO_LAND_RUNNING",
"needs_final_review_status": "NOT_NEEDED",
"created_time": 123,
"updated_time": 222
}]}}]}}]
""" > "$TESTTMP/mockduit"
sh % "'HG_ARC_CONDUIT_MOCK=$TESTTMP/mockduit' hg log -T '{syncstatus}\\n' -r ." == "committed"

View File

@ -0,0 +1,187 @@
#debugruntest-compatible
# Copyright (c) Meta Platforms, Inc. and affiliates.
#
# This software may be used and distributed according to the terms of the
# GNU General Public License version 2.
# Setup
$ cat >> $HGRCPATH << 'EOF'
> [extensions]
> arcconfig=$TESTDIR/../edenscm/hgext/extlib/phabricator/arcconfig.py
> phabstatus=
> smartlog=
> EOF
$ hg init repo
$ cd repo
$ touch foo
$ hg ci -qAm 'Differential Revision: https://phabricator.fb.com/D1'
# With an invalid arc configuration
$ hg log -T '{syncstatus}\n' -r .
arcconfig configuration problem. No diff information can be provided.
Error info: no .arcconfig found
Error
# Configure arc...
$ echo '{}' > .arcrc
$ echo '{"config" : {"default" : "https://a.com/api"}, "hosts" : {"https://a.com/api/" : { "user" : "testuser", "oauth" : "garbage_cert"}}}' > .arcconfig
# And now with bad responses:
$ cat > $TESTTMP/mockduit << 'EOF'
> [{}]
> EOF
$ HG_ARC_CONDUIT_MOCK=$TESTTMP/mockduit hg log -T '{syncstatus}\n' -r .
Error talking to phabricator. No diff information can be provided.
Error info: Unexpected graphql response format
Error
$ cat > $TESTTMP/mockduit << 'EOF'
> [{"errors": [{"message": "failed, yo"}]}]
> EOF
$ HG_ARC_CONDUIT_MOCK=$TESTTMP/mockduit hg log -T '{syncstatus}\n' -r .
Error talking to phabricator. No diff information can be provided.
Error info: failed, yo
Error
# Missing status field is treated as an error
$ cat > $TESTTMP/mockduit << 'EOF'
> [{"data": {"query": [{"results": {"nodes": [{
> "number": 1,
> "latest_active_diff": {
> "local_commit_info": {
> "nodes": [
> {"property_value": "{\"lolwut\": {\"time\": 0, \"commit\": \"lolwut\"}}"}
> ]
> }
> },
> "differential_diffs": {"count": 3},
> "created_time": 123,
> "updated_time": 222
> }]}}]}}]
> EOF
$ HG_ARC_CONDUIT_MOCK=$TESTTMP/mockduit hg log -T '{syncstatus}\n' -r .
Error talking to phabricator. No diff information can be provided.
Error info: Unexpected graphql response format
Error
# Missing count field is treated as an error
$ cat > $TESTTMP/mockduit << 'EOF'
> [{"data": {"query": [{"results": {"nodes": [{
> "number": 1,
> "diff_status_name": "Approved",
> "latest_active_diff": {
> "local_commit_info": {
> "nodes": [
> {"property_value": "{\"lolwut\": {\"time\": 0, \"commit\": \"lolwut\"}}"}
> ]
> }
> },
> "created_time": 123,
> "updated_time": 222
> }]}}]}}]
> EOF
$ HG_ARC_CONDUIT_MOCK=$TESTTMP/mockduit hg log -T '{syncstatus}\n' -r .
Error talking to phabricator. No diff information can be provided.
Error info: Unexpected graphql response format
Error
# Missing hash doesn't make us explode
$ cat > $TESTTMP/mockduit << 'EOF'
> [{"data": {"query": [{"results": {"nodes": [{
> "number": 1,
> "diff_status_name": "Approved",
> "latest_active_diff": {
> "local_commit_info": {
> "nodes": [
> {"property_value": "{\"lolwut\": {\"time\": 0}}"}
> ]
> }
> },
> "differential_diffs": {"count": 3},
> "is_landing": false,
> "land_job_status": "NO_LAND_RUNNING",
> "needs_final_review_status": "NOT_NEEDED",
> "created_time": 123,
> "updated_time": 222
> }]}}]}}]
> EOF
$ HG_ARC_CONDUIT_MOCK=$TESTTMP/mockduit hg log -T '{phabcommit}\n' -r .
# Hash field displayed
$ cat > $TESTTMP/mockduit << 'EOF'
> [{"data": {"query": [{"results": {"nodes": [{
> "number": 1,
> "diff_status_name": "Approved",
> "latest_active_diff": {
> "local_commit_info": {
> "nodes": [
> {"property_value": "{\"lolwut\": {\"commit\": \"ffffff\", \"time\": 0}}"}
> ]
> }
> },
> "differential_diffs": {"count": 3},
> "is_landing": false,
> "land_job_status": "NO_LAND_RUNNING",
> "needs_final_review_status": "NOT_NEEDED",
> "created_time": 123,
> "updated_time": 222
> }]}}]}}]
> EOF
$ HG_ARC_CONDUIT_MOCK=$TESTTMP/mockduit hg log -T '{phabcommit}\n' -r .
ffffff
# Missing hash field is treated as unsync
$ cat > $TESTTMP/mockduit << 'EOF'
> [{"data": {"query": [{"results": {"nodes": [{
> "number": 1,
> "diff_status_name": "Approved",
> "latest_active_diff": {
> "local_commit_info": {
> "nodes": [
> {"property_value": "{\"lolwut\": {\"time\": 0}}"}
> ]
> }
> },
> "differential_diffs": {"count": 3},
> "is_landing": false,
> "land_job_status": "NO_LAND_RUNNING",
> "needs_final_review_status": "NOT_NEEDED",
> "created_time": 123,
> "updated_time": 222
> }]}}]}}]
> EOF
$ HG_ARC_CONDUIT_MOCK=$TESTTMP/mockduit hg log -T '{syncstatus}\n' -r .
unsync
# And finally, the success case
$ cat > $TESTTMP/mockduit << 'EOF'
> [{"data": {"query": [{"results": {"nodes": [{
> "number": 1,
> "diff_status_name": "Committed",
> "latest_active_diff": {
> "local_commit_info": {
> "nodes": [
> {"property_value": "{\"lolwut\": {\"time\": 0, \"commit\": \"lolwut\"}}"}
> ]
> }
> },
> "differential_diffs": {"count": 3},
> "is_landing": false,
> "land_job_status": "NO_LAND_RUNNING",
> "needs_final_review_status": "NOT_NEEDED",
> "created_time": 123,
> "updated_time": 222
> }]}}]}}]
> EOF
$ HG_ARC_CONDUIT_MOCK=$TESTTMP/mockduit hg log -T '{syncstatus}\n' -r .
committed

View File

@ -1,40 +0,0 @@
# Copyright (c) Meta Platforms, Inc. and affiliates.
#
# This software may be used and distributed according to the terms of the
# GNU General Public License version 2.
from __future__ import absolute_import
from testutil.dott import feature, sh, testtmp # noqa: F401
sh % "'CACHEDIR=`pwd`/hgcache'"
sh % "setconfig experimental.allowfilepeer=True"
sh % '. "$TESTDIR/library.sh"'
sh % "hg init client1"
sh % "cd client1"
(
sh % "cat"
<< r"""
[remotefilelog]
reponame=master
cachepath=$CACHEDIR
"""
>> ".hg/hgrc"
)
sh % "echo a" > "a"
sh % "mkdir dir"
sh % "echo b" > "dir/b"
sh % "hg commit -Aqm 'initial commit'"
sh % "hg init ../client2"
sh % "cd ../client2"
sh % "hg pull ../client1" == r"""
pulling from ../client1
requesting all changes
adding changesets
adding manifests
adding file changes"""

View File

@ -0,0 +1,27 @@
#debugruntest-compatible
# Copyright (c) Meta Platforms, Inc. and affiliates.
#
# This software may be used and distributed according to the terms of the
# GNU General Public License version 2.
$ CACHEDIR=`pwd`/hgcache
$ setconfig experimental.allowfilepeer=True
$ . "$TESTDIR/library.sh"
$ hg init client1
$ cd client1
$ cat >> .hg/hgrc << 'EOF'
> [remotefilelog]
> reponame=master
> cachepath=$CACHEDIR
> EOF
$ echo a > a
$ mkdir dir
$ echo b > dir/b
$ hg commit -Aqm 'initial commit'
$ hg init ../client2
$ cd ../client2
$ hg pull -q ../client1

View File

@ -1,66 +0,0 @@
# Copyright (c) Meta Platforms, Inc. and affiliates.
#
# This software may be used and distributed according to the terms of the
# GNU General Public License version 2.
from __future__ import absolute_import
from testutil.dott import feature, sh, testtmp # noqa: F401
# test interaction between sparse and treemanifest (sparse file listing)
(
sh % "cat"
<< r"""
[extensions]
sparse=
treemanifest=
[treemanifest]
treeonly = True
[remotefilelog]
reponame = master
cachepath = $PWD/hgcache
"""
>> "$HGRCPATH"
)
# Setup the repository
sh % "hg init myrepo"
sh % "cd myrepo"
sh % "touch show"
sh % "touch hide"
sh % "mkdir -p subdir/foo/spam subdir/bar/ham hiddensub/foo hiddensub/bar"
sh % "touch subdir/foo/spam/show"
sh % "touch subdir/bar/ham/hide"
sh % "touch hiddensub/foo/spam"
sh % "touch hiddensub/bar/ham"
sh % "hg add ." == r"""
adding hiddensub/bar/ham
adding hiddensub/foo/spam
adding hide
adding show
adding subdir/bar/ham/hide
adding subdir/foo/spam/show"""
sh % "hg commit -m Init"
sh % "hg sparse include show"
sh % "hg sparse exclude hide"
sh % "hg sparse include subdir"
sh % "hg sparse exclude subdir/foo"
# Test cwd
sh % "hg sparse cwd" == r"""
- hiddensub
- hide
show
subdir"""
sh % "cd subdir"
sh % "hg sparse cwd" == r"""
bar
- foo"""
sh % "hg sparse include foo"
sh % "hg sparse cwd" == r"""
bar
foo"""

View File

@ -0,0 +1,58 @@
#debugruntest-compatible
# Copyright (c) Meta Platforms, Inc. and affiliates.
#
# This software may be used and distributed according to the terms of the
# GNU General Public License version 2.
# test interaction between sparse and treemanifest (sparse file listing)
$ cat >> $HGRCPATH << EOF
> [extensions]
> sparse=
> treemanifest=
> [treemanifest]
> treeonly = True
> [remotefilelog]
> reponame = master
> cachepath = $PWD/hgcache
> EOF
# Setup the repository
$ hg init myrepo
$ cd myrepo
$ touch show
$ touch hide
$ mkdir -p subdir/foo/spam subdir/bar/ham hiddensub/foo hiddensub/bar
$ touch subdir/foo/spam/show
$ touch subdir/bar/ham/hide
$ touch hiddensub/foo/spam
$ touch hiddensub/bar/ham
$ hg add .
adding hiddensub/bar/ham
adding hiddensub/foo/spam
adding hide
adding show
adding subdir/bar/ham/hide
adding subdir/foo/spam/show
$ hg commit -m Init
$ hg sparse include show
$ hg sparse exclude hide
$ hg sparse include subdir
$ hg sparse exclude subdir/foo
# Test cwd
$ hg sparse cwd
- hiddensub
- hide
show
subdir
$ cd subdir
$ hg sparse cwd
bar
- foo
$ hg sparse include foo
$ hg sparse cwd
bar
foo

View File

@ -1,37 +0,0 @@
# Copyright (c) Meta Platforms, Inc. and affiliates.
#
# This software may be used and distributed according to the terms of the
# GNU General Public License version 2.
from __future__ import absolute_import
from testutil.dott import feature, sh, testtmp # noqa: F401
# Set up
(
sh % "cat"
<< r"""
[experimental]
evolution=all
[extensions]
amend=
tweakdefaults=
"""
>> "$HGRCPATH"
)
# Test hg bookmark works with hidden commits
sh % "hg init repo1"
sh % "cd repo1"
sh % "touch a"
sh % "hg commit -A a -m a"
sh % "echo 1" >> "a"
sh % "hg commit a -m a1"
sh % "hg hide da7a5140a611 -q"
sh % "hg bookmark b -r da7a5140a611 -q"
# Same test but with remotenames enabled
sh % "hg bookmark b2 -r da7a5140a611 -q --config 'extensions.remotenames='"

View File

@ -0,0 +1,30 @@
#debugruntest-compatible
# Copyright (c) Meta Platforms, Inc. and affiliates.
#
# This software may be used and distributed according to the terms of the
# GNU General Public License version 2.
# Set up
$ cat >> $HGRCPATH << 'EOF'
> [experimental]
> evolution=all
> [extensions]
> amend=
> tweakdefaults=
> EOF
# Test hg bookmark works with hidden commits
$ hg init repo1
$ cd repo1
$ touch a
$ hg commit -A a -m a
$ echo 1 >> a
$ hg commit a -m a1
$ hg hide da7a5140a611 -q
$ hg bookmark b -r da7a5140a611 -q
# Same test but with remotenames enabled
$ hg bookmark b2 -r da7a5140a611 -q --config 'extensions.remotenames='

View File

@ -1,40 +0,0 @@
# Copyright (c) Meta Platforms, Inc. and affiliates.
#
# This software may be used and distributed according to the terms of the
# GNU General Public License version 2.
from __future__ import absolute_import
from testutil.dott import feature, sh, testtmp # noqa: F401
# TODO: Make this test compatibile with obsstore enabled.
sh % "setconfig 'experimental.evolution='"
# Set up extensions (order is important here, we must test tweakdefaults loading last)
(
sh % "cat"
<< r"""
[extensions]
rebase=
remotenames=
tweakdefaults=
"""
>> "$HGRCPATH"
)
# Run test
sh % "hg init repo"
sh % "cd repo"
sh % "touch a"
sh % "hg commit -Aqm a"
sh % "touch b"
sh % "hg commit -Aqm b"
sh % "hg bookmark AB"
sh % "hg up '.^'" == r"""
0 files updated, 0 files merged, 1 files removed, 0 files unresolved
(leaving bookmark AB)"""
sh % "touch c"
sh % "hg commit -Aqm c"
sh % "hg bookmark C -t AB"
sh % "hg rebase" == 'rebasing d5e255ef74f8 "c" (C)'

View File

@ -0,0 +1,36 @@
#debugruntest-compatible
# Copyright (c) Meta Platforms, Inc. and affiliates.
#
# This software may be used and distributed according to the terms of the
# GNU General Public License version 2.
# TODO: Make this test compatibile with obsstore enabled.
$ setconfig 'experimental.evolution='
# Set up extensions (order is important here, we must test tweakdefaults loading last)
$ cat >> $HGRCPATH << 'EOF'
> [extensions]
> rebase=
> remotenames=
> tweakdefaults=
> EOF
# Run test
$ hg init repo
$ cd repo
$ touch a
$ hg commit -Aqm a
$ touch b
$ hg commit -Aqm b
$ hg bookmark AB
$ hg up '.^'
0 files updated, 0 files merged, 1 files removed, 0 files unresolved
(leaving bookmark AB)
$ touch c
$ hg commit -Aqm c
$ hg bookmark C -t AB
$ hg rebase
rebasing d5e255ef74f8 "c" (C)

View File

@ -1,64 +0,0 @@
# coding=utf-8
# Copyright (c) Meta Platforms, Inc. and affiliates.
#
# This software may be used and distributed according to the terms of the
# GNU General Public License version 2.
from __future__ import absolute_import
from testutil.dott import feature, sh, testtmp # noqa: F401
sh % "configure modernclient"
sh.enable("remotenames")
# Set up without remotenames
(
sh % "cat"
<< r"""
[extensions]
rebase=
tweakdefaults=
"""
>> "$HGRCPATH"
)
sh % "newclientrepo repo"
sh % "cd .."
sh % "echo a" > "repo/a"
sh % "hg -R repo commit -qAm a"
sh % "hg -R repo bookmark master"
sh % "hg -R repo push -q -r . --to book --create"
sh % "newclientrepo clone test:repo_server book"
# Pull --rebase with no local changes
sh % "echo b" > "../repo/b"
sh % "hg -R ../repo commit -qAm b"
sh % "hg -R ../repo push -q -r . --to book"
sh % "hg pull --rebase -d book" == r"""
pulling from test:repo_server
searching for changes
1 files updated, 0 files merged, 0 files removed, 0 files unresolved
nothing to rebase - fast-forwarded to book"""
sh % "hg log -G -T '{desc} {desc}'" == r"""
@ b b
o a a"""
# Make a local commit and check pull --rebase still works.
sh % "echo x" > "x"
sh % "hg commit -qAm x"
sh % "echo c" > "../repo/c"
sh % "hg -R ../repo commit -qAm c"
sh % "hg -R ../repo push -q -r . --to book"
sh % "hg pull --rebase -d book" == r'''
pulling from test:repo_server
searching for changes
rebasing 86d71924e1d0 "x"'''
sh % "hg log -G -T '{desc} {desc}'" == r"""
@ x x
o c c
o b b
o a a"""

View File

@ -0,0 +1,60 @@
#debugruntest-compatible
# coding=utf-8
# Copyright (c) Meta Platforms, Inc. and affiliates.
#
# This software may be used and distributed according to the terms of the
# GNU General Public License version 2.
$ configure modernclient
$ enable remotenames
# Set up without remotenames
$ cat >> $HGRCPATH << 'EOF'
> [extensions]
> rebase=
> tweakdefaults=
> EOF
$ newclientrepo repo
$ cd ..
$ echo a > repo/a
$ hg -R repo commit -qAm a
$ hg -R repo bookmark master
$ hg -R repo push -q -r . --to book --create
$ newclientrepo clone test:repo_server book
# Pull --rebase with no local changes
$ echo b > ../repo/b
$ hg -R ../repo commit -qAm b
$ hg -R ../repo push -q -r . --to book
$ hg pull --rebase -d book
pulling from test:repo_server
searching for changes
1 files updated, 0 files merged, 0 files removed, 0 files unresolved
nothing to rebase - fast-forwarded to book
$ hg log -G -T '{desc} {desc}'
@ b b
o a a
# Make a local commit and check pull --rebase still works.
$ echo x > x
$ hg commit -qAm x
$ echo c > ../repo/c
$ hg -R ../repo commit -qAm c
$ hg -R ../repo push -q -r . --to book
$ hg pull --rebase -d book
pulling from test:repo_server
searching for changes
rebasing 86d71924e1d0 "x"
$ hg log -G -T '{desc} {desc}'
@ x x
o c c
o b b
o a a

View File

@ -1,65 +0,0 @@
# coding=utf-8
# Copyright (c) Meta Platforms, Inc. and affiliates.
#
# This software may be used and distributed according to the terms of the
# GNU General Public License version 2.
from __future__ import absolute_import
from testutil.dott import feature, sh, testtmp # noqa: F401
sh % "configure modernclient"
# Set up with remotenames
(
sh % "cat"
<< r"""
[extensions]
rebase=
remotenames=
tweakdefaults=
"""
>> "$HGRCPATH"
)
sh % "newclientrepo repo"
sh % "cd .."
sh % "echo a" > "repo/a"
sh % "hg -R repo commit -qAm a"
sh % "hg -R repo bookmark master"
sh % "hg -R repo push -q -r . --to book --create"
sh % "newclientrepo clone test:repo_server book"
# Pull --rebase with no local changes
sh % "hg bookmark localbookmark -t book"
sh % "echo b" > "../repo/b"
sh % "hg -R ../repo commit -qAm b"
sh % "hg -R ../repo push -q -r . --to book"
sh % "hg pull --rebase" == r"""
pulling from test:repo_server
searching for changes
1 files updated, 0 files merged, 0 files removed, 0 files unresolved
nothing to rebase - fast-forwarded to book"""
sh % "hg log -G -T '{desc}: {bookmarks}'" == r"""
@ b: localbookmark
o a:"""
# Make a local commit and check pull --rebase still works.
sh % "echo x" > "x"
sh % "hg commit -qAm x"
sh % "echo c" > "../repo/c"
sh % "hg -R ../repo commit -qAm c"
sh % "hg -R ../repo push -q -r . --to book"
sh % "hg pull --rebase" == r"""
pulling from test:repo_server
searching for changes
rebasing 86d71924e1d0 "x" (localbookmark)"""
sh % "hg log -G -T '{desc}: {bookmarks}'" == r"""
@ x: localbookmark
o c:
o b:
o a:"""

View File

@ -0,0 +1,61 @@
#debugruntest-compatible
# coding=utf-8
# Copyright (c) Meta Platforms, Inc. and affiliates.
#
# This software may be used and distributed according to the terms of the
# GNU General Public License version 2.
$ configure modernclient
# Set up with remotenames
$ cat >> $HGRCPATH << 'EOF'
> [extensions]
> rebase=
> remotenames=
> tweakdefaults=
> EOF
$ newclientrepo repo
$ cd ..
$ echo a > repo/a
$ hg -R repo commit -qAm a
$ hg -R repo bookmark master
$ hg -R repo push -q -r . --to book --create
$ newclientrepo clone test:repo_server book
# Pull --rebase with no local changes
$ hg bookmark localbookmark -t book
$ echo b > ../repo/b
$ hg -R ../repo commit -qAm b
$ hg -R ../repo push -q -r . --to book
$ hg pull --rebase
pulling from test:repo_server
searching for changes
1 files updated, 0 files merged, 0 files removed, 0 files unresolved
nothing to rebase - fast-forwarded to book
$ hg log -G -T '{desc}: {bookmarks}'
@ b: localbookmark
o a:
# Make a local commit and check pull --rebase still works.
$ echo x > x
$ hg commit -qAm x
$ echo c > ../repo/c
$ hg -R ../repo commit -qAm c
$ hg -R ../repo push -q -r . --to book
$ hg pull --rebase
pulling from test:repo_server
searching for changes
rebasing 86d71924e1d0 "x" (localbookmark)
$ hg log -G -T '{desc}: {bookmarks}'
@ x: localbookmark
o c:
o b:
o a:

View File

@ -1,83 +0,0 @@
# coding=utf-8
# Copyright (c) Meta Platforms, Inc. and affiliates.
#
# This software may be used and distributed according to the terms of the
# GNU General Public License version 2.
from __future__ import absolute_import
from testutil.dott import feature, sh, testtmp # noqa: F401
(
sh % "cat"
<< r"""
[extensions]
tweakdefaults=
rebase=
[experimental]
updatecheck=noconflict
"""
>> "$HGRCPATH"
)
sh % "setconfig 'ui.suggesthgprev=True'"
# Set up the repository.
sh % "hg init repo"
sh % "cd repo"
sh % "hg debugbuilddag -m '+4 *3 +1'"
sh % "hg log --graph -r '0::' -T '{rev}'" == r"""
o 5
o 4
o 3
o 2
o 1
o 0"""
sh % "hg up 3" == "1 files updated, 0 files merged, 0 files removed, 0 files unresolved"
# Make an uncommitted change.
sh % "echo foo" > "foo"
sh % "hg add foo"
sh % "hg st" == "A foo"
# Can always update to current commit.
sh % "hg up ." == "0 files updated, 0 files merged, 0 files removed, 0 files unresolved"
# Abort with --check set, succeed with --merge
sh % "hg up 2 --check" == r"""
abort: uncommitted changes
[255]"""
sh % "hg up --merge 2" == "1 files updated, 0 files merged, 0 files removed, 0 files unresolved"
# Updates to other branches should fail without --merge.
sh % "hg up 4 --check" == r"""
abort: uncommitted changes
[255]"""
sh % "hg up --merge 4" == "1 files updated, 0 files merged, 0 files removed, 0 files unresolved"
# Certain flags shouldn't work together.
sh % "hg up --check --merge 3" == r"""
abort: can only specify one of -C/--clean, -c/--check, or -m/--merge
[255]"""
sh % "hg up --check --clean 3" == r"""
abort: can only specify one of -C/--clean, -c/--check, or -m/--merge
[255]"""
sh % "hg up --clean --merge 3" == r"""
abort: can only specify one of -C/--clean, -c/--check, or -m/--merge
[255]"""
# --clean should work as expected.
sh % "hg st" == "A foo"
sh % "hg up --clean 3" == "1 files updated, 0 files merged, 0 files removed, 0 files unresolved"
sh % "hg st" == "? foo"
sh % "enable amend"
sh % "hg update '.^'" == r"""
1 files updated, 0 files merged, 0 files removed, 0 files unresolved
hint[update-prev]: use 'hg prev' to move to the parent changeset
hint[hint-ack]: use 'hg hint --ack update-prev' to silence these hints"""

View File

@ -0,0 +1,90 @@
#debugruntest-compatible
# coding=utf-8
# Copyright (c) Meta Platforms, Inc. and affiliates.
#
# This software may be used and distributed according to the terms of the
# GNU General Public License version 2.
$ cat >> $HGRCPATH << 'EOF'
> [extensions]
> tweakdefaults=
> rebase=
> [experimental]
> updatecheck=noconflict
> EOF
$ setconfig 'ui.suggesthgprev=True'
# Set up the repository.
$ hg init repo
$ cd repo
$ hg debugbuilddag -m '+4 *3 +1'
$ hg log --graph -r '0::' -T '{rev}'
o 5
o 4
o 3
o 2
o 1
o 0
$ hg up 3
1 files updated, 0 files merged, 0 files removed, 0 files unresolved
# Make an uncommitted change.
$ echo foo > foo
$ hg add foo
$ hg st
A foo
# Can always update to current commit.
$ hg up .
0 files updated, 0 files merged, 0 files removed, 0 files unresolved
# Abort with --check set, succeed with --merge
$ hg up 2 --check
abort: uncommitted changes
[255]
$ hg up --merge 2
1 files updated, 0 files merged, 0 files removed, 0 files unresolved
# Updates to other branches should fail without --merge.
$ hg up 4 --check
abort: uncommitted changes
[255]
$ hg up --merge 4
1 files updated, 0 files merged, 0 files removed, 0 files unresolved
# Certain flags shouldn't work together.
$ hg up --check --merge 3
abort: can only specify one of -C/--clean, -c/--check, or -m/--merge
[255]
$ hg up --check --clean 3
abort: can only specify one of -C/--clean, -c/--check, or -m/--merge
[255]
$ hg up --clean --merge 3
abort: can only specify one of -C/--clean, -c/--check, or -m/--merge
[255]
# --clean should work as expected.
$ hg st
A foo
$ hg up --clean 3
1 files updated, 0 files merged, 0 files removed, 0 files unresolved
$ hg st
? foo
$ enable amend
$ hg update '.^'
1 files updated, 0 files merged, 0 files removed, 0 files unresolved
hint[update-prev]: use 'hg prev' to move to the parent changeset
hint[hint-ack]: use 'hg hint --ack update-prev' to silence these hints

View File

@ -1,44 +0,0 @@
# Copyright (c) Meta Platforms, Inc. and affiliates.
#
# This software may be used and distributed according to the terms of the
# GNU General Public License version 2.
from __future__ import absolute_import
from testutil.dott import feature, sh, testtmp # noqa: F401
# Test whereami
sh % "hg init repo1"
sh % "cd repo1"
sh % "cat" << r"""
[extensions]
whereami=
""" > ".hg/hgrc"
sh % "hg whereami" == "0000000000000000000000000000000000000000"
sh % "echo a" > "a"
sh % "hg add a"
sh % "hg commit -m a"
sh % "hg whereami" == "cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b"
sh % "echo b" > "b"
sh % "hg add b"
sh % "hg commit -m b"
sh % "hg up '.^'" == "0 files updated, 0 files merged, 1 files removed, 0 files unresolved"
sh % "echo c" > "c"
sh % "hg add c"
sh % "hg commit -m c"
sh % "hg merge 1" == r"""
1 files updated, 0 files merged, 0 files removed, 0 files unresolved
(branch merge, don't forget to commit)"""
sh % "hg whereami" == r"""
d36c0562f908c692f5204d606d4ff3537d41f1bf
d2ae7f538514cd87c17547b0de4cea71fe1af9fb"""

View File

@ -0,0 +1,43 @@
#debugruntest-compatible
# Copyright (c) Meta Platforms, Inc. and affiliates.
#
# This software may be used and distributed according to the terms of the
# GNU General Public License version 2.
# Test whereami
$ hg init repo1
$ cd repo1
$ cat > .hg/hgrc << 'EOF'
> [extensions]
> whereami=
> EOF
$ hg whereami
0000000000000000000000000000000000000000
$ echo a > a
$ hg add a
$ hg commit -m a
$ hg whereami
cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b
$ echo b > b
$ hg add b
$ hg commit -m b
$ hg up '.^'
0 files updated, 0 files merged, 1 files removed, 0 files unresolved
$ echo c > c
$ hg add c
$ hg commit -m c
$ hg merge 1
1 files updated, 0 files merged, 0 files removed, 0 files unresolved
(branch merge, don't forget to commit)
$ hg whereami
d36c0562f908c692f5204d606d4ff3537d41f1bf
d2ae7f538514cd87c17547b0de4cea71fe1af9fb