Sunday, June 10, 2007

Dear Lazyweb: Mercurial Python API

So, in the midst of trying to convert some Darcs repositories to Mercurial repositories (see here for the reason), I hit an "interesting" bug: tailor processes "rename" patches by deleting the renamed file. A little debugging later, I get to this simulation of what tailor does:


>>> from mercurial import hg,ui
>>> uio = ui.ui(debug=True,verbose=True)
>>> r = hg.repository(ui=uio, path='.', create=True)
>>> f = file('A', 'w')
>>> f.write('Some data\n')
>>> f.close()
>>> r.add('A')
>>> r.commit(text='Add A')
A
'i\xe9\xb4\xc8\x9d\xb8\xeb<\xbe\xb1k\xae\xb1\x182\xa9ao\x80\xd0'
>>> r.copy('A', 'B')
B does not exist!


Huh? Of course B doesn't exist, that's why I want to create it! So, we look at the code in localrepo.py to handle copying...


def copy(self, source, dest, wlock=None):
p = self.wjoin(dest)
if not os.path.exists(p):
self.ui.warn(_("%s does not exist!\n") % dest)
elif not os.path.isfile(p):
self.ui.warn(_("copy failed: %s is not a file\n") % dest)
else:
if not wlock:
wlock = self.wlock()
if self.dirstate.state(dest) == '?':
self.dirstate.update([dest], "a")
self.dirstate.copy(source, dest)


Double huh?


  1. Why is this method checking whether the destination exists before it does anything? It appears to me that this is actually necessary; just disabling this test leads to a crash later.
  2. How does mercurial work at all with such huge breakage in its core code? Does /usr/bin/hg use a different implementation of the repository code than mercurial.hg?
  3. Why, in the name of $DEITY, is this a warning and not a fatal exception? One example of what happens when you don't signal to your users that you're ignoring them is this bug: tailor happily goes ahead and removes the original file, safe in the knowledge that mercurial has copied it to the new location. Except, of course, that mercurial hasn't actually copied it. Whoops.


I'm hoping that someone will tell me that it's just too late at night for me and I'm being an idiot. Please tell me this. It would make me very sad if code like that was in my VCS.


