[PATCH 5 of 6 remotenames-ext] tests: test various combinations of repos with and without extension

Ryan McElroy rm at fb.com
Mon Feb 19 06:53:42 EST 2018


# HG changeset patch
# User Ryan McElroy <rmcelroy at fb.com>
# Date 1519041052 28800
#      Mon Feb 19 03:50:52 2018 -0800
# Node ID 0cf83d6117fa918a8a9f6da6bd9747e09241de2a
# Parent  b1949aca17c6456ba1a7599e9ca121d269fb1ce6
tests: test various combinations of repos with and without extension

Cases from sandcastle make it clear that there are circumstances where
a one local repo talks to another local repo, one with remotenames enabled and
the other without remotenames enabled, that crashes can happen.

Let's add a test case to find some of these so we can prove they are fixed.

diff --git a/tests/test-remotenames-on-and-off.t b/tests/test-remotenames-on-and-off.t
new file mode 100644
--- /dev/null
+++ b/tests/test-remotenames-on-and-off.t
@@ -0,0 +1,64 @@
+iSet up global extensions
+  $ cat >> $HGRCPATH <<EOF
+  > [extensions]
+  > rebase=
+  > EOF
+
+Create a repo without remotenames
+  $ hg init off
+  $ cd off
+  $ echo a > a
+  $ hg ci -qAm a
+  $ cd ..
+
+Clone repo and turn remotenames on
+  $ hg clone off on
+  updating to branch default
+  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
+  $ cat >> on/.hg/hgrc <<EOF
+  > [extensions]
+  > remotenames=
+  > EOF
+
+Ensure no crashes when working from repo with remotenames on
+  $ hg -R off bookmark foo
+  $ cd on
+
+  $ hg pull
+  pulling from $TESTTMP/off
+  searching for changes
+  no changes found
+
+  $ hg push --to bar --create
+  pushing rev cb9a9f314b8b to destination $TESTTMP/off bookmark bar
+  searching for changes
+  no changes found
+  exporting bookmark bar
+  [1]
+
+  $ hg pull --rebase
+  pulling from $TESTTMP/off
+  searching for changes
+  no changes found
+
+  $ cd ..
+
+Check for crashes when working from repo with remotenames off
+  $ cd off
+
+  $ hg pull ../on 2>&1 | grep Error
+  AttributeError: 'localrepository' object has no attribute '_remotenames'
+
+  $ cat >> .hg/hgrc <<EOF
+  > [paths]
+  > default = $TESTTMP/on
+  > EOF
+
+  $ hg pull 2>&1 | grep Error
+  AttributeError: 'localrepository' object has no attribute '_remotenames'
+
+  $ hg push 2>&1 | grep Error
+  AttributeError: 'localrepository' object has no attribute '_remotenames'
+
+  $ hg pull --rebase 2>&1 | grep Error
+  AttributeError: 'localrepository' object has no attribute '_remotenames'


More information about the Mercurial-devel mailing list