##// END OF EJS Templates
Merge with crew-stable
Alexis S. L. Carvalho -
r4232:0d51eb29 merge default
parent child Browse files
Show More
@@ -138,7 +138,7 b' def walk(repo, pats=[], opts={}, node=No'
138 exact = dict.fromkeys(files)
138 exact = dict.fromkeys(files)
139 for src, fn in repo.walk(node=node, files=files, match=matchfn,
139 for src, fn in repo.walk(node=node, files=files, match=matchfn,
140 badmatch=badmatch):
140 badmatch=badmatch):
141 yield src, fn, util.pathto(repo.getcwd(), fn), fn in exact
141 yield src, fn, util.pathto(repo.root, repo.getcwd(), fn), fn in exact
142
142
143 def findrenames(repo, added=None, removed=None, threshold=0.5):
143 def findrenames(repo, added=None, removed=None, threshold=0.5):
144 '''find renamed files -- yields (before, after, score) tuples'''
144 '''find renamed files -- yields (before, after, score) tuples'''
@@ -493,7 +493,7 b' def docopy(ui, repo, pats, opts, wlock):'
493 # target: ossep
493 # target: ossep
494 def copy(origsrc, abssrc, relsrc, target, exact):
494 def copy(origsrc, abssrc, relsrc, target, exact):
495 abstarget = util.canonpath(repo.root, cwd, target)
495 abstarget = util.canonpath(repo.root, cwd, target)
496 reltarget = util.pathto(cwd, abstarget)
496 reltarget = util.pathto(repo.root, cwd, abstarget)
497 prevsrc = targets.get(abstarget)
497 prevsrc = targets.get(abstarget)
498 if prevsrc is not None:
498 if prevsrc is not None:
499 ui.warn(_('%s: not overwriting - %s collides with %s\n') %
499 ui.warn(_('%s: not overwriting - %s collides with %s\n') %
@@ -2172,9 +2172,19 b' def revert(ui, repo, *pats, **opts):'
2172
2172
2173 # walk target manifest.
2173 # walk target manifest.
2174
2174
2175 def badmatch(path):
2176 if path in names:
2177 return True
2178 path_ = path + '/'
2179 for f in names:
2180 if f.startswith(path_):
2181 return True
2182 return False
2183
2175 for src, abs, rel, exact in cmdutil.walk(repo, pats, opts, node=node,
2184 for src, abs, rel, exact in cmdutil.walk(repo, pats, opts, node=node,
2176 badmatch=names.has_key):
2185 badmatch=badmatch):
2177 if abs in names: continue
2186 if abs in names or src == 'b':
2187 continue
2178 names[abs] = (rel, exact)
2188 names[abs] = (rel, exact)
2179 target_only[abs] = True
2189 target_only[abs] = True
2180
2190
@@ -2414,11 +2424,12 b' def status(ui, repo, *pats, **opts):'
2414 format = "%s %%s%s" % (char, end)
2424 format = "%s %%s%s" % (char, end)
2415
2425
2416 for f in changes:
2426 for f in changes:
2417 ui.write(format % util.pathto(cwd, f))
2427 ui.write(format % util.pathto(repo.root, cwd, f))
2418 if ((all or opts.get('copies')) and not opts.get('no_status')):
2428 if ((all or opts.get('copies')) and not opts.get('no_status')):
2419 copied = repo.dirstate.copied(f)
2429 copied = repo.dirstate.copied(f)
2420 if copied:
2430 if copied:
2421 ui.write(' %s%s' % (util.pathto(cwd, copied), end))
2431 ui.write(' %s%s' % (util.pathto(repo.root, cwd, copied),
2432 end))
2422
2433
2423 def tag(ui, repo, name, rev_=None, **opts):
2434 def tag(ui, repo, name, rev_=None, **opts):
2424 """add a tag for the current or given revision
2435 """add a tag for the current or given revision
@@ -33,10 +33,14 b' class dirstate(object):'
33 cwd = os.getcwd()
33 cwd = os.getcwd()
34 if cwd == self.root: return ''
34 if cwd == self.root: return ''
35 # self.root ends with a path separator if self.root is '/' or 'C:\'
35 # self.root ends with a path separator if self.root is '/' or 'C:\'
36 common_prefix_len = len(self.root)
36 rootsep = self.root
37 if not self.root.endswith(os.sep):
37 if not rootsep.endswith(os.sep):
38 common_prefix_len += 1
38 rootsep += os.sep
39 return cwd[common_prefix_len:]
39 if cwd.startswith(rootsep):
40 return cwd[len(rootsep):]
41 else:
42 # we're outside the repo. return an absolute path.
43 return cwd
40
44
41 def hgignore(self):
45 def hgignore(self):
42 '''return the contents of .hgignore files as a list of patterns.
46 '''return the contents of .hgignore files as a list of patterns.
@@ -361,7 +365,7 b' class dirstate(object):'
361 elif stat.S_ISSOCK(st.st_mode): kind = _('socket')
365 elif stat.S_ISSOCK(st.st_mode): kind = _('socket')
362 elif stat.S_ISDIR(st.st_mode): kind = _('directory')
366 elif stat.S_ISDIR(st.st_mode): kind = _('directory')
363 self.ui.warn(_('%s: unsupported file type (type is %s)\n') % (
367 self.ui.warn(_('%s: unsupported file type (type is %s)\n') % (
364 util.pathto(self.getcwd(), f),
368 util.pathto(self.root, self.getcwd(), f),
365 kind))
369 kind))
366 return False
370 return False
367
371
@@ -471,7 +475,7 b' class dirstate(object):'
471 if not found:
475 if not found:
472 if inst.errno != errno.ENOENT or not badmatch:
476 if inst.errno != errno.ENOENT or not badmatch:
473 self.ui.warn('%s: %s\n' % (
477 self.ui.warn('%s: %s\n' % (
474 util.pathto(self.getcwd(), ff),
478 util.pathto(self.root, self.getcwd(), ff),
475 inst.strerror))
479 inst.strerror))
476 elif badmatch and badmatch(ff) and imatch(nf):
480 elif badmatch and badmatch(ff) and imatch(nf):
477 yield 'b', ff, None
481 yield 'b', ff, None
@@ -1066,8 +1066,6 b' class hgweb(object):'
1066 headers={'status': '401 Unauthorized'})
1066 headers={'status': '401 Unauthorized'})
1067 return
1067 return
1068
1068
1069 req.httphdr("application/mercurial-0.1")
1070
1071 their_heads = req.form['heads'][0].split(' ')
1069 their_heads = req.form['heads'][0].split(' ')
1072
1070
1073 def check_heads():
1071 def check_heads():
@@ -1079,6 +1077,8 b' class hgweb(object):'
1079 bail(_('unsynced changes\n'))
1077 bail(_('unsynced changes\n'))
1080 return
1078 return
1081
1079
1080 req.httphdr("application/mercurial-0.1")
1081
1082 # do not lock repo until all changegroup data is
1082 # do not lock repo until all changegroup data is
1083 # streamed. save to temporary file.
1083 # streamed. save to temporary file.
1084
1084
@@ -1089,67 +1089,78 b' class hgweb(object):'
1089 for s in util.filechunkiter(req, limit=length):
1089 for s in util.filechunkiter(req, limit=length):
1090 fp.write(s)
1090 fp.write(s)
1091
1091
1092 lock = self.repo.lock()
1093 try:
1092 try:
1094 if not check_heads():
1093 lock = self.repo.lock()
1095 req.write('0\n')
1094 try:
1096 req.write(_('unsynced changes\n'))
1095 if not check_heads():
1097 return
1096 req.write('0\n')
1097 req.write(_('unsynced changes\n'))
1098 return
1098
1099
1099 fp.seek(0)
1100 fp.seek(0)
1100 header = fp.read(6)
1101 header = fp.read(6)
1101 if not header.startswith("HG"):
1102 if not header.startswith("HG"):
1102 # old client with uncompressed bundle
1103 # old client with uncompressed bundle
1103 def generator(f):
1104 def generator(f):
1104 yield header
1105 yield header
1105 for chunk in f:
1106 for chunk in f:
1106 yield chunk
1107 yield chunk
1107 elif not header.startswith("HG10"):
1108 elif not header.startswith("HG10"):
1108 req.write("0\n")
1109 req.write("0\n")
1109 req.write(_("unknown bundle version\n"))
1110 req.write(_("unknown bundle version\n"))
1110 return
1111 return
1111 elif header == "HG10GZ":
1112 elif header == "HG10GZ":
1112 def generator(f):
1113 def generator(f):
1113 zd = zlib.decompressobj()
1114 zd = zlib.decompressobj()
1114 for chunk in f:
1115 for chunk in f:
1115 yield zd.decompress(chunk)
1116 yield zd.decompress(chunk)
1116 elif header == "HG10BZ":
1117 elif header == "HG10BZ":
1117 def generator(f):
1118 def generator(f):
1118 zd = bz2.BZ2Decompressor()
1119 zd = bz2.BZ2Decompressor()
1119 zd.decompress("BZ")
1120 zd.decompress("BZ")
1120 for chunk in f:
1121 for chunk in f:
1121 yield zd.decompress(chunk)
1122 yield zd.decompress(chunk)
1122 elif header == "HG10UN":
1123 elif header == "HG10UN":
1123 def generator(f):
1124 def generator(f):
1124 for chunk in f:
1125 for chunk in f:
1125 yield chunk
1126 yield chunk
1127 else:
1128 req.write("0\n")
1129 req.write(_("unknown bundle compression type\n"))
1130 return
1131 gen = generator(util.filechunkiter(fp, 4096))
1132
1133 # send addchangegroup output to client
1134
1135 old_stdout = sys.stdout
1136 sys.stdout = cStringIO.StringIO()
1137
1138 try:
1139 url = 'remote:%s:%s' % (proto,
1140 req.env.get('REMOTE_HOST', ''))
1141 try:
1142 ret = self.repo.addchangegroup(
1143 util.chunkbuffer(gen), 'serve', url)
1144 except util.Abort, inst:
1145 sys.stdout.write("abort: %s\n" % inst)
1146 ret = 0
1147 finally:
1148 val = sys.stdout.getvalue()
1149 sys.stdout = old_stdout
1150 req.write('%d\n' % ret)
1151 req.write(val)
1152 finally:
1153 lock.release()
1154 except (OSError, IOError), inst:
1155 req.write('0\n')
1156 filename = getattr(inst, 'filename', '')
1157 # Don't send our filesystem layout to the client
1158 if filename.startswith(self.repo.root):
1159 filename = filename[len(self.repo.root)+1:]
1126 else:
1160 else:
1127 req.write("0\n")
1161 filename = ''
1128 req.write(_("unknown bundle compression type\n"))
1162 error = getattr(inst, 'strerror', 'Unknown error')
1129 return
1163 req.write('%s: %s\n' % (error, filename))
1130 gen = generator(util.filechunkiter(fp, 4096))
1131
1132 # send addchangegroup output to client
1133
1134 old_stdout = sys.stdout
1135 sys.stdout = cStringIO.StringIO()
1136
1137 try:
1138 url = 'remote:%s:%s' % (proto,
1139 req.env.get('REMOTE_HOST', ''))
1140 try:
1141 ret = self.repo.addchangegroup(util.chunkbuffer(gen),
1142 'serve', url)
1143 except util.Abort, inst:
1144 sys.stdout.write("abort: %s\n" % inst)
1145 ret = 0
1146 finally:
1147 val = sys.stdout.getvalue()
1148 sys.stdout = old_stdout
1149 req.write('%d\n' % ret)
1150 req.write(val)
1151 finally:
1152 lock.release()
1153 finally:
1164 finally:
1154 fp.close()
1165 fp.close()
1155 os.unlink(tempname)
1166 os.unlink(tempname)
@@ -75,6 +75,14 b' def netlocunsplit(host, port, user=None,'
75 return userpass + '@' + hostport
75 return userpass + '@' + hostport
76 return hostport
76 return hostport
77
77
78 # work around a bug in Python < 2.4.2
79 # (it leaves a "\n" at the end of Proxy-authorization headers)
80 class request(urllib2.Request):
81 def add_header(self, key, val):
82 if key.lower() == 'proxy-authorization':
83 val = val.strip()
84 return urllib2.Request.add_header(self, key, val)
85
78 class httpsendfile(file):
86 class httpsendfile(file):
79 def __len__(self):
87 def __len__(self):
80 return os.fstat(self.fileno()).st_size
88 return os.fstat(self.fileno()).st_size
@@ -238,7 +246,7 b' class httprepository(remoterepository):'
238 if data:
246 if data:
239 self.ui.debug(_("sending %s bytes\n") %
247 self.ui.debug(_("sending %s bytes\n") %
240 headers.get('content-length', 'X'))
248 headers.get('content-length', 'X'))
241 resp = urllib2.urlopen(urllib2.Request(cu, data, headers))
249 resp = urllib2.urlopen(request(cu, data, headers))
242 except urllib2.HTTPError, inst:
250 except urllib2.HTTPError, inst:
243 if inst.code == 401:
251 if inst.code == 401:
244 raise util.Abort(_('authorization failed'))
252 raise util.Abort(_('authorization failed'))
@@ -902,7 +902,7 b' class localrepository(repo.repository):'
902 yield 'b', fn
902 yield 'b', fn
903 else:
903 else:
904 self.ui.warn(_('%s: No such file in rev %s\n') % (
904 self.ui.warn(_('%s: No such file in rev %s\n') % (
905 util.pathto(self.getcwd(), fn), short(node)))
905 util.pathto(self.root, self.getcwd(), fn), short(node)))
906 else:
906 else:
907 for src, fn in self.dirstate.walk(files, match, badmatch=badmatch):
907 for src, fn in self.dirstate.walk(files, match, badmatch=badmatch):
908 yield src, fn
908 yield src, fn
@@ -450,7 +450,10 b' def update(repo, node, branchmerge, forc'
450 wc = repo.workingctx()
450 wc = repo.workingctx()
451 if node is None:
451 if node is None:
452 # tip of current branch
452 # tip of current branch
453 node = repo.branchtags()[wc.branch()]
453 try:
454 node = repo.branchtags()[wc.branch()]
455 except KeyError:
456 raise util.Abort(_("branch %s not found") % wc.branch())
454 overwrite = force and not branchmerge
457 overwrite = force and not branchmerge
455 forcemerge = force and branchmerge
458 forcemerge = force and branchmerge
456 pl = wc.parents()
459 pl = wc.parents()
@@ -359,7 +359,7 b' def updatedir(ui, repo, patches, wlock=N'
359 cfiles = patches.keys()
359 cfiles = patches.keys()
360 cwd = repo.getcwd()
360 cwd = repo.getcwd()
361 if cwd:
361 if cwd:
362 cfiles = [util.pathto(cwd, f) for f in patches.keys()]
362 cfiles = [util.pathto(repo.root, cwd, f) for f in patches.keys()]
363 for f in patches:
363 for f in patches:
364 ctype, gp = patches[f]
364 ctype, gp = patches[f]
365 if ctype == 'RENAME':
365 if ctype == 'RENAME':
@@ -325,13 +325,22 b" def globre(pat, head='^', tail='$'):"
325
325
326 _globchars = {'[': 1, '{': 1, '*': 1, '?': 1}
326 _globchars = {'[': 1, '{': 1, '*': 1, '?': 1}
327
327
328 def pathto(n1, n2):
328 def pathto(root, n1, n2):
329 '''return the relative path from one place to another.
329 '''return the relative path from one place to another.
330 root should use os.sep to separate directories
330 n1 should use os.sep to separate directories
331 n1 should use os.sep to separate directories
331 n2 should use "/" to separate directories
332 n2 should use "/" to separate directories
332 returns an os.sep-separated path.
333 returns an os.sep-separated path.
334
335 If n1 is a relative path, it's assumed it's
336 relative to root.
337 n2 should always be relative to root.
333 '''
338 '''
334 if not n1: return localpath(n2)
339 if not n1: return localpath(n2)
340 if os.path.isabs(n1):
341 if os.path.splitdrive(root)[0] != os.path.splitdrive(n1)[0]:
342 return os.path.join(root, localpath(n2))
343 n2 = '/'.join((pconvert(root), n2))
335 a, b = n1.split(os.sep), n2.split('/')
344 a, b = n1.split(os.sep), n2.split('/')
336 a.reverse()
345 a.reverse()
337 b.reverse()
346 b.reverse()
@@ -32,6 +32,17 b' hg --cwd a diff -r0:1 > tip.patch'
32 hg --cwd b import -mpatch ../tip.patch
32 hg --cwd b import -mpatch ../tip.patch
33 rm -r b
33 rm -r b
34
34
35 echo % hg -R repo import
36 # put the clone in a subdir - having a directory named "a"
37 # used to hide a bug.
38 mkdir dir
39 hg clone -r0 a dir/b
40 hg --cwd a export tip > dir/tip.patch
41 cd dir
42 hg -R b import tip.patch
43 cd ..
44 rm -r dir
45
35 echo % import from stdin
46 echo % import from stdin
36 hg clone -r0 a b
47 hg clone -r0 a b
37 hg --cwd a export tip | hg --cwd b import -
48 hg --cwd a export tip | hg --cwd b import -
@@ -30,6 +30,14 b' adding file changes'
30 added 1 changesets with 2 changes to 2 files
30 added 1 changesets with 2 changes to 2 files
31 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
31 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
32 applying ../tip.patch
32 applying ../tip.patch
33 % hg -R repo import
34 requesting all changes
35 adding changesets
36 adding manifests
37 adding file changes
38 added 1 changesets with 2 changes to 2 files
39 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
40 applying tip.patch
33 % import from stdin
41 % import from stdin
34 requesting all changes
42 requesting all changes
35 adding changesets
43 adding changesets
@@ -68,8 +68,8 b' guards'
68 series:
68 series:
69 abort: repository already exists!
69 abort: repository already exists!
70 % qinit; <stuff>; qinit -c
70 % qinit; <stuff>; qinit -c
71 adding A
71 adding .hg/patches/A
72 adding B
72 adding .hg/patches/B
73 A .hgignore
73 A .hgignore
74 A A
74 A A
75 A B
75 A B
@@ -48,3 +48,7 b' hg id'
48 hg up -q 1
48 hg up -q 1
49 hg up -q
49 hg up -q
50 hg id
50 hg id
51 hg branch foobar
52 hg up
53
54 exit 0
@@ -83,3 +83,4 b' 67ec16bde7f1575d523313b9bca000f6a6f12dca'
83 % update with no arguments: tipmost revision of the current branch
83 % update with no arguments: tipmost revision of the current branch
84 bf1bc2f45e83
84 bf1bc2f45e83
85 4909a3732169 (foo) tip
85 4909a3732169 (foo) tip
86 abort: branch foobar not found
@@ -88,5 +88,8 b' hg revert --all -rtip'
88 echo %% issue332
88 echo %% issue332
89 hg ci -A -m b -d '1000001 0'
89 hg ci -A -m b -d '1000001 0'
90 echo foobar > b/b
90 echo foobar > b/b
91 hg revert b
91 mkdir newdir
92 echo foo > newdir/newfile
93 hg add newdir/newfile
94 hg revert b newdir
92 true
95 true
@@ -61,3 +61,4 b' reverting a'
61 %% issue332
61 %% issue332
62 adding b/b
62 adding b/b
63 reverting b/b
63 reverting b/b
64 forgetting newdir/newfile
@@ -90,3 +90,9 b' hg rm fenugreek'
90 debugwalk fenugreek
90 debugwalk fenugreek
91 touch new
91 touch new
92 debugwalk new
92 debugwalk new
93 chdir ..
94 debugwalk -R t t/mammals/skunk
95 mkdir t2
96 chdir t2
97 debugwalk -R ../t ../t/mammals/skunk
98 debugwalk --cwd ../t mammals/skunk
@@ -276,3 +276,16 b' m fenugreek fenugreek exact'
276 hg debugwalk new
276 hg debugwalk new
277 f new new exact
277 f new new exact
278
278
279 cd ..
280
281 hg debugwalk -R t t/mammals/skunk
282 f mammals/skunk t/mammals/skunk exact
283
284 cd t2
285
286 hg debugwalk -R ../t ../t/mammals/skunk
287 f mammals/skunk ../t/mammals/skunk exact
288
289 hg debugwalk --cwd ../t mammals/skunk
290 f mammals/skunk mammals/skunk exact
291
General Comments 0
You need to be logged in to leave comments. Login now