[PATCH 0 of 5 next] First batch of work towards standard bookmark workflow

34 views
Skip to first unread message

David Carr

unread,
Oct 7, 2012, 8:37:38 PM10/7/12
to hg-...@googlegroups.com
The first patch in this series is an unrelated test fix; I just kept running
into it as I was working on the other changes.

This is a series of patches towards making Hg-Git's workflow work as close to
the normal Hg bookmark workflow as possible. This is the portion that I have
ready at the moment; other patches will follow.

My approach has been to first establish a test scenario which compares the
behavior of a command between an equivalent git remote and hg remote. If
the behavior doesn't match well and I see a way to improve it, I make the
miminal change needed to make that scenario match better. Then, I add that
test scenario to the test corpus. If I come across scenarios that don't
match, but that I can't come up with a way to improve, I'll document the
limitation and add the scenario to the test, so that the difference is better
understood.

While these patches don't yet touch core bookmark behaviors, the next batch
of patches should include tweaks to the gitrepo implementation of listkeys
that will support hooking into the "divergent bookmark" support in modern
versions of Mercurial.

David Carr

unread,
Oct 7, 2012, 8:37:39 PM10/7/12
to hg-...@googlegroups.com
# HG changeset patch
# User David M. Carr <da...@carrclan.us>
# Date 1349653079 14400
# Node ID 6e27c42c99d077721142cb171d203b2b6b6e6dc1
# Parent c5d4900a804e6bdaf7753d5de0a2aacd330f6e51
tests: fix test-subrepos.t sporadically failing

I was seeing sporadic failures running this test on Mac OS X 10.8.
They looked like this:
+ sed: 1: "s_/private/var/folders/ ...": bad flag in substitute command: 'T'

My assumption is that some character was being included in the path of the
temporary directory that sed didn't like. It looks like the sed function was
being used to eliminate differences between test runs due to the path changing
each run. That isn't needed any more now that we're using the unified test
format, since said replacement is taken care of for us by run-tests.py. Thus,
this changeset removes the calls to sed and updates the output to use the result
from the framework-level replacement.

diff --git a/tests/test-subrepos.t b/tests/test-subrepos.t
--- a/tests/test-subrepos.t
+++ b/tests/test-subrepos.t
@@ -150,19 +150,19 @@
pulling from $TESTTMP/gitrepo1
importing git objects into hg
(run 'hg update' to get a working copy)
- $ hg checkout -C | sed "s_$(dirname $(pwd))_TEMPLOCATION_"
- cloning subrepo hgsub from TEMPLOCATION/hgsub
+ $ hg checkout -C
+ cloning subrepo hgsub from $TESTTMP/hgsub
2 files updated, 0 files merged, 0 files removed, 0 files unresolved
$ cd ..
$ echo % pull shall bring .hgsub entry which was added to the git repo
% pull shall bring .hgsub entry which was added to the git repo
- $ cat hgrepo/.hgsub | sed "s_$(pwd)_TEMPLOCATION_"
- hgsub = TEMPLOCATION/hgsub
+ $ cat hgrepo/.hgsub
+ hgsub = $TESTTMP/hgsub
subrepo1 = [git]../gitsubrepo
xyz/subrepo2 = [git]../gitsubrepo
$ echo % .hgsubstate shall list revision of the subrepo added through git repo
% .hgsubstate shall list revision of the subrepo added through git repo
- $ cat hgrepo/.hgsubstate | sed "s_$(pwd)_TEMPLOCATION_"
+ $ cat hgrepo/.hgsubstate
481ec30d580f333ae3a77f94c973ce37b69d5bda hgsub
56f0304c5250308f14cfbafdc27bd12d40154d17 subrepo1
aabf7cd015089aff0b84596e69aa37b24a3d090a xyz/subrepo2

David Carr

