##// END OF EJS Templates
issue6528: add a config option to control the fixing on the fly...
issue6528: add a config option to control the fixing on the fly This will allow people who know to be safe to avoid any performance overhead (and other potential issue). Differential Revision: https://phab.mercurial-scm.org/D11271

File last commit:

r47827:4c7bc42a stable
r48630:2813d406 5.9rc1 stable
Show More
test-git-interop.t
425 lines | 9.9 KiB | text/troff | Tads3Lexer
/ tests / test-git-interop.t
Matt Harbison
tests: skip test-git-interop.t on Windows...
r47656 #require pygit2 no-windows
Augie Fackler
git: skeleton of a new extension to _directly_ operate on git repos...
r44961
Setup:
Augie Fackler
git: key off `git` in .hg/requires rather than separate file...
r44977 $ GIT_AUTHOR_NAME='test'; export GIT_AUTHOR_NAME
Augie Fackler
git: skeleton of a new extension to _directly_ operate on git repos...
r44961 > GIT_AUTHOR_EMAIL='test@example.org'; export GIT_AUTHOR_EMAIL
> GIT_AUTHOR_DATE="2007-01-01 00:00:00 +0000"; export GIT_AUTHOR_DATE
> GIT_COMMITTER_NAME="$GIT_AUTHOR_NAME"; export GIT_COMMITTER_NAME
> GIT_COMMITTER_EMAIL="$GIT_AUTHOR_EMAIL"; export GIT_COMMITTER_EMAIL
> GIT_COMMITTER_DATE="$GIT_AUTHOR_DATE"; export GIT_COMMITTER_DATE
Matt Harbison
tests: synchronize the git and Mercurial username...
r47827 > HGUSER="test <test@example.org>"; export HGUSER
Augie Fackler
git: skeleton of a new extension to _directly_ operate on git repos...
r44961 > count=10
> gitcommit() {
> GIT_AUTHOR_DATE="2007-01-01 00:00:$count +0000";
> GIT_COMMITTER_DATE="$GIT_AUTHOR_DATE"
> git commit "$@" >/dev/null 2>/dev/null || echo "git commit error"
> count=`expr $count + 1`
> }
test: enforce master to be the default branch in test...
r47596 $ git config --global init.defaultBranch master
Augie Fackler
git: skeleton of a new extension to _directly_ operate on git repos...
r44961
Augie Fackler
git: key off `git` in .hg/requires rather than separate file...
r44977
Matt Harbison
git: show the version of `pygit2` with verbose version output...
r46562 $ hg version -v --config extensions.git= | grep '^[E ]'
Enabled extensions:
git internal (pygit2 *) (glob)
Augie Fackler
git: key off `git` in .hg/requires rather than separate file...
r44977 Test auto-loading extension works:
$ mkdir nogit
$ cd nogit
$ mkdir .hg
$ echo git >> .hg/requires
$ hg status
abort: repository specified git format in .hg/requires but has no .git directory
[255]
Joerg Sonnenberger
tests: resort to fix test with newer git versions...
r47554 $ git config --global init.defaultBranch master
Augie Fackler
git: key off `git` in .hg/requires rather than separate file...
r44977 $ git init
Initialized empty Git repository in $TESTTMP/nogit/.git/
This status invocation shows some hg gunk because we didn't use
`hg init --git`, which fixes up .git/info/exclude for us.
$ hg status
? .hg/cache/git-commits.sqlite
? .hg/cache/git-commits.sqlite-shm
? .hg/cache/git-commits.sqlite-wal
? .hg/requires
$ cd ..
Now globally enable extension for the rest of the test:
Augie Fackler
git: add debug logging when there's a mismatch in the cached heads list...
r45478 $ cat <<EOF >> $HGRCPATH
> [extensions]
> git=
> [git]
> log-index-cache-miss = yes
> EOF
Augie Fackler
git: skeleton of a new extension to _directly_ operate on git repos...
r44961
Matt Harbison
git: make changelog.tiprev() return int instead of tuple (issue6510)...
r47820 Test some edge cases around a commitless repo first
$ mkdir empty
$ cd empty
$ git init
Initialized empty Git repository in $TESTTMP/empty/.git/
$ hg init --git
$ hg heads
[1]
Matt Harbison
git: initialize `extra` to have at least the branch name for nullid...
r47826 $ hg tip
changeset: -1:000000000000
tag: tip
user:
date: Thu Jan 01 00:00:00 1970 +0000
Matt Harbison
git: make changelog.tiprev() return int instead of tuple (issue6510)...
r47820 $ cd ..
Augie Fackler
git: skeleton of a new extension to _directly_ operate on git repos...
r44961 Make a new repo with git:
$ mkdir foo
$ cd foo
$ git init
Initialized empty Git repository in $TESTTMP/foo/.git/
Ignore the .hg directory within git:
$ echo .hg >> .git/info/exclude
$ echo alpha > alpha
$ git add alpha
$ gitcommit -am 'Add alpha'
$ echo beta > beta
$ git add beta
$ gitcommit -am 'Add beta'
$ echo gamma > gamma
$ git status
On branch master
Untracked files:
(use "git add <file>..." to include in what will be committed)
Matt Harbison
tests: stabilize test-git-interop.t for some versions of git...
r47818 (?)
Augie Fackler
git: skeleton of a new extension to _directly_ operate on git repos...
r44961 gamma
nothing added to commit but untracked files present (use "git add" to track)
Without creating the .hg, hg status fails:
$ hg status
Augie Fackler
git: update test for hg and git output changes...
r46538 abort: no repository found in '$TESTTMP/foo' (.hg not found)
[10]
Augie Fackler
git: skeleton of a new extension to _directly_ operate on git repos...
r44961 But if you run hg init --git, it works:
$ hg init --git
$ hg id --traceback
Augie Fackler
git: add debug logging when there's a mismatch in the cached heads list...
r45478 heads mismatch, rebuilding dagcache
Augie Fackler
git: skeleton of a new extension to _directly_ operate on git repos...
r44961 3d9be8deba43 tip master
$ hg status
? gamma
Log works too:
$ hg log
changeset: 1:3d9be8deba43
bookmark: master
tag: tip
user: test <test@example.org>
date: Mon Jan 01 00:00:11 2007 +0000
summary: Add beta
changeset: 0:c5864c9d16fb
user: test <test@example.org>
date: Mon Jan 01 00:00:10 2007 +0000
summary: Add alpha
and bookmarks:
$ hg bookmarks
* master 1:3d9be8deba43
diff even works transparently in both systems:
$ echo blah >> alpha
$ git diff
diff --git a/alpha b/alpha
index 4a58007..faed1b7 100644
--- a/alpha
+++ b/alpha
@@ -1* +1,2 @@ (glob)
alpha
+blah
$ hg diff --git
diff --git a/alpha b/alpha
--- a/alpha
+++ b/alpha
@@ -1,1 +1,2 @@
alpha
+blah
Remove a file, it shows as such:
$ rm alpha
$ hg status
! alpha
? gamma
Revert works:
$ hg revert alpha --traceback
$ hg status
? gamma
$ git status
On branch master
Untracked files:
(use "git add <file>..." to include in what will be committed)
Matt Harbison
tests: stabilize test-git-interop.t for some versions of git...
r47818 (?)
Augie Fackler
git: skeleton of a new extension to _directly_ operate on git repos...
r44961 gamma
nothing added to commit but untracked files present (use "git add" to track)
Add shows sanely in both:
$ hg add gamma
$ hg status
A gamma
$ hg files
alpha
beta
gamma
$ git ls-files
alpha
beta
gamma
$ git status
On branch master
Changes to be committed:
Matt Harbison
tests: stabilize test-git-interop.t for some versions of git...
r47818 (use "git restore --staged <file>..." to unstage) (?)
(use "git reset HEAD <file>..." to unstage) (?)
(?)
Augie Fackler
git: skeleton of a new extension to _directly_ operate on git repos...
r44961 new file: gamma
forget does what it should as well:
$ hg forget gamma
$ hg status
? gamma
$ git status
On branch master
Untracked files:
(use "git add <file>..." to include in what will be committed)
Matt Harbison
tests: stabilize test-git-interop.t for some versions of git...
r47818 (?)
Augie Fackler
git: skeleton of a new extension to _directly_ operate on git repos...
r44961 gamma
nothing added to commit but untracked files present (use "git add" to track)
clean up untracked file
$ rm gamma
hg log FILE
$ echo a >> alpha
Matt Harbison
tests: synchronize the git and Mercurial username...
r47827 $ hg ci -m 'more alpha' --traceback --date '1583558723 18000'
Augie Fackler
git: skeleton of a new extension to _directly_ operate on git repos...
r44961 $ echo b >> beta
$ hg ci -m 'more beta'
Augie Fackler
git: add debug logging when there's a mismatch in the cached heads list...
r45478 heads mismatch, rebuilding dagcache
Augie Fackler
git: skeleton of a new extension to _directly_ operate on git repos...
r44961 $ echo a >> alpha
$ hg ci -m 'even more alpha'
Augie Fackler
git: add debug logging when there's a mismatch in the cached heads list...
r45478 heads mismatch, rebuilding dagcache
Augie Fackler
git: skeleton of a new extension to _directly_ operate on git repos...
r44961 $ hg log -G alpha
Augie Fackler
git: add debug logging when there's a mismatch in the cached heads list...
r45478 heads mismatch, rebuilding dagcache
Matt Harbison
tests: synchronize the git and Mercurial username...
r47827 @ changeset: 4:cf6ddf5d9b8a
Augie Fackler
git: skeleton of a new extension to _directly_ operate on git repos...
r44961 : bookmark: master
: tag: tip
Matt Harbison
tests: synchronize the git and Mercurial username...
r47827 : user: test <test@example.org>
Augie Fackler
git: skeleton of a new extension to _directly_ operate on git repos...
r44961 : date: Thu Jan 01 00:00:00 1970 +0000
: summary: even more alpha
:
Matt Harbison
tests: synchronize the git and Mercurial username...
r47827 o changeset: 2:5b2c80b027ce
: user: test <test@example.org>
: date: Sat Mar 07 00:25:23 2020 -0500
Augie Fackler
git: skeleton of a new extension to _directly_ operate on git repos...
r44961 : summary: more alpha
:
o changeset: 0:c5864c9d16fb
user: test <test@example.org>
date: Mon Jan 01 00:00:10 2007 +0000
summary: Add alpha
$ hg log -G beta
Matt Harbison
tests: synchronize the git and Mercurial username...
r47827 o changeset: 3:980d4f79a9c6
: user: test <test@example.org>
Augie Fackler
git: skeleton of a new extension to _directly_ operate on git repos...
r44961 : date: Thu Jan 01 00:00:00 1970 +0000
: summary: more beta
:
o changeset: 1:3d9be8deba43
| user: test <test@example.org>
~ date: Mon Jan 01 00:00:11 2007 +0000
summary: Add beta
Augie Fackler
tests: add coverage for repo.changelog.children() in the git extension...
r45382 $ hg log -r "children(3d9be8deba43)" -T"{node|short} {children}\n"
Matt Harbison
tests: synchronize the git and Mercurial username...
r47827 5b2c80b027ce 3:980d4f79a9c6
Augie Fackler
tests: add coverage for repo.changelog.children() in the git extension...
r45382
Augie Fackler
git: skeleton of a new extension to _directly_ operate on git repos...
r44961 hg annotate
$ hg annotate alpha
0: alpha
2: a
4: a
$ hg annotate beta
1: beta
3: b
Files in subdirectories. TODO: case-folding support, make this `A`
instead of `a`.
$ mkdir a
$ echo "This is file mu." > a/mu
$ hg ci -A -m 'Introduce file a/mu'
adding a/mu
Both hg and git agree a/mu is part of the repo
$ git ls-files
a/mu
alpha
beta
$ hg files
a/mu
alpha
beta
hg and git status both clean
$ git status
On branch master
nothing to commit, working tree clean
$ hg status
Augie Fackler
git: add debug logging when there's a mismatch in the cached heads list...
r45478 heads mismatch, rebuilding dagcache
Augie Fackler
git: skeleton of a new extension to _directly_ operate on git repos...
r44961
Martin von Zweigbergk
git: make {shortest()} return shortest *unique* prefix...
r44962
node|shortest works correctly
$ hg log -T '{node}\n' | sort
3d9be8deba43482be2c81a4cb4be1f10d85fa8bc
Matt Harbison
tests: synchronize the git and Mercurial username...
r47827 5b2c80b027ce4250f88957326c199a2dc48dad60
980d4f79a9c617d60d0fe1fb383753c4a61bea8e
c1a41c49866ecc9c5411be932653e5b430961dd5
Martin von Zweigbergk
git: make {shortest()} return shortest *unique* prefix...
r44962 c5864c9d16fb3431fe2c175ff84dc6accdbb2c18
Matt Harbison
tests: synchronize the git and Mercurial username...
r47827 cf6ddf5d9b8a120bf90020342bcf7a96d0167279
$ hg log -r c1a41c49866ecc9c5411be932653e5b430961dd5 --template "{shortest(node,1)}\n"
c1
Martin von Zweigbergk
git: make {shortest()} return shortest *unique* prefix...
r44962
Matt Harbison
git: fix partial node matching...
r47819 This covers gitlog._partialmatch()
Matt Harbison
tests: synchronize the git and Mercurial username...
r47827 $ hg log -r c
abort: ambiguous revision identifier: c
Matt Harbison
git: fix partial node matching...
r47819 [10]
Matt Harbison
tests: synchronize the git and Mercurial username...
r47827 $ hg log -r c1
changeset: 5:c1a41c49866e
bookmark: master
tag: tip
user: test <test@example.org>
date: Thu Jan 01 00:00:00 1970 +0000
summary: Introduce file a/mu
Matt Harbison
git: fix partial node matching...
r47819
$ hg log -r dead
abort: unknown revision 'dead'
[255]
Augie Fackler
tests: add coverage for repo.changelog.findmissing() in test-git-interop.t...
r45381 This coveres changelog.findmissing()
$ hg merge --preview 3d9be8deba43
Augie Fackler
git: add coverage for manifest.diff() so we don't regress
r45451
This covers manifest.diff()
$ hg diff -c 3d9be8deba43
diff -r c5864c9d16fb -r 3d9be8deba43 beta
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/beta Mon Jan 01 00:00:11 2007 +0000
@@ -0,0 +1,1 @@
+beta
Augie Fackler
git: fix index handling of removed files during commit (issue6398)...
r45992
Connor Sheehan
git: add test showing `hg commit -i` working on a git repo...
r46152 Interactive commit should work as expected
$ echo bar >> alpha
$ echo bar >> beta
$ hg commit -m "test interactive commit" -i --config ui.interactive=true --config ui.interface=text << EOF
> y
> y
> n
> EOF
diff --git a/alpha b/alpha
1 hunks, 1 lines changed
examine changes to 'alpha'?
(enter ? for help) [Ynesfdaq?] y
@@ -1,3 +1,4 @@
alpha
a
a
+bar
record change 1/2 to 'alpha'?
(enter ? for help) [Ynesfdaq?] y
diff --git a/beta b/beta
1 hunks, 1 lines changed
examine changes to 'beta'?
(enter ? for help) [Ynesfdaq?] n
Status should be consistent for both systems
$ hg status
heads mismatch, rebuilding dagcache
M beta
Augie Fackler
git: update test for hg and git output changes...
r46538 $ git status | egrep -v '^$|^ \(use '
Connor Sheehan
git: add test showing `hg commit -i` working on a git repo...
r46152 On branch master
Changes not staged for commit:
modified: beta
no changes added to commit (use "git add" and/or "git commit -a")
Contents of each commit should be the same
$ hg ex -r .
# HG changeset patch
Matt Harbison
tests: synchronize the git and Mercurial username...
r47827 # User test <test@example.org>
Connor Sheehan
git: add test showing `hg commit -i` working on a git repo...
r46152 # Date 0 0
# Thu Jan 01 00:00:00 1970 +0000
Matt Harbison
tests: synchronize the git and Mercurial username...
r47827 # Node ID 6024eda7986da123aa6797dd4603bd399d49bf5c
# Parent c1a41c49866ecc9c5411be932653e5b430961dd5
Connor Sheehan
git: add test showing `hg commit -i` working on a git repo...
r46152 test interactive commit
Matt Harbison
tests: synchronize the git and Mercurial username...
r47827 diff -r c1a41c49866e -r 6024eda7986d alpha
Connor Sheehan
git: add test showing `hg commit -i` working on a git repo...
r46152 --- a/alpha Thu Jan 01 00:00:00 1970 +0000
+++ b/alpha Thu Jan 01 00:00:00 1970 +0000
@@ -1,3 +1,4 @@
alpha
a
a
+bar
$ git show
Matt Harbison
tests: synchronize the git and Mercurial username...
r47827 commit 6024eda7986da123aa6797dd4603bd399d49bf5c
Author: test <test@example.org>
Connor Sheehan
git: add test showing `hg commit -i` working on a git repo...
r46152 Date: Thu Jan 1 00:00:00 1970 +0000
test interactive commit
diff --git a/alpha b/alpha
index d112a75..d2a2e9a 100644
--- a/alpha
+++ b/alpha
@@ -1,3 +1,4 @@
alpha
a
a
+bar
Augie Fackler
git: fix index handling of removed files during commit (issue6398)...
r45992 Deleting files should also work (this was issue6398)
Connor Sheehan
git: add test showing `hg commit -i` working on a git repo...
r46152 $ hg revert -r . --all
reverting beta
Augie Fackler
git: fix index handling of removed files during commit (issue6398)...
r45992 $ hg rm beta
$ hg ci -m 'remove beta'
Connor Sheehan
git: add test showing `hg commit -i` working on a git repo...
r46152
Matt Harbison
git: make changelog.tiprev() return int instead of tuple (issue6510)...
r47820 This covers changelog.tiprev() (issue6510)
$ hg log -r '(.^^):'
heads mismatch, rebuilding dagcache
Matt Harbison
tests: synchronize the git and Mercurial username...
r47827 changeset: 5:c1a41c49866e
user: test <test@example.org>
Matt Harbison
git: make changelog.tiprev() return int instead of tuple (issue6510)...
r47820 date: Thu Jan 01 00:00:00 1970 +0000
summary: Introduce file a/mu
Matt Harbison
tests: synchronize the git and Mercurial username...
r47827 changeset: 6:6024eda7986d
user: test <test@example.org>
Matt Harbison
git: make changelog.tiprev() return int instead of tuple (issue6510)...
r47820 date: Thu Jan 01 00:00:00 1970 +0000
summary: test interactive commit
Matt Harbison
tests: synchronize the git and Mercurial username...
r47827 changeset: 7:1a0fee76bfc4
Matt Harbison
git: make changelog.tiprev() return int instead of tuple (issue6510)...
r47820 bookmark: master
tag: tip
Matt Harbison
tests: synchronize the git and Mercurial username...
r47827 user: test <test@example.org>
Matt Harbison
git: make changelog.tiprev() return int instead of tuple (issue6510)...
r47820 date: Thu Jan 01 00:00:00 1970 +0000
summary: remove beta
Matt Harbison
tests: add coverage for git.changelog.headrevs(...)...
r47821 This covers changelog.headrevs() with a non-None arg
$ hg log -r 'heads(.)' -Tcompact
Matt Harbison
tests: synchronize the git and Mercurial username...
r47827 7[tip][master] 1a0fee76bfc4 1970-01-01 00:00 +0000 test
Matt Harbison
tests: add coverage for git.changelog.headrevs(...)...
r47821 remove beta