changelog: do not treat draft remove heads as unconditionally visible

Summary: This makes it possible to hide draft branches using `hg hide`.

Reviewed By: markbt

Differential Revision: D20403505

fbshipit-source-id: d316e02c24ce636fdc6593f95a5d974b1ba0fc85
This commit is contained in:
Jun Wu 2020-03-12 12:58:47 -07:00 committed by Facebook GitHub Bot
parent d37a1fe4ff
commit e5ef3a81b2
2 changed files with 35 additions and 2 deletions

View File

@ -405,7 +405,10 @@ class changelog(revlog.revlog):
def _headrevs(self, additionalheads, includepublic=True, includedraft=True):
# This should only be used by repo.heads()
if self._uiconfig.configbool("experimental", "narrow-heads"):
publicnodes, draftnodes = self._remotenodes()
# Do not treat the draft heads returned by remotenames as
# unconditionally visible. This makes it possible to hide
# them by "hg hide".
publicnodes, _draftnodes = self._remotenodes()
torev = self.nodemap.__getitem__
nodes = list(additionalheads)
if includepublic:
@ -415,7 +418,7 @@ class changelog(revlog.revlog):
visibleheads = self._visibleheads.allheads()
else:
visibleheads = self._visibleheads.heads
nodes += visibleheads + draftnodes
nodes += visibleheads
revs = list(map(torev, nodes))
r = self.index2.headsancestors(revs)
return r

View File

@ -4,6 +4,7 @@
$ enable remotenames amend
$ setconfig experimental.narrow-heads=true visibility.enabled=true mutation.record=true mutation.enabled=true mutation.date="0 0" experimental.evolution= remotenames.rename.default=remote
$ setconfig 'infinitepush.branchpattern=re:(^hack/.*)'
$ shorttraceback
Prepare the server repo
@ -197,3 +198,32 @@ Visible heads got out of sync with "." or bookmarks
|
~
Prepare the server repo with draft branches
$ newrepo server1
$ setconfig treemanifest.server=true
$ drawdag << 'EOS'
> B C
> |/
> A
> EOS
$ hg bookmark -r $B master
$ hg bookmark -r $C hack/feature-foo
Prepare the client repo
$ hg clone $TESTTMP/server1 $TESTTMP/client1 -q --pull
$ cd $TESTTMP/client1
$ hg log -r 'draft()' -T '{desc}\n'
C
Check the draft branch can be hidden
$ hg hide $C
hiding commit dc0947a82db8 "C"
1 changeset hidden
$ hg log -r 'draft()' -T '{desc}\n'