comparison mercurial/localrepo.py @ 14036:90d997a812dc

changegroup: do not count closed new heads (issue2697) If a closed head gets pulled, we currently see (example): $ hg pull pulling from $TESTTMP/repo2 searching for changes adding changesets adding manifests adding file changes added 2 changesets with 1 changes to 1 files (+1 heads) (run 'hg heads' to see heads, 'hg merge' to merge) A subsequent 'hg heads' doesn't show that head because it is closed. This patch improves the UI response texts for that same use case to: $ hg pull pulling from $TESTTMP/repo2 searching for changes adding changesets adding manifests adding file changes added 2 changesets with 1 changes to 1 files (run 'hg update' to get a working copy) That is, the part "(+1 heads)" is not shown in that case any longer.
author Adrian Buehlmann <adrian@cadifra.com>
date Sun, 24 Apr 2011 20:11:05 +0200
parents 97ed99d1f419
children 58e58406ed19
comparison
equal deleted inserted replaced
14035:865c30d54c30 14036:90d997a812dc
1688 1688
1689 # write changelog data to temp files so concurrent readers will not see 1689 # write changelog data to temp files so concurrent readers will not see
1690 # inconsistent view 1690 # inconsistent view
1691 cl = self.changelog 1691 cl = self.changelog
1692 cl.delayupdate() 1692 cl.delayupdate()
1693 oldheads = len(cl.heads()) 1693 oldheads = cl.heads()
1694 1694
1695 tr = self.transaction("\n".join([srctype, urlmod.hidepassword(url)])) 1695 tr = self.transaction("\n".join([srctype, urlmod.hidepassword(url)]))
1696 try: 1696 try:
1697 trp = weakref.proxy(tr) 1697 trp = weakref.proxy(tr)
1698 # pull off the changeset group 1698 # pull off the changeset group
1779 except error.LookupError: 1779 except error.LookupError:
1780 raise util.Abort( 1780 raise util.Abort(
1781 _('missing file data for %s:%s - run hg verify') % 1781 _('missing file data for %s:%s - run hg verify') %
1782 (f, hex(n))) 1782 (f, hex(n)))
1783 1783
1784 newheads = len(cl.heads()) 1784 dh = 0
1785 heads = "" 1785 if oldheads:
1786 if oldheads and newheads != oldheads: 1786 heads = cl.heads()
1787 heads = _(" (%+d heads)") % (newheads - oldheads) 1787 dh = len(heads) - len(oldheads)
1788 for h in heads:
1789 if h not in oldheads and 'close' in self[h].extra():
1790 dh -= 1
1791 htext = ""
1792 if dh:
1793 htext = _(" (%+d heads)") % dh
1788 1794
1789 self.ui.status(_("added %d changesets" 1795 self.ui.status(_("added %d changesets"
1790 " with %d changes to %d files%s\n") 1796 " with %d changes to %d files%s\n")
1791 % (changesets, revisions, files, heads)) 1797 % (changesets, revisions, files, htext))
1792 1798
1793 if changesets > 0: 1799 if changesets > 0:
1794 p = lambda: cl.writepending() and self.root or "" 1800 p = lambda: cl.writepending() and self.root or ""
1795 self.hook('pretxnchangegroup', throw=True, 1801 self.hook('pretxnchangegroup', throw=True,
1796 node=hex(cl.node(clstart)), source=srctype, 1802 node=hex(cl.node(clstart)), source=srctype,
1815 for i in xrange(clstart, clend): 1821 for i in xrange(clstart, clend):
1816 self.hook("incoming", node=hex(cl.node(i)), 1822 self.hook("incoming", node=hex(cl.node(i)),
1817 source=srctype, url=url) 1823 source=srctype, url=url)
1818 1824
1819 # never return 0 here: 1825 # never return 0 here:
1820 if newheads < oldheads: 1826 if dh < 0:
1821 return newheads - oldheads - 1 1827 return dh - 1
1822 else: 1828 else:
1823 return newheads - oldheads + 1 1829 return dh + 1
1824
1825 1830
1826 def stream_in(self, remote, requirements): 1831 def stream_in(self, remote, requirements):
1827 lock = self.lock() 1832 lock = self.lock()
1828 try: 1833 try:
1829 fp = remote.stream_out() 1834 fp = remote.stream_out()