[PATCH 1 of 2 v2] changegroup.writebundle: provide ui

Eric Sumner ericsumner at fb.com
Fri Jan 16 23:43:51 UTC 2015


# HG changeset patch
# User Eric Sumner <ericsumner at fb.com>
# Date 1421361581 28800
#      Thu Jan 15 14:39:41 2015 -0800
# Node ID ab7ce7835e3db57ae762483011ae3284c3314496
# Parent  55f663bdf6b3e045898789f64e5e878bcaaddf1b
changegroup.writebundle: provide ui

The next diff will add support for writing bundle2 files to writebundle, but
the bundle2 generator wants access to a ui object.  This changes the signature
and callsites to pass one in.

diff --git a/hgext/shelve.py b/hgext/shelve.py
--- a/hgext/shelve.py
+++ b/hgext/shelve.py
@@ -43,6 +43,7 @@
         self.repo = repo
         self.name = name
         self.vfs = scmutil.vfs(repo.join('shelved'))
+        self.ui = self.repo.ui
         if filetype:
             self.fname = name + '.' + filetype
         else:
@@ -82,7 +83,7 @@
         return bundlerepo.bundlerepository(self.repo.baseui, self.repo.root,
                                            self.vfs.join(self.fname))
     def writebundle(self, cg):
-        changegroup.writebundle(cg, self.fname, 'HG10UN', self.vfs)
+        changegroup.writebundle(self.ui, cg, self.fname, 'HG10UN', self.vfs)
 
 class shelvedstate(object):
     """Handle persistence during unshelving operations.
diff --git a/mercurial/bundlerepo.py b/mercurial/bundlerepo.py
--- a/mercurial/bundlerepo.py
+++ b/mercurial/bundlerepo.py
@@ -410,7 +410,7 @@
         else:
             cg = other.changegroupsubset(incoming, rheads, 'incoming')
         bundletype = localrepo and "HG10BZ" or "HG10UN"
-        fname = bundle = changegroup.writebundle(cg, bundlename, bundletype)
+        fname = bundle = changegroup.writebundle(ui, cg, bundlename, bundletype)
         # keep written bundle?
         if bundlename:
             bundle = None
diff --git a/mercurial/changegroup.py b/mercurial/changegroup.py
--- a/mercurial/changegroup.py
+++ b/mercurial/changegroup.py
@@ -79,7 +79,7 @@
 # hgweb uses this list to communicate its preferred type
 bundlepriority = ['HG10GZ', 'HG10BZ', 'HG10UN']
 
-def writebundle(cg, filename, bundletype, vfs=None):
+def writebundle(ui, cg, filename, bundletype, vfs=None):
     """Write a bundle file and return its filename.
 
     Existing files will not be overwritten.
diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -1218,7 +1218,7 @@
         scmutil.nochangesfound(ui, repo, outgoing and outgoing.excluded)
         return 1
 
-    changegroup.writebundle(cg, fname, bundletype)
+    changegroup.writebundle(ui, cg, fname, bundletype)
 
 @command('cat',
     [('o', 'output', '',
@@ -2166,7 +2166,7 @@
     bundletype = btypes.get(bundletype)
     if bundletype not in changegroup.bundletypes:
         raise util.Abort(_('unknown bundle type specified with --type'))
-    changegroup.writebundle(bundle, bundlepath, bundletype)
+    changegroup.writebundle(ui, bundle, bundlepath, bundletype)
 
 @command('debugignore', [], '')
 def debugignore(ui, repo, *values, **opts):
diff --git a/mercurial/httppeer.py b/mercurial/httppeer.py
--- a/mercurial/httppeer.py
+++ b/mercurial/httppeer.py
@@ -193,7 +193,7 @@
                 type = x
                 break
 
-        tempname = changegroup.writebundle(cg, None, type)
+        tempname = changegroup.writebundle(self.ui, cg, None, type)
         fp = httpconnection.httpsendfile(self.ui, tempname, "rb")
         headers = {'Content-Type': 'application/mercurial-0.1'}
 
diff --git a/mercurial/repair.py b/mercurial/repair.py
--- a/mercurial/repair.py
+++ b/mercurial/repair.py
@@ -31,7 +31,7 @@
         bundletype = "HG10BZ"
     else:
         bundletype = "HG10UN"
-    return changegroup.writebundle(cg, name, bundletype, vfs)
+    return changegroup.writebundle(repo.ui, cg, name, bundletype, vfs)
 
 def _collectfiles(repo, striprev):
     """find out the filelogs affected by the strip"""


More information about the Mercurial-devel mailing list