* clean up error handling when user requests to use a non file object
# HG changeset patch
# User shaleh@speakeasy.net
# Node ID
1ae21732349f5b6dba2941609a044d9c365a6fb2
# Parent
94744f6fe0e7c19b10fab7eb24249f3eeaa5489a
* clean up error handling when user requests to use a non file object
- use os.path.exists() to verify the item exists
- use os.path.isfile() to check whether the item is a file or not
diff -r
94744f6fe0e7 -r
1ae21732349f mercurial/hg.py
--- a/mercurial/hg.py Mon Jul 04 11:06:01 2005 -0800
+++ b/mercurial/hg.py Mon Jul 04 11:20:20 2005 -0800
@@ -753,8 +753,10 @@
def add(self, list):
for f in list:
p = self.wjoin(f)
- if not os.path.isfile(p):
- self.ui.warn("%s does not exist!\n" % f)
+ if not os.path.exists(p):
+ self.ui.warn("%s does not exist!\n" % f)
+ elif not os.path.isfile(p):
+ self.ui.warn("%s not added: mercurial only supports files currently\n" % f)
elif self.dirstate.state(f) == 'n':
self.ui.warn("%s already tracked!\n" % f)
else:
@@ -770,7 +772,7 @@
def remove(self, list):
for f in list:
p = self.wjoin(f)
- if os.path.isfile(p):
+ if os.path.exists(p):
self.ui.warn("%s still exists!\n" % f)
elif self.dirstate.state(f) == 'a':
self.ui.warn("%s never committed!\n" % f)
@@ -782,8 +784,10 @@
def copy(self, source, dest):
p = self.wjoin(dest)
- if not os.path.isfile(dest):
+ if not os.path.exists(dest):
self.ui.warn("%s does not exist!\n" % dest)
+ elif not os.path.isfile(dest):
+ self.ui.warn("copy failed: %s is not a file\n" % dest)
else:
if self.dirstate.state(dest) == '?':
self.dirstate.update([dest], "a")