[PATCH 0 of 6] prep for test unification, push fixes

18 views
Skip to first unread message

David Carr

unread,
Sep 5, 2012, 11:33:47 PM9/5/12
to hg-...@googlegroups.com
This series of patches lays some groundwork for shifting the tests to the
unified format. First, I fix a couple tests that were being skipped due to
missing an exec bit. Then, I update the supported Hg versions to eliminate
a version too old to support unified tests, and add the latest released
version. Last, I included a couple actual code fixes for push support
weirdness that I uncovered while working on subsequent test unification
patches.

David Carr

unread,
Sep 5, 2012, 11:33:49 PM9/5/12
to hg-...@googlegroups.com
# HG changeset patch
# User David M. Carr <da...@carrclan.us>
# Date 1346902051 14400
# Node ID 3f7fedb28bee01c9e6fcbabb422a395456ddf74b
# Parent 1eea0c53216ea267d8edf9221b2ddce2c4714728
makefile: remove support for hg 1.6.4

This version is too old to support unified tests with all-version-tests.

diff --git a/Makefile b/Makefile
--- a/Makefile
+++ b/Makefile
@@ -25,8 +25,7 @@
# latest Ubuntu LTS release (2.0.2 for 12.04 LTS) may be dropped if they
# interfere with new development. The latest released minor version should be
# listed for each major version; earlier minor versions are not needed.
-all-version-tests: tests-1.6.4 tests-1.7.5 tests-1.8.4 tests-1.9.3 \
- tests-2.0.2 tests-2.1.2 tests-2.2.3 tests-2.3 \
- tests-tip
+all-version-tests: tests-1.7.5 tests-1.8.4 tests-1.9.3 tests-2.0.2 \
+ tests-2.1.2 tests-2.2.3 tests-2.3 tests-tip

.PHONY: tests all-version-tests

David Carr

unread,
Sep 5, 2012, 11:33:48 PM9/5/12
to hg-...@googlegroups.com
# HG changeset patch
# User David M. Carr <da...@carrclan.us>
# Date 1346902051 14400
# Node ID 1eea0c53216ea267d8edf9221b2ddce2c4714728
# Parent d2caea2696703a711f250f0ba79da5096ed3f419
tests: fix exec mode on test-help and test-keywords

These tests were being skipped with "not executable" messages

diff --git a/tests/test-help b/tests/test-help
old mode 100644
new mode 100755
diff --git a/tests/test-keywords b/tests/test-keywords
old mode 100644
new mode 100755

David Carr

unread,
Sep 5, 2012, 11:33:50 PM9/5/12
to hg-...@googlegroups.com
# HG changeset patch
# User David M. Carr <da...@carrclan.us>
# Date 1346902051 14400
# Node ID 9dd1bf3151966b66a2b9927b0a8d4833e8191b24
# Parent 3f7fedb28bee01c9e6fcbabb422a395456ddf74b
makefile: add update support from hg 2.3 to hg 2.3.1

diff --git a/Makefile b/Makefile
--- a/Makefile
+++ b/Makefile
@@ -26,6 +26,6 @@
# interfere with new development. The latest released minor version should be
# listed for each major version; earlier minor versions are not needed.
all-version-tests: tests-1.7.5 tests-1.8.4 tests-1.9.3 tests-2.0.2 \
- tests-2.1.2 tests-2.2.3 tests-2.3 tests-tip
+ tests-2.1.2 tests-2.2.3 tests-2.3.1 tests-tip

.PHONY: tests all-version-tests

David Carr

unread,
Sep 5, 2012, 11:33:51 PM9/5/12
to hg-...@googlegroups.com
# HG changeset patch
# User David M. Carr <da...@carrclan.us>
# Date 1346902051 14400
# Node ID 68e5dddc7a2044fe338fd1c6ad142b114309aed2
# Parent 9dd1bf3151966b66a2b9927b0a8d4833e8191b24
push: return 1 if no changes found, 0 if success

While working on some other tests, I noticed that the push command was returning
exit code 1 on success. This changeset makes hgrepo.push use the same return
code contract as localrepo.push, which makes the exit codes behave as expected.

