Make cloneunified update after pulling, delete on abort.
authorGregory Szorc <gps@mozilla.com>
Sun, 21 Jul 2013 23:51:08 -0700
changeset 12 62331886f4afb9b2d88ffbe66b1e18ecbdfb2f30
parent 11 a5568c1aa771bcf04b9f0e0a44e6360f39c908bf
child 13 f5848ffdb34efbc499d52d7cb18f9f3b316fd85d
push id4
push usergszorc@mozilla.com
push dateMon, 22 Jul 2013 06:56:47 +0000
Make cloneunified update after pulling, delete on abort.
__init__.py
--- a/__init__.py
+++ b/__init__.py
@@ -70,23 +70,23 @@ the revision <tree>/<name>. e.g. 'centra
 Remote refs are read-only and are updated automatically during repository pull
 and push operations.
 
 This feature is similar to Git remote refs.
 """
 
 import errno
 import os
+import shutil
 import sys
 
 import mercurial.commands as commands
 
 from mercurial.i18n import _
 from mercurial.commands import (
-    bookmark,
     pull,
     push,
 )
 from mercurial.error import (
     RepoError,
 )
 from mercurial.localrepo import (
     repofilecache,
@@ -166,42 +166,50 @@ def cloneunified(ui, dest='gecko', **opt
     add changesets and remote tracking markers into a common repository.
 
     If the destination path is not given, 'gecko' will be used.
 
     This command is effectively an alias for a number of other commands.
     However, due to the way Mercurial internally stores data, it is recommended
     to run this command to ensure optimal storage of data.
     """
-    repo = hg.repository(ui, ui.expandpath(dest), create=True)
+    path = ui.expandpath(dest)
+    repo = hg.repository(ui, path, create=True)
+
+    success = False
 
-    for r in ('esr17', 'release', 'beta', 'aurora', 'central', 'inbound'):
-        tree, uri = resolve_trees_to_uris([r])[0]
-        ui.warn('Pulling changesets from %s\n' % uri)
-        peer = hg.peer(ui, {}, uri)
-        result = repo.pull(peer)
-        ui.write('%s\n' % result)
+    try:
+        for tree in ('esr17', 'release', 'beta', 'aurora', 'central',
+            'inbound'):
+            peer = hg.peer(ui, {}, tree)
+            result = repo.pull(peer)
+        res = update(ui, repo, rev='central/default')
+        success = True
+        return res
+    finally:
+        if not success:
+            shutil.rmtree(path)
 
 
 @command('pushtree',
     [('r', 'rev', 'tip', _('revision'), _('REV'))],
     _('hg pushtree [-r REV] TREE'))
 def pushtree(ui, repo, tree=None, rev=None, **opts):
     """Push changesets to a Mozilla repository.
 
     If only the tree argument is defined, we will attempt to push the current
     tip to the repository specified. This may fail due to pushed mq patches,
     local changes, etc. Please note we only attempt to push the current tip and
     it's ancestors, not all changesets not in the remote repository. This is
     different from the default behavior of |hg push| and is the distinguishing
     difference from that command.
 
     If you would like to push a non-active head, specify it with -r REV. For
-    example, if you are currently on mozilla-central but wish to push the
-    inbound bookmark to mozilla-inbound, run  |hg pushtree -r inbound inbound|.
+    example, if you are currently on mozilla-central but wish to push inbound
+    to mozilla-inbound, run `hg pushtree -r inbound/default inbound`.
     """
     if not tree:
         raise util.Abort(_('A tree must be specified.'))
 
     return push(ui, repo, rev=rev, dest=tree)
 
 
 @command('treestatus', [], _('hg treestatus [TREE] ...'))