Show More
@@ -1,70 +1,69 b'' | |||
|
1 | 1 | # Copyright 2006, 2007 Matt Mackall <mpm@selenic.com> |
|
2 | 2 | # |
|
3 | 3 | # This software may be used and distributed according to the terms of the |
|
4 | 4 | # GNU General Public License version 2 or any later version. |
|
5 | 5 | |
|
6 | 6 | '''share a common history between several working directories''' |
|
7 | 7 | |
|
8 | 8 | from mercurial.i18n import _ |
|
9 |
from mercurial import cmdutil, hg, |
|
|
9 | from mercurial import cmdutil, hg, util | |
|
10 | 10 | |
|
11 | 11 | cmdtable = {} |
|
12 | 12 | command = cmdutil.command(cmdtable) |
|
13 | 13 | testedwith = 'internal' |
|
14 | 14 | |
|
15 | 15 | @command('share', |
|
16 | 16 | [('U', 'noupdate', None, _('do not create a working copy'))], |
|
17 |
_('[-U] SOURCE [DEST]') |
|
|
17 | _('[-U] SOURCE [DEST]'), | |
|
18 | norepo=True) | |
|
18 | 19 | def share(ui, source, dest=None, noupdate=False): |
|
19 | 20 | """create a new shared repository |
|
20 | 21 | |
|
21 | 22 | Initialize a new repository and working directory that shares its |
|
22 | 23 | history with another repository. |
|
23 | 24 | |
|
24 | 25 | .. note:: |
|
25 | 26 | |
|
26 | 27 | using rollback or extensions that destroy/modify history (mq, |
|
27 | 28 | rebase, etc.) can cause considerable confusion with shared |
|
28 | 29 | clones. In particular, if two shared clones are both updated to |
|
29 | 30 | the same changeset, and one of them destroys that changeset |
|
30 | 31 | with rollback, the other clone will suddenly stop working: all |
|
31 | 32 | operations will fail with "abort: working directory has unknown |
|
32 | 33 | parent". The only known workaround is to use debugsetparents on |
|
33 | 34 | the broken clone to reset it to a changeset that still exists. |
|
34 | 35 | """ |
|
35 | 36 | |
|
36 | 37 | return hg.share(ui, source, dest, not noupdate) |
|
37 | 38 | |
|
38 | 39 | @command('unshare', [], '') |
|
39 | 40 | def unshare(ui, repo): |
|
40 | 41 | """convert a shared repository to a normal one |
|
41 | 42 | |
|
42 | 43 | Copy the store data to the repo and remove the sharedpath data. |
|
43 | 44 | """ |
|
44 | 45 | |
|
45 | 46 | if repo.sharedpath == repo.path: |
|
46 | 47 | raise util.Abort(_("this is not a shared repo")) |
|
47 | 48 | |
|
48 | 49 | destlock = lock = None |
|
49 | 50 | lock = repo.lock() |
|
50 | 51 | try: |
|
51 | 52 | # we use locks here because if we race with commit, we |
|
52 | 53 | # can end up with extra data in the cloned revlogs that's |
|
53 | 54 | # not pointed to by changesets, thus causing verify to |
|
54 | 55 | # fail |
|
55 | 56 | |
|
56 | 57 | destlock = hg.copystore(ui, repo, repo.path) |
|
57 | 58 | |
|
58 | 59 | sharefile = repo.join('sharedpath') |
|
59 | 60 | util.rename(sharefile, sharefile + '.old') |
|
60 | 61 | |
|
61 | 62 | repo.requirements.discard('sharedpath') |
|
62 | 63 | repo._writerequirements() |
|
63 | 64 | finally: |
|
64 | 65 | destlock and destlock.release() |
|
65 | 66 | lock and lock.release() |
|
66 | 67 | |
|
67 | 68 | # update store, spath, sopener and sjoin of repo |
|
68 | 69 | repo.unfiltered().__init__(repo.baseui, repo.root) |
|
69 | ||
|
70 | commands.norepo += " share" |
General Comments 0
You need to be logged in to leave comments.
Login now