Patchwork [1,of,3,RFC,cg3] changegroup: note during bundle apply if the repo was empty

login
register
mail settings
Submitter Augie Fackler
Date Dec. 3, 2015, 3:58 p.m.
Message ID <b65caadb6a3928729cf8.1449158315@arthedain.pit.corp.google.com>
Download mbox | patch
Permalink /patch/11790/
State Accepted
Delegated to: Martin von Zweigbergk
Headers show

Comments

Augie Fackler - Dec. 3, 2015, 3:58 p.m.
# HG changeset patch
# User Augie Fackler <augie@google.com>
# Date 1449084737 18000
#      Wed Dec 02 14:32:17 2015 -0500
# Node ID b65caadb6a3928729cf8dc81110be59279a7d65a
# Parent  8117e2cd959e49f30a189208b807ad3d622ae312
# EXP-Topic cg3
changegroup: note during bundle apply if the repo was empty

An upcoming change for exchanging treemanifest data will need to
update the repository capabilities, which we should only do if the
repository was empty before we started applying this changegroup. In
the future we will probably need a strategy for upgrading to
treemanifest in requires during a pull (I'm assuming at some point
we'll make it possible to have a flag day to enable treemanifests on
an existing history.)

Patch

diff --git a/mercurial/changegroup.py b/mercurial/changegroup.py
--- a/mercurial/changegroup.py
+++ b/mercurial/changegroup.py
@@ -312,6 +312,7 @@  class cg1unpacker(object):
         - number of heads stays the same: 1
         """
         repo = repo.unfiltered()
+        wasempty = (len(repo.changelog) == 0)
         def csmap(x):
             repo.ui.debug("add changeset %s\n" % short(x))
             return len(cl)
@@ -386,7 +387,7 @@  class cg1unpacker(object):
             self.callback = None
             pr = prog(_('files'), efiles)
             newrevs, newfiles = _addchangegroupfiles(
-                repo, self, revmap, trp, pr, needfiles)
+                repo, self, revmap, trp, pr, needfiles, wasempty)
             revisions += newrevs
             files += newfiles
 
@@ -903,7 +904,7 @@  def changegroup(repo, basenodes, source)
     # to avoid a race we use changegroupsubset() (issue1320)
     return changegroupsubset(repo, basenodes, repo.heads(), source)
 
-def _addchangegroupfiles(repo, source, revmap, trp, pr, needfiles):
+def _addchangegroupfiles(repo, source, revmap, trp, pr, needfiles, wasempty):
     revisions = 0
     files = 0
     while True: