##// END OF EJS Templates
patch: do not patch unknown files (issue752)
Patrick Mezard -
r14453:ea3d5481 default
parent child Browse files
Show More
@@ -0,0 +1,67 b''
1 $ cat <<EOF >> $HGRCPATH
2 > [extensions]
3 > purge =
4 > EOF
5
6 $ hg init test
7 $ cd test
8 $ echo a > changed
9 $ echo a > removed
10 $ echo a > source
11 $ hg ci -Am addfiles
12 adding changed
13 adding removed
14 adding source
15 $ echo a >> changed
16 $ echo a > added
17 $ hg add added
18 $ hg rm removed
19 $ hg cp source copied
20 $ hg diff --git > ../unknown.diff
21
22 Test adding on top of an unknown file
23
24 $ hg up -qC 0
25 $ hg purge
26 $ echo a > added
27 $ hg import --no-commit ../unknown.diff
28 applying ../unknown.diff
29 file added already exists
30 1 out of 1 hunks FAILED -- saving rejects to file added.rej
31 abort: patch failed to apply
32 [255]
33
34 Test modifying an unknown file
35
36 $ hg revert -aq
37 $ hg purge
38 $ hg rm changed
39 $ hg ci -m removechanged
40 $ echo a > changed
41 $ hg import --no-commit ../unknown.diff
42 applying ../unknown.diff
43 abort: cannot patch changed: file is not tracked
44 [255]
45
46 Test removing an unknown file
47
48 $ hg up -qC 0
49 $ hg purge
50 $ hg rm removed
51 $ hg ci -m removeremoved
52 created new head
53 $ echo a > removed
54 $ hg import --no-commit ../unknown.diff
55 applying ../unknown.diff
56 abort: cannot patch removed: file is not tracked
57 [255]
58
59 Test copying onto an unknown file
60
61 $ hg up -qC 0
62 $ hg purge
63 $ echo a > copied
64 $ hg import --no-commit ../unknown.diff
65 applying ../unknown.diff
66 abort: cannot create copied: destination already exists
67 [255]
@@ -445,13 +445,19 b' class workingbackend(fsbackend):'
445 445 self.changed = set()
446 446 self.copied = []
447 447
448 def _checkknown(self, fname):
449 if self.repo.dirstate[fname] == '?' and self.exists(fname):
450 raise PatchError(_('cannot patch %s: file is not tracked') % fname)
451
448 452 def setfile(self, fname, data, mode, copysource):
453 self._checkknown(fname)
449 454 super(workingbackend, self).setfile(fname, data, mode, copysource)
450 455 if copysource is not None:
451 456 self.copied.append((copysource, fname))
452 457 self.changed.add(fname)
453 458
454 459 def unlink(self, fname):
460 self._checkknown(fname)
455 461 super(workingbackend, self).unlink(fname)
456 462 self.removed.add(fname)
457 463 self.changed.add(fname)
@@ -106,18 +106,3 b' replace broken symlink with another brok'
106 106 now at: movelink
107 107 $ $TESTDIR/readlink.py linkb
108 108 linkb -> linkb
109
110 check patch does not overwrite untracked symlinks
111
112 $ hg qpop
113 popping movelink
114 now at: link
115 $ ln -s linkbb linkb
116 $ hg qpush
117 applying movelink
118 cannot create linkb: destination already exists
119 1 out of 1 hunks FAILED -- saving rejects to file linkb.rej
120 patch failed, unable to continue (try -v)
121 patch failed, rejects left in working dir
122 errors during apply, please fix and refresh movelink
123 [2]
General Comments 0
You need to be logged in to leave comments. Login now