diff --git a/hggit/git_handler.py b/hggit/git_handler.py
--- a/hggit/git_handler.py
+++ b/hggit/git_handler.py
@@ -241,15 +241,24 @@

def push(self, remote, revs, force):
self.export_commits()
- changed_refs = self.upload_pack(remote, revs, force)
+ old_refs, new_refs = self.upload_pack(remote, revs, force)
remote_name = self.remote_name(remote)

- if remote_name and changed_refs:
- for ref, sha in changed_refs.iteritems():
- self.ui.status(" %s::%s => GIT:%s\n" %
- (remote_name, ref, sha[0:8]))
+ if remote_name and new_refs:
+ for ref, sha in new_refs.iteritems():
+ self.ui.status(" %s::%s => GIT:%s\n" %
+ (remote_name, ref, sha[0:8]))

- self.update_remote_branches(remote_name, changed_refs)
+ self.update_remote_branches(remote_name, new_refs)
+ if old_refs == new_refs:
+ ret = None
+ elif len(new_refs) > len(old_refs):
+ ret = 1 + (len(new_refs) - len(old_refs))
+ elif len(old_refs) > len(new_refs):
+ ret = -1 - (len(new_refs) - len(old_refs))
+ else:
+ ret = 1
+ return ret

def clear(self):
mapfile = self.repo.join(self.mapfile)
@@ -765,15 +774,17 @@

def upload_pack(self, remote, revs, force):
client, path = self.get_transport_and_path(remote)
+ old_refs = {}
def changed(refs):
+ old_refs.update(refs)
to_push = revs or set(self.local_heads().values() + self.tags.values())
return self.get_changed_refs(refs, to_push, force)

genpack = self.git.object_store.generate_pack_contents
try:
self.ui.status(_("creating and sending data\n"))
- changed_refs = client.send_pack(path, changed, genpack)
- return changed_refs
+ new_refs = client.send_pack(path, changed, genpack)
+ return old_refs, new_refs
except (HangupException, GitProtocolError), e:
raise hgutil.Abort(_("git remote error: ") + str(e))

diff --git a/hggit/hgrepo.py b/hggit/hgrepo.py
--- a/hggit/hgrepo.py
+++ b/hggit/hgrepo.py
@@ -19,7 +19,7 @@
def push(self, remote, force=False, revs=None, newbranch=None):
if isinstance(remote, gitrepo):
git = GitHandler(self, self.ui)
- git.push(remote.path, revs, force)
+ return git.push(remote.path, revs, force)
else: #pragma: no cover
# newbranch was added in 1.6
if newbranch is None:
diff --git a/tests/test-push b/tests/test-push
--- a/tests/test-push
+++ b/tests/test-push
@@ -69,6 +69,7 @@

hg book -r 1 beta
hg push -r beta
+echo [$?]

cd ..

@@ -88,9 +89,11 @@
cd hgrepo
echo % this should fail
hg push -r master
+echo [$?]

echo % ... even with -f
hg push -fr master
+echo [$?]

hg pull
# TODO shouldn't need to do this since we're (in theory) pushing master explicitly,
@@ -102,8 +105,16 @@

echo % this should also fail
hg push -r master
+echo [$?]

echo % ... but succeed with -f
hg push -fr master
+echo [$?]
+
+echo % this should fail, no changes to push
+hg push -r master
+# This was broken in Mercurial (incorrectly returning 0) until issue3228 was
+# fixed in 2.1
+echo [$?] | sed s/0/1/

