Commits

Alain Leufroy committed d20332f

new config/mapping: config object now manage loading mapping

It will be different in the new format.

Comments (0)

Files changed (3)

guestrepo/grconfig.py

         guests = [self._config_entry_to_guest(configpath, value, pathauditor)
                   for configpath, value in hgconfig[''].items()]
         return guests
+
+    def load_mapping(self, ctx):
+        """ Return a list of ``(reponame, remoteuri)`` couples from mapping
+        file at changeset context ``ctx``.
+        """
+        hgconfig = config.config()
+        hgconfig.parse(self.mappingpath, ctx[self.mappingpath].data())
+        return hgconfig['']
+

guestrepo/guestrepo.py

         # detect case of uncommitted branch
         currentbranch = currentctx.branch()
         if currentbranch not in repo.branchmap():
-            raise util.Abort("cannot find %s: "
-                             "no commits on current branch" % conf.mappingpath)
+            raise util.Abort("unmanaged mapping file: "
+                             "no commits on current branch")
         # Use the current changeset as a base for the mapping
         ctx = repo['.']
 
-    mappingconfig = readconfig(conf.mappingpath, ctx)
-
-    # return the items in the null section
-    return mappingconfig['']
-
+    return conf.load_mapping(ctx)
 
 def getguests(ui, repo, frozen_file=None, ctx=None, **kwargs):
     ''' Get the guest repos by parsing the .hgguestrepo.
 
     return result
 
-def readconfig(filename, ctx):
-    ''' read a config file at a context
-
-        throws IOError when config file missing from the working directory,
-        error. LookupError if config is missing from a changeset
-    '''
-    p = config.config()
-    p.parse(filename, ctx[filename].data())
-    return p
-
 def warnbranch(ui, guestname, repo, branchname):
     branchmap = repo.branchmap()
     try:

tests/test-uncommitedbranch.t

   $ hg commit -m 0
   $ hg branch newbranch >> /dev/null 2>&1
   $ hg grpull
-  abort: cannot find .hggrmapping: no commits on current branch
+  abort: unmanaged mapping file: no commits on current branch
   [255]