Graham Helliwell avatar Graham Helliwell committed ddabc25

Split away push action from UI

Comments (0)

Files changed (2)

guestrepo/__init__.py

     mercurial repository.
 '''
 
-from guestrepo import grpull, push, grupdate, freeze, summary, state, grout, grin
+from guestrepo import grpull, grpush, grupdate, freeze, summary, state, grout, grin
 
 import convert
 import lockedui
    "grpull": (grpull,
               localopt + threadopt + updateopt + forcepartialopt,
               "hg grpull [REPO [+]] [options]"),
-   "grpush": (push,
-              localopt + threadopt,
+   "grpush": (grpush,
+              localopt + threadopt + forcepartialopt,
               "hg grpush [REPO [+]] [options]"),
    "grupdate": (grupdate,
               localopt + threadopt + pullopt + forcepartialopt,

guestrepo/guestrepo.py

 
     see help for the guestrepo extension for more information on the files used
     '''
-    return pullupdate(ui,repo, opts.get('pull'), True, args, opts)
+    return repoaction(ui, repo, opts.get('pull'), True, False, args, opts)
 
-def push(ui, repo, *args, **opts):
+def grpush(ui, repo, *args, **opts):
     '''push guest repos
 
     Push each guest to the path specified in the mapping file.
 
     see help for the guestrepo extension for more information on the files used
     '''
+    return repoaction(ui, repo, False, False, True, args, opts)
 
-    guests = getguests(repo)
-    if args:
-        guests = matchguests(repo.root,
-                             os.getcwd(),
-                             args,
-                             guests)
-
+def push(ui, repo, mapping, guests, opts):
     def pushaction(ui, repo, guest):
         commands.push(ui, repo, guest.uri)
 
-    mapping = True
-    if opts.get('local'):
-        mapping = 'local'
-
     workers = makeworkers(ui, opts)
     try:
         applyguests(ui, repo, guests, workers, pushaction,
         workers.join()
     if len(workers.errors) > 0:
         showerrors(ui, workers)
-        return 1
+        return False
     else:
-        return 0
+        return True
 
 def grpull(ui, repo, *args, **opts):
     '''pull  guest repos
 
     see help for the guestrepo extension for more information on the files used
     '''
-    return pullupdate(ui,repo, True, opts.get('update'), args, opts)
+    return repoaction(ui,repo, True, opts.get('update'), False, args, opts)
 
 def summary(ui, repo, **opts):
     '''print a summary of the guest repos
 
 #####################
 
-def pullupdate(ui, repo, shouldpull, shouldupdate, args, opts):
+def repoaction(ui, repo, shouldpull, shouldupdate, shouldpush, args, opts):
     local = opts.get('local')
+    mapping = 'local' if local else True
     abortIfInvalid= not opts.get('forcepartial')
     succeeded = True
 
                          guests)
 
     if (shouldpull):
-       succeeded = pull(ui, repo, local, guests, opts)
+       succeeded = pull(ui, repo, mapping, guests, opts)
     if succeeded and shouldupdate:
-       succeeded = update(ui, repo, local, guests, opts)
+       succeeded = update(ui, repo, local, mapping, guests, opts)
+    if succeeded and shouldpush:
+       succeeded = push(ui, repo, mapping, guests, opts)
     return 0 if succeeded else 1
 
-def pull(ui, repo, local, guests, opts):
+def pull(ui, repo, mapping, guests, opts):
     def pullaction(ui, repo, guest):
         ui.status('pulling %s\n' % guest.canonpath)
         commands.pull(ui, repo, guest.uri)
 
-    mapping = True
-    if local:
-        mapping = 'local'
-
     workers = makeworkers(ui, opts)
     try:
         applyguests(ui, repo, guests, workers, pullaction,
     else:
         return True
 
-def update(ui, repo, local, guests, opts):
+def update(ui, repo, local, mapping, guests, opts):
     path = dirtyrecursive(ui, repo, local, guests)
     if path:
         raise util.Abort("repository %s contains uncommitted changes" % path)
         warnbranch(ui, guest.name, repo, guest.csid)
         commands.update(ui, repo, guest.csid)
 
-    mapping = True
-    if local:
-        mapping = 'local'
-
     workers = makeworkers(ui, opts)
     try:
         applyguests(ui, repo, guests, workers, syncaction,
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.