changeset 4699:a6b62584d0b2

unbundle: accept multiple file arguments update test-bundle for multiple unbundle support
author Giorgos Keramidas <keramida@ceid.upatras.gr>
date Sun, 24 Jun 2007 10:08:38 -0500
parents 30e826bd8ed1
children a2e025fcd256 c71bf1d251ad
files mercurial/commands.py tests/test-bundle tests/test-bundle.out tests/test-globalopts.out tests/test-help.out
diffstat 5 files changed, 36 insertions(+), 16 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -2614,18 +2614,22 @@ def tip(ui, repo, **opts):
     """
     cmdutil.show_changeset(ui, repo, opts).show(nullrev+repo.changelog.count())
 
-def unbundle(ui, repo, fname, **opts):
-    """apply a changegroup file
-
-    Apply a compressed changegroup file generated by the bundle
-    command.
+def unbundle(ui, repo, fname1, *fnames, **opts):
+    """apply one or more changegroup files
+
+    Apply one or more compressed changegroup files generated by the
+    bundle command.
     """
-    if os.path.exists(fname):
-        f = open(fname, "rb")
-    else:
-        f = urllib.urlopen(fname)
-    gen = changegroup.readbundle(f, fname)
-    modheads = repo.addchangegroup(gen, 'unbundle', 'bundle:' + fname)
+    fnames = (fname1,) + fnames
+    result = None
+    for fname in fnames:
+        if os.path.exists(fname):
+            f = open(fname, "rb")
+        else:
+            f = urllib.urlopen(fname)
+        gen = changegroup.readbundle(f, fname)
+        modheads = repo.addchangegroup(gen, 'unbundle', 'bundle:' + fname)
+
     return postincoming(ui, repo, modheads, opts['update'])
 
 def update(ui, repo, node=None, rev=None, clean=False, date=None):
@@ -3079,7 +3083,7 @@ table = {
         (unbundle,
          [('u', 'update', None,
            _('update to new tip if changesets were unbundled'))],
-         _('hg unbundle [-u] FILE')),
+         _('hg unbundle [-u] FILE...')),
     "^update|up|checkout|co":
         (update,
          [('C', 'clean', None, _('overwrite locally modified files')),
--- a/tests/test-bundle
+++ b/tests/test-bundle
@@ -62,6 +62,13 @@ hg -R bundle://../full.hg outgoing ../pa
 hg -R bundle://../does-not-exist.hg outgoing ../partial2
 cd ..
 
+# test for http://www.selenic.com/mercurial/bts/issue216
+rm -r empty
+hg init empty
+hg -R test bundle --base null -r 0 ../0.hg
+hg -R test bundle --base 0    -r 1 ../1.hg
+hg -R empty unbundle -u ../0.hg ../1.hg
+
 # test for 540d1059c802
 hg init orig
 cd orig
--- a/tests/test-bundle.out
+++ b/tests/test-bundle.out
@@ -211,6 +211,15 @@ date:        Mon Jan 12 13:46:40 1970 +0
 summary:     0.3m
 
 abort: No such file or directory: ../does-not-exist.hg
+adding changesets
+adding manifests
+adding file changes
+added 1 changesets with 1 changes to 1 files
+adding changesets
+adding manifests
+adding file changes
+added 1 changesets with 1 changes to 1 files
+1 files updated, 0 files merged, 0 files removed, 0 files unresolved
 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
 searching for changes
 comparing with ../bundle.hg
--- a/tests/test-globalopts.out
+++ b/tests/test-globalopts.out
@@ -161,7 +161,7 @@ list of commands:
  tag          add a tag for the current or given revision
  tags         list repository tags
  tip          show the tip revision
- unbundle     apply a changegroup file
+ unbundle     apply one or more changegroup files
  update       update working directory
  verify       verify the integrity of the repository
  version      output version and copyright information
@@ -213,7 +213,7 @@ list of commands:
  tag          add a tag for the current or given revision
  tags         list repository tags
  tip          show the tip revision
- unbundle     apply a changegroup file
+ unbundle     apply one or more changegroup files
  update       update working directory
  verify       verify the integrity of the repository
  version      output version and copyright information
--- a/tests/test-help.out
+++ b/tests/test-help.out
@@ -84,7 +84,7 @@ list of commands:
  tag          add a tag for the current or given revision
  tags         list repository tags
  tip          show the tip revision
- unbundle     apply a changegroup file
+ unbundle     apply one or more changegroup files
  update       update working directory
  verify       verify the integrity of the repository
  version      output version and copyright information
@@ -132,7 +132,7 @@ use "hg -v help" to show aliases and glo
  tag          add a tag for the current or given revision
  tags         list repository tags
  tip          show the tip revision
- unbundle     apply a changegroup file
+ unbundle     apply one or more changegroup files
  update       update working directory
  verify       verify the integrity of the repository
  version      output version and copyright information