changeset 1375:f2b00be33e2c

Fix traceback when nothing was added during unbundle The changegroup and commit hook are now run only when something is modified. The correct number of changesets added is printed.
author Benoit Boissinot <benoit.boissinot@ens-lyon.org>
date Mon, 03 Oct 2005 14:45:14 -0700
parents c3654cfaa77d
children 524ca4a06f70
files mercurial/localrepo.py
diffstat 1 files changed, 9 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/localrepo.py	Mon Oct 03 14:43:11 2005 -0700
+++ b/mercurial/localrepo.py	Mon Oct 03 14:45:14 2005 -0700
@@ -992,6 +992,8 @@
         co = self.changelog.tip()
         cn = self.changelog.addgroup(getgroup(), csmap, tr, 1) # unique
         cnr, cor = map(self.changelog.rev, (cn, co))
+        if cn == nullid:
+            cnr = cor
         changesets = cnr - cor
 
         # pull off the manifest group
@@ -1022,12 +1024,14 @@
 
         tr.close()
 
-        if not self.hook("changegroup", node=hex(self.changelog.node(cor+1))):
-            self.ui.warn("abort: changegroup hook returned failure!\n")
-            return 1
+        if changesets > 0:
+            if not self.hook("changegroup",
+                              node=hex(self.changelog.node(cor+1))):
+                self.ui.warn("abort: changegroup hook returned failure!\n")
+                return 1
 
-        for i in range(cor + 1, cnr + 1):
-            self.hook("commit", node=hex(self.changelog.node(i)))
+            for i in range(cor + 1, cnr + 1):
+                self.hook("commit", node=hex(self.changelog.node(i)))
 
         return