1. Graham Helliwell
  2. guestrepo

Commits

Graham Helliwell  committed 3e6a3dc

Make the lack of hgguestrepo file a warning rather than an error - makes the result look cleaner in a catch-all hook.

  • Participants
  • Parent commits dfd89dd
  • Branches default

Comments (0)

Files changed (1)

File guestrepo/guestrepo.py

View file
  • Ignore whitespace
 #####################
 
 def repoactions(ui, repo, orderedactions, args, opts):
+    '''Assumes orderedactions is non-empty. Returns true iff all actions fail.'''
     local = opts.get('local')
     mapping = 'local' if local else True
-    abortIfInvalid= not opts.get('forcepartial')
+    continueOnError = opts.get('forcepartial')
 
-    guests = getguests(repo, None, abortIfInvalid)
+    try:
+        guests = getguests(repo, None, continueOnError)
+    except IOError:
+        ui.warn("No guest repositories are configured for repository at '{0}'.\n".format(repo.origroot))
+        return 0
+
     if args:
        guests = matchguests(repo.root, os.getcwd(), args, guests)
 
-    successes = list( action(ui, repo, mapping, guests, opts) for action in orderedactions )
-    return 0 if any(successes) else 1
+    failures = list(not action(ui, repo, mapping, guests, opts) for action in orderedactions )
+    return any(failures)
 
 def pull(ui, repo, mapping, guests, opts):
     def pullaction(ui, repo, guest):
     if path:
         raise util.Abort("repository %s contains uncommitted changes" % path)
 
-    def syncaction(ui, repo, guest):
+    def updateaction(ui, repo, guest):
         ui.status('GR updating %s\n' % guest.canonpath)
         warnbranch(ui, guest.name, repo, guest.csid)
         commands.update(ui, repo, guest.csid)
 
-    runparallelaction(ui, repo, mapping, guests, syncaction, True, opts)
+    runparallelaction(ui, repo, mapping, guests, updateaction, True, opts)
 
 def push(ui, repo, mapping, guests, opts):
     def pushaction(ui, repo, guest):
     return mappingconfig['']
 
 
-def getguests(repo, ctx=None, abortIfInvalid=True):
+def getguests(repo, ctx=None, skipUnauthorized=False):
     ''' Get the guest repos by parsing the .hgguestrepo.
 
         The uri field of the guests is not set until they are matched using the
                                       configpath,
                                       auditor = pathauditor)
         except util.Abort:
-               canonpath = authorizedoutisderoot(os.path.join(repo.root, configpath), abortIfInvalid)
+               canonpath = authorizedoutisderoot(os.path.join(repo.root, configpath), skipUnauthorized)
 
         if canonpath == None:
            continue
 
     return guests
 
-def authorizedoutisderoot(path, abortIfInvalid=True):
+def authorizedoutisderoot(path, continueOnError=False):
     '''A path is authorized if anywhere above it in the file tree there's a file called .grauth
        If the given path is authorized the normalized path is returned.
        If the given path is not authorized, an Abort exception is thrown if abortIfInvalid==True, or None is returned otherwise.
 
     bestgrauthlocation, p = os.path.split(path)
     bestgrauthlocation = os.path.join(bestgrauthlocation, GR_AUTHFILENAME)
-    if abortIfInvalid:
+    if not continueOnError:
        raise util.Abort("'{0}' not under root. To override this check, add an empty file called '{1}'".format(path, bestgrauthlocation))
     return None