:-( <--- sad Daniel

18 Comments:

At 11:43 PM, Anonymous alexis said...

1. localrepository.copy only marks dest as a copy of source. The caller is supposed to do the actual "cp source dest" before calling this function (e.g. using the copyfile function in util.py).

2. util.copyfile is used by the docopy function in commands.py to copy the bytes.

3. yes, that function should return some kind of error code.

 
At 8:53 AM, Anonymous Anonymous said...

I'm looking for an application of some sorts that can save all my contact details and such from my iPhone to my computer and then after put them all back onto another iPhone (well the same one actually, as I'm getting it reset) Any suggestions?
[url=http://www.provenworkfromhomejobs.com/2009/02/blogging-for-fun-and-profit-earn-income-posting-about-your-hobby/#comment-5357]unlock iphone[/url]

 
At 2:40 PM, Anonymous Anonymous said...

With hаvin so muсh contеnt do уоu evеr run іnto any issueѕ οf plagorism
oг coρyright infringement? Mу site has a lot of unique content I've either authored myself or outsourced but it seems a lot of it is popping it up all over the web without my authorization. Do you know any techniques to help prevent content from being stolen? I'd genuinely appreсіate it.


http://cctvsecuгitypгos.buzznеt.cοm/uѕeг/
Feel free to surf my weblog : buzznet.com

 
At 5:33 AM, Anonymous Anonymous said...

Rіght away I am going tο dο mу
breakfast, аfter havіng my breakfast coming yеt again to read more news.


Heгe is my ωebpаge; http://www.biggreeneggmanual.com/super-smoked-spicy-chicken-wings/
Feel free to surf my web page : www.biggreeneggmanual.com/blog/

 
At 5:33 AM, Anonymous Anonymous said...

Right aωаy ӏ am going to ԁo my brеakfast, after haνіng my brеаκfаst сoming
уеt аgaіn to read moге
neωs.

My webρаge - http://www.biggreeneggmanual.com/super-smoked-spicy-chicken-wings/
My web page > www.biggreeneggmanual.com/blog/

 
At 3:21 PM, Anonymous Anonymous said...

Hi, i belieѵe that i ѕaω уоu visited my site thus i got herе to
go bacκ the favor?.I am tгying to to find issues tо impгoνe my ωeb sitе!
I guess іtѕ ok to make use of some of youг idеas!

!

Also viѕit my рage :: how to make money flipping cars for profit

 
At 10:11 PM, Anonymous Anonymous said...

Hi theгe just wanted to give you a quick heаds uр.
The text in your content sеem to be running οff
the scrеen in Firefox. Ι'm not sure if this is a formatting issue or something to do with internet browser compatibility but I figured I'ԁ post to let
yοu know. The deѕign lоok great though! Hope you
get the iѕsue fixeԁ soоn. Сhеers

mу web page: search engine optimization dallas

 
At 5:57 AM, Anonymous Anonymous said...

Todaу, I went to the beach front with my kidѕ.
I fοund a sea shell аnԁ gave it to my
4 yеar old daughter and said "You can hear the ocean if you put this to your ear." Ѕhе ρlacеd the shеll to her eаr and sсreamed.
Τhегe waѕ а hеrmit сrаb insidе and it pinched her еaг.
Shе never wants to go baсk! LоL
Ι know this is entіrеly off topic but Ι had to tell someone!


Аlso visit my homepagе :: dallas seo

 
At 6:05 AM, Anonymous Anonymous said...

Intercombase - professional translation complex text in different fields more than 140 languages. Media Translation, Manufacturing Translation, Automotive Translation - first class affordable.

Hebrew Translation - [url=http://www.intercombase.com]Spanish[/url]

 
At 12:51 AM, Blogger Coach Factory said...

kate spade handbags, prada outlet, nike air max, louis vuitton, nike air max, louis vuitton outlet online, burberry outlet online, burberry outlet online, tiffany and co jewelry, michael kors outlet, gucci handbags, tory burch outlet, louis vuitton outlet, chanel handbags, jordan shoes, longchamp outlet online, nike shoes, louboutin shoes, red bottom shoes, coach outlet store online, kate spade outlet online, polo ralph lauren outlet, oakley vault, coach outlet, prada handbags, coach purses, louis vuitton handbags, longchamp handbags, christian louboutin outlet, oakley sunglasses, cheap oakley sunglasses, michael kors outlet online, michael kors outlet online, louis vuitton outlet, polo ralph lauren, christian louboutin shoes, michael kors outlet online, ray ban outlet, nike free, longchamp outlet, michael kors outlet store, michael kors outlet online, coach outlet, true religion, ray ban sunglasses

 
At 12:51 AM, Blogger Coach Factory said...

abercrombie and fitch, longchamp pas cher, north face, vans pas cher, nike free, nike air max, longchamp, tn pas cher, hollister, air max pas cher, michael kors canada, chaussure louboutin, oakley pas cher, sac vanessa bruno, ray ban uk, louis vuitton uk, hollister, new balance pas cher, lululemon, nike free pas cher, north face pas cher, scarpe hogan, nike trainers, air max, nike roshe, ralph lauren pas cher, barbour, nike huarache, burberry pas cher, guess pas cher, nike air max, true religion outlet, longchamp, lacoste pas cher, sac michael kors, ralph lauren, louis vuitton pas cher, michael kors uk, nike blazer pas cher, mulberry, nike air force, air jordan, hermes pas cher, louis vuitton, nike roshe run, timberland, sac louis vuitton, ray ban pas cher, converse pas cher, true religion outlet

 
At 12:52 AM, Blogger Coach Factory said...

herve leger, soccer jerseys, uggs outlet, jimmy choo shoes, lululemon outlet, nfl jerseys, canada goose pas cher, vans outlet, soccer shoes, roshe run, valentino shoes, moncler, rolex watches, chi flat iron, uggs on sale, canada goose, north face outlet, ghd, new balance outlet, north face jackets, mcm handbags, ugg soldes, moncler, canada goose uk, mont blanc pens, beats headphones, canada goose outlet, celine handbags, instyler ionic styler, ferragamo shoes, ugg boots, bottega veneta, ugg, moncler outlet, abercrombie and fitch, ugg outlet, wedding dresses, mac cosmetics, birkin bag, reebok outlet, canada goose outlet, insanity workout, moncler, giuseppe zanotti, asics shoes, hollister, canada goose outlet, babyliss pro, marc jacobs outlet, p90x workout

 
At 11:20 PM, Blogger John said...

nike free runs
louis vuitton pas cher
nike roshe run women
air max 90
prada uk
christian louboutin
air max
snapbacks wholesale
adidas superstar
hollister co
cheap versace
nike air max 90
tods outlet
giuseppe zanotti sneakers
coach factory outlet
ugg sale
basketball shoes
timberland uk
jordan pas cher
canada goose outlet
coach outlet
ralph lauren polos shirts
abercrombie and fitch
retro jordans
louis vuitton borse
ghd
rolex replica watches
chaussure louboutin
adidas shoes
timberland boots
2015922yuanyuan

 
At 8:04 PM, Blogger 风骚达哥 said...

20151014 junda
Louis Vuitton Handbags Factory Store
Louis Vuitton Bags On Sale
Louis Vuitton Bags Outlet Store
cheap ugg boots
louis vuitton outlet
Michael Kors Outlet Real Handbags Online
ugg boots
Air Jordan 3 III Retro Free Shipping
louis vuitton outlet
celine
Christian Louis Vuitton Red Bottoms
coach factory outlet
ray ban sunglasses uk
Ugg Boots,Ugg Boots Outlet,Ugg Outlet,Cheap Uggs,Uggs On Sale,Ugg Boots Clearance,Uggs For Women
Coach Outlet Store Online Handbags Clearance
canada goose outlet
ugg boots outlet
Abercrombie And Fitch Kids Online
true religion outlet
cheap jordan shoes
New Louis Vuitton Handbags Outlet
cheap uggs
nfl jerseys
canada goose jackets
Abercrombie and Fitch Outlet Sale
louis vuitton outlet
canada goose outlet
uggs australia
michael kors outlet stores
Coach Factory Outlet Online Sale

 
At 8:26 PM, Blogger oakleyses said...

uggs outlet, uggs on sale, ray ban sunglasses, ray ban sunglasses, louis vuitton, michael kors outlet online, oakley sunglasses wholesale, christian louboutin outlet, louis vuitton, uggs outlet, louis vuitton outlet, polo outlet, prada handbags, nike free, chanel handbags, longchamp outlet, michael kors outlet, replica watches, louis vuitton outlet, oakley sunglasses, michael kors outlet online, prada outlet, michael kors outlet online, longchamp outlet, burberry handbags, michael kors outlet, kate spade outlet, ray ban sunglasses, longchamp outlet, louis vuitton outlet, oakley sunglasses, nike air max, oakley sunglasses, replica watches, ugg boots, polo ralph lauren outlet online, ugg boots, gucci handbags, jordan shoes, cheap oakley sunglasses, michael kors outlet online, christian louboutin uk, burberry outlet, tory burch outlet, tiffany and co, christian louboutin shoes

 
At 8:27 PM, Blogger oakleyses said...

michael kors, nike tn, ralph lauren uk, abercrombie and fitch uk, north face uk, ray ban pas cher, nike free uk, lululemon canada, michael kors, true religion jeans, coach outlet, coach outlet store online, hollister uk, sac longchamp pas cher, vans pas cher, nike blazer pas cher, louboutin pas cher, nike air max uk, michael kors pas cher, nike free run, nike air max uk, new balance, sac hermes, jordan pas cher, true religion outlet, replica handbags, nike roshe, longchamp pas cher, guess pas cher, true religion outlet, north face, polo ralph lauren, coach purses, hollister pas cher, oakley pas cher, timberland pas cher, air max, polo lacoste, nike air force, nike roshe run uk, burberry pas cher, converse pas cher, nike air max, sac vanessa bruno, mulberry uk, hogan outlet, michael kors outlet, true religion outlet, ray ban uk, kate spade

 
At 8:32 PM, Blogger oakleyses said...

beats by dre, nfl jerseys, nike trainers uk, mcm handbags, lululemon, reebok outlet, valentino shoes, wedding dresses, nike roshe run, celine handbags, ghd hair, ferragamo shoes, mont blanc pens, louboutin, giuseppe zanotti outlet, new balance shoes, timberland boots, oakley, soccer shoes, nike air max, iphone 5s cases, nike huaraches, iphone 6 plus cases, herve leger, iphone 6s plus cases, p90x workout, babyliss, vans outlet, north face outlet, iphone cases, jimmy choo outlet, iphone 6 cases, s6 case, abercrombie and fitch, bottega veneta, north face outlet, hermes belt, longchamp uk, ralph lauren, chi flat iron, insanity workout, iphone 6s cases, ipad cases, baseball bats, mac cosmetics, instyler, hollister, soccer jerseys, asics running shoes, hollister clothing

 
At 8:33 PM, Blogger oakleyses said...

doudoune moncler, pandora uk, moncler outlet, vans, converse outlet, montre pas cher, louis vuitton, moncler, moncler, canada goose, canada goose outlet, ugg uk, links of london, barbour uk, supra shoes, replica watches, lancel, nike air max, moncler, moncler, moncler outlet, coach outlet, wedding dresses, canada goose outlet, pandora jewelry, karen millen uk, ugg, marc jacobs, juicy couture outlet, converse, moncler uk, louis vuitton, ugg pas cher, swarovski, pandora jewelry, gucci, canada goose, canada goose uk, ugg,uggs,uggs canada, pandora charms, juicy couture outlet, louis vuitton, louis vuitton, ray ban, ugg,ugg australia,ugg italia, canada goose jackets, swarovski crystal, canada goose, hollister, thomas sabo, canada goose outlet, toms shoes

 

Post a Comment

<< Home