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