##// END OF EJS Templates
copy: add option to unmark file as copied...
Martin von Zweigbergk -
r44844:8be0c635 default
parent child Browse files
Show More
@@ -1410,12 +1410,15 b' def openrevlog(repo, cmd, file_, opts):'
1410 1410
1411 1411
1412 1412 def copy(ui, repo, pats, opts, rename=False):
1413 check_incompatible_arguments(opts, b'forget', [b'dry_run'])
1414
1413 1415 # called with the repo lock held
1414 1416 #
1415 1417 # hgsep => pathname that uses "/" to separate directories
1416 1418 # ossep => pathname that uses os.sep to separate directories
1417 1419 cwd = repo.getcwd()
1418 1420 targets = {}
1421 forget = opts.get(b"forget")
1419 1422 after = opts.get(b"after")
1420 1423 dryrun = opts.get(b"dry_run")
1421 1424 ctx = repo[None]
@@ -1423,6 +1426,24 b' def copy(ui, repo, pats, opts, rename=Fa'
1423 1426
1424 1427 uipathfn = scmutil.getuipathfn(repo, legacyrelativevalue=True)
1425 1428
1429 if forget:
1430 match = scmutil.match(wctx, pats, opts)
1431
1432 current_copies = wctx.p1copies()
1433 current_copies.update(wctx.p2copies())
1434
1435 for f in wctx.walk(match):
1436 if f in current_copies:
1437 wctx[f].markcopied(None)
1438 elif match.exact(f):
1439 ui.warn(
1440 _(
1441 b'%s: not unmarking as copy - file is not marked as copied\n'
1442 )
1443 % uipathfn(f)
1444 )
1445 return
1446
1426 1447 def walkpat(pat):
1427 1448 srcs = []
1428 1449 m = scmutil.match(ctx, [pat], opts, globbed=True)
@@ -2309,6 +2309,7 b' def continuecmd(ui, repo, **opts):'
2309 2309 @command(
2310 2310 b'copy|cp',
2311 2311 [
2312 (b'', b'forget', None, _(b'unmark a file as copied')),
2312 2313 (b'A', b'after', None, _(b'record a copy that has already occurred')),
2313 2314 (
2314 2315 b'f',
@@ -2333,8 +2334,11 b' def copy(ui, repo, *pats, **opts):'
2333 2334 exist in the working directory. If invoked with -A/--after, the
2334 2335 operation is recorded, but no copying is performed.
2335 2336
2336 This command takes effect with the next commit. To undo a copy
2337 before that, see :hg:`revert`.
2337 To undo marking a file as copied, use --forget. With that option,
2338 all given (positional) arguments are unmarked as copies. The destination
2339 file(s) will be left in place (still tracked).
2340
2341 This command takes effect with the next commit.
2338 2342
2339 2343 Returns 0 on success, 1 if errors are encountered.
2340 2344 """
@@ -12,6 +12,8 b''
12 12 commits that are being merged, when there are conflicts. Also works
13 13 for conflicts caused by e.g. `hg graft`.
14 14
15 * `hg copy --forget` can be used to unmark a file as copied.
16
15 17
16 18 == New Experimental Features ==
17 19
@@ -257,7 +257,7 b' Show all commands + options'
257 257 commit: addremove, close-branch, amend, secret, edit, force-close-branch, interactive, include, exclude, message, logfile, date, user, subrepos
258 258 config: untrusted, edit, local, global, template
259 259 continue: dry-run
260 copy: after, force, include, exclude, dry-run
260 copy: forget, after, force, include, exclude, dry-run
261 261 debugancestor:
262 262 debugapplystreamclonebundle:
263 263 debugbuilddag: mergeable-file, overwritten-file, new-file
@@ -262,5 +262,62 b' mention --force:'
262 262 xyzzy: not overwriting - file exists
263 263 ('hg copy --after' to record the copy)
264 264 [1]
265 $ hg co -qC .
266 $ rm baz xyzzy
267
268
269 Test unmarking copy of a single file
270
271 # Set up by creating a copy
272 $ hg cp bar baz
273 # Test uncopying a non-existent file
274 $ hg copy --forget non-existent
275 non-existent: $ENOENT$
276 # Test uncopying an tracked but unrelated file
277 $ hg copy --forget foo
278 foo: not unmarking as copy - file is not marked as copied
279 # Test uncopying a copy source
280 $ hg copy --forget bar
281 bar: not unmarking as copy - file is not marked as copied
282 # baz should still be marked as a copy
283 $ hg st -C
284 A baz
285 bar
286 # Test the normal case
287 $ hg copy --forget baz
288 $ hg st -C
289 A baz
290 # Test uncopy with matching an non-matching patterns
291 $ hg cp bar baz --after
292 $ hg copy --forget bar baz
293 bar: not unmarking as copy - file is not marked as copied
294 $ hg st -C
295 A baz
296 # Test uncopy with no exact matches
297 $ hg cp bar baz --after
298 $ hg copy --forget .
299 $ hg st -C
300 A baz
301 $ hg forget baz
302 $ rm baz
303
304 Test unmarking copy of a directory
305
306 $ mkdir dir
307 $ echo foo > dir/foo
308 $ echo bar > dir/bar
309 $ hg add dir
310 adding dir/bar
311 adding dir/foo
312 $ hg ci -m 'add dir/'
313 $ hg cp dir dir2
314 copying dir/bar to dir2/bar
315 copying dir/foo to dir2/foo
316 $ touch dir2/untracked
317 $ hg copy --forget dir2
318 $ hg st -C
319 A dir2/bar
320 A dir2/foo
321 ? dir2/untracked
265 322
266 323 $ cd ..
General Comments 0
You need to be logged in to leave comments. Login now