hg
changeset 213 d2172916ef6c
parent 210 d2badbd7d1ad
child 219 8ff4532376a4
equal deleted inserted replaced
212:48398a5353e3 213:d2172916ef6c
   117     cmd = "help"
   117     cmd = "help"
   118 
   118 
   119 ui = ui.ui(options["verbose"], options["debug"], options["quiet"],
   119 ui = ui.ui(options["verbose"], options["debug"], options["quiet"],
   120            not options["noninteractive"])
   120            not options["noninteractive"])
   121     
   121     
   122 if cmd == "init":
   122 try:
   123     repo = hg.repository(ui, ".", create=1)
   123     repo = hg.repository(ui=ui)
       
   124 except IOError:
       
   125     ui.warn("Unable to open repository\n")
   124     sys.exit(0)
   126     sys.exit(0)
   125 elif cmd == "branch" or cmd == "clone":
       
   126     os.system("cp -al %s/.hg .hg" % args[0])
       
   127     sys.exit(0)
       
   128 elif cmd == "help":
       
   129     help()
       
   130     sys.exit(0)
       
   131 else:
       
   132     try:
       
   133         repo = hg.repository(ui=ui)
       
   134     except IOError:
       
   135         ui.warn("Unable to open repository\n")
       
   136         sys.exit(0)
       
   137 
   127 
   138 relpath = None
   128 relpath = None
   139 if os.getcwd() != repo.root:
   129 if os.getcwd() != repo.root:
   140     relpath = os.getcwd()[len(repo.root) + 1: ]
   130     relpath = os.getcwd()[len(repo.root) + 1: ]
   141 
   131 
   219         if files:
   209         if files:
   220             if os.system("patch -p%d < %s %s" % (strip, pf, quiet)):
   210             if os.system("patch -p%d < %s %s" % (strip, pf, quiet)):
   221                 raise "patch failed!"
   211                 raise "patch failed!"
   222         repo.commit(repo.current, files, text)
   212         repo.commit(repo.current, files, text)
   223 
   213 
   224 elif cmd == "status":
       
   225     (c, a, d) = repo.diffdir(repo.root, repo.current)
       
   226     if relpath:
       
   227         (c, a, d) = map(lambda x: filterfiles(x, [ relpath ]), (c, a, d))
       
   228 
       
   229     for f in c: print "C", f
       
   230     for f in a: print "?", f
       
   231     for f in d: print "R", f
       
   232 
       
   233 elif cmd == "diff":
   214 elif cmd == "diff":
   234     revs = []
   215     revs = []
   235 
   216 
   236     if args:
   217     if args:
   237         doptions = {}
   218         doptions = {}