unread,
Oct 7, 2012, 8:37:40 PM10/7/12
to hg-...@googlegroups.com
# HG changeset patch
# User David M. Carr <da...@carrclan.us>
# Date 1349653731 14400
# Node ID 461fe932c388585a73e26d33b74fe4a22b0b118b
# Parent 6e27c42c99d077721142cb171d203b2b6b6e6dc1
tests: add coverage for bookmark workflow comparison; cloning

diff --git a/tests/test-bookmark-workflow.t b/tests/test-bookmark-workflow.t
new file mode 100644
--- /dev/null
+++ b/tests/test-bookmark-workflow.t
@@ -0,0 +1,99 @@
+This test demonstrates how Hg works with remote Hg bookmarks compared with
+remote branches via Hg-Git. Ideally, they would behave identically. In
+practice, some differences are unavoidable, but we should try to minimize
+them.
+
+This test should not bother testing the behavior of bookmark creation,
+deletion, activation, deactivation, etc. These behaviors, while important to
+the end user, don't vary at all when Hg-Git is in use. Only the synchonization
+of bookmarks should be considered "under test", and mutation of bookmarks
+locally is only to provide a test fixture.
+
+# Fails for some reason, need to investigate
+# $ "$TESTDIR/hghave" git || exit 80
+
+Bail if the user does not have dulwich
+ $ python -c 'import dulwich, dulwich.repo' || exit 80
+
+ $ echo "[extensions]" >> $HGRCPATH
+ $ echo "hggit=$(echo $(dirname $TESTDIR))/hggit" >> $HGRCPATH
+
+ $ GIT_AUTHOR_NAME='test'; export GIT_AUTHOR_NAME
+ $ GIT_AUTHOR_EMAIL='te...@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
+
+ $ gitcount=10
+ $ gitcommit()
+ > {
+ > GIT_AUTHOR_DATE="2007-01-01 00:00:$gitcount +0000"
+ > GIT_COMMITTER_DATE="$GIT_AUTHOR_DATE"
+ > git commit "$@" >/dev/null 2>/dev/null || echo "git commit error"
+ > gitcount=`expr $gitcount + 1`
+ > }
+ $ hgcount=10
+ $ hgcommit()
+ > {
+ > HGDATE="2007-01-01 00:00:$hgcount +0000"
+ > hg commit -u "test <te...@example.org>" -d "$HGDATE" "$@" >/dev/null 2>/dev/null || echo "hg commit error"
+ > hgcount=`expr $hgcount + 1`
+ > }
+ $ gitstate()
+ > {
+ > git log --format=" %h \"%s\" refs:%d" $@ | sed 's/HEAD, //'
+ > }
+ $ hgstate()
+ > {
+ > hg log --template " {rev} {node|short} \"{desc}\" bookmarks: [{bookmarks}]\n" $@
+ > }
+ $ hggitstate()
+ > {
+ > hg log --template " {rev} {node|short} {gitnode|short} \"{desc}\" bookmarks: [{bookmarks}]\n" $@
+ > }
+
+Initialize remote hg and git repos with equivalent initial contents
+ $ hg init hgremoterepo
+ $ cd hgremoterepo
+ $ hg bookmark master
+ $ for f in alpha beta gamma delta; do
+ > echo $f > $f; hg add $f; hgcommit -m "add $f"
+ > done
+ $ hg bookmark -r 1 b1
+ $ hgstate
+ 3 fc2664cac217 "add delta" bookmarks: [master]
+ 2 d85ced7ae9d6 "add gamma" bookmarks: []
+ 1 7bcd915dc873 "add beta" bookmarks: [b1]
+ 0 3442585be8a6 "add alpha" bookmarks: []
+ $ cd ..
+ $ git init -q gitremoterepo
+ $ cd gitremoterepo
+ $ for f in alpha beta gamma delta; do
+ > echo $f > $f; git add $f; gitcommit -m "add $f"
+ > done
+ $ git branch b1 9497a4e
+ $ gitstate
+ 55b133e "add delta" refs: (master)
+ d338971 "add gamma" refs:
+ 9497a4e "add beta" refs: (b1)
+ 7eeab2e "add alpha" refs:
+ $ cd ..
+
+Cloning transfers all bookmarks from remote to local
+ $ hg clone -q hgremoterepo purehglocalrepo
+ $ cd purehglocalrepo
+ $ hgstate
+ 3 fc2664cac217 "add delta" bookmarks: [master]
+ 2 d85ced7ae9d6 "add gamma" bookmarks: []
+ 1 7bcd915dc873 "add beta" bookmarks: [b1]
+ 0 3442585be8a6 "add alpha" bookmarks: []
+ $ cd ..
+ $ hg clone -q gitremoterepo hggitlocalrepo
+ $ cd hggitlocalrepo
+ $ hggitstate
+ 3 fc2664cac217 55b133e1d558 "add delta" bookmarks: [master]
+ 2 d85ced7ae9d6 d338971a96e2 "add gamma" bookmarks: []
+ 1 7bcd915dc873 9497a4ee62e1 "add beta" bookmarks: [b1]
+ 0 3442585be8a6 7eeab2ea75ec "add alpha" bookmarks: []
+ $ cd ..

