mercurial/commands.py
changeset 3283 d89e98840b08
parent 3277 23682d3e4111
child 3292 399c04369a1b
child 3293 a225055b3b59
equal deleted inserted replaced
3282:f49c90b46897 3283:d89e98840b08
   764                         'if you want to auto-merge)\n'))
   764                         'if you want to auto-merge)\n'))
   765 
   765 
   766 def bundle(ui, repo, fname, dest=None, **opts):
   766 def bundle(ui, repo, fname, dest=None, **opts):
   767     """create a changegroup file
   767     """create a changegroup file
   768 
   768 
   769     Generate a compressed changegroup file collecting all changesets
   769     Generate a compressed changegroup file collecting changesets.
   770     not found in the other repository.
   770     not found in the other repository.
       
   771 
       
   772     If no destination repository is specified the destination is
       
   773     assumed to have all the node specified by --base.
   771 
   774 
   772     This file can then be transferred using conventional means and
   775     This file can then be transferred using conventional means and
   773     applied to another repository with the unbundle command. This is
   776     applied to another repository with the unbundle command. This is
   774     useful when native push and pull are not available or when
   777     useful when native push and pull are not available or when
   775     exporting an entire repository is undesirable. The standard file
   778     exporting an entire repository is undesirable. The standard file
   776     extension is ".hg".
   779     extension is ".hg".
   777 
   780 
   778     Unlike import/export, this exactly preserves all changeset
   781     Unlike import/export, this exactly preserves all changeset
   779     contents including permissions, rename data, and revision history.
   782     contents including permissions, rename data, and revision history.
   780     """
   783     """
   781     dest = ui.expandpath(dest or 'default-push', dest or 'default')
   784     revs = opts.get('rev') or None
   782     setremoteconfig(ui, opts)
   785     if revs:
   783     other = hg.repository(ui, dest)
   786         revs = [repo.lookup(rev) for rev in revs]
   784     o = repo.findoutgoing(other, force=opts['force'])
   787     base = opts.get('base')
   785     cg = repo.changegroup(o, 'bundle')
   788     if base:
       
   789         if dest:
       
   790             raise util.Abort(_("--base is incompatible with specifiying "
       
   791                                "a destination"))
       
   792         o = []
       
   793         for n in base:
       
   794             o.extend(repo.changelog.children(repo.lookup(n)))
       
   795         # add common ancestor
       
   796         if revs:
       
   797             all = o + revs
       
   798         else:
       
   799             all = o + repo.changelog.heads()
       
   800         ancestor = reduce(lambda a, b: repo.changelog.ancestor(a, b), all)
       
   801         o.append(ancestor)
       
   802     else:
       
   803         setremoteconfig(ui, opts)
       
   804         dest = ui.expandpath(dest or 'default-push', dest or 'default')
       
   805         other = hg.repository(ui, dest)
       
   806         o = repo.findoutgoing(other, force=opts['force'])
       
   807 
       
   808     if revs:
       
   809         cg = repo.changegroupsubset(o, revs, 'bundle')
       
   810     else:
       
   811         cg = repo.changegroup(o, 'bundle')
   786     write_bundle(cg, fname)
   812     write_bundle(cg, fname)
   787 
   813 
   788 def cat(ui, repo, file1, *pats, **opts):
   814 def cat(ui, repo, file1, *pats, **opts):
   789     """output the latest or given revisions of files
   815     """output the latest or given revisions of files
   790 
   816 
  2787          _('hg backout [OPTION]... REV')),
  2813          _('hg backout [OPTION]... REV')),
  2788     "bundle":
  2814     "bundle":
  2789         (bundle,
  2815         (bundle,
  2790          [('f', 'force', None,
  2816          [('f', 'force', None,
  2791            _('run even when remote repository is unrelated')),
  2817            _('run even when remote repository is unrelated')),
       
  2818           ('r', 'rev', [],
       
  2819            _('a changeset you would like to bundle')),
       
  2820           ('', 'base', [],
       
  2821            _('a base changeset to specify instead of a destination')),
  2792          ] + remoteopts,
  2822          ] + remoteopts,
  2793          _('hg bundle FILE DEST')),
  2823          _('hg bundle [--base REV]... [--rev REV]... FILE [DEST]')),
  2794     "cat":
  2824     "cat":
  2795         (cat,
  2825         (cat,
  2796          [('o', 'output', '', _('print output to file with formatted name')),
  2826          [('o', 'output', '', _('print output to file with formatted name')),
  2797           ('r', 'rev', '', _('print the given revision')),
  2827           ('r', 'rev', '', _('print the given revision')),
  2798          ] + walkopts,
  2828          ] + walkopts,