[PATCH STABLE] push: do not try to push remote obsolete if local has none

Patrick Mezard patrick at mezard.eu
Tue Jul 24 14:31:21 CDT 2012


# HG changeset patch
# User Patrick Mezard <patrick at mezard.eu>
# Date 1343157656 -7200
# Branch stable
# Node ID 82797a37383d8e12d63db1426a01127ff1aec5c0
# Parent  d1b49b02bc161faed1f397cb8fe13a38299bbc01
push: do not try to push remote obsolete if local has none

diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py
--- a/mercurial/localrepo.py
+++ b/mercurial/localrepo.py
@@ -1951,8 +1951,8 @@
                         if not r:
                             self.ui.warn(_('updating %s to public failed!\n')
                                             % newremotehead)
-                if ('obsolete' in remote.listkeys('namespaces')
-                    and self.obsstore):
+                if (self.obsstore and
+                    'obsolete' in remote.listkeys('namespaces')):
                     data = self.listkeys('obsolete')['dump']
                     r = remote.pushkey('obsolete', 'dump', '', data)
                     if not r:
diff --git a/tests/test-hook.t b/tests/test-hook.t
--- a/tests/test-hook.t
+++ b/tests/test-hook.t
@@ -214,7 +214,6 @@
   searching for changes
   no changes found
   listkeys hook: HG_NAMESPACE=phases HG_VALUES={'cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b': '1', 'publishing': 'True'}
-  listkeys hook: HG_NAMESPACE=namespaces HG_VALUES={'bookmarks': '', 'namespaces': '', 'obsolete': '', 'phases': ''}
   listkeys hook: HG_NAMESPACE=bookmarks HG_VALUES={'bar': '0000000000000000000000000000000000000000', 'foo': '0000000000000000000000000000000000000000'}
   listkeys hook: HG_NAMESPACE=bookmarks HG_VALUES={'bar': '0000000000000000000000000000000000000000', 'foo': '0000000000000000000000000000000000000000'}
   exporting bookmark baz
diff --git a/tests/test-obsolete.t b/tests/test-obsolete.t
--- a/tests/test-obsolete.t
+++ b/tests/test-obsolete.t
@@ -14,6 +14,16 @@
   >    hg id --debug -ir "desc('$1')"
   > }
 
+  $ cat > debugkeys.py <<EOF
+  > def reposetup(ui, repo):
+  >     class debugkeysrepo(repo.__class__):
+  >         def listkeys(self, namespace):
+  >             ui.write('listkeys %s\n' % (namespace,))
+  >             return super(debugkeysrepo, self).listkeys(namespace)
+  > 
+  >     if repo.local():
+  >         repo.__class__ = debugkeysrepo
+  > EOF
 
   $ hg init tmpa
   $ cd tmpa
@@ -178,6 +188,16 @@
   ca819180edb99ed25ceafb3e9584ac287e240b00 1337133713371337133713371337133713371337 0 {'date': '1338 0', 'user': 'test'}
   1337133713371337133713371337133713371337 5601fb93a350734d935195fee37f4054c529ff39 0 {'date': '1339 0', 'user': 'test'}
 
+Check obsolete keys are exchanged only if source has an obsolete store
+
+  $ hg init empty
+  $ hg --config extensions.debugkeys=debugkeys.py -R empty push tmpd
+  pushing to tmpd
+  no changes found
+  listkeys phases
+  listkeys bookmarks
+  [1]
+
 
 Destination repo have existing data
 ---------------------------------------


More information about the Mercurial-devel mailing list