David Carr

unread,
Oct 7, 2012, 8:37:41 PM10/7/12
to hg-...@googlegroups.com
# HG changeset patch
# User David M. Carr <da...@carrclan.us>
# Date 1349654304 14400
# Node ID 36812cecfb9e9f6b4d6613e1414c8e74a6331ee5
# Parent 461fe932c388585a73e26d33b74fe4a22b0b118b
tests: add coverage for outgoing with no changes

diff --git a/tests/test-bookmark-workflow.t b/tests/test-bookmark-workflow.t
--- a/tests/test-bookmark-workflow.t
+++ b/tests/test-bookmark-workflow.t
@@ -97,3 +97,19 @@
1 7bcd915dc873 9497a4ee62e1 "add beta" bookmarks: [b1]
0 3442585be8a6 7eeab2ea75ec "add alpha" bookmarks: []
$ cd ..
+
+No changes
+ $ cd purehglocalrepo
+ $ hg outgoing
+ comparing with $TESTTMP/hgremoterepo
+ searching for changes
+ no changes found
+ [1]
+ $ cd ..
+ $ cd hggitlocalrepo
+ $ hg outgoing
+ comparing with $TESTTMP/gitremoterepo
+ searching for changes
+ no changes found
+ [1]
+ $ cd ..

David Carr

unread,
Oct 7, 2012, 8:37:42 PM10/7/12
to hg-...@googlegroups.com
# HG changeset patch
# User David M. Carr <da...@carrclan.us>
# Date 1349655087 14400
# Node ID 4bc39fd24db3869e3e427b3f6b5d2f895a2bfa56
# Parent 36812cecfb9e9f6b4d6613e1414c8e74a6331ee5
push: change "no changes" default output to match normal mercurial

The output for "hg push" when there were no changes didn't quite match between
Mercurial with and without Hg-Git, so I changed the behavior to bring it into
synch. The existing "creating and sending data" message was changed to be
included if --verbose is specified.

diff --git a/hggit/git_handler.py b/hggit/git_handler.py
--- a/hggit/git_handler.py
+++ b/hggit/git_handler.py
@@ -862,7 +862,8 @@

genpack = self.git.object_store.generate_pack_contents
try:
- self.ui.status(_("creating and sending data\n"))
+ self.ui.status(_("searching for changes\n"))
+ self.ui.note(_("creating and sending data\n"))
new_refs = client.send_pack(path, changed, genpack)
return old_refs, new_refs
except (HangupException, GitProtocolError), e:
diff --git a/tests/test-conflict-1.t b/tests/test-conflict-1.t
old mode 100755
new mode 100644
--- a/tests/test-conflict-1.t
+++ b/tests/test-conflict-1.t
@@ -61,7 +61,7 @@
$ hg push -r master ../gitrepo
pushing to ../gitrepo
exporting hg objects to git
- creating and sending data
+ searching for changes
$ cd ..

