Patchwork [05,of,11] wireproto: clarify cryptic 'remote: unsynced changes' error message on push

login
register
mail settings
Submitter Mads Kiilerich
Date April 15, 2013, 1:14 a.m.
Message ID <12e520feac56d34ae3ed.1365988460@xps>
Download mbox | patch
Permalink /patch/1308/
State Accepted
Commit 6b618aa08b6eb6394b934d0ea7829f1b24f4b9f3
Headers show

Comments

Mads Kiilerich - April 15, 2013, 1:14 a.m.
# HG changeset patch
# User Mads Kiilerich <madski@unity3d.com>
# Date 1365684858 -7200
# Node ID 12e520feac56d34ae3eddedefc993b07d264e7d6
# Parent  6893b09ebdd94f34e58aba9c483eaba588b6bc30
wireproto: clarify cryptic 'remote: unsynced changes' error message on push

The message was not very much to the point and did not in any way help an
ordinary user.

'repository changed while preparing/uploading bundle - please try again'
is more correct, gives the user some understanding of what is going on, and
tells how to 'recover' from the situation.

The 'bundle' aspect could be seen as an implementation detail that shouldn't be
mentioned, but I think it helps giving an exact error message.

The message could still leave the user wondering why Mercurial doesn't lock the
repo and how unsafe it thus is. Explaining that is however too much detail.

Patch

diff --git a/mercurial/wireproto.py b/mercurial/wireproto.py
--- a/mercurial/wireproto.py
+++ b/mercurial/wireproto.py
@@ -602,7 +602,8 @@  def unbundle(repo, proto, heads):
 
     # fail early if possible
     if not check_heads():
-        return pusherr('unsynced changes')
+        return pusherr('repository changed while preparing changes - '
+                       'please try again')
 
     # write bundle data to temporary file because it can be big
     fd, tempname = tempfile.mkstemp(prefix='hg-unbundle-')
@@ -615,7 +616,8 @@  def unbundle(repo, proto, heads):
             if not check_heads():
                 # someone else committed/pushed/unbundled while we
                 # were transferring data
-                return pusherr('unsynced changes')
+                return pusherr('repository changed while uploading changes - '
+                               'please try again')
 
             # push can proceed
             fp.seek(0)
diff --git a/tests/test-push-cgi.t b/tests/test-push-cgi.t
--- a/tests/test-push-cgi.t
+++ b/tests/test-push-cgi.t
@@ -35,17 +35,17 @@  test preparation
   1 changesets found
   $ CONTENT_LENGTH=279; export CONTENT_LENGTH;
 
-expect unsynced changes
+expect failure because heads doesn't match (formerly known as 'unsynced changes')
 
   $ QUERY_STRING="cmd=unbundle&heads=0000000000000000000000000000000000000000"; export QUERY_STRING
   $ python hgweb.cgi <bundle.hg >page1 2>&1
   $ cat page1
   Status: 200 Script output follows\r (esc)
   Content-Type: application/mercurial-0.1\r (esc)
-  Content-Length: 19\r (esc)
+  Content-Length: 64\r (esc)
   \r (esc)
   0
-  unsynced changes
+  repository changed while preparing changes - please try again
 
 successful force push