Commits

Graham Helliwell committed 31f020e Merge

Merge

  • Participants
  • Parent commits ecf04bb, 96e093f

Comments (0)

Files changed (2)

File guestrepo/__init__.py

     mercurial repository.
 '''
 
-from guestrepo import pull, push, grupdate, freeze, summary, state, grout, grin
+from guestrepo import grpull, push, grupdate, freeze, summary, state, grout, grin
 
 import convert
 import lockedui
 localopt = [('l', 'local', False,
            "use the .hggrmapping file in the working directory")]
 
+pullopt = [('p', 'pull', False,
+           "perform a grpull before the grupdate")]
+
+updateopt = [('u', 'update', False,
+           "perform a grupdate after the grpull")]
+
 threadopt = [('j', 'threads', 1,
           'number of threads to use. '
           'WARNING: ssh prompts are broken, and username and password prompts '
 # See the readme for a description of each command
 # format: {"command-name": (function, options-list, help-string)}
 cmdtable = {
-   "grpull": (pull,
-              localopt + threadopt,
+   "grpull": (grpull,
+              localopt + threadopt + updateopt,
               "hg grpull [REPO [+]] [options]"),
    "grpush": (push,
               localopt + threadopt,
               "hg grpush [REPO [+]] [options]"),
    "grupdate": (grupdate,
-              localopt + threadopt,
+              localopt + threadopt + pullopt,
               "hg grupdate [REPO [+]] [options]"),
    "grfreeze": (freeze,
               [],

File guestrepo/guestrepo.py

     the current branch. Use this option if hggrmapping is modified but not yet
     committed.
 
+    The `--pull` flag causes a grpull to happen before the grupdate. If the grpull
+    fails the grupdate will not begin.
+
     see help for the guestrepo extension for more information on the files used
     '''
-    local = opts.get('local')
-
-    guests = getguests(repo)
-    if args:
-        guests = matchguests(repo.root,
-                             os.getcwd(),
-                             args,
-                             guests)
-
-    path = dirtyrecursive(ui, repo, local, guests)
-    if path:
-        raise util.Abort("repository %s contains uncommitted changes" % path)
-
-    def syncaction(ui, repo, guest):
-        ui.status('GR updating %s\n' % guest.canonpath)
-        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,
-                    [], mapping, True)
-    finally:
-        workers.join()
-    if len(workers.errors) > 0:
-        showerrors(ui, workers)
-        return 1
-    else:
-        return 0
+    return pullupdate(ui,repo, opts.get('pull'), True, args, opts)
 
 def push(ui, repo, *args, **opts):
     '''push guest repos
     else:
         return 0
 
-def pull(ui, repo, *args, **opts):
+def grpull(ui, repo, *args, **opts):
     '''pull  guest repos
 
     Pull each guest repo from the location specified in the mapping file.
     the current branch. Use this option if hggrmapping is modified but not yet
     committed.
 
+    The `--update` flag causes a grupdate to happen after the grpull. If the grpull
+    fails the grupdate will not begin. Equivalent to grupdate --pull.
+
     see help for the guestrepo extension for more information on the files used
     '''
-
-    guests = getguests(repo)
-    if args:
-        guests = matchguests(repo.root,
-                             os.getcwd(),
-                             args,
-                             guests)
-
-    def pullaction(ui, repo, guest):
-        ui.status('pulling %s\n' % guest.canonpath)
-        commands.pull(ui, repo, guest.uri)
-
-    mapping = True
-    if opts.get('local'):
-        mapping = 'local'
-
-    workers = makeworkers(ui, opts)
-    try:
-        applyguests(ui, repo, guests, workers, pullaction,
-                    [], mapping, True)
-    finally:
-        workers.join()
-    if len(workers.errors) > 0:
-        showerrors(ui, workers)
-        return 1
-    else:
-        return 0
+    return pullupdate(ui,repo, True, opts.get('update'), args, opts)
 
 def summary(ui, repo, **opts):
     '''print a summary of the guest repos
    else:
       return 0
 
-
 def grin(ui,repo,**opts):
    """
    List the incoming changes for all guestrepos.
       return 0
 
 
+def pull(ui, repo, local, args, opts):
+    guests = getguests(repo)
+    if args:
+        guests = matchguests(repo.root,
+                             os.getcwd(),
+                             args,
+                             guests)
+
+    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,
+                    [], mapping, True)
+    finally:
+        workers.join()
+    if len(workers.errors) > 0:
+        showerrors(ui, workers)
+        return 1
+    else:
+        return 0
+
+def update(ui, repo, local, args, opts):
+    guests = getguests(repo)
+    if args:
+        guests = matchguests(repo.root,
+                             os.getcwd(),
+                             args,
+                             guests)
+
+    path = dirtyrecursive(ui, repo, local, guests)
+    if path:
+        raise util.Abort("repository %s contains uncommitted changes" % path)
+
+    def syncaction(ui, repo, guest):
+        ui.status('GR updating %s\n' % guest.canonpath)
+        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,
+                    [], mapping, True)
+    finally:
+        workers.join()
+    if len(workers.errors) > 0:
+        showerrors(ui, workers)
+        return 1
+    else:
+        return 0
+
 #####################
 
 _AUTHFILENAME = '.grauth'