$ hg clone gitrepo hgrepo2 | grep -v '^updating'
diff --git a/tests/test-conflict-2.t b/tests/test-conflict-2.t
old mode 100755
new mode 100644
--- a/tests/test-conflict-2.t
+++ b/tests/test-conflict-2.t
@@ -61,7 +61,7 @@
$ hg push -r master ../gitrepo
pushing to ../gitrepo
exporting hg objects to git
- creating and sending data
+ searching for changes
$ cd ..

$ hg clone gitrepo hgrepo2 | grep -v '^updating'
diff --git a/tests/test-convergedmerge.t b/tests/test-convergedmerge.t
old mode 100755
new mode 100644
--- a/tests/test-convergedmerge.t
+++ b/tests/test-convergedmerge.t
@@ -62,7 +62,7 @@
$ hg push -r master ../gitrepo
pushing to ../gitrepo
exporting hg objects to git
- creating and sending data
+ searching for changes
$ cd ..

$ hg clone gitrepo hgrepo2 | grep -v '^updating'
diff --git a/tests/test-empty-working-tree.t b/tests/test-empty-working-tree.t
old mode 100755
new mode 100644
--- a/tests/test-empty-working-tree.t
+++ b/tests/test-empty-working-tree.t
@@ -40,7 +40,7 @@
$ hg push ../gitrepo2
pushing to ../gitrepo2
exporting hg objects to git
- creating and sending data
+ searching for changes

$ cd ../gitrepo2
$ git log --pretty=medium
diff --git a/tests/test-encoding.t b/tests/test-encoding.t
old mode 100755
new mode 100644
--- a/tests/test-encoding.t
+++ b/tests/test-encoding.t
@@ -122,7 +122,7 @@
$ hg push ../gitrepo2
pushing to ../gitrepo2
exporting hg objects to git
- creating and sending data
+ searching for changes

$ cd ../gitrepo2
$ git log --pretty=medium
diff --git a/tests/test-file-removal.t b/tests/test-file-removal.t
old mode 100755
new mode 100644
--- a/tests/test-file-removal.t
+++ b/tests/test-file-removal.t
@@ -109,7 +109,7 @@
$ hg push ../gitrepo2
pushing to ../gitrepo2
exporting hg objects to git
- creating and sending data
+ searching for changes

$ cd ../gitrepo2
$ git log --pretty=medium
diff --git a/tests/test-git-tags.t b/tests/test-git-tags.t
old mode 100755
new mode 100644
--- a/tests/test-git-tags.t
+++ b/tests/test-git-tags.t
@@ -72,7 +72,7 @@
$ hg push
pushing to $TESTTMP/gitrepo
exporting hg objects to git
- creating and sending data
+ searching for changes
default::refs/heads/master => GIT:3b7fd1b3

$ cd ..
diff --git a/tests/test-hg-author.t b/tests/test-hg-author.t
old mode 100755
new mode 100644
--- a/tests/test-hg-author.t
+++ b/tests/test-hg-author.t
@@ -55,7 +55,7 @@
$ hg push
pushing to $TESTTMP/gitrepo
exporting hg objects to git
- creating and sending data
+ searching for changes
default::refs/heads/master => GIT:cffa0e8d

$ echo gamma >> beta
@@ -63,7 +63,7 @@
$ hg push
pushing to $TESTTMP/gitrepo
exporting hg objects to git
- creating and sending data
+ searching for changes
default::refs/heads/master => GIT:2b9ec6a4

$ echo gamma > gamma
@@ -72,7 +72,7 @@
$ hg push
pushing to $TESTTMP/gitrepo
exporting hg objects to git
- creating and sending data
+ searching for changes
default::refs/heads/master => GIT:fee30180

$ echo delta > delta
@@ -81,7 +81,7 @@
$ hg push
pushing to $TESTTMP/gitrepo
exporting hg objects to git
- creating and sending data
+ searching for changes
default::refs/heads/master => GIT:d1659250

