Show More
@@ -106,6 +106,21 b' annotate [-r <rev> -u -n -c] [files ...]' | |||||
106 | -c, --changeset list the changeset |
|
106 | -c, --changeset list the changeset | |
107 | -n, --number list the revision number (default) |
|
107 | -n, --number list the revision number (default) | |
108 |
|
108 | |||
|
109 | bundle <file> <other>:: | |||
|
110 | (EXPERIMENTAL) | |||
|
111 | ||||
|
112 | Generate a compressed changegroup file collecting all changesets | |||
|
113 | not found in the other repository. | |||
|
114 | ||||
|
115 | This file can then be transferred using conventional means and | |||
|
116 | applied to another repository with the unbundle command. This is | |||
|
117 | useful when native push and pull are not available or when | |||
|
118 | exporting an entire repository is undesirable. The standard file | |||
|
119 | extension is ".hg". | |||
|
120 | ||||
|
121 | Unlike import/export, this exactly preserves all changeset | |||
|
122 | contents including permissions, rename data, and revision history. | |||
|
123 | ||||
109 | cat <file> [revision]:: |
|
124 | cat <file> [revision]:: | |
110 | Output to stdout the given revision for the specified file. |
|
125 | Output to stdout the given revision for the specified file. | |
111 |
|
126 | |||
@@ -512,6 +527,12 b' tags::' | |||||
512 | tip:: |
|
527 | tip:: | |
513 | Show the tip revision. |
|
528 | Show the tip revision. | |
514 |
|
529 | |||
|
530 | unbundle <file>:: | |||
|
531 | (EXPERIMENTAL) | |||
|
532 | ||||
|
533 | Apply a compressed changegroup file generated by the bundle | |||
|
534 | command. | |||
|
535 | ||||
515 | undo:: |
|
536 | undo:: | |
516 | Undo the last commit or pull transaction. |
|
537 | Undo the last commit or pull transaction. | |
517 |
|
538 |
@@ -7,10 +7,10 b'' | |||||
7 |
|
7 | |||
8 | from demandload import demandload |
|
8 | from demandload import demandload | |
9 | from node import * |
|
9 | from node import * | |
10 | demandload(globals(), "os re sys signal shutil imp") |
|
10 | demandload(globals(), "os re sys signal shutil imp urllib") | |
11 | demandload(globals(), "fancyopts ui hg util lock revlog") |
|
11 | demandload(globals(), "fancyopts ui hg util lock revlog") | |
12 | demandload(globals(), "fnmatch hgweb mdiff random signal time traceback") |
|
12 | demandload(globals(), "fnmatch hgweb mdiff random signal time traceback") | |
13 | demandload(globals(), "errno socket version struct atexit sets") |
|
13 | demandload(globals(), "errno socket version struct atexit sets bz2") | |
14 |
|
14 | |||
15 | class UnknownCommand(Exception): |
|
15 | class UnknownCommand(Exception): | |
16 | """Exception raised if command is not in the command table.""" |
|
16 | """Exception raised if command is not in the command table.""" | |
@@ -549,6 +549,26 b' def annotate(ui, repo, *pats, **opts):' | |||||
549 | for p, l in zip(zip(*pieces), lines): |
|
549 | for p, l in zip(zip(*pieces), lines): | |
550 | ui.write("%s: %s" % (" ".join(p), l[1])) |
|
550 | ui.write("%s: %s" % (" ".join(p), l[1])) | |
551 |
|
551 | |||
|
552 | def bundle(ui, repo, fname, dest="default-push", **opts): | |||
|
553 | """create a changegroup file""" | |||
|
554 | f = open(fname, "wb") | |||
|
555 | dest = ui.expandpath(dest) | |||
|
556 | other = hg.repository(ui, dest) | |||
|
557 | o = repo.findoutgoing(other) | |||
|
558 | cg = repo.changegroup(o) | |||
|
559 | ||||
|
560 | try: | |||
|
561 | f.write("HG10") | |||
|
562 | z = bz2.BZ2Compressor(9) | |||
|
563 | while 1: | |||
|
564 | chunk = cg.read(4096) | |||
|
565 | if not chunk: | |||
|
566 | break | |||
|
567 | f.write(z.compress(chunk)) | |||
|
568 | f.write(z.flush()) | |||
|
569 | except: | |||
|
570 | os.unlink(fname) | |||
|
571 | ||||
552 | def cat(ui, repo, file1, rev=None, **opts): |
|
572 | def cat(ui, repo, file1, rev=None, **opts): | |
553 | """output the latest or given revision of a file""" |
|
573 | """output the latest or given revision of a file""" | |
554 | r = repo.file(relpath(repo, [file1])[0]) |
|
574 | r = repo.file(relpath(repo, [file1])[0]) | |
@@ -1534,6 +1554,30 b' def tip(ui, repo):' | |||||
1534 | n = repo.changelog.tip() |
|
1554 | n = repo.changelog.tip() | |
1535 | show_changeset(ui, repo, changenode=n) |
|
1555 | show_changeset(ui, repo, changenode=n) | |
1536 |
|
1556 | |||
|
1557 | def unbundle(ui, repo, fname): | |||
|
1558 | f = urllib.urlopen(fname) | |||
|
1559 | ||||
|
1560 | if f.read(4) != "HG10": | |||
|
1561 | ui.warn("abort: not a Mercurial bundle file!\n") | |||
|
1562 | return -1 | |||
|
1563 | ||||
|
1564 | class bzread: | |||
|
1565 | def __init__(self, f): | |||
|
1566 | self.zd = bz2.BZ2Decompressor() | |||
|
1567 | self.f = f | |||
|
1568 | self.buf = "" | |||
|
1569 | def read(self, l): | |||
|
1570 | while l > len(self.buf): | |||
|
1571 | r = self.f.read(4096) | |||
|
1572 | if r: | |||
|
1573 | self.buf += self.zd.decompress(r) | |||
|
1574 | else: | |||
|
1575 | break | |||
|
1576 | d, self.buf = self.buf[:l], self.buf[l:] | |||
|
1577 | return d | |||
|
1578 | ||||
|
1579 | repo.addchangegroup(bzread(f)) | |||
|
1580 | ||||
1537 | def undo(ui, repo): |
|
1581 | def undo(ui, repo): | |
1538 | """undo the last commit or pull |
|
1582 | """undo the last commit or pull | |
1539 |
|
1583 | |||
@@ -1610,6 +1654,10 b' table = {' | |||||
1610 | ('I', 'include', [], 'include path in search'), |
|
1654 | ('I', 'include', [], 'include path in search'), | |
1611 | ('X', 'exclude', [], 'exclude path from search')], |
|
1655 | ('X', 'exclude', [], 'exclude path from search')], | |
1612 | 'hg annotate [OPTION]... FILE...'), |
|
1656 | 'hg annotate [OPTION]... FILE...'), | |
|
1657 | "bundle": | |||
|
1658 | (bundle, | |||
|
1659 | [], | |||
|
1660 | 'hg bundle FILE DEST'), | |||
1613 | "cat": |
|
1661 | "cat": | |
1614 | (cat, |
|
1662 | (cat, | |
1615 | [('o', 'output', "", 'output to file')], |
|
1663 | [('o', 'output', "", 'output to file')], | |
@@ -1776,6 +1824,10 b' table = {' | |||||
1776 | 'hg tag [OPTION]... NAME [REV]'), |
|
1824 | 'hg tag [OPTION]... NAME [REV]'), | |
1777 | "tags": (tags, [], 'hg tags'), |
|
1825 | "tags": (tags, [], 'hg tags'), | |
1778 | "tip": (tip, [], 'hg tip'), |
|
1826 | "tip": (tip, [], 'hg tip'), | |
|
1827 | "unbundle": | |||
|
1828 | (unbundle, | |||
|
1829 | [], | |||
|
1830 | 'hg unbundle FILE'), | |||
1779 | "undo": (undo, [], 'hg undo'), |
|
1831 | "undo": (undo, [], 'hg undo'), | |
1780 | "^update|up|checkout|co": |
|
1832 | "^update|up|checkout|co": | |
1781 | (update, |
|
1833 | (update, |
@@ -604,8 +604,8 b' class revlog:' | |||||
604 | link = linkmapper(cs) |
|
604 | link = linkmapper(cs) | |
605 | if node in self.nodemap: |
|
605 | if node in self.nodemap: | |
606 | # this can happen if two branches make the same change |
|
606 | # this can happen if two branches make the same change | |
607 | if unique: |
|
607 | # if unique: | |
608 | raise RevlogError("already have %s" % hex(node[:4])) |
|
608 | # raise RevlogError("already have %s" % hex(node[:4])) | |
609 | chain = node |
|
609 | chain = node | |
610 | continue |
|
610 | continue | |
611 | delta = chunk[80:] |
|
611 | delta = chunk[80:] |
General Comments 0
You need to be logged in to leave comments.
Login now