push: do not try to push remote obsolete if local has none stable
authorPatrick Mezard <patrick@mezard.eu>
Tue, 24 Jul 2012 21:20:56 +0200
branchstable
changeset 17252 16fad7323e56
parent 17251 98166640b356
child 17253 67f56ff5afcd
push: do not try to push remote obsolete if local has none
mercurial/localrepo.py
tests/test-hook.t
tests/test-obsolete.t
--- a/mercurial/localrepo.py	Thu Jul 26 02:54:13 2012 +0200
+++ b/mercurial/localrepo.py	Tue Jul 24 21:20:56 2012 +0200
@@ -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:
--- a/tests/test-hook.t	Thu Jul 26 02:54:13 2012 +0200
+++ b/tests/test-hook.t	Tue Jul 24 21:20:56 2012 +0200
@@ -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
--- a/tests/test-obsolete.t	Thu Jul 26 02:54:13 2012 +0200
+++ b/tests/test-obsolete.t	Tue Jul 24 21:20:56 2012 +0200
@@ -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]
+
 clone support
 (markers are copied and extinct changesets are included to allow hardlinks)