$ echo epsilon > epsilon
@@ -90,7 +90,7 @@
$ hg push
pushing to $TESTTMP/gitrepo
exporting hg objects to git
- creating and sending data
+ searching for changes
default::refs/heads/master => GIT:ee985f12

$ echo zeta > zeta
@@ -99,7 +99,7 @@
$ hg push
pushing to $TESTTMP/gitrepo
exporting hg objects to git
- creating and sending data
+ searching for changes
default::refs/heads/master => GIT:d21e26b4

$ echo eta > eta
@@ -108,7 +108,7 @@
$ hg push
pushing to $TESTTMP/gitrepo
exporting hg objects to git
- creating and sending data
+ searching for changes
default::refs/heads/master => GIT:8c878c97

$ echo theta > theta
@@ -117,7 +117,7 @@
$ hg push
pushing to $TESTTMP/gitrepo
exporting hg objects to git
- creating and sending data
+ searching for changes
default::refs/heads/master => GIT:1e03e913

$ hg log --graph | egrep -v ': *(not-master|master)'
diff --git a/tests/test-hg-branch.t b/tests/test-hg-branch.t
old mode 100755
new mode 100644
--- a/tests/test-hg-branch.t
+++ b/tests/test-hg-branch.t
@@ -58,7 +58,7 @@
$ hg push
pushing to $TESTTMP/gitrepo
exporting hg objects to git
- creating and sending data
+ searching for changes
default::refs/heads/master => GIT:05c2bcbe

$ hg branch gamma | grep -v 'permanent and global'
@@ -67,7 +67,7 @@
$ hg push
pushing to $TESTTMP/gitrepo
exporting hg objects to git
- creating and sending data
+ searching for changes
default::refs/heads/master => GIT:296802ef

$ hg log --graph | $filterhash | egrep -v ': *(not-master|master)'
diff --git a/tests/test-hg-tags.t b/tests/test-hg-tags.t
old mode 100755
new mode 100644
--- a/tests/test-hg-tags.t
+++ b/tests/test-hg-tags.t
@@ -53,7 +53,7 @@
$ hg push
pushing to $TESTTMP/gitrepo
exporting hg objects to git
- creating and sending data
+ searching for changes
default::refs/tags/alpha => GIT:7eeab2ea
default::refs/heads/master => GIT:9a2616b9

diff --git a/tests/test-merge.t b/tests/test-merge.t
old mode 100755
new mode 100644
--- a/tests/test-merge.t
+++ b/tests/test-merge.t
@@ -70,7 +70,7 @@
$ hg push ../gitrepo2
pushing to ../gitrepo2
exporting hg objects to git
- creating and sending data
+ searching for changes

$ cd ..
$ cd gitrepo2
diff --git a/tests/test-octopus.t b/tests/test-octopus.t
old mode 100755
new mode 100644
--- a/tests/test-octopus.t
+++ b/tests/test-octopus.t
@@ -97,7 +97,7 @@
$ hg push ../gitrepo2
pushing to ../gitrepo2
exporting hg objects to git
- creating and sending data
+ searching for changes

$ cd ../gitrepo2
$ git log --pretty=medium | sed s/\\.\\.\\.//g
diff --git a/tests/test-push.t b/tests/test-push.t
old mode 100755
new mode 100644
--- a/tests/test-push.t
+++ b/tests/test-push.t
@@ -60,7 +60,7 @@
$ hg push -r beta
pushing to $TESTTMP/gitrepo
exporting hg objects to git
- creating and sending data
+ searching for changes
default::refs/heads/beta => GIT:cffa0e8d

$ cd ..
@@ -90,7 +90,7 @@
% this should fail
$ hg push -r master
pushing to $TESTTMP/gitrepo
- creating and sending data
+ searching for changes
abort: refs/heads/master changed on the server, please pull and merge before pushing
[255]

@@ -98,7 +98,7 @@
% ... even with -f
$ hg push -fr master
pushing to $TESTTMP/gitrepo
- creating and sending data
+ searching for changes
abort: refs/heads/master changed on the server, please pull and merge before pushing
[255]

