Show More
@@ -6,7 +6,9 b'' | |||||
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 | |
@@ -28,11 +30,46 b' def share(ui, source, dest=None, noupdat' | |||||
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