Show More
@@ -856,12 +856,11 b' def docopy(ui, repo, pats, opts):' | |||
|
856 | 856 | |
|
857 | 857 | def targetpathfn(pat, dest, srcs): |
|
858 | 858 | if os.path.isdir(pat): |
|
859 | if pat.endswith(os.sep): | |
|
860 | pat = pat[:-len(os.sep)] | |
|
859 | abspfx = util.canonpath(repo.root, cwd, pat) | |
|
861 | 860 | if destdirexists: |
|
862 |
striplen = len(os.path.split( |
|
|
861 | striplen = len(os.path.split(abspfx)[0]) | |
|
863 | 862 | else: |
|
864 |
striplen = len( |
|
|
863 | striplen = len(abspfx) | |
|
865 | 864 | if striplen: |
|
866 | 865 | striplen += len(os.sep) |
|
867 | 866 | res = lambda p: os.path.join(dest, p[striplen:]) |
@@ -875,23 +874,25 b' def docopy(ui, repo, pats, opts):' | |||
|
875 | 874 | if util.patkind(pat, None)[0]: |
|
876 | 875 | # a mercurial pattern |
|
877 | 876 | res = lambda p: os.path.join(dest, os.path.basename(p)) |
|
878 | elif len(util.canonpath(repo.root, cwd, pat)) < len(srcs[0][0]): | |
|
877 | else: | |
|
878 | abspfx = util.canonpath(repo.root, cwd, pat) | |
|
879 | if len(abspfx) < len(srcs[0][0]): | |
|
879 | 880 | # A directory. Either the target path contains the last |
|
880 | 881 | # component of the source path or it does not. |
|
881 | 882 | def evalpath(striplen): |
|
882 | 883 | score = 0 |
|
883 | 884 | for s in srcs: |
|
884 |
t = os.path.join(dest, s[ |
|
|
885 | t = os.path.join(dest, s[0][striplen:]) | |
|
885 | 886 | if os.path.exists(t): |
|
886 | 887 | score += 1 |
|
887 | 888 | return score |
|
888 | 889 | |
|
889 | if pat.endswith(os.sep): | |
|
890 | pat = pat[:-len(os.sep)] | |
|
891 |
striplen = |
|
|
892 |
if os.path.isdir(os.path.join(dest, os.path.split( |
|
|
890 | striplen = len(abspfx) | |
|
891 | if striplen: | |
|
892 | striplen += len(os.sep) | |
|
893 | if os.path.isdir(os.path.join(dest, os.path.split(abspfx)[1])): | |
|
893 | 894 | score = evalpath(striplen) |
|
894 |
striplen1 = len(os.path.split( |
|
|
895 | striplen1 = len(os.path.split(abspfx)[0]) | |
|
895 | 896 | if striplen1: |
|
896 | 897 | striplen1 += len(os.sep) |
|
897 | 898 | if evalpath(striplen1) > score: |
@@ -934,7 +935,7 b' def docopy(ui, repo, pats, opts):' | |||
|
934 | 935 | |
|
935 | 936 | for targetpath, srcs in copylist: |
|
936 | 937 | for abssrc, relsrc, exact in srcs: |
|
937 |
copy(abssrc, relsrc, targetpath( |
|
|
938 | copy(abssrc, relsrc, targetpath(abssrc), exact) | |
|
938 | 939 | |
|
939 | 940 | if errors: |
|
940 | 941 | ui.warn(_('(consider using --after)\n')) |
@@ -134,3 +134,21 b' mkdir d3' | |||
|
134 | 134 | hg rename d1/* d2/* d3 |
|
135 | 135 | hg status |
|
136 | 136 | hg update -C |
|
137 | ||
|
138 | echo "# move a whole subtree with \"hg rename .\"" | |
|
139 | mkdir d3 | |
|
140 | (cd d1; hg rename . ../d3) | |
|
141 | hg status | |
|
142 | hg update -C | |
|
143 | ||
|
144 | echo "# move a whole subtree with \"hg rename --after .\"" | |
|
145 | mkdir d3 | |
|
146 | mv d1/* d3 | |
|
147 | (cd d1; hg rename --after . ../d3) | |
|
148 | hg status | |
|
149 | hg update -C | |
|
150 | ||
|
151 | echo "# move the parent tree with \"hg rename ..\"" | |
|
152 | (cd d1/d11; hg rename .. ../../d3) | |
|
153 | hg status | |
|
154 | hg update -C |
@@ -181,3 +181,54 b' R d1/a' | |||
|
181 | 181 | R d1/b |
|
182 | 182 | R d1/ba |
|
183 | 183 | R d1/d11/a1 |
|
184 | # move a whole subtree with "hg rename ." | |
|
185 | copying a to ../d3/d1/a | |
|
186 | copying b to ../d3/d1/b | |
|
187 | copying ba to ../d3/d1/ba | |
|
188 | copying d11/a1 to ../d3/d1/d11/a1 | |
|
189 | removing a | |
|
190 | removing b | |
|
191 | removing ba | |
|
192 | removing d11/a1 | |
|
193 | A d3/d1/a | |
|
194 | A d3/d1/b | |
|
195 | A d3/d1/ba | |
|
196 | A d3/d1/d11/a1 | |
|
197 | R d1/a | |
|
198 | R d1/b | |
|
199 | R d1/ba | |
|
200 | R d1/d11/a1 | |
|
201 | # move a whole subtree with "hg rename --after ." | |
|
202 | copying a to ../d3/a | |
|
203 | copying b to ../d3/b | |
|
204 | copying ba to ../d3/ba | |
|
205 | copying d11/a1 to ../d3/d11/a1 | |
|
206 | removing a | |
|
207 | removing b | |
|
208 | removing ba | |
|
209 | removing d11/a1 | |
|
210 | A d3/a | |
|
211 | A d3/b | |
|
212 | A d3/ba | |
|
213 | A d3/d11/a1 | |
|
214 | R d1/a | |
|
215 | R d1/b | |
|
216 | R d1/ba | |
|
217 | R d1/d11/a1 | |
|
218 | # move the parent tree with "hg rename .." | |
|
219 | copying ../a to ../../d3/a | |
|
220 | copying ../b to ../../d3/b | |
|
221 | copying ../ba to ../../d3/ba | |
|
222 | copying a1 to ../../d3/d11/a1 | |
|
223 | removing ../a | |
|
224 | removing ../b | |
|
225 | removing ../ba | |
|
226 | removing a1 | |
|
227 | A d3/a | |
|
228 | A d3/b | |
|
229 | A d3/ba | |
|
230 | A d3/d11/a1 | |
|
231 | R d1/a | |
|
232 | R d1/b | |
|
233 | R d1/ba | |
|
234 | R d1/d11/a1 |
General Comments 0
You need to be logged in to leave comments.
Login now