@@ -131,7 +131,7 @@
% this should also fail
$ hg push -r master
pushing to $TESTTMP/gitrepo
- creating and sending data
+ searching for changes
abort: pushing refs/heads/master overwrites 72f56395749d
[255]

@@ -139,7 +139,7 @@
% ... but succeed with -f
$ hg push -fr master
pushing to $TESTTMP/gitrepo
- creating and sending data
+ searching for changes
default::refs/heads/master => GIT:cc119202

$ echo % this should fail, no changes to push
@@ -148,7 +148,7 @@
issue3228 was fixed in 2.1
$ hg push -r master && false
pushing to $TESTTMP/gitrepo
- creating and sending data
+ searching for changes
no changes found
[1]

diff --git a/tests/test-subrepos.t b/tests/test-subrepos.t
--- a/tests/test-subrepos.t
+++ b/tests/test-subrepos.t
@@ -116,7 +116,7 @@
$ hg push
pushing to $TESTTMP/gitrepo1
exporting hg objects to git
- creating and sending data
+ searching for changes
default::refs/heads/master => GIT:4663c492
$ cd ..
$ cd gitrepo1
diff --git a/tests/test-tree-decomposition.t b/tests/test-tree-decomposition.t
old mode 100755
new mode 100644
--- a/tests/test-tree-decomposition.t
+++ b/tests/test-tree-decomposition.t
@@ -68,7 +68,7 @@
$ hg push ../gitrepo2
pushing to ../gitrepo2
exporting hg objects to git
- creating and sending data
+ searching for changes

$ cd ../gitrepo2
$ git log --pretty=medium

David Carr

unread,
Oct 7, 2012, 8:37:43 PM10/7/12
to hg-...@googlegroups.com
# HG changeset patch
# User David M. Carr <da...@carrclan.us>
# Date 1349655591 14400
# Node ID c0c1a96ef56df4589e63a4e60b67fc5ccd0f4c34
# Parent 4bc39fd24db3869e3e427b3f6b5d2f895a2bfa56
tests: add workflow coverage for push with no changes

test-bookmark-workflow.t now skips all Mercurial versions below 2.1, as the
return code is different, and it's more important for this test to accurately
show that we match the behavior of current Mercurial than that all versions
behave the same.

diff --git a/tests/test-bookmark-workflow.t b/tests/test-bookmark-workflow.t
--- a/tests/test-bookmark-workflow.t
+++ b/tests/test-bookmark-workflow.t
@@ -15,6 +15,10 @@
Bail if the user does not have dulwich
$ python -c 'import dulwich, dulwich.repo' || exit 80

+Skip if Mercurial < 2.1; workflow was different before that
+ $ python -c 'from mercurial import util ; assert \
+ > util.version() != "unknown" and util.version() >= "2.1"' || exit 80
+
$ echo "[extensions]" >> $HGRCPATH
$ echo "hggit=$(echo $(dirname $TESTDIR))/hggit" >> $HGRCPATH

@@ -105,6 +109,11 @@
searching for changes
no changes found
[1]
+ $ hg push
+ pushing to $TESTTMP/hgremoterepo
+ searching for changes
+ no changes found
+ [1]
$ cd ..
$ cd hggitlocalrepo
$ hg outgoing
@@ -112,4 +121,9 @@
searching for changes
no changes found
[1]
+ $ hg push
+ pushing to $TESTTMP/gitremoterepo
+ searching for changes
+ no changes found
+ [1]
$ cd ..

Augie Fackler

unread,
Oct 8, 2012, 12:38:00 PM10/8/12
to hg-...@googlegroups.com
pushed, thanks
> --
> You received this message because you are subscribed to the Google Groups "hg-git" group.
> To post to this group, send email to hg-...@googlegroups.com.
> To unsubscribe from this group, send email to hg-git+un...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/hg-git?hl=en.
>

Reply all
Reply to author
Forward
0 new messages