##// END OF EJS Templates
context: name files relative to cwd in warning messages...
Matt Harbison -
r33501:7008f681 default
parent child Browse files
Show More
@@ -33,6 +33,7 b' from . import ('
33 33 mdiff,
34 34 obsolete as obsmod,
35 35 patch,
36 pathutil,
36 37 phases,
37 38 pycompat,
38 39 repoview,
@@ -1518,17 +1519,20 b' class workingctx(committablectx):'
1518 1519 (missing and self.deleted()))
1519 1520
1520 1521 def add(self, list, prefix=""):
1521 join = lambda f: os.path.join(prefix, f)
1522 1522 with self._repo.wlock():
1523 1523 ui, ds = self._repo.ui, self._repo.dirstate
1524 uipath = lambda f: ds.pathto(pathutil.join(prefix, f))
1524 1525 rejected = []
1525 1526 lstat = self._repo.wvfs.lstat
1526 1527 for f in list:
1527 scmutil.checkportable(ui, join(f))
1528 # ds.pathto() returns an absolute file when this is invoked from
1529 # the keyword extension. That gets flagged as non-portable on
1530 # Windows, since it contains the drive letter and colon.
1531 scmutil.checkportable(ui, os.path.join(prefix, f))
1528 1532 try:
1529 1533 st = lstat(f)
1530 1534 except OSError:
1531 ui.warn(_("%s does not exist!\n") % join(f))
1535 ui.warn(_("%s does not exist!\n") % uipath(f))
1532 1536 rejected.append(f)
1533 1537 continue
1534 1538 if st.st_size > 10000000:
@@ -1536,13 +1540,13 b' class workingctx(committablectx):'
1536 1540 "to manage this file\n"
1537 1541 "(use 'hg revert %s' to cancel the "
1538 1542 "pending addition)\n")
1539 % (f, 3 * st.st_size // 1000000, join(f)))
1543 % (f, 3 * st.st_size // 1000000, uipath(f)))
1540 1544 if not (stat.S_ISREG(st.st_mode) or stat.S_ISLNK(st.st_mode)):
1541 1545 ui.warn(_("%s not added: only files and symlinks "
1542 "supported currently\n") % join(f))
1546 "supported currently\n") % uipath(f))
1543 1547 rejected.append(f)
1544 1548 elif ds[f] in 'amn':
1545 ui.warn(_("%s already tracked!\n") % join(f))
1549 ui.warn(_("%s already tracked!\n") % uipath(f))
1546 1550 elif ds[f] == 'r':
1547 1551 ds.normallookup(f)
1548 1552 else:
@@ -1550,12 +1554,13 b' class workingctx(committablectx):'
1550 1554 return rejected
1551 1555
1552 1556 def forget(self, files, prefix=""):
1553 join = lambda f: os.path.join(prefix, f)
1554 1557 with self._repo.wlock():
1558 ds = self._repo.dirstate
1559 uipath = lambda f: ds.pathto(pathutil.join(prefix, f))
1555 1560 rejected = []
1556 1561 for f in files:
1557 1562 if f not in self._repo.dirstate:
1558 self._repo.ui.warn(_("%s not tracked!\n") % join(f))
1563 self._repo.ui.warn(_("%s not tracked!\n") % uipath(f))
1559 1564 rejected.append(f)
1560 1565 elif self._repo.dirstate[f] != 'a':
1561 1566 self._repo.dirstate.remove(f)
@@ -1566,9 +1571,10 b' class workingctx(committablectx):'
1566 1571 def undelete(self, list):
1567 1572 pctxs = self.parents()
1568 1573 with self._repo.wlock():
1574 ds = self._repo.dirstate
1569 1575 for f in list:
1570 1576 if self._repo.dirstate[f] != 'r':
1571 self._repo.ui.warn(_("%s not removed!\n") % f)
1577 self._repo.ui.warn(_("%s not removed!\n") % ds.pathto(f))
1572 1578 else:
1573 1579 fctx = f in pctxs[0] and pctxs[0][f] or pctxs[1][f]
1574 1580 t = fctx.data()
@@ -1581,11 +1587,13 b' class workingctx(committablectx):'
1581 1587 except OSError as err:
1582 1588 if err.errno != errno.ENOENT:
1583 1589 raise
1584 self._repo.ui.warn(_("%s does not exist!\n") % dest)
1590 self._repo.ui.warn(_("%s does not exist!\n")
1591 % self._repo.dirstate.pathto(dest))
1585 1592 return
1586 1593 if not (stat.S_ISREG(st.st_mode) or stat.S_ISLNK(st.st_mode)):
1587 1594 self._repo.ui.warn(_("copy failed: %s is not a file or a "
1588 "symbolic link\n") % dest)
1595 "symbolic link\n")
1596 % self._repo.dirstate.pathto(dest))
1589 1597 else:
1590 1598 with self._repo.wlock():
1591 1599 if self._repo.dirstate[dest] in '?':
@@ -14,6 +14,11 b''
14 14 adding a
15 15 $ hg st
16 16 A a
17 $ mkdir dir
18 $ cd dir
19 $ hg add ../a
20 ../a already tracked!
21 $ cd ..
17 22
18 23 $ echo b > b
19 24 $ hg add -n b
General Comments 0
You need to be logged in to leave comments. Login now