mirror of
https://github.com/facebook/sapling.git
synced 2024-10-08 07:49:11 +03:00
* clean up error handling when user requests to use a non file object
# HG changeset patch # User shaleh@speakeasy.net # Node ID 1ae21732349f5b6dba2941609a044d9c365a6fb2 # Parent d3df6f5c87d045ba97457269261c35c30b04524b * 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 d3df6f5c87d0 -r 1ae21732349f mercurial/hg.py
This commit is contained in:
parent
2c86300941
commit
6e0d7d452c
@ -753,8 +753,10 @@ class localrepository:
|
||||
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 @@ class localrepository:
|
||||
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 @@ class localrepository:
|
||||
|
||||
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")
|
||||
|
Loading…
Reference in New Issue
Block a user