# HG changeset patch # User shaleh@speakeasy.net # Date 1120504820 28800 # Node ID 48c3eb2bf844a7e30b98b303e7477c7177da18ca # Parent 4c02464cb9f0f274ddb218adb1cb8c8d48757428 * 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 diff -r 4c02464cb9f0 -r 48c3eb2bf844 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")