[issue1916] hg bails when ) 1) forget to pull/update 2) commit/push specific files only 3) pull/update

timeless timeless at gmail.com
Sat Nov 21 10:44:02 CST 2009


# HG changeset patch
# User timeless at mozdev.org
# Date 1258821791 -7200
# Node ID 726a846440a00465c74f6d5069377fad157b955b
# Parent  b5170b8b32a5a8a77a9062da5726c0e4a667410d
Handle forgetting to pull distinctly from intentionally forking (issue1916)

If a user clones a repository and makes a change and commits, they haven't
added any heads. When a second user clones that same repository at that same
point and commits, they too haven't added a head. One of them will lose a push
race. When this happens, we want to tell them that they need to pull, not that
they need to merge (as neither of them have anything locally that needed to
merge).

diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py
--- a/mercurial/localrepo.py
+++ b/mercurial/localrepo.py
@@ -1509,8 +1509,12 @@ class localrepository(repo.repository):
                 else:
                     self.ui.warn(_("abort: push creates new remote heads!\n"))

-                self.ui.status(_("(did you forget to merge?"
-                                 " use push -f to force)\n"))
+                if len(lheads) == len(rheads):
+                    self.ui.status(_("(did you forget to pull?"
+                                     " use push -f to force)\n"))
+                else:
+                    self.ui.status(_("(did you forget to merge?"
+                                     " use push -f to force)\n"))
                 return False
             return True

diff --git a/tests/test-push-warn.out b/tests/test-push-warn.out
--- a/tests/test-push-warn.out
+++ b/tests/test-push-warn.out
@@ -3,7 +3,7 @@ 1 files updated, 0 files merged, 0 files
 pushing to ../a
 searching for changes
 abort: push creates new remote heads!
-(did you forget to merge? use push -f to force)
+(did you forget to pull? use push -f to force)
 pulling from ../a
 searching for changes
 adding changesets
@@ -45,7 +45,7 @@ 0
 pushing to ../c
 searching for changes
 abort: push creates new remote heads!
-(did you forget to merge? use push -f to force)
+(did you forget to pull? use push -f to force)
 1
 pushing to ../c
 searching for changes
@@ -91,7 +91,7 @@ 1
 pushing to ../f
 searching for changes
 abort: push creates new remote heads!
-(did you forget to merge? use push -f to force)
+(did you forget to pull? use push -f to force)
 1
 % push replacement head on existing branches
 pushing to ../f
@@ -138,5 +138,5 @@ created new head
 pushing to h
 searching for changes
 abort: push creates new remote heads!
-(did you forget to merge? use push -f to force)
+(did you forget to pull? use push -f to force)


More information about the Mercurial-devel mailing list