cd ..
diff --git a/tests/test-push.out b/tests/test-push.out
--- a/tests/test-push.out
+++ b/tests/test-push.out
@@ -9,6 +9,7 @@
default::refs/heads/beta => GIT:cffa0e8d
default::refs/heads/not-master => GIT:7eeab2ea
default::refs/heads/master => GIT:7eeab2ea
+[0]
% should have two different branches
beta cffa0e8 add beta
master 7eeab2e add alpha
@@ -20,10 +21,12 @@
pushing to git://localhost/gitrepo
creating and sending data
abort: refs/heads/master changed on the server, please pull and merge before pushing
+[255]
% ... even with -f
pushing to git://localhost/gitrepo
creating and sending data
abort: refs/heads/master changed on the server, please pull and merge before pushing
+[255]
pulling from git://localhost/gitrepo
importing git objects into hg
(run 'hg update' to get a working copy)
@@ -45,9 +48,18 @@
pushing to git://localhost/gitrepo
creating and sending data
abort: pushing refs/heads/master overwrites 72f56395749d
+[255]
% ... but succeed with -f
pushing to git://localhost/gitrepo
creating and sending data
default::refs/heads/beta => GIT:cffa0e8d
default::refs/heads/not-master => GIT:7eeab2ea
default::refs/heads/master => GIT:cc119202
+[0]
+% this should fail, no changes to push
+pushing to git://localhost/gitrepo
+creating and sending data
+ default::refs/heads/beta => GIT:cffa0e8d
+ default::refs/heads/not-master => GIT:7eeab2ea
+ default::refs/heads/master => GIT:cc119202
+[1]

David Carr

unread,
Sep 5, 2012, 11:33:52 PM9/5/12
to hg-...@googlegroups.com
# HG changeset patch
# User David M. Carr <da...@carrclan.us>
# Date 1346902051 14400
# Node ID 4793c3725abe04df1fc867200e416fa9fda7c422
# Parent 68e5dddc7a2044fe338fd1c6ad142b114309aed2
push: only output updated refs

diff --git a/hggit/git_handler.py b/hggit/git_handler.py
--- a/hggit/git_handler.py
+++ b/hggit/git_handler.py
@@ -245,9 +245,10 @@
remote_name = self.remote_name(remote)

if remote_name and new_refs:
- for ref, sha in new_refs.iteritems():
+ for ref, new_sha in new_refs.iteritems():
+ if new_sha != old_refs.get(ref):
self.ui.status(" %s::%s => GIT:%s\n" %
- (remote_name, ref, sha[0:8]))
+ (remote_name, ref, new_sha[0:8]))

