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