diff mercurial/localrepo.py @ 2019:ced2d3620f95

add merge command. means same thing as "update -m". repo.addchangegroup method now returns number of heads modified and added, so command line can tell whether update or merge needed. this makes tiny change to ssh wire protocol, but change is backwards compatible. pull command now returns 0 if no changes to pull.
author Vadim Gelfer <vadim.gelfer@gmail.com>
date Wed, 29 Mar 2006 10:27:16 -0800
parents 65cc17ae9649
children 00925397236c
line wrap: on
line diff
--- a/mercurial/localrepo.py
+++ b/mercurial/localrepo.py
@@ -964,7 +964,7 @@ class localrepository(object):
 
         if not fetch:
             self.ui.status(_("no changes found\n"))
-            return 1
+            return 0
 
         if heads is None:
             cg = remote.changegroup(fetch, 'pull')
@@ -1340,6 +1340,8 @@ class localrepository(object):
         return util.chunkbuffer(gengroup())
 
     def addchangegroup(self, source):
+        """add changegroup to repo.
+        returns number of heads modified or added + 1."""
 
         def csmap(x):
             self.ui.debug(_("add changeset %s\n") % short(x))
@@ -1349,7 +1351,7 @@ class localrepository(object):
             return cl.rev(x)
 
         if not source:
-            return
+            return 0
 
         self.hook('prechangegroup', throw=True)
 
@@ -1424,6 +1426,8 @@ class localrepository(object):
             for i in range(cor + 1, cnr + 1):
                 self.hook("incoming", node=hex(self.changelog.node(i)))
 
+        return newheads - oldheads + 1
+
     def update(self, node, allow=False, force=False, choose=None,
                moddirstate=True, forcemerge=False, wlock=None):
         pl = self.dirstate.parents()
@@ -1624,8 +1628,8 @@ class localrepository(object):
                         cf = _(" (resolve)")
                     self.ui.status(" %s%s\n" % (f, cf))
                 self.ui.warn(_("aborting update spanning branches!\n"))
-                self.ui.status(_("(use update -m to merge across branches"
-                                 " or -C to lose changes)\n"))
+                self.ui.status(_("(use 'hg merge' to merge across branches"
+                                 " or '-C' to lose changes)\n"))
                 return 1
             branch_merge = True