diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py
index 1d155582a8eaadd4da3f0186654d5836b2a1f8a7_bWVyY3VyaWFsL2xvY2FscmVwby5weQ==..a959f71670771a9dae97e73ec86da222950233a4_bWVyY3VyaWFsL2xvY2FscmVwby5weQ== 100644
--- a/mercurial/localrepo.py
+++ b/mercurial/localrepo.py
@@ -692,7 +692,13 @@
         return self
 
     def cancopy(self):
-        return self.local() # so statichttprepo's override of local() works
+        # so statichttprepo's override of local() works
+        if not self.local():
+            return False
+        if not self.ui.configbool('phases', 'publish', True):
+            return True
+        # if publishing we can't copy if there is filtered content
+        return not self.filtered('visible').changelog.filteredrevs
 
     def join(self, f):
         return os.path.join(self.path, f)
diff --git a/tests/test-phases.t b/tests/test-phases.t
index 1d155582a8eaadd4da3f0186654d5836b2a1f8a7_dGVzdHMvdGVzdC1waGFzZXMudA==..a959f71670771a9dae97e73ec86da222950233a4_dGVzdHMvdGVzdC1waGFzZXMudA== 100644
--- a/tests/test-phases.t
+++ b/tests/test-phases.t
@@ -507,3 +507,46 @@
   [1]
 
   $ cd ..
+
+test hidden changeset are not cloned as public (issue3935)
+
+  $ cd initialrepo
+
+(enabling evolution)
+  $ cat > ../obs.py << EOF
+  > import mercurial.obsolete
+  > mercurial.obsolete._enabled = True
+  > EOF
+  $ echo '[extensions]' >> $HGRCPATH
+  $ echo "obs=${TESTTMP}/obs.py" >> $HGRCPATH
+
+(making a changeset hidden; H in that case)
+  $ hg debugobsolete `hg id --debug -r 5`
+
+  $ cd ..
+  $ hg clone initialrepo clonewithobs
+  requesting all changes
+  adding changesets
+  adding manifests
+  adding file changes
+  added 7 changesets with 6 changes to 6 files
+  updating to branch default
+  6 files updated, 0 files merged, 0 files removed, 0 files unresolved
+  $ cd clonewithobs
+  $ hg log -G --template "{rev} {phase} {desc}\n"
+  @    6 public merge B' and E
+  |\
+  | o  5 public B'
+  | |
+  o |  4 public E
+  | |
+  o |  3 public D
+  | |
+  o |  2 public C
+  |/
+  o  1 public B
+  |
+  o  0 public A
+  
+
+