##// END OF EJS Templates
merge with crew.
Vadim Gelfer -
r2721:d1fa79e7 merge default
parent child Browse files
Show More
@@ -38,7 +38,8 b' versionstr = "0.45"'
38
38
39 repomap = {}
39 repomap = {}
40
40
41 commands.norepo += " qversion"
41 commands.norepo += " qclone qversion"
42
42 class queue:
43 class queue:
43 def __init__(self, ui, path, patchdir=None):
44 def __init__(self, ui, path, patchdir=None):
44 self.basepath = path
45 self.basepath = path
@@ -1177,6 +1178,52 b' def init(ui, repo, **opts):'
1177 r.add(['.hgignore', 'series'])
1178 r.add(['.hgignore', 'series'])
1178 return 0
1179 return 0
1179
1180
1181 def clone(ui, source, dest=None, **opts):
1182 '''clone main and patch repository at same time
1183
1184 If source is local, destination will have no patches applied. If
1185 source is remote, this command can not check if patches are
1186 applied in source, so cannot guarantee that patches are not
1187 applied in destination. If you clone remote repository, be sure
1188 before that it has no patches applied.
1189
1190 Source patch repository is looked for in <src>/.hg/patches by
1191 default. Use -p <url> to change.
1192 '''
1193 ui.setconfig_remoteopts(**opts)
1194 if dest is None:
1195 dest = hg.defaultdest(source)
1196 sr = hg.repository(ui, ui.expandpath(source))
1197 qbase, destrev = None, None
1198 if sr.local():
1199 reposetup(ui, sr)
1200 sq = repomap[sr]
1201 if sq.applied:
1202 qbase = revlog.bin(sq.applied[0].split(':')[0])
1203 if not hg.islocal(dest):
1204 destrev = sr.parents(qbase)[0]
1205 ui.note(_('cloning main repo\n'))
1206 sr, dr = hg.clone(ui, sr, dest,
1207 pull=opts['pull'],
1208 rev=destrev,
1209 update=False,
1210 stream=opts['uncompressed'])
1211 ui.note(_('cloning patch repo\n'))
1212 spr, dpr = hg.clone(ui, opts['patches'] or (sr.url() + '/.hg/patches'),
1213 dr.url() + '/.hg/patches',
1214 pull=opts['pull'],
1215 update=not opts['noupdate'],
1216 stream=opts['uncompressed'])
1217 if dr.local():
1218 if qbase:
1219 ui.note(_('stripping applied patches from destination repo\n'))
1220 reposetup(ui, dr)
1221 dq = repomap[dr]
1222 dq.strip(dr, qbase, update=False, backup=None)
1223 if not opts['noupdate']:
1224 ui.note(_('updating destination repo\n'))
1225 dr.update(dr.changelog.tip())
1226
1180 def commit(ui, repo, *pats, **opts):
1227 def commit(ui, repo, *pats, **opts):
1181 """commit changes in the queue repository"""
1228 """commit changes in the queue repository"""
1182 q = repomap[repo]
1229 q = repomap[repo]
@@ -1369,6 +1416,16 b' def reposetup(ui, repo):'
1369
1416
1370 cmdtable = {
1417 cmdtable = {
1371 "qapplied": (applied, [], 'hg qapplied [PATCH]'),
1418 "qapplied": (applied, [], 'hg qapplied [PATCH]'),
1419 "qclone": (clone,
1420 [('', 'pull', None, _('use pull protocol to copy metadata')),
1421 ('U', 'noupdate', None, _('do not update the new working directories')),
1422 ('', 'uncompressed', None,
1423 _('use uncompressed transfer (fast over LAN)')),
1424 ('e', 'ssh', '', _('specify ssh command to use')),
1425 ('p', 'patches', '', _('location of source patch repo')),
1426 ('', 'remotecmd', '',
1427 _('specify hg command to run on the remote side'))],
1428 'hg qclone [OPTION]... SOURCE [DEST]'),
1372 "qcommit|qci":
1429 "qcommit|qci":
1373 (commit,
1430 (commit,
1374 commands.table["^commit|ci"][1],
1431 commands.table["^commit|ci"][1],
@@ -57,6 +57,23 b' schemes = {'
57 'static-http': static_http,
57 'static-http': static_http,
58 }
58 }
59
59
60 remote_schemes = [
61 'bundle',
62 'hg',
63 'http',
64 'https',
65 'old-http',
66 'ssh',
67 'static-http',
68 ]
69
70 def islocal(repo):
71 '''return true if repo or path is local'''
72 if isinstance(repo, str):
73 c = repo.find(':')
74 return c <= 0 or repo[:c] not in remote_schemes
75 return repo.local()
76
60 def repository(ui, path=None, create=0):
77 def repository(ui, path=None, create=0):
61 scheme = None
78 scheme = None
62 if path:
79 if path:
@@ -74,6 +91,10 b' def repository(ui, path=None, create=0):'
74 scheme)
91 scheme)
75 return ctor(ui, path)
92 return ctor(ui, path)
76
93
94 def defaultdest(source):
95 '''return default destination of clone if none is given'''
96 return os.path.basename(os.path.normpath(source))
97
77 def clone(ui, source, dest=None, pull=False, rev=None, update=True,
98 def clone(ui, source, dest=None, pull=False, rev=None, update=True,
78 stream=False):
99 stream=False):
79 """Make a copy of an existing repository.
100 """Make a copy of an existing repository.
@@ -90,7 +111,9 b' def clone(ui, source, dest=None, pull=Fa'
90 If an exception is raised, the partly cloned/updated destination
111 If an exception is raised, the partly cloned/updated destination
91 repository will be deleted.
112 repository will be deleted.
92
113
93 Keyword arguments:
114 Arguments:
115
116 source: repository object or URL
94
117
95 dest: URL of destination repository to create (defaults to base
118 dest: URL of destination repository to create (defaults to base
96 name of source repository)
119 name of source repository)
@@ -105,8 +128,24 b' def clone(ui, source, dest=None, pull=Fa'
105 update: update working directory after clone completes, if
128 update: update working directory after clone completes, if
106 destination is local repository
129 destination is local repository
107 """
130 """
131 if isinstance(source, str):
132 src_repo = repository(ui, source)
133 else:
134 src_repo = source
135 source = src_repo.url()
136
108 if dest is None:
137 if dest is None:
109 dest = os.path.basename(os.path.normpath(source))
138 dest = defaultdest(source)
139
140 def localpath(path):
141 if path.startswith('file://'):
142 return path[7:]
143 if path.startswith('file:'):
144 return path[5:]
145 return path
146
147 dest = localpath(dest)
148 source = localpath(source)
110
149
111 if os.path.exists(dest):
150 if os.path.exists(dest):
112 raise util.Abort(_("destination '%s' already exists"), dest)
151 raise util.Abort(_("destination '%s' already exists"), dest)
@@ -121,8 +160,6 b' def clone(ui, source, dest=None, pull=Fa'
121 if self.dir_:
160 if self.dir_:
122 self.rmtree(self.dir_, True)
161 self.rmtree(self.dir_, True)
123
162
124 src_repo = repository(ui, source)
125
126 dest_repo = None
163 dest_repo = None
127 try:
164 try:
128 dest_repo = repository(ui, dest)
165 dest_repo = repository(ui, dest)
@@ -133,7 +170,7 b' def clone(ui, source, dest=None, pull=Fa'
133 dest_path = None
170 dest_path = None
134 dir_cleanup = None
171 dir_cleanup = None
135 if dest_repo.local():
172 if dest_repo.local():
136 dest_path = os.path.realpath(dest)
173 dest_path = os.path.realpath(dest_repo.root)
137 dir_cleanup = DirCleanup(dest_path)
174 dir_cleanup = DirCleanup(dest_path)
138
175
139 abspath = source
176 abspath = source
General Comments 0
You need to be logged in to leave comments. Login now