self.update_remote_branches(remote_name, new_refs)
if old_refs == new_refs:
diff --git a/tests/test-git-tags.out b/tests/test-git-tags.out
--- a/tests/test-git-tags.out
+++ b/tests/test-git-tags.out
@@ -19,6 +19,4 @@
pushing to git://localhost/gitrepo
exporting hg objects to git
creating and sending data
- default::refs/tags/beta => GIT:e6f255c6
- default::refs/tags/alpha => GIT:7eeab2ea
default::refs/heads/master => GIT:3b7fd1b3
diff --git a/tests/test-hg-author.out b/tests/test-hg-author.out
--- a/tests/test-hg-author.out
+++ b/tests/test-hg-author.out
@@ -7,42 +7,34 @@
pushing to git://localhost/gitrepo
exporting hg objects to git
creating and sending data
- default::refs/heads/not-master => GIT:7eeab2ea
default::refs/heads/master => GIT:cffa0e8d
pushing to git://localhost/gitrepo
exporting hg objects to git
creating and sending data
- default::refs/heads/not-master => GIT:7eeab2ea
default::refs/heads/master => GIT:2b9ec6a4
pushing to git://localhost/gitrepo
exporting hg objects to git
creating and sending data
- default::refs/heads/not-master => GIT:7eeab2ea
default::refs/heads/master => GIT:fee30180
pushing to git://localhost/gitrepo
exporting hg objects to git
creating and sending data
- default::refs/heads/not-master => GIT:7eeab2ea
default::refs/heads/master => GIT:d1659250
pushing to git://localhost/gitrepo
exporting hg objects to git
creating and sending data
- default::refs/heads/not-master => GIT:7eeab2ea
default::refs/heads/master => GIT:ee985f12
pushing to git://localhost/gitrepo
exporting hg objects to git
creating and sending data
- default::refs/heads/not-master => GIT:7eeab2ea
default::refs/heads/master => GIT:d21e26b4
pushing to git://localhost/gitrepo
exporting hg objects to git
creating and sending data
- default::refs/heads/not-master => GIT:7eeab2ea
default::refs/heads/master => GIT:8c878c97
pushing to git://localhost/gitrepo
exporting hg objects to git
creating and sending data
- default::refs/heads/not-master => GIT:7eeab2ea
default::refs/heads/master => GIT:1e03e913
@ changeset: 8:d3c51ce68cfd
| tag: default/master
diff --git a/tests/test-hg-branch.out b/tests/test-hg-branch.out
--- a/tests/test-hg-branch.out
+++ b/tests/test-hg-branch.out
@@ -7,13 +7,11 @@
pushing to git://localhost/gitrepo
exporting hg objects to git
creating and sending data
- default::refs/heads/not-master => GIT:7eeab2ea
default::refs/heads/master => GIT:05c2bcbe
marked working directory as branch gamma
pushing to git://localhost/gitrepo
exporting hg objects to git
creating and sending data
- default::refs/heads/not-master => GIT:7eeab2ea
default::refs/heads/master => GIT:296802ef
@ changeset: 2:05aed681ccb3
| branch: gamma
diff --git a/tests/test-hg-tags.out b/tests/test-hg-tags.out
--- a/tests/test-hg-tags.out
+++ b/tests/test-hg-tags.out
@@ -7,7 +7,6 @@
pushing to git://localhost/gitrepo
exporting hg objects to git
creating and sending data
- default::refs/heads/not-master => GIT:7eeab2ea
default::refs/tags/alpha => GIT:7eeab2ea
default::refs/heads/master => GIT:9a2616b9
@ changeset: 1:d529e9229f6d
diff --git a/tests/test-push.out b/tests/test-push.out
--- a/tests/test-push.out
+++ b/tests/test-push.out
@@ -7,8 +7,6 @@
exporting hg objects to git
creating and sending data
default::refs/heads/beta => GIT:cffa0e8d
- default::refs/heads/not-master => GIT:7eeab2ea
- default::refs/heads/master => GIT:7eeab2ea
[0]
% should have two different branches
beta cffa0e8 add beta
@@ -52,14 +50,9 @@
% ... but succeed with -f
pushing to git://localhost/gitrepo
creating and sending data
- default::refs/heads/beta => GIT:cffa0e8d
- default::refs/heads/not-master => GIT:7eeab2ea
default::refs/heads/master => GIT:cc119202
[0]
% this should fail, no changes to push
pushing to git://localhost/gitrepo
creating and sending data
- default::refs/heads/beta => GIT:cffa0e8d
- default::refs/heads/not-master => GIT:7eeab2ea
- default::refs/heads/master => GIT:cc119202
[1]

David Carr

unread,
Sep 5, 2012, 11:33:53 PM9/5/12
to hg-...@googlegroups.com
# HG changeset patch
# User David M. Carr <da...@carrclan.us>
# Date 1346902051 14400
# Node ID ccd521a1f585c1c02fca2e3c81df299af72ced1c
# Parent 4793c3725abe04df1fc867200e416fa9fda7c422
push: state when no changes are found

diff --git a/hggit/git_handler.py b/hggit/git_handler.py
--- a/hggit/git_handler.py
+++ b/hggit/git_handler.py
@@ -252,6 +252,7 @@

self.update_remote_branches(remote_name, new_refs)
if old_refs == new_refs:
+ self.ui.status(_("no changes found\n"))
ret = None
elif len(new_refs) > len(old_refs):
ret = 1 + (len(new_refs) - len(old_refs))
diff --git a/tests/test-push.out b/tests/test-push.out
--- a/tests/test-push.out
+++ b/tests/test-push.out
@@ -55,4 +55,5 @@
% this should fail, no changes to push
pushing to git://localhost/gitrepo
creating and sending data
+no changes found
[1]

Augie Fackler

unread,
Sep 6, 2012, 5:37:49 PM9/6/12
to hg-...@googlegroups.